diff --git a/lib/PayPro.js b/lib/PayPro.js index 471992f..d5f3f9f 100644 --- a/lib/PayPro.js +++ b/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; }; diff --git a/lib/browser/PayPro.js b/lib/browser/PayPro.js index 6c845ef..0d47462 100644 --- a/lib/browser/PayPro.js +++ b/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; }; diff --git a/lib/common/PayPro.js b/lib/common/PayPro.js index 3813bad..9b151a4 100644 --- a/lib/common/PayPro.js +++ b/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; }