@@ -802,6 +802,9 @@ export class SignedXml {
802
802
803
803
signatureXml += this . createSignedInfo ( doc , prefix ) ;
804
804
signatureXml += this . getKeyInfo ( prefix ) ;
805
+ if ( this . xadesQualifyingProperties != null ) {
806
+ signatureXml += `<${ currentPrefix } Object>${ this . xadesQualifyingProperties ( ) } </${ currentPrefix } Object>` ;
807
+ }
805
808
signatureXml += `</${ currentPrefix } Signature>` ;
806
809
807
810
this . originalXmlWithIds = doc . toString ( ) ;
@@ -918,21 +921,29 @@ export class SignedXml {
918
921
prefix = prefix ? `${ prefix } :` : prefix ;
919
922
920
923
for ( const ref of this . getReferences ( ) ) {
921
- const nodes = xpath . selectWithResolver ( ref . xpath ?? "" , doc , this . namespaceResolver ) ;
924
+ let nodes = xpath . selectWithResolver ( ref . xpath ?? "" , doc , this . namespaceResolver ) ;
922
925
923
926
if ( ! utils . isArrayHasLength ( nodes ) ) {
924
- throw new Error (
925
- `the following xpath cannot be signed because it was not found: ${ ref . xpath } ` ,
926
- ) ;
927
+ if ( this . xadesQualifyingProperties != null ) {
928
+ nodes = xpath . selectWithResolver ( ref . xpath ?? "" , new xmldom . DOMParser ( ) . parseFromString ( this . xadesQualifyingProperties ( ) ) , this . namespaceResolver ) ;
929
+ }
930
+ if ( ! utils . isArrayHasLength ( nodes ) ) {
931
+ throw new Error (
932
+ `the following xpath cannot be signed because it was not found: ${ ref . xpath } ` ,
933
+ ) ;
934
+ }
927
935
}
928
936
929
937
for ( const node of nodes ) {
938
+ let addattr = "" ;
939
+ if ( node . localName == "SignedProperties" ) addattr = ' Type="http://uri.etsi.org/01903#SignedProperties"' ;
930
940
if ( ref . isEmptyUri ) {
931
- res += `<${ prefix } Reference URI="">` ;
932
- } else {
933
- const id = this . ensureHasId ( node ) ;
934
- ref . uri = id ;
935
- res += `<${ prefix } Reference URI="#${ id } ">` ;
941
+ res += `<${ prefix } Reference URI=""${ addattr } >` ;
942
+ }
943
+ else {
944
+ const id = this . ensureHasId ( node ) ;
945
+ ref . uri = id ;
946
+ res += `<${ prefix } Reference URI="#${ id } "${ addattr } >` ;
936
947
}
937
948
res += `<${ prefix } Transforms>` ;
938
949
for ( const trans of ref . transforms || [ ] ) {
0 commit comments