Browse Source

paypro: allow users to return verification properties via PayPro.verify.

patch-2
Christopher Jeffrey 11 years ago
parent
commit
f34b98d253
  1. 9
      lib/PayPro.js
  2. 9
      lib/browser/PayPro.js
  3. 4
      lib/common/PayPro.js

9
lib/PayPro.js

@ -41,7 +41,7 @@ PayPro.prototype.x509Sign = function(key) {
return sig;
};
PayPro.prototype.x509Verify = function() {
PayPro.prototype.x509Verify = function(returnTrust) {
var self = this;
var crypto = require('crypto');
var pki_type = this.get('pki_type');
@ -125,6 +125,13 @@ PayPro.prototype.x509Verify = function() {
&& sigVerified;
});
if (returnTrust) {
return {
verified: verified,
chainVerified: chainVerified
};
}
return verified && chainVerified;
};

9
lib/browser/PayPro.js

@ -53,7 +53,7 @@ PayPro.prototype.x509Sign = function(key) {
return sig;
};
PayPro.prototype.x509Verify = function(key) {
PayPro.prototype.x509Verify = function(returnTrust) {
var sig = this.get('signature');
var pki_type = this.get('pki_type');
var pki_data = this.get('pki_data');
@ -147,6 +147,13 @@ PayPro.prototype.x509Verify = function(key) {
&& sigVerified;
});
if (returnTrust) {
return {
verified: verified,
chainVerified: chainVerified
};
}
return verified && chainVerified;
};

4
lib/common/PayPro.js

@ -337,7 +337,7 @@ PayPro.prototype.sign = function(key) {
return this;
};
PayPro.prototype.verify = function() {
PayPro.prototype.verify = function(returnTrust) {
if (this.messageType !== 'PaymentRequest')
throw new Error('Verifying can only be performed on a PaymentRequest');
@ -346,7 +346,7 @@ PayPro.prototype.verify = function() {
if (pki_type === 'SIN') {
return this.sinVerify();
} else if (pki_type === 'x509+sha1' || pki_type === 'x509+sha256') {
return this.x509Verify();
return this.x509Verify(returnTrust);
} else if (pki_type === 'none') {
return true;
}

Loading…
Cancel
Save