Comparing version 2.0.0-rc.3 to 2.0.0
@@ -241,3 +241,3 @@ "use strict"; | ||
selection.forEach(function (_s) { | ||
data.push(_s.nodeValue.toString()); | ||
data.push(String(_s.nodeValue).trim().replace(/\r?\n/g, '')); | ||
}); | ||
@@ -344,7 +344,6 @@ return data.length === 1 ? data[0] : data; | ||
*/ | ||
verifySignature: function (xml, opts, index) { | ||
if (index === void 0) { index = 0; } | ||
verifySignature: function (xml, opts) { | ||
try { | ||
var doc = new dom().parseFromString(xml); | ||
var selection_1 = xpath_1.select("//*[local-name(.)='Signature']", doc); | ||
var selection = xpath_1.select("//*[local-name(.)='Signature']", doc); | ||
var sig_1 = new xml_crypto_1.SignedXml(); | ||
@@ -362,5 +361,5 @@ sig_1.signatureAlgorithm = opts.signatureAlgorithm; | ||
var res_1 = true; | ||
selection_1.forEach(function (s) { | ||
var signature = new dom().parseFromString(selection_1[index].toString()); | ||
xml = xml.replace(/<ds:Signature(.*?)>(.*?)<\/(.*?)ds:Signature>/, ''); | ||
xml = xml.replace(/<ds:Signature(.*?)>(.*?)<\/(.*?)ds:Signature>/g, ''); | ||
selection.forEach(function (s) { | ||
var signature = new dom().parseFromString(s.toString()); | ||
sig_1.loadSignature(signature); | ||
@@ -570,8 +569,8 @@ res_1 = res_1 && sig_1.checkSignature(xml); | ||
var parseEntireXML = new dom().parseFromString(String(entireXML)); | ||
var encryptedDataNode = getEntireBody(parseEntireXML, 'EncryptedData'); | ||
var encryptedData = !lodash_1.isUndefined(encryptedDataNode) ? utility_1.default.parseString(String(encryptedDataNode)) : ''; | ||
if (encryptedData === '') { | ||
var encryptedAssertionNode = getEntireBody(parseEntireXML, 'EncryptedAssertion'); | ||
var encryptedAssertion = !lodash_1.isUndefined(encryptedAssertionNode) ? utility_1.default.parseString(String(encryptedAssertionNode)) : ''; | ||
if (encryptedAssertion === '') { | ||
return reject(new Error('undefined assertion or invalid syntax')); | ||
} | ||
return xmlenc.decrypt(encryptedData, { | ||
return xmlenc.decrypt(encryptedAssertion, { | ||
key: utility_1.default.readPrivateKey(hereSetting.encPrivateKey, hereSetting.encPrivateKeyPass), | ||
@@ -585,3 +584,3 @@ }, function (err, res) { | ||
} | ||
return resolve(String(parseEntireXML).replace('<saml:EncryptedAssertion>', '').replace('</saml:EncryptedAssertion>', '').replace(encryptedData, res)); | ||
return resolve(String(parseEntireXML).replace(/\r?\n/g, '').replace(/<saml:EncryptedAssertion(.*?)>(.*?)<\/(.*?)EncryptedAssertion>/g, res)); | ||
}); | ||
@@ -588,0 +587,0 @@ }); |
{ | ||
"name": "samlify", | ||
"version": "2.0.0-rc.3", | ||
"version": "2.0.0", | ||
"description": "High-level API for Single Sign On (SAML 2.0)", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -47,4 +47,4 @@ /** | ||
[key: string]: any; | ||
signature?: any; | ||
issuer?: string; | ||
signature?: string | string[]; | ||
issuer?: string | string[]; | ||
nameid?: string; | ||
@@ -324,3 +324,3 @@ notexist?: boolean; | ||
selection.forEach(_s => { | ||
data.push(_s.nodeValue.toString()); | ||
data.push(String(_s.nodeValue).trim().replace(/\r?\n/g, '')); | ||
}); | ||
@@ -448,3 +448,3 @@ return data.length === 1 ? data[0] : data; | ||
*/ | ||
verifySignature(xml: string, opts: SignatureVerifierOptions, index: number = 0) { | ||
verifySignature(xml: string, opts: SignatureVerifierOptions) { | ||
@@ -464,5 +464,5 @@ try { | ||
let res = true; | ||
xml = xml.replace(/<ds:Signature(.*?)>(.*?)<\/(.*?)ds:Signature>/g, ''); | ||
selection.forEach(s => { | ||
const signature = new dom().parseFromString(selection[index].toString()); | ||
xml = xml.replace(/<ds:Signature(.*?)>(.*?)<\/(.*?)ds:Signature>/, ''); | ||
const signature = new dom().parseFromString(s.toString()); | ||
sig.loadSignature(signature); | ||
@@ -668,8 +668,8 @@ res = res && sig.checkSignature(xml); | ||
const parseEntireXML = new dom().parseFromString(String(entireXML)); | ||
const encryptedDataNode = getEntireBody(parseEntireXML, 'EncryptedData'); | ||
const encryptedData = !isUndefined(encryptedDataNode) ? utility.parseString(String(encryptedDataNode)) : ''; | ||
if (encryptedData === '') { | ||
const encryptedAssertionNode = getEntireBody(parseEntireXML, 'EncryptedAssertion'); | ||
const encryptedAssertion = !isUndefined(encryptedAssertionNode) ? utility.parseString(String(encryptedAssertionNode)) : ''; | ||
if (encryptedAssertion === '') { | ||
return reject(new Error('undefined assertion or invalid syntax')); | ||
} | ||
return xmlenc.decrypt(encryptedData, { | ||
return xmlenc.decrypt(encryptedAssertion, { | ||
key: utility.readPrivateKey(hereSetting.encPrivateKey, hereSetting.encPrivateKeyPass), | ||
@@ -683,3 +683,3 @@ }, (err, res) => { | ||
} | ||
return resolve(String(parseEntireXML).replace('<saml:EncryptedAssertion>', '').replace('</saml:EncryptedAssertion>', '').replace(encryptedData, res)); | ||
return resolve(String(parseEntireXML).replace(/\r?\n/g, '').replace(/<saml:EncryptedAssertion(.*?)>(.*?)<\/(.*?)EncryptedAssertion>/g, res)); | ||
}); | ||
@@ -686,0 +686,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5131028
1
5066