paypro: allow users to return verification properties via PayPro.verify.
This commit is contained in:
parent
e34f9a4061
commit
f34b98d253
|
@ -41,7 +41,7 @@ PayPro.prototype.x509Sign = function(key) {
|
||||||
return sig;
|
return sig;
|
||||||
};
|
};
|
||||||
|
|
||||||
PayPro.prototype.x509Verify = function() {
|
PayPro.prototype.x509Verify = function(returnTrust) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var pki_type = this.get('pki_type');
|
var pki_type = this.get('pki_type');
|
||||||
|
@ -125,6 +125,13 @@ PayPro.prototype.x509Verify = function() {
|
||||||
&& sigVerified;
|
&& sigVerified;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (returnTrust) {
|
||||||
|
return {
|
||||||
|
verified: verified,
|
||||||
|
chainVerified: chainVerified
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return verified && chainVerified;
|
return verified && chainVerified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ PayPro.prototype.x509Sign = function(key) {
|
||||||
return sig;
|
return sig;
|
||||||
};
|
};
|
||||||
|
|
||||||
PayPro.prototype.x509Verify = function(key) {
|
PayPro.prototype.x509Verify = function(returnTrust) {
|
||||||
var sig = this.get('signature');
|
var sig = this.get('signature');
|
||||||
var pki_type = this.get('pki_type');
|
var pki_type = this.get('pki_type');
|
||||||
var pki_data = this.get('pki_data');
|
var pki_data = this.get('pki_data');
|
||||||
|
@ -147,6 +147,13 @@ PayPro.prototype.x509Verify = function(key) {
|
||||||
&& sigVerified;
|
&& sigVerified;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (returnTrust) {
|
||||||
|
return {
|
||||||
|
verified: verified,
|
||||||
|
chainVerified: chainVerified
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return verified && chainVerified;
|
return verified && chainVerified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ PayPro.prototype.sign = function(key) {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
PayPro.prototype.verify = function() {
|
PayPro.prototype.verify = function(returnTrust) {
|
||||||
if (this.messageType !== 'PaymentRequest')
|
if (this.messageType !== 'PaymentRequest')
|
||||||
throw new Error('Verifying can only be performed on a PaymentRequest');
|
throw new Error('Verifying can only be performed on a PaymentRequest');
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ PayPro.prototype.verify = function() {
|
||||||
if (pki_type === 'SIN') {
|
if (pki_type === 'SIN') {
|
||||||
return this.sinVerify();
|
return this.sinVerify();
|
||||||
} else if (pki_type === 'x509+sha1' || pki_type === 'x509+sha256') {
|
} else if (pki_type === 'x509+sha1' || pki_type === 'x509+sha256') {
|
||||||
return this.x509Verify();
|
return this.x509Verify(returnTrust);
|
||||||
} else if (pki_type === 'none') {
|
} else if (pki_type === 'none') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue