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

This commit is contained in:
Christopher Jeffrey 2014-08-28 17:50:57 -07:00
parent e34f9a4061
commit f34b98d253
3 changed files with 18 additions and 4 deletions

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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;
}