@@ -323,6 +323,7 @@ export class SignedXml {
323
323
valid(ated). Put simply: if one fails, they are all not trustworthy.
324
324
*/
325
325
this . signedReferences = [ ] ;
326
+ // TODO: add this breaking change here later on for even more security: `this.references = [];`
326
327
if ( callback ) {
327
328
callback ( new Error ( "Could not validate all references" ) , false ) ;
328
329
return ;
@@ -357,6 +358,7 @@ export class SignedXml {
357
358
// but that may cause some breaking changes, so we'll handle that in v7.x.
358
359
// If we were validating `signedInfoCanon` first, we wouldn't have to reset this array.
359
360
this . signedReferences = [ ] ;
361
+ // TODO: add this breaking change here later on for even more security: `this.references = [];`
360
362
361
363
if ( callback ) {
362
364
callback (
@@ -539,14 +541,14 @@ export class SignedXml {
539
541
}
540
542
}
541
543
542
- ref . getValidatedNode = ( xpathSelector ?: string ) => {
544
+ ref . getValidatedNode = deprecate ( ( xpathSelector ?: string ) => {
543
545
xpathSelector = xpathSelector || ref . xpath ;
544
546
if ( typeof xpathSelector !== "string" || ref . validationError != null ) {
545
547
return null ;
546
548
}
547
549
const selectedValue = xpath . select1 ( xpathSelector , doc ) ;
548
550
return isDomNode . isNodeLike ( selectedValue ) ? selectedValue : null ;
549
- } ;
551
+ } , "`ref.getValidatedNode()` is deprecated and insecure. Use `ref.signedReference` or `this.getSignedReferences()` instead." ) ;
550
552
551
553
if ( ! isDomNode . isNodeLike ( elem ) ) {
552
554
const validationError = new Error (
@@ -573,6 +575,7 @@ export class SignedXml {
573
575
// thus the `canonXml` and _only_ the `canonXml` can be trusted.
574
576
// Append this to `signedReferences`.
575
577
this . signedReferences . push ( canonXml ) ;
578
+ ref . signedReference = canonXml ;
576
579
577
580
return true ;
578
581
}
@@ -821,13 +824,18 @@ export class SignedXml {
821
824
}
822
825
823
826
/**
824
- * @deprecated Use `.getSignedReferences()` instead.
825
827
* Returns the list of references.
826
828
*/
827
- getReferences = deprecate (
828
- ( ) => this . references ,
829
- "getReferences() is deprecated. Use `.getSignedReferences()` instead." ,
830
- ) ;
829
+ getReferences ( ) {
830
+ // TODO: Refactor once `getValidatedNode` is removed
831
+ /* Once we completely remove the deprecated `getValidatedNode()` method,
832
+ we can change this to return a clone to prevent accidental mutations,
833
+ e.g.:
834
+ return [...this.references];
835
+ */
836
+
837
+ return this . references ;
838
+ }
831
839
832
840
getSignedReferences ( ) {
833
841
return [ ...this . signedReferences ] ;
0 commit comments