11import type {
2- CanonicalizationAlgorithmName ,
3- TransformAlgorithmName ,
2+ CanonicalizationAlgorithmURI ,
3+ TransformAlgorithmURI ,
44 TransformAlgorithmOptions ,
55 ComputeSignatureOptions ,
66 ErrorFirstCallback ,
77 GetKeyInfoContentArgs ,
8- HashAlgorithmName ,
8+ HashAlgorithmURI ,
99 IdAttributeType ,
1010 ObjectAttributes ,
1111 Reference ,
12- SignatureAlgorithmName ,
12+ SignatureAlgorithmURI ,
1313 SignedXmlOptions ,
14- DigestAlgorithmMap ,
14+ HashAlgorithmMap ,
1515 SignatureAlgorithmMap ,
1616 CanonicalizationAlgorithmMap ,
1717 TransformAlgorithmMap ,
@@ -32,7 +32,7 @@ import * as utils from "./utils";
3232import { XMLDSIG_URIS } from "./xmldsig-uris" ;
3333const {
3434 CANONICALIZATION_ALGORITHMS ,
35- DIGEST_ALGORITHMS ,
35+ HASH_ALGORITHMS ,
3636 SIGNATURE_ALGORITHMS ,
3737 TRANSFORM_ALGORITHMS ,
3838 NAMESPACES ,
@@ -60,13 +60,13 @@ export class SignedXml {
6060 publicCert ?: crypto . KeyLike ;
6161 /**
6262 * One of the supported signature algorithms.
63- * @see {@link SignatureAlgorithmName }
63+ * @see {@link SignatureAlgorithmURI }
6464 */
65- signatureAlgorithm ?: SignatureAlgorithmName = undefined ;
65+ signatureAlgorithm ?: SignatureAlgorithmURI = undefined ;
6666 /**
6767 * Rules used to convert an XML document into its canonical form.
6868 */
69- canonicalizationAlgorithm ?: CanonicalizationAlgorithmName = undefined ;
69+ canonicalizationAlgorithm ?: CanonicalizationAlgorithmURI = undefined ;
7070 /**
7171 * It specifies a list of namespace prefixes that should be considered "inclusive" during the canonicalization process.
7272 * Only applicable when using exclusive canonicalization.
@@ -79,7 +79,7 @@ export class SignedXml {
7979 } ;
8080
8181 maxTransforms : number | null ;
82- implicitTransforms : ReadonlyArray < TransformAlgorithmName > = [ ] ;
82+ implicitTransforms : ReadonlyArray < TransformAlgorithmURI > = [ ] ;
8383 keyInfoAttributes : { [ attrName : string ] : string } = { } ;
8484 getKeyInfoContent = SignedXml . getKeyInfoContent ;
8585 getCertFromKeyInfo = SignedXml . getCertFromKeyInfo ;
@@ -116,7 +116,7 @@ export class SignedXml {
116116 /**
117117 * To add a new hash algorithm create a new class that implements the {@link HashAlgorithm} interface, and register it here. More info: {@link https://github.com/node-saml/xml-crypto#customizing-algorithms|Customizing Algorithms}
118118 */
119- HashAlgorithms : DigestAlgorithmMap ;
119+ HashAlgorithms : HashAlgorithmMap ;
120120
121121 /**
122122 * To add a new signature algorithm create a new class that implements the {@link SignatureAlgorithm} interface, and register it here. More info: {@link https://github.com/node-saml/xml-crypto#customizing-algorithms|Customizing Algorithms}
@@ -144,11 +144,11 @@ export class SignedXml {
144144 [ TRANSFORM_ALGORITHMS . ENVELOPED_SIGNATURE ] : envelopedSignatures . EnvelopedSignature ,
145145 } ) ;
146146
147- static readonly getDefaultDigestAlgorithms = ( ) : DigestAlgorithmMap => ( {
147+ static readonly getDefaultHashAlgorithms = ( ) : HashAlgorithmMap => ( {
148148 // TODO: In v7.x we may consider removing sha1 from defaults
149- [ DIGEST_ALGORITHMS . SHA1 ] : hashAlgorithms . Sha1 ,
150- [ DIGEST_ALGORITHMS . SHA256 ] : hashAlgorithms . Sha256 ,
151- [ DIGEST_ALGORITHMS . SHA512 ] : hashAlgorithms . Sha512 ,
149+ [ HASH_ALGORITHMS . SHA1 ] : hashAlgorithms . Sha1 ,
150+ [ HASH_ALGORITHMS . SHA256 ] : hashAlgorithms . Sha256 ,
151+ [ HASH_ALGORITHMS . SHA512 ] : hashAlgorithms . Sha512 ,
152152 } ) ;
153153
154154 static readonly getDefaultSignatureAlgorithms = ( ) : SignatureAlgorithmMap => ( {
@@ -187,7 +187,7 @@ export class SignedXml {
187187 getCertFromKeyInfo,
188188 objects,
189189 allowedSignatureAlgorithms,
190- allowedDigestAlgorithms ,
190+ allowedHashAlgorithms ,
191191 allowedCanonicalizationAlgorithms,
192192 allowedTransformAlgorithms,
193193 } = options ;
@@ -215,7 +215,7 @@ export class SignedXml {
215215 this . objects = objects ;
216216 this . CanonicalizationAlgorithms =
217217 allowedCanonicalizationAlgorithms ?? SignedXml . getDefaultCanonicalizationAlgorithms ( ) ;
218- this . HashAlgorithms = allowedDigestAlgorithms ?? SignedXml . getDefaultDigestAlgorithms ( ) ;
218+ this . HashAlgorithms = allowedHashAlgorithms ?? SignedXml . getDefaultHashAlgorithms ( ) ;
219219 this . SignatureAlgorithms =
220220 allowedSignatureAlgorithms ?? SignedXml . getDefaultSignatureAlgorithms ( ) ;
221221 // TODO: use default transform algorithms if not provided (breaking change)
@@ -503,7 +503,7 @@ export class SignedXml {
503503 }
504504 }
505505
506- private findSignatureAlgorithm ( name ?: SignatureAlgorithmName ) {
506+ private findSignatureAlgorithm ( name ?: SignatureAlgorithmURI ) {
507507 if ( name == null ) {
508508 throw new Error ( "signatureAlgorithm is required" ) ;
509509 }
@@ -515,7 +515,7 @@ export class SignedXml {
515515 }
516516 }
517517
518- private findCanonicalizationAlgorithm ( name : CanonicalizationAlgorithmName ) {
518+ private findCanonicalizationAlgorithm ( name : CanonicalizationAlgorithmURI ) {
519519 if ( name != null ) {
520520 const algo = this . CanonicalizationAlgorithms [ name ] ;
521521 if ( algo ) {
@@ -526,7 +526,7 @@ export class SignedXml {
526526 throw new Error ( `canonicalization algorithm '${ name } ' is not supported` ) ;
527527 }
528528
529- private findHashAlgorithm ( name : HashAlgorithmName ) {
529+ private findHashAlgorithm ( name : HashAlgorithmURI ) {
530530 const algo = this . HashAlgorithms [ name ] ;
531531 if ( algo ) {
532532 return new algo ( ) ;
@@ -535,7 +535,7 @@ export class SignedXml {
535535 }
536536 }
537537
538- private findTransformAlgorithm ( name : TransformAlgorithmName ) {
538+ private findTransformAlgorithm ( name : TransformAlgorithmURI ) {
539539 // TODO: remove this fallback (breaking change)
540540 if ( this . TransformAlgorithms == null ) {
541541 return this . findCanonicalizationAlgorithm ( name ) ;
@@ -709,7 +709,7 @@ export class SignedXml {
709709 }
710710
711711 if ( isDomNode . isAttributeNode ( node ) ) {
712- this . canonicalizationAlgorithm = node . value as CanonicalizationAlgorithmName ;
712+ this . canonicalizationAlgorithm = node . value as CanonicalizationAlgorithmURI ;
713713
714714 if ( ! this . findCanonicalizationAlgorithm ( this . canonicalizationAlgorithm ) ) {
715715 throw new Error (
@@ -724,7 +724,7 @@ export class SignedXml {
724724 ) ;
725725
726726 if ( isDomNode . isAttributeNode ( signatureAlgorithm ) ) {
727- this . signatureAlgorithm = signatureAlgorithm . value as SignatureAlgorithmName ;
727+ this . signatureAlgorithm = signatureAlgorithm . value as SignatureAlgorithmURI ;
728728 }
729729
730730 const signedInfoNodes = utils . findChildren ( this . signatureNode , "SignedInfo" ) ;
@@ -862,9 +862,9 @@ export class SignedXml {
862862 */
863863 if (
864864 transforms . length === 0 ||
865- transforms [ transforms . length - 1 ] === "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
865+ transforms [ transforms . length - 1 ] === TRANSFORM_ALGORITHMS . ENVELOPED_SIGNATURE
866866 ) {
867- transforms . push ( "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" ) ;
867+ transforms . push ( CANONICALIZATION_ALGORITHMS . C14N ) ;
868868 }
869869 const refUri = isDomNode . isElementNode ( refNode )
870870 ? refNode . getAttribute ( "URI" ) || undefined
@@ -1192,7 +1192,7 @@ export class SignedXml {
11921192 }
11931193
11941194 const currentPrefix = prefix ? `${ prefix } :` : "" ;
1195- const signatureNamespace = "http://www.w3.org/2000/09/xmldsig#" ;
1195+ const signatureNamespace = XMLDSIG_URIS . NAMESPACES . ds ;
11961196
11971197 // Find the SignedInfo element to append to
11981198 const signedInfoNode = xpath . select1 ( `./*[local-name(.)='SignedInfo']` , signatureElem ) ;
@@ -1395,11 +1395,7 @@ export class SignedXml {
13951395 let attr ;
13961396
13971397 if ( this . idMode === "wssecurity" ) {
1398- attr = utils . findAttr (
1399- node ,
1400- "Id" ,
1401- "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" ,
1402- ) ;
1398+ attr = utils . findAttr ( node , "Id" , XMLDSIG_URIS . NAMESPACES . wsu ) ;
14031399 } else {
14041400 this . idAttributes . some ( ( idAttribute ) => {
14051401 if ( typeof idAttribute === "string" ) {
0 commit comments