xml-crypto
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -137,3 +137,3 @@ var select = require('./xpath.js').SelectNodes | ||
*/ | ||
function SignedXml(idMode) { | ||
function SignedXml(idMode, options) { | ||
this.idMode = idMode | ||
@@ -153,2 +153,4 @@ this.references = [] | ||
this.keyInfo = null | ||
this.idAttributes = [ 'Id', 'ID' ]; | ||
if (options && options.idAttribute) this.idAttributes.splice(0, 0, options.idAttribute); | ||
} | ||
@@ -230,12 +232,14 @@ | ||
var uri = ref.uri[0]=="#" ? ref.uri.substring(1) : ref.uri | ||
var elem = select(doc, "//*[@*[local-name(.)='Id']='" + uri + "']") | ||
var elem = []; | ||
for (var index in this.idAttributes) { | ||
elem = select(doc, "//*[@*[local-name(.)='" + this.idAttributes[index] + "']='" + uri + "']") | ||
if (elem.length > 0) break; | ||
} | ||
if (elem.length==0) { | ||
elem = select(doc, "//*[@*[local-name(.)='ID']='" + uri + "']") | ||
if (elem.length==0) { | ||
this.validationErrors.push("invalid signature: the signature refernces an element with uri "+ | ||
ref.uri + " but could not find such element in the xml") | ||
return false | ||
} | ||
this.validationErrors.push("invalid signature: the signature refernces an element with uri "+ | ||
ref.uri + " but could not find such element in the xml") | ||
return false | ||
} | ||
var canonXml = this.getCanonXml(ref.transforms, elem[0]) | ||
@@ -242,0 +246,0 @@ var hash = this.findHashAlgorithm(ref.digestAlgorithm) |
{ | ||
"name": "xml-crypto", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Xml digital signature and encryption library for Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { "node": ">=0.4.0" }, |
## xml-crypto | ||
An xml digital signature library for node. Xml encryption is coming soon. Written is pure javascript! | ||
For more information visit [my blog](http://webservices20.blogspot.com/). | ||
For more information visit [my blog](http://webservices20.blogspot.com/) or [my twitter](https://twitter.com/YaronNaveh). | ||
@@ -6,0 +6,0 @@ ## Install |
@@ -166,3 +166,3 @@ var ExclusiveCanonicalization = require("../lib/exclusive-canonicalization").ExclusiveCanonicalization | ||
compare(test, | ||
"<root><child><inner></inner</child></root>", | ||
"<root><child><inner></inner></child></root>", | ||
"//*[local-name(.)='child']", | ||
@@ -169,0 +169,0 @@ "<child><inner></inner></child>") |
@@ -350,6 +350,12 @@ var select = require('../lib/xpath.js').SelectNodes | ||
//verify each of the signed nodes now has an "Id" attribute with the right value | ||
xml_assert.nodeExists(test, doc, xpath.replace("{id}", "0").replace("{elem}", "x")) | ||
xml_assert.nodeExists(test, doc, xpath.replace("{id}", "1").replace("{elem}", "y")) | ||
xml_assert.nodeExists(test, doc, xpath.replace("{id}", "2").replace("{elem}", "w")) | ||
nodeExists(test, doc, xpath.replace("{id}", "0").replace("{elem}", "x")) | ||
nodeExists(test, doc, xpath.replace("{id}", "1").replace("{elem}", "y")) | ||
nodeExists(test, doc, xpath.replace("{id}", "2").replace("{elem}", "w")) | ||
} | ||
} | ||
function nodeExists(test, doc, xpath) { | ||
if (!doc && !xpath) return | ||
var node = select(doc, xpath) | ||
test.ok(node.length==1, "xpath " + xpath + " not found") | ||
} |
@@ -0,0 +0,0 @@ var select = require('../lib/xpath.js').SelectNodes |
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
322908
5153