xml-crypto
Advanced tools
Comparing version 0.5.27 to 0.6.0
@@ -17,5 +17,7 @@ /* jshint laxcomma: true */ | ||
var right = b.namespaceURI + b.localName | ||
var res = left.localeCompare(right); | ||
return res; | ||
if (left===right) return 0 | ||
else if (left<right) return -1 | ||
else return 1 | ||
}; | ||
@@ -27,3 +29,3 @@ | ||
if (attr1 == attr2) { return 0; } | ||
return attr1.localeCompare(attr2); | ||
return attr1.localeCompare(attr2); | ||
}; | ||
@@ -30,0 +32,0 @@ |
@@ -182,3 +182,3 @@ var select = require('xpath.js') | ||
this.signatureXml = "" | ||
this.signatureXmlDoc = null | ||
this.signatureNode = null | ||
this.signatureValue = "" | ||
@@ -234,3 +234,3 @@ this.originalXmlWithIds = "" | ||
SignedXml.prototype.validateSignatureValue = function() { | ||
var signedInfo = utils.findChilds(this.signatureXmlDoc.documentElement, "SignedInfo") | ||
var signedInfo = utils.findChilds(this.signatureNode, "SignedInfo") | ||
if (signedInfo.length==0) throw new Error("could not find SignedInfo element in the message") | ||
@@ -306,9 +306,12 @@ var signedInfoCanon = this.getCanonXml([this.canonicalizationAlgorithm], signedInfo[0]) | ||
SignedXml.prototype.loadSignature = function(signatureXml) { | ||
this.signatureXml = signatureXml | ||
SignedXml.prototype.loadSignature = function(signatureNode) { | ||
if (typeof signatureNode === 'string') { | ||
this.signatureNode = signatureNode = new Dom().parseFromString(signatureNode); | ||
} else { | ||
this.signatureNode = signatureNode; | ||
} | ||
var doc = new Dom().parseFromString(signatureXml) | ||
this.signatureXmlDoc = doc | ||
this.signatureXml = signatureNode.toString(); | ||
var nodes = select(doc, "//*[local-name(.)='CanonicalizationMethod']/@Algorithm") | ||
var nodes = select(signatureNode, ".//*[local-name(.)='CanonicalizationMethod']/@Algorithm") | ||
if (nodes.length==0) throw new Error("could not find CanonicalizationMethod/@Algorithm element") | ||
@@ -318,6 +321,6 @@ this.canonicalizationAlgorithm = nodes[0].value | ||
this.signatureAlgorithm = | ||
utils.findFirst(doc, "//*[local-name(.)='SignatureMethod']/@Algorithm").value | ||
utils.findFirst(signatureNode, ".//*[local-name(.)='SignatureMethod']/@Algorithm").value | ||
this.references = [] | ||
var references = select(doc, "//*[local-name(.)='SignedInfo']/*[local-name(.)='Reference']") | ||
var references = select(signatureNode, ".//*[local-name(.)='SignedInfo']/*[local-name(.)='Reference']") | ||
if (references.length == 0) throw new Error("could not find any Reference elements") | ||
@@ -332,5 +335,5 @@ | ||
this.signatureValue = | ||
utils.findFirst(doc, "//*[local-name(.)='SignatureValue']/text()").data.replace(/\n/g, '') | ||
utils.findFirst(signatureNode, ".//*[local-name(.)='SignatureValue']/text()").data.replace(/\n/g, '') | ||
this.keyInfo = select(doc, "//*[local-name(.)='KeyInfo']") | ||
this.keyInfo = select(signatureNode, ".//*[local-name(.)='KeyInfo']") | ||
} | ||
@@ -337,0 +340,0 @@ |
{ | ||
"name": "xml-crypto", | ||
"version": "0.5.27", | ||
"version": "0.6.0", | ||
"description": "Xml digital signature and encryption library for Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { "node": ">=0.4.0" }, |
@@ -11,3 +11,3 @@ var crypto = require('../index'); | ||
sig.keyInfoProvider = new crypto.FileKeyInfo("./test/static/feide_public.pem"); | ||
sig.loadSignature(signature.toString()); | ||
sig.loadSignature(signature); | ||
var result = sig.checkSignature(xml); | ||
@@ -24,3 +24,3 @@ test.equal(result, true); | ||
sig.keyInfoProvider = new crypto.FileKeyInfo("./test/static/saml_external_ns.pem"); | ||
sig.loadSignature(signature.toString()); | ||
sig.loadSignature(signature); | ||
var result = sig.checkSignature(xml); | ||
@@ -37,3 +37,3 @@ test.equal(result, true); | ||
sig.keyInfoProvider = new crypto.FileKeyInfo("./test/static/feide_public.pem"); | ||
sig.loadSignature(signature.toString()); | ||
sig.loadSignature(signature); | ||
var result = sig.checkSignature(xml); | ||
@@ -40,0 +40,0 @@ // This doesn't matter, just want to make sure that we don't fail due to unknown algorithm |
@@ -58,3 +58,3 @@ var select = require('xpath.js') | ||
sig.keyInfoProvider = new crypto.FileKeyInfo("./test/static/empty_uri.pem"); | ||
sig.loadSignature(signature.toString()); | ||
sig.loadSignature(signature); | ||
var result = sig.checkSignature(sampleXml); | ||
@@ -83,3 +83,3 @@ test.equal(result, true); | ||
sig.keyInfoProvider = new crypto.FileKeyInfo("./test/static/windows_store_certificate.pem"); | ||
sig.loadSignature(signature.toString()); | ||
sig.loadSignature(signature); | ||
var result = sig.checkSignature(xml); | ||
@@ -101,3 +101,3 @@ test.equal(result, true); | ||
sig.keyInfoProvider = new crypto.FileKeyInfo("./test/static/signature_with_inclusivenamespaces.pem"); | ||
sig.loadSignature(signature.toString()); | ||
sig.loadSignature(signature); | ||
var result = sig.checkSignature(xml); | ||
@@ -104,0 +104,0 @@ test.equal(result, true); |
@@ -479,2 +479,3 @@ var select = require('xpath.js') | ||
passLoadSignature(test, "./test/static/valid_signature.xml"); | ||
passLoadSignature(test, "./test/static/valid_signature.xml", true); | ||
passLoadSignature(test, "./test/static/valid_signature_with_root_level_sig_namespace.xml"); | ||
@@ -529,3 +530,3 @@ test.done() | ||
function passLoadSignature(test, file) { | ||
function passLoadSignature(test, file, toString) { | ||
var xml = fs.readFileSync(file).toString() | ||
@@ -535,3 +536,3 @@ var doc = new dom().parseFromString(xml) | ||
var sig = new SignedXml() | ||
sig.loadSignature(node.toString()) | ||
sig.loadSignature(toString ? node.toString() : node) | ||
@@ -582,3 +583,3 @@ test.equal("http://www.w3.org/2001/10/xml-exc-c14n#", | ||
sig.keyInfoProvider = new FileKeyInfo("./test/static/client_public.pem") | ||
sig.loadSignature(node.toString()) | ||
sig.loadSignature(node) | ||
var res = sig.checkSignature(xml) | ||
@@ -585,0 +586,0 @@ console.log(sig.validationErrors) |
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
303795
2294