@@ -70,7 +70,7 @@ export class SignedXml {
70
70
* Contains the references that were signed.
71
71
* @see {@link Reference }
72
72
*/
73
- references : Reference [ ] = [ ] ;
73
+ private references : Reference [ ] = [ ] ;
74
74
75
75
/**
76
76
* Contains validation errors (if any) after {@link checkSignature} method is called
@@ -253,9 +253,9 @@ export class SignedXml {
253
253
254
254
const doc = new xmldom . DOMParser ( ) . parseFromString ( xml ) ;
255
255
256
- if ( ! this . validateReferences ( doc ) ) {
256
+ if ( ! this . getReferences ( ) . every ( ( ref ) => this . validateReference ( ref , doc ) ) ) {
257
257
if ( callback ) {
258
- callback ( new Error ( "Could not validate references" ) ) ;
258
+ callback ( new Error ( "Could not validate all references" ) ) ;
259
259
return ;
260
260
}
261
261
@@ -372,7 +372,7 @@ export class SignedXml {
372
372
}
373
373
374
374
validateElementAgainstReferences ( elem : Element , doc : Document ) : Reference {
375
- for ( const ref of this . references ) {
375
+ for ( const ref of this . getReferences ( ) ) {
376
376
const uri = ref . uri ?. [ 0 ] === "#" ? ref . uri . substring ( 1 ) : ref . uri ;
377
377
let targetElem : xpath . SelectSingleReturnType ;
378
378
@@ -647,6 +647,10 @@ export class SignedXml {
647
647
} ) ;
648
648
}
649
649
650
+ getReferences ( ) : Reference [ ] {
651
+ return this . references ;
652
+ }
653
+
650
654
/**
651
655
* Compute the signature of the given XML (using the already defined settings).
652
656
*
@@ -879,7 +883,7 @@ export class SignedXml {
879
883
prefix = prefix || "" ;
880
884
prefix = prefix ? `${ prefix } :` : prefix ;
881
885
882
- for ( const ref of this . references ) {
886
+ for ( const ref of this . getReferences ( ) ) {
883
887
const nodes = xpath . selectWithResolver ( ref . xpath ?? "" , doc , this . namespaceResolver ) ;
884
888
885
889
if ( ! utils . isArrayHasLength ( nodes ) ) {
0 commit comments