You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-1Lines changed: 40 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -250,17 +250,20 @@ The `SignedXml` constructor provides an abstraction for sign and verify xml docu
250
250
-`keyInfoAttributes` - object - default `{}` - a hash of attributes and values `attrName: value` to add to the KeyInfo node
251
251
-`getKeyInfoContent` - function - default `noop` - a function that returns the content of the KeyInfo node
252
252
-`getCertFromKeyInfo` - function - default `SignedXml.getCertFromKeyInfo` - a function that returns the certificate from the `<KeyInfo />` node
253
+
-`objects` - array - default `undefined` - an array of objects defining the content of the `<Object/>` nodes
253
254
254
255
#### API
255
256
256
257
A `SignedXml` object provides the following methods:
257
258
258
259
To sign xml documents:
259
260
260
-
-`addReference(xpath, transforms, digestAlgorithm)` - adds a reference to a xml element where:
261
+
-`addReference({ xpath, transforms, digestAlgorithm, id, type })` - adds a reference to a xml element where:
261
262
-`xpath` - a string containing a XPath expression referencing a xml element
262
263
-`transforms` - an array of [transform algorithms](#canonicalization-and-transformation-algorithms), the referenced element will be transformed for each value in the array
263
264
-`digestAlgorithm` - one of the supported [hashing algorithms](#hashing-algorithms)
265
+
-`id` - an optional `Id` attribute to add to the reference element
266
+
-`type` - the optional `Type` attribute to add to the reference element (represented as a URI)
264
267
-`computeSignature(xml, [options])` - compute the signature of the given xml where:
265
268
-`xml` - a string containing a xml document
266
269
-`options` - an object with the following properties:
@@ -523,6 +526,42 @@ sig.computeSignature(xml, {
523
526
});
524
527
```
525
528
529
+
### How to add custom Objects to the signature
530
+
531
+
Use the `objects` option when creating a SignedXml instance to add custom Objects to the signature.
532
+
533
+
```javascript
534
+
var SignedXml =require("xml-crypto").SignedXml,
535
+
fs =require("fs");
536
+
537
+
var xml ="<library>"+"<book>"+"<name>Harry Potter</name>"+"</book>"+"</library>";
0 commit comments