@@ -516,12 +516,12 @@ Set `action` to one of the following:
516516- after - append to specific node (use the ` referenceNode ` property)
517517
518518``` javascript
519- var SignedXml = require (" xml-crypto" ).SignedXml ,
520- fs = require (" fs" );
519+ const SignedXml = require (" xml-crypto" ).SignedXml ;
520+ const fs = require (" fs" );
521521
522- var xml = " <library>" + " <book>" + " <name>Harry Potter</name>" + " </book>" + " </library>" ;
522+ const xml = " <library>" + " <book>" + " <name>Harry Potter</name>" + " </book>" + " </library>" ;
523523
524- var sig = new SignedXml ({ privateKey: fs .readFileSync (" client.pem" ) });
524+ const sig = new SignedXml ({ privateKey: fs .readFileSync (" client.pem" ) });
525525sig .addReference ({
526526 xpath: " //*[local-name(.)='book']" ,
527527 digestAlgorithm: " http://www.w3.org/2000/09/xmldsig#sha1" ,
@@ -530,7 +530,7 @@ sig.addReference({
530530sig .canonicalizationAlgorithm = " http://www.w3.org/2001/10/xml-exc-c14n#" ;
531531sig .signatureAlgorithm = " http://www.w3.org/2000/09/xmldsig#rsa-sha1" ;
532532sig .computeSignature (xml, {
533- location: { reference: " //*[local-name(.)='book']" , action: " after" }, // This will place the signature after the book element
533+ location: { reference: " //*[local-name(.)='book']" , action: " after" }, // This will place the signature after the book element
534534});
535535```
536536
@@ -539,10 +539,10 @@ sig.computeSignature(xml, {
539539Use the ` objects ` option when creating a SignedXml instance to add custom Objects to the signature.
540540
541541``` javascript
542- var SignedXml = require (" xml-crypto" ).SignedXml ,
543- fs = require (" fs" );
542+ const SignedXml = require (" xml-crypto" ).SignedXml ;
543+ const fs = require (" fs" );
544544
545- var xml = " <library>" + " <book>" + " <name>Harry Potter</name>" + " </book>" + " </library>" ;
545+ const xml = " <library>" + " <book>" + " <name>Harry Potter</name>" + " </book>" + " </library>" ;
546546
547547const sig = new SignedXml ({
548548 privateKey: fs .readFileSync (" client.pem" ),
@@ -562,7 +562,7 @@ const sig = new SignedXml({
562562// Add a reference to the Object element
563563sig .addReference ({
564564 xpath: " //*[@Id='Object1']" ,
565- digestAlgorithm: " http://www.w3.org/2000/09/xmldsig#sha1 " ,
565+ digestAlgorithm: " http://www.w3.org/2001/04/xmlenc#sha256 " ,
566566 transforms: [" http://www.w3.org/2001/10/xml-exc-c14n#" ],
567567});
568568
0 commit comments