xml-crypto
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -11,3 +11,4 @@ var xpath = require('./xpath'); | ||
if (signature) signature.parentNode.removeChild(signature) | ||
return node.toString(); | ||
//return node.toString(); | ||
return node | ||
}; | ||
@@ -14,0 +15,0 @@ |
var utils = require('./utils') | ||
, Dom = require('xmldom').DOMParser | ||
@@ -131,2 +132,4 @@ exports.ExclusiveCanonicalization = ExclusiveCanonicalization | ||
return res | ||
//var doc = new Dom().parseFromString(res) | ||
//return doc.documentElement | ||
} | ||
@@ -133,0 +136,0 @@ |
@@ -412,12 +412,16 @@ var select = require('./xpath.js').SelectNodes | ||
SignedXml.prototype.getCanonXml = function(transforms, node) { | ||
var nodeToSign = node | ||
var canonXml = node.toString() | ||
SignedXml.prototype.getCanonXml = function(transforms, node) { | ||
var canonXml = node | ||
for (var t in transforms) { | ||
var transform = this.findCanonicalizationAlgorithm(transforms[t]) | ||
canonXml = transform.process(nodeToSign) | ||
var canonDoc = new Dom().parseFromString(canonXml) | ||
nodeToSign = canonDoc.documentElement | ||
canonXml = transform.process(canonXml) | ||
//TODO: currently transform.process may return either Node or String value (enveloped transformation returns Node, exclusive-canonicalization returns String). | ||
//This eitehr needs to be more explicit in the API, or all should return the same. | ||
//exclusive-canonicalization returns String since it builds the Xml by hand. If it had used xmldom it would inccorectly minimize empty tags | ||
//to <x/> instead of <x></x> and also incorrectly handle some delicate line break issues. | ||
//enveloped transformation returns Node since if it would return String consider this case: | ||
//<x xmlns:p='ns'><p:y/></x> | ||
//if only y is the node to sign then a string would be <p:y/> without the definition of the p namespace. probably xmldom toString() should have added it. | ||
} | ||
return canonXml | ||
return canonXml.toString() | ||
} | ||
@@ -440,3 +444,3 @@ | ||
attr = utils.findAttr(node, this.idAttributes[index], null); | ||
break; | ||
if (attr !== undefined) break; | ||
} | ||
@@ -443,0 +447,0 @@ } |
{ | ||
"name": "xml-crypto", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Xml digital signature and encryption library for Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { "node": ">=0.4.0" }, |
var ExclusiveCanonicalization = require("../lib/exclusive-canonicalization").ExclusiveCanonicalization | ||
, Dom = require('xmldom').DOMParser | ||
, select = require('../lib/xpath.js').SelectNodes | ||
, SignedXml = require('../lib/signed-xml.js').SignedXml | ||
@@ -11,3 +12,3 @@ | ||
var can = new ExclusiveCanonicalization() | ||
var result = can.process(elem) | ||
var result = can.process(elem).toString() | ||
@@ -288,3 +289,13 @@ test.equal(expected, result) | ||
}, | ||
"Multiple Canonicalization with namespace definition outside of signed element": function (test) { | ||
//var doc = new Dom().parseFromString("<x xmlns:p=\"myns\"><p:y><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"></ds:Signature></p:y></x>") | ||
var doc = new Dom().parseFromString("<x xmlns:p=\"myns\"><p:y></p:y></x>") | ||
var node = select(doc, "//*[local-name(.)='y']")[0] | ||
var sig = new SignedXml() | ||
var res = sig.getCanonXml(["http://www.w3.org/2000/09/xmldsig#enveloped-signature", "http://www.w3.org/2001/10/xml-exc-c14n#"], node) | ||
test.equal("<p:y xmlns:p=\"myns\"></p:y>", res) | ||
test.done() | ||
}, | ||
} |
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
325143
5183