@@ -1094,8 +1094,7 @@ export class SignedXml {
10941094 return ;
10951095 }
10961096
1097- prefix = prefix || "" ;
1098- const prefixed = prefix ? `${ prefix } :` : prefix ;
1097+ const currentPrefix = prefix ? `${ prefix } :` : "" ;
10991098 const signatureNamespace = "http://www.w3.org/2000/09/xmldsig#" ;
11001099
11011100 // Find the SignedInfo element to append to
@@ -1112,9 +1111,9 @@ export class SignedXml {
11121111 ref . xpath ?? "" ,
11131112 doc ,
11141113 this . namespaceResolver ,
1115- ) as Element [ ] ;
1114+ ) ;
11161115
1117- if ( ! nodes . length ) {
1116+ if ( ! utils . isArrayHasLength ( nodes ) ) {
11181117 throw new Error (
11191118 `the following xpath cannot be signed because it was not found: ${ ref . xpath } ` ,
11201119 ) ;
@@ -1168,7 +1167,7 @@ export class SignedXml {
11681167 // Create the reference element directly using DOM methods to avoid namespace issues
11691168 const referenceElem = signatureDoc . createElementNS (
11701169 signatureNamespace ,
1171- `${ prefixed } Reference` ,
1170+ `${ currentPrefix } Reference` ,
11721171 ) ;
11731172 referenceElem . setAttribute ( "URI" , targetUri ) ;
11741173
@@ -1182,14 +1181,14 @@ export class SignedXml {
11821181
11831182 const transformsElem = signatureDoc . createElementNS (
11841183 signatureNamespace ,
1185- `${ prefixed } Transforms` ,
1184+ `${ currentPrefix } Transforms` ,
11861185 ) ;
11871186
11881187 for ( const trans of ref . transforms || [ ] ) {
11891188 const transform = this . findCanonicalizationAlgorithm ( trans ) ;
11901189 const transformElem = signatureDoc . createElementNS (
11911190 signatureNamespace ,
1192- `${ prefixed } Transform` ,
1191+ `${ currentPrefix } Transform` ,
11931192 ) ;
11941193 transformElem . setAttribute ( "Algorithm" , transform . getAlgorithmName ( ) ) ;
11951194
@@ -1216,13 +1215,13 @@ export class SignedXml {
12161215
12171216 const digestMethodElem = signatureDoc . createElementNS (
12181217 signatureNamespace ,
1219- `${ prefixed } DigestMethod` ,
1218+ `${ currentPrefix } DigestMethod` ,
12201219 ) ;
12211220 digestMethodElem . setAttribute ( "Algorithm" , digestAlgorithm . getAlgorithmName ( ) ) ;
12221221
12231222 const digestValueElem = signatureDoc . createElementNS (
12241223 signatureNamespace ,
1225- `${ prefixed } DigestValue` ,
1224+ `${ currentPrefix } DigestValue` ,
12261225 ) ;
12271226 digestValueElem . textContent = digestAlgorithm . getHash ( canonXml ) ;
12281227
@@ -1372,10 +1371,7 @@ export class SignedXml {
13721371 }
13731372 const transform = this . findCanonicalizationAlgorithm ( this . canonicalizationAlgorithm ) ;
13741373 const algo = this . findSignatureAlgorithm ( this . signatureAlgorithm ) ;
1375- let currentPrefix ;
1376-
1377- currentPrefix = prefix || "" ;
1378- currentPrefix = currentPrefix ? `${ currentPrefix } :` : currentPrefix ;
1374+ const currentPrefix = prefix ? `${ prefix } :` : "" ;
13791375
13801376 let res = `<${ currentPrefix } SignedInfo>` ;
13811377 res += `<${ currentPrefix } CanonicalizationMethod Algorithm="${ transform . getAlgorithmName ( ) } "` ;
0 commit comments