xml-crypto
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -0,0 +0,0 @@ var select = require('xml-crypto').xpath |
@@ -0,0 +0,0 @@ var select = require('xpath').select |
@@ -0,0 +0,0 @@ /* jshint laxcomma: true */ |
@@ -0,0 +0,0 @@ var xpath = require('xpath'); |
@@ -0,0 +0,0 @@ /* jshint laxcomma: true */ |
@@ -664,2 +664,3 @@ var xpath = require('xpath') | ||
* - `location` {{ reference: String, action: String }} | ||
* - `existingPrefixes` {Object} A hash of prefixes and namespaces `prefix: namespace` already in the xml | ||
* An object with a `reference` key which should | ||
@@ -686,2 +687,3 @@ * contain a XPath expression, an `action` key which | ||
location = opts.location || {}; | ||
existingPrefixes = opts.existingPrefixes || {}; | ||
// defaults to the root node | ||
@@ -724,4 +726,13 @@ location.reference = location.reference || "/*"; | ||
var signatureDoc = new Dom().parseFromString(this.signatureXml) | ||
var existingPrefixesString = "" | ||
Object.keys(existingPrefixes).forEach(function(key) { | ||
existingPrefixesString += "xmlns:" + key + '="' + existingPrefixes[key] + '" ' | ||
}); | ||
// A trick to remove the namespaces that already exist in the xml | ||
// This only works if the prefix and namespace match with those in te xml | ||
var dummySignatureWrapper = "<Dummy " + existingPrefixesString + ">" + this.signatureXml + "</Dummy>" | ||
var xml = new Dom().parseFromString(dummySignatureWrapper) | ||
var signatureDoc = xml.documentElement.firstChild; | ||
var referenceNode = xpath.select(location.reference, doc); | ||
@@ -736,9 +747,9 @@ | ||
if (location.action === "append") { | ||
referenceNode.appendChild(signatureDoc.documentElement); | ||
referenceNode.appendChild(signatureDoc); | ||
} else if (location.action === "prepend") { | ||
referenceNode.insertBefore(signatureDoc.documentElement, referenceNode.firstChild); | ||
referenceNode.insertBefore(signatureDoc, referenceNode.firstChild); | ||
} else if (location.action === "before") { | ||
referenceNode.parentNode.insertBefore(signatureDoc.documentElement, referenceNode); | ||
referenceNode.parentNode.insertBefore(signatureDoc, referenceNode); | ||
} else if (location.action === "after") { | ||
referenceNode.parentNode.insertBefore(signatureDoc.documentElement, referenceNode.nextSibling); | ||
referenceNode.parentNode.insertBefore(signatureDoc, referenceNode.nextSibling); | ||
} | ||
@@ -745,0 +756,0 @@ |
@@ -0,0 +0,0 @@ var select = require('xpath').select |
{ | ||
"name": "xml-crypto", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "Xml digital signature and encryption library for Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -207,2 +207,3 @@ ## xml-crypto | ||
- `location` - customize the location of the signature, pass an object with a `reference` key which should contain a XPath expression to a reference node, an `action` key which should contain one of the following values: `append`, `prepend`, `before`, `after` | ||
- `existingPrefixes` - A hash of prefixes and namespaces `prefix: namespace` that shouldn't be in the signature because they already exist in the xml | ||
- `getSignedXml()` - returns the original xml document with the signature in it, **must be called only after `computeSignature`** | ||
@@ -209,0 +210,0 @@ - `getSignatureXml()` - returns just the signature part, **must be called only after `computeSignature`** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
75503
1294
456