xml-crypto-next 7.0.3 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/c14n-canonicalization-2.d.ts +37 -0
- package/build/c14n-canonicalization-2.d.ts.map +1 -0
- package/build/c14n-canonicalization-2.js +228 -0
- package/build/c14n-canonicalization.d.ts +48 -0
- package/build/c14n-canonicalization.d.ts.map +1 -0
- package/{lib → build}/c14n-canonicalization.js +95 -75
- package/{lib → build}/enveloped-signature.d.ts +1 -1
- package/build/enveloped-signature.d.ts.map +1 -0
- package/{lib → build}/enveloped-signature.js +4 -9
- package/build/exclusive-canonicalization.d.ts +57 -0
- package/build/exclusive-canonicalization.d.ts.map +1 -0
- package/{lib → build}/exclusive-canonicalization.js +116 -102
- package/{lib → build}/hash-algorithms.d.ts +5 -1
- package/build/hash-algorithms.d.ts.map +1 -0
- package/build/hash-algorithms.js +70 -0
- package/build/index.d.ts +9 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +23 -0
- package/build/signature-algorithms.d.ts +244 -0
- package/build/signature-algorithms.d.ts.map +1 -0
- package/build/signature-algorithms.js +480 -0
- package/{lib → build}/signed-xml.d.ts +2 -2
- package/build/signed-xml.d.ts.map +1 -0
- package/{lib → build}/signed-xml.js +143 -102
- package/{lib → build}/types.d.ts +43 -6
- package/build/types.d.ts.map +1 -0
- package/{lib → build}/types.js +1 -5
- package/{lib → build}/utils.d.ts +34 -4
- package/build/utils.d.ts.map +1 -0
- package/{lib → build}/utils.js +189 -62
- package/build/xmldsig2-transform.d.ts +18 -0
- package/build/xmldsig2-transform.d.ts.map +1 -0
- package/build/xmldsig2-transform.js +65 -0
- package/package.json +74 -73
- package/types/c14n-canonicalization-2.d.ts +38 -0
- package/types/c14n-canonicalization-2.d.ts.map +1 -0
- package/types/c14n-canonicalization.d.ts +49 -0
- package/types/c14n-canonicalization.d.ts.map +1 -0
- package/types/enveloped-signature.d.ts +8 -0
- package/types/enveloped-signature.d.ts.map +1 -0
- package/types/exclusive-canonicalization.d.ts +58 -0
- package/types/exclusive-canonicalization.d.ts.map +1 -0
- package/types/hash-algorithms.d.ts +26 -0
- package/types/hash-algorithms.d.ts.map +1 -0
- package/types/index.d.ts +10 -0
- package/types/index.d.ts.map +1 -0
- package/types/signature-algorithms.d.ts +112 -0
- package/types/signature-algorithms.d.ts.map +1 -0
- package/types/signed-xml.d.ts +237 -0
- package/types/signed-xml.d.ts.map +1 -0
- package/types/src/c14n-canonicalization-2.d.ts +38 -0
- package/types/src/c14n-canonicalization-2.d.ts.map +1 -0
- package/types/src/c14n-canonicalization.d.ts +49 -0
- package/types/src/c14n-canonicalization.d.ts.map +1 -0
- package/types/src/enveloped-signature.d.ts +8 -0
- package/types/src/enveloped-signature.d.ts.map +1 -0
- package/types/src/exclusive-canonicalization.d.ts +58 -0
- package/types/src/exclusive-canonicalization.d.ts.map +1 -0
- package/types/src/hash-algorithms.d.ts +26 -0
- package/types/src/hash-algorithms.d.ts.map +1 -0
- package/types/src/index.d.ts +10 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/signature-algorithms.d.ts +245 -0
- package/types/src/signature-algorithms.d.ts.map +1 -0
- package/types/src/signed-xml.d.ts +237 -0
- package/types/src/signed-xml.d.ts.map +1 -0
- package/types/src/types.d.ts +182 -0
- package/types/src/types.d.ts.map +1 -0
- package/types/src/utils.d.ts +96 -0
- package/types/src/utils.d.ts.map +1 -0
- package/types/src/xmldsig2-transform.d.ts +19 -0
- package/types/src/xmldsig2-transform.d.ts.map +1 -0
- package/types/types.d.ts +182 -0
- package/types/types.d.ts.map +1 -0
- package/types/utils.d.ts +96 -0
- package/types/utils.d.ts.map +1 -0
- package/types/xmldsig2-transform.d.ts +19 -0
- package/types/xmldsig2-transform.d.ts.map +1 -0
- package/lib/c14n-canonicalization.d.ts +0 -39
- package/lib/c14n-canonicalization.js.map +0 -1
- package/lib/enveloped-signature.js.map +0 -1
- package/lib/exclusive-canonicalization.d.ts +0 -38
- package/lib/exclusive-canonicalization.js.map +0 -1
- package/lib/hash-algorithms.js +0 -84
- package/lib/hash-algorithms.js.map +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -28
- package/lib/index.js.map +0 -1
- package/lib/signature-algorithms.d.ts +0 -112
- package/lib/signature-algorithms.js +0 -304
- package/lib/signature-algorithms.js.map +0 -1
- package/lib/signed-xml.js.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/utils.js.map +0 -1
|
@@ -1,101 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import * as isDomNode from "@xmldom/is-dom-node";
|
|
2
|
+
import * as xmldom from "@xmldom/xmldom";
|
|
3
|
+
import { deprecate } from "util";
|
|
4
|
+
import * as xpath from "xpath";
|
|
5
|
+
import * as c14n from "./c14n-canonicalization.js";
|
|
6
|
+
import * as c14n2 from "./c14n-canonicalization-2.js";
|
|
7
|
+
import * as envelopedSignatures from "./enveloped-signature.js";
|
|
8
|
+
import * as execC14n from "./exclusive-canonicalization.js";
|
|
9
|
+
import * as xmldsig2 from "./xmldsig2-transform.js";
|
|
10
|
+
import * as hashAlgorithms from "./hash-algorithms.js";
|
|
11
|
+
import * as signatureAlgorithms from "./signature-algorithms.js";
|
|
12
|
+
import * as utils from "./utils.js";
|
|
13
|
+
export class SignedXml {
|
|
14
|
+
idMode;
|
|
15
|
+
idAttributes;
|
|
16
|
+
/**
|
|
17
|
+
* A {@link Buffer} or pem encoded {@link String} containing your private key
|
|
18
|
+
*/
|
|
19
|
+
privateKey;
|
|
20
|
+
publicCert;
|
|
21
|
+
/**
|
|
22
|
+
* One of the supported signature algorithms.
|
|
23
|
+
* @see {@link SignatureAlgorithmType}
|
|
24
|
+
*/
|
|
25
|
+
signatureAlgorithm = undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Rules used to convert an XML document into its canonical form.
|
|
28
|
+
*/
|
|
29
|
+
canonicalizationAlgorithm = undefined;
|
|
30
|
+
/**
|
|
31
|
+
* It specifies a list of namespace prefixes that should be considered "inclusive" during the canonicalization process.
|
|
32
|
+
*/
|
|
33
|
+
inclusiveNamespacesPrefixList = [];
|
|
34
|
+
namespaceResolver = {
|
|
35
|
+
lookupNamespaceURI: function ( /* prefix */) {
|
|
36
|
+
throw new Error("Not implemented");
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
implicitTransforms = [];
|
|
40
|
+
keyInfoAttributes = {};
|
|
41
|
+
getKeyInfoContent = SignedXml.getKeyInfoContent;
|
|
42
|
+
getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
|
|
43
|
+
objects;
|
|
44
|
+
// Internal state
|
|
45
|
+
id = 0;
|
|
46
|
+
signedXml = "";
|
|
47
|
+
signatureXml = "";
|
|
48
|
+
signatureNode = null;
|
|
49
|
+
signatureValue = "";
|
|
50
|
+
originalXmlWithIds = "";
|
|
51
|
+
keyInfo = null;
|
|
52
|
+
/**
|
|
53
|
+
* Contains the references that were signed.
|
|
54
|
+
* @see {@link Reference}
|
|
55
|
+
*/
|
|
56
|
+
references = [];
|
|
57
|
+
/**
|
|
58
|
+
* Contains the canonicalized XML of the references that were validly signed.
|
|
59
|
+
*
|
|
60
|
+
* This populates with the canonical XML of the reference only after
|
|
61
|
+
* verifying the signature is cryptographically authentic.
|
|
62
|
+
*/
|
|
63
|
+
signedReferences = [];
|
|
64
|
+
/**
|
|
65
|
+
* To add a new transformation algorithm create a new class that implements the {@link TransformationAlgorithm} interface, and register it here. More info: {@link https://github.com/node-saml/xml-crypto#customizing-algorithms|Customizing Algorithms}
|
|
66
|
+
*/
|
|
67
|
+
CanonicalizationAlgorithms = {
|
|
68
|
+
// XMLDSig 1.0/1.1 - Compatibility Mode
|
|
69
|
+
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315": c14n.C14nCanonicalization,
|
|
70
|
+
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments": c14n.C14nCanonicalizationWithComments,
|
|
71
|
+
"http://www.w3.org/2001/10/xml-exc-c14n#": execC14n.ExclusiveCanonicalization,
|
|
72
|
+
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments": execC14n.ExclusiveCanonicalizationWithComments,
|
|
73
|
+
"http://www.w3.org/2000/09/xmldsig#enveloped-signature": envelopedSignatures.EnvelopedSignature,
|
|
74
|
+
// XMLDSig 2.0
|
|
75
|
+
"http://www.w3.org/2010/xml-c14n2": c14n2.C14nCanonicalization2,
|
|
76
|
+
"http://www.w3.org/2010/xml-c14n2#WithComments": c14n2.C14nCanonicalization2WithComments,
|
|
77
|
+
"http://www.w3.org/2010/xmldsig2#transform": xmldsig2.XmlDsig2Transform,
|
|
78
|
+
};
|
|
79
|
+
// TODO: In v7.x we may consider deprecating sha1
|
|
80
|
+
/**
|
|
81
|
+
* 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}
|
|
82
|
+
*/
|
|
83
|
+
HashAlgorithms = {
|
|
84
|
+
// XMLDSig 1.0/1.1
|
|
85
|
+
"http://www.w3.org/2000/09/xmldsig#sha1": hashAlgorithms.Sha1,
|
|
86
|
+
"http://www.w3.org/2001/04/xmlenc#sha256": hashAlgorithms.Sha256,
|
|
87
|
+
"http://www.w3.org/2001/04/xmlenc#sha384": hashAlgorithms.Sha384,
|
|
88
|
+
"http://www.w3.org/2001/04/xmlenc#sha512": hashAlgorithms.Sha512,
|
|
89
|
+
// XMLDSig 2.0 - Required
|
|
90
|
+
"http://www.w3.org/2001/04/xmldsig-more#sha224": hashAlgorithms.Sha224,
|
|
91
|
+
// XMLDSig 2.0 - Optional
|
|
92
|
+
"http://www.w3.org/2001/04/xmldsig-more#shake256": hashAlgorithms.Shake256,
|
|
93
|
+
};
|
|
94
|
+
// TODO: In v7.x we may consider deprecating sha1
|
|
95
|
+
/**
|
|
96
|
+
* 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}
|
|
97
|
+
*/
|
|
98
|
+
SignatureAlgorithms = {
|
|
99
|
+
// XMLDSig 1.0/1.1 - RSA
|
|
100
|
+
"http://www.w3.org/2000/09/xmldsig#rsa-sha1": signatureAlgorithms.RsaSha1,
|
|
101
|
+
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256": signatureAlgorithms.RsaSha256,
|
|
102
|
+
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha224": signatureAlgorithms.RsaSha224,
|
|
103
|
+
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha384": signatureAlgorithms.RsaSha384,
|
|
104
|
+
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512": signatureAlgorithms.RsaSha512,
|
|
105
|
+
// XMLDSig 1.0/1.1 - RSA-PSS
|
|
106
|
+
"http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1": signatureAlgorithms.RsaSha256Mgf1,
|
|
107
|
+
"http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1": signatureAlgorithms.RsaSha384Mgf1,
|
|
108
|
+
"http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1": signatureAlgorithms.RsaSha512Mgf1,
|
|
109
|
+
// XMLDSig 1.0/1.1 - ECDSA
|
|
110
|
+
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1": signatureAlgorithms.EcdsaSha1,
|
|
111
|
+
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224": signatureAlgorithms.EcdsaSha224,
|
|
112
|
+
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256": signatureAlgorithms.EcdsaSha256,
|
|
113
|
+
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384": signatureAlgorithms.EcdsaSha384,
|
|
114
|
+
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512": signatureAlgorithms.EcdsaSha512,
|
|
115
|
+
// XMLDSig 1.0/1.1 - DSA
|
|
116
|
+
"http://www.w3.org/2000/09/xmldsig#dsa-sha1": signatureAlgorithms.DsaSha1,
|
|
117
|
+
"http://www.w3.org/2009/xmldsig11#dsa-sha256": signatureAlgorithms.DsaSha256,
|
|
118
|
+
// XMLDSig 1.0/1.1 - EdDSA
|
|
119
|
+
"http://www.w3.org/2007/05/xmldsig-more#eddsa-ed25519": signatureAlgorithms.Ed25519,
|
|
120
|
+
"http://www.w3.org/2021/04/xmldsig-more#eddsa-ed448": signatureAlgorithms.Ed448,
|
|
121
|
+
// XMLDSig 1.0/1.1 - HMAC
|
|
122
|
+
"http://www.w3.org/2000/09/xmldsig#hmac-sha1": signatureAlgorithms.HmacSha1,
|
|
123
|
+
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha224": signatureAlgorithms.HmacSha224,
|
|
124
|
+
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha256": signatureAlgorithms.HmacSha256,
|
|
125
|
+
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha384": signatureAlgorithms.HmacSha384,
|
|
126
|
+
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha512": signatureAlgorithms.HmacSha512,
|
|
127
|
+
// Disabled by default due to key confusion concerns.
|
|
128
|
+
// 'http://www.w3.org/2000/09/xmldsig#hmac-sha1': SignatureAlgorithms.HmacSha1
|
|
129
|
+
};
|
|
130
|
+
static defaultNsForPrefix = {
|
|
131
|
+
ds: "http://www.w3.org/2000/09/xmldsig#",
|
|
132
|
+
};
|
|
133
|
+
static noop = () => null;
|
|
15
134
|
/**
|
|
16
135
|
* The SignedXml constructor provides an abstraction for sign and verify xml documents. The object is constructed using
|
|
17
136
|
* @param options {@link SignedXmlOptions}
|
|
18
137
|
*/
|
|
19
138
|
constructor(options = {}) {
|
|
20
|
-
/**
|
|
21
|
-
* One of the supported signature algorithms.
|
|
22
|
-
* @see {@link SignatureAlgorithmType}
|
|
23
|
-
*/
|
|
24
|
-
this.signatureAlgorithm = undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Rules used to convert an XML document into its canonical form.
|
|
27
|
-
*/
|
|
28
|
-
this.canonicalizationAlgorithm = undefined;
|
|
29
|
-
/**
|
|
30
|
-
* It specifies a list of namespace prefixes that should be considered "inclusive" during the canonicalization process.
|
|
31
|
-
*/
|
|
32
|
-
this.inclusiveNamespacesPrefixList = [];
|
|
33
|
-
this.namespaceResolver = {
|
|
34
|
-
lookupNamespaceURI: function ( /* prefix */) {
|
|
35
|
-
throw new Error("Not implemented");
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
this.implicitTransforms = [];
|
|
39
|
-
this.keyInfoAttributes = {};
|
|
40
|
-
this.getKeyInfoContent = SignedXml.getKeyInfoContent;
|
|
41
|
-
this.getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
|
|
42
|
-
// Internal state
|
|
43
|
-
this.id = 0;
|
|
44
|
-
this.signedXml = "";
|
|
45
|
-
this.signatureXml = "";
|
|
46
|
-
this.signatureNode = null;
|
|
47
|
-
this.signatureValue = "";
|
|
48
|
-
this.originalXmlWithIds = "";
|
|
49
|
-
this.keyInfo = null;
|
|
50
|
-
/**
|
|
51
|
-
* Contains the references that were signed.
|
|
52
|
-
* @see {@link Reference}
|
|
53
|
-
*/
|
|
54
|
-
this.references = [];
|
|
55
|
-
/**
|
|
56
|
-
* Contains the canonicalized XML of the references that were validly signed.
|
|
57
|
-
*
|
|
58
|
-
* This populates with the canonical XML of the reference only after
|
|
59
|
-
* verifying the signature is cryptographically authentic.
|
|
60
|
-
*/
|
|
61
|
-
this.signedReferences = [];
|
|
62
|
-
/**
|
|
63
|
-
* To add a new transformation algorithm create a new class that implements the {@link TransformationAlgorithm} interface, and register it here. More info: {@link https://github.com/node-saml/xml-crypto#customizing-algorithms|Customizing Algorithms}
|
|
64
|
-
*/
|
|
65
|
-
this.CanonicalizationAlgorithms = {
|
|
66
|
-
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315": c14n.C14nCanonicalization,
|
|
67
|
-
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments": c14n.C14nCanonicalizationWithComments,
|
|
68
|
-
"http://www.w3.org/2001/10/xml-exc-c14n#": execC14n.ExclusiveCanonicalization,
|
|
69
|
-
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments": execC14n.ExclusiveCanonicalizationWithComments,
|
|
70
|
-
"http://www.w3.org/2000/09/xmldsig#enveloped-signature": envelopedSignatures.EnvelopedSignature,
|
|
71
|
-
};
|
|
72
|
-
// TODO: In v7.x we may consider deprecating sha1
|
|
73
|
-
/**
|
|
74
|
-
* 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}
|
|
75
|
-
*/
|
|
76
|
-
this.HashAlgorithms = {
|
|
77
|
-
"http://www.w3.org/2000/09/xmldsig#sha1": hashAlgorithms.Sha1,
|
|
78
|
-
"http://www.w3.org/2001/04/xmlenc#sha256": hashAlgorithms.Sha256,
|
|
79
|
-
"http://www.w3.org/2001/04/xmlenc#sha384": hashAlgorithms.Sha384,
|
|
80
|
-
"http://www.w3.org/2001/04/xmlenc#sha512": hashAlgorithms.Sha512,
|
|
81
|
-
};
|
|
82
|
-
// TODO: In v7.x we may consider deprecating sha1
|
|
83
|
-
/**
|
|
84
|
-
* 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}
|
|
85
|
-
*/
|
|
86
|
-
this.SignatureAlgorithms = {
|
|
87
|
-
"http://www.w3.org/2000/09/xmldsig#rsa-sha1": signatureAlgorithms.RsaSha1,
|
|
88
|
-
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256": signatureAlgorithms.RsaSha256,
|
|
89
|
-
"http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1": signatureAlgorithms.RsaSha256Mgf1,
|
|
90
|
-
"http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1": signatureAlgorithms.RsaSha384Mgf1,
|
|
91
|
-
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha384": signatureAlgorithms.RsaSha384,
|
|
92
|
-
"http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1": signatureAlgorithms.RsaSha512Mgf1,
|
|
93
|
-
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512": signatureAlgorithms.RsaSha512,
|
|
94
|
-
"http://www.w3.org/2007/05/xmldsig-more#eddsa-ed25519": signatureAlgorithms.Ed25519,
|
|
95
|
-
"http://www.w3.org/2021/04/xmldsig-more#eddsa-ed448": signatureAlgorithms.Ed488,
|
|
96
|
-
// Disabled by default due to key confusion concerns.
|
|
97
|
-
// 'http://www.w3.org/2000/09/xmldsig#hmac-sha1': SignatureAlgorithms.HmacSha1
|
|
98
|
-
};
|
|
99
139
|
const { idMode, idAttribute, privateKey, publicCert, signatureAlgorithm, canonicalizationAlgorithm, inclusiveNamespacesPrefixList, implicitTransforms, keyInfoAttributes, getKeyInfoContent, getCertFromKeyInfo, objects, } = options;
|
|
100
140
|
// Options
|
|
101
141
|
this.idMode = idMode;
|
|
@@ -369,7 +409,9 @@ class SignedXml {
|
|
|
369
409
|
let elem;
|
|
370
410
|
if (typeof elemOrXpath === "string") {
|
|
371
411
|
const firstElem = xpath.select1(elemOrXpath, doc);
|
|
412
|
+
// @ts-expect-error misssing Node properties are not needed
|
|
372
413
|
isDomNode.assertIsElementNode(firstElem);
|
|
414
|
+
// @ts-expect-error misssing Node properties are not needed
|
|
373
415
|
elem = firstElem;
|
|
374
416
|
}
|
|
375
417
|
else {
|
|
@@ -388,7 +430,7 @@ class SignedXml {
|
|
|
388
430
|
const canonXml = this.getCanonReferenceXml(doc, ref, elem);
|
|
389
431
|
const hash = this.findHashAlgorithm(ref.digestAlgorithm);
|
|
390
432
|
const digest = hash.getHash(canonXml);
|
|
391
|
-
if (utils.validateDigestValue(digest, ref.digestValue)) {
|
|
433
|
+
if (ref.digestValue != null && typeof ref.digestValue === "string" && utils.validateDigestValue(digest, ref.digestValue)) {
|
|
392
434
|
return ref;
|
|
393
435
|
}
|
|
394
436
|
}
|
|
@@ -421,7 +463,7 @@ class SignedXml {
|
|
|
421
463
|
}
|
|
422
464
|
}
|
|
423
465
|
}
|
|
424
|
-
ref.getValidatedNode =
|
|
466
|
+
ref.getValidatedNode = deprecate((xpathSelector) => {
|
|
425
467
|
xpathSelector = xpathSelector || ref.xpath;
|
|
426
468
|
if (typeof xpathSelector !== "string" || ref.validationError != null) {
|
|
427
469
|
return null;
|
|
@@ -437,7 +479,7 @@ class SignedXml {
|
|
|
437
479
|
const canonXml = this.getCanonReferenceXml(doc, ref, elem);
|
|
438
480
|
const hash = this.findHashAlgorithm(ref.digestAlgorithm);
|
|
439
481
|
const digest = hash.getHash(canonXml);
|
|
440
|
-
if (!utils.validateDigestValue(digest, ref.digestValue)) {
|
|
482
|
+
if (ref.digestValue == null || typeof ref.digestValue !== "string" || !utils.validateDigestValue(digest, ref.digestValue)) {
|
|
441
483
|
const validationError = new Error(`invalid signature: for uri ${ref.uri} calculated digest is ${digest} but the xml to validate supplies digest ${ref.digestValue}`);
|
|
442
484
|
ref.validationError = validationError;
|
|
443
485
|
return false;
|
|
@@ -689,6 +731,7 @@ class SignedXml {
|
|
|
689
731
|
} // No specific nodes to ID for empty URI
|
|
690
732
|
const nodes = xpath.selectWithResolver(ref.xpath ?? "", doc, this.namespaceResolver);
|
|
691
733
|
for (const node of nodes) {
|
|
734
|
+
// @ts-expect-error misssing Node properties are not needed
|
|
692
735
|
isDomNode.assertIsElementNode(node);
|
|
693
736
|
this.ensureHasId(node);
|
|
694
737
|
}
|
|
@@ -805,6 +848,7 @@ class SignedXml {
|
|
|
805
848
|
const signatureNamespace = "http://www.w3.org/2000/09/xmldsig#";
|
|
806
849
|
// Find the SignedInfo element to append to
|
|
807
850
|
const signedInfoNode = xpath.select1(`./*[local-name(.)='SignedInfo']`, signatureElem);
|
|
851
|
+
// @ts-expect-error misssing Node properties are not needed
|
|
808
852
|
isDomNode.assertIsElementNode(signedInfoNode); // Type-safe assertion
|
|
809
853
|
// Signature document is technically the same document as the one we are signing,
|
|
810
854
|
// but we will extract it here for clarity (and also make it support detached signatures in the future)
|
|
@@ -817,10 +861,12 @@ class SignedXml {
|
|
|
817
861
|
}
|
|
818
862
|
// Process the reference
|
|
819
863
|
for (const node of nodes) {
|
|
864
|
+
// @ts-expect-error misssing Node properties are not needed
|
|
820
865
|
isDomNode.assertIsElementNode(node);
|
|
821
866
|
// Must not be a reference to Signature, SignedInfo, or a child of SignedInfo
|
|
822
867
|
if (node === signatureElem ||
|
|
823
868
|
node === signedInfoNode ||
|
|
869
|
+
// @ts-expect-error misssing Node properties are not needed
|
|
824
870
|
utils.isDescendantOf(node, signedInfoNode)) {
|
|
825
871
|
throw new Error(`Cannot sign a reference to the Signature or SignedInfo element itself: ${ref.xpath}`);
|
|
826
872
|
}
|
|
@@ -867,6 +913,7 @@ class SignedXml {
|
|
|
867
913
|
referenceElem.appendChild(digestMethodElem);
|
|
868
914
|
referenceElem.appendChild(digestValueElem);
|
|
869
915
|
// Append the reference element to SignedInfo
|
|
916
|
+
// @ts-expect-error misssing Node properties are not needed
|
|
870
917
|
signedInfoNode.appendChild(referenceElem);
|
|
871
918
|
}
|
|
872
919
|
}
|
|
@@ -1034,9 +1081,3 @@ class SignedXml {
|
|
|
1034
1081
|
return this.signedXml;
|
|
1035
1082
|
}
|
|
1036
1083
|
}
|
|
1037
|
-
exports.SignedXml = SignedXml;
|
|
1038
|
-
SignedXml.defaultNsForPrefix = {
|
|
1039
|
-
ds: "http://www.w3.org/2000/09/xmldsig#",
|
|
1040
|
-
};
|
|
1041
|
-
SignedXml.noop = () => null;
|
|
1042
|
-
//# sourceMappingURL=signed-xml.js.map
|
package/{lib → build}/types.d.ts
RENAMED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import * as crypto from "crypto";
|
|
2
2
|
export type ErrorFirstCallback<T> = (err: Error | null, result?: T) => void;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* XML Version support
|
|
5
|
+
* XML 1.0: https://www.w3.org/TR/xml/
|
|
6
|
+
* XML 1.1: https://www.w3.org/TR/xml11/
|
|
7
|
+
*/
|
|
8
|
+
export type XmlVersion = "1.0" | "1.1";
|
|
9
|
+
/**
|
|
10
|
+
* XML Signature Version
|
|
11
|
+
* XMLDSig 1.0: https://www.w3.org/TR/xmldsig-core/
|
|
12
|
+
* XMLDSig 1.1: https://www.w3.org/TR/xmldsig-core1/
|
|
13
|
+
* XMLDSig 2.0: https://www.w3.org/TR/xmldsig-core2/
|
|
14
|
+
*/
|
|
15
|
+
export type XmlSignatureVersion = "1.0" | "1.1" | "2.0";
|
|
16
|
+
export type CanonicalizationAlgorithmType = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" | "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" | "http://www.w3.org/2006/12/xml-c14n11" | "http://www.w3.org/2006/12/xml-c14n11#WithComments" | "http://www.w3.org/2001/10/xml-exc-c14n#" | "http://www.w3.org/2001/10/xml-exc-c14n#WithComments" | "http://www.w3.org/2010/xml-c14n2" | "http://www.w3.org/2010/xml-c14n2#WithComments" | string;
|
|
17
|
+
export type CanonicalizationOrTransformAlgorithmType = CanonicalizationAlgorithmType | "http://www.w3.org/2000/09/xmldsig#enveloped-signature" | "http://www.w3.org/2010/xmldsig2#transform";
|
|
18
|
+
export type HashAlgorithmType = "http://www.w3.org/2000/09/xmldsig#sha1" | "http://www.w3.org/2001/04/xmlenc#sha256" | "http://www.w3.org/2001/04/xmlenc#sha384" | "http://www.w3.org/2001/04/xmlenc#sha512" | "http://www.w3.org/2001/04/xmldsig-more#sha224" | "http://www.w3.org/2001/04/xmldsig-more#shake256" | string;
|
|
19
|
+
export type SignatureAlgorithmType = "http://www.w3.org/2000/09/xmldsig#rsa-sha1" | "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" | "http://www.w3.org/2001/04/xmldsig-more#rsa-sha224" | "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384" | "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" | "http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1" | "http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1" | "http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1" | "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1" | "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224" | "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256" | "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384" | "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512" | "http://www.w3.org/2000/09/xmldsig#dsa-sha1" | "http://www.w3.org/2009/xmldsig11#dsa-sha256" | "http://www.w3.org/2007/05/xmldsig-more#eddsa-ed25519" | "http://www.w3.org/2021/04/xmldsig-more#eddsa-ed448" | "http://www.w3.org/2000/09/xmldsig#hmac-sha1" | "http://www.w3.org/2001/04/xmldsig-more#hmac-sha224" | "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256" | "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384" | "http://www.w3.org/2001/04/xmldsig-more#hmac-sha512" | string;
|
|
7
20
|
/**
|
|
8
21
|
* @param cert the certificate as a string or array of strings (@see https://www.w3.org/TR/2008/REC-xmldsig-core-20080610/#sec-X509Data)
|
|
9
22
|
* @param prefix an optional namespace alias to be used for the generated XML
|
|
@@ -85,22 +98,46 @@ export interface ComputeSignatureOptions {
|
|
|
85
98
|
}
|
|
86
99
|
/**
|
|
87
100
|
* Represents a reference node for XML digital signature.
|
|
101
|
+
*
|
|
102
|
+
* For XMLDSig 2.0 mode:
|
|
103
|
+
* - URI attribute MUST NOT be present
|
|
104
|
+
* - Must contain exactly one Transform with algorithm "http://www.w3.org/2010/xmldsig2#transform"
|
|
105
|
+
* - Selection is specified via dsig2:Selection element
|
|
88
106
|
*/
|
|
89
107
|
export interface Reference {
|
|
90
108
|
xpath?: string;
|
|
91
109
|
transforms: ReadonlyArray<CanonicalizationOrTransformAlgorithmType>;
|
|
92
110
|
digestAlgorithm: HashAlgorithmType;
|
|
93
|
-
uri
|
|
111
|
+
uri?: string;
|
|
94
112
|
digestValue?: unknown;
|
|
95
113
|
inclusiveNamespacesPrefixList: string[];
|
|
96
|
-
isEmptyUri
|
|
114
|
+
isEmptyUri?: boolean;
|
|
97
115
|
id?: string;
|
|
98
116
|
type?: string;
|
|
99
117
|
ancestorNamespaces?: NamespacePrefix[];
|
|
118
|
+
selectionMethod?: "xpath" | "xpointer" | "stream" | "xpath-filter";
|
|
119
|
+
selectionExpression?: string;
|
|
100
120
|
validationError?: Error;
|
|
101
121
|
getValidatedNode(xpathSelector?: string): Node | null;
|
|
102
122
|
signedReference?: string;
|
|
103
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* XMLDSig 2.0 Reference with Selection element
|
|
126
|
+
*/
|
|
127
|
+
export interface Reference2 extends Reference {
|
|
128
|
+
uri?: never;
|
|
129
|
+
selectionMethod: "xpath" | "xpointer" | "stream" | "xpath-filter";
|
|
130
|
+
selectionExpression: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* KeyInfoReference for XMLDSig 2.0
|
|
134
|
+
* Provides a secure way to reference KeyInfo elements
|
|
135
|
+
* @see https://www.w3.org/TR/xmldsig-core2/#sec-KeyInfoReference
|
|
136
|
+
*/
|
|
137
|
+
export interface KeyInfoReference {
|
|
138
|
+
uri: string;
|
|
139
|
+
inclusiveNamespacesPrefixList?: string[];
|
|
140
|
+
}
|
|
104
141
|
/** Implement this to create a new CanonicalizationOrTransformationAlgorithm */
|
|
105
142
|
export interface CanonicalizationOrTransformationAlgorithm {
|
|
106
143
|
process(node: Node, options: CanonicalizationOrTransformationAlgorithmProcessOptions): Node | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,6BAA6B,GAErC,iDAAiD,GACjD,8DAA8D,GAC9D,sCAAsC,GACtC,mDAAmD,GACnD,yCAAyC,GACzC,qDAAqD,GAErD,kCAAkC,GAClC,+CAA+C,GAC/C,MAAM,CAAC;AAEX,MAAM,MAAM,wCAAwC,GAChD,6BAA6B,GAC7B,uDAAuD,GAEvD,2CAA2C,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAEzB,wCAAwC,GACxC,yCAAyC,GACzC,yCAAyC,GACzC,yCAAyC,GAEzC,+CAA+C,GAE/C,iDAAiD,GACjD,MAAM,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAE9B,4CAA4C,GAC5C,mDAAmD,GACnD,mDAAmD,GACnD,mDAAmD,GACnD,mDAAmD,GACnD,wDAAwD,GACxD,wDAAwD,GACxD,wDAAwD,GAExD,mDAAmD,GACnD,qDAAqD,GACrD,qDAAqD,GACrD,qDAAqD,GACrD,qDAAqD,GAErD,4CAA4C,GAC5C,6CAA6C,GAE7C,sDAAsD,GACtD,oDAAoD,GAEpD,6CAA6C,GAC7C,oDAAoD,GACpD,oDAAoD,GACpD,oDAAoD,GACpD,oDAAoD,G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CAAC,MAAM,CAAC,GACpC,IAAI,CAAC;IAER;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;IAExF,eAAe,CACb,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,CAAC,OAAO,EACnB,cAAc,EAAE,MAAM,EACtB,QAAQ,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,GACrC,IAAI,CAAC;IAER,gBAAgB,IAAI,sBAAsB,CAAC;CAC5C;AAED,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,IAAI,wCAAwC,CAAC;IAE7D,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;CAC7B;AA8BD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,EACnE,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAC7B;IACD,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAChD,CAiBA"}
|
package/{lib → build}/types.js
RENAMED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable no-unused-vars */
|
|
3
2
|
// Type definitions for @node-saml/xml-crypto
|
|
4
3
|
// Project: https://github.com/node-saml/xml-crypto#readme
|
|
5
4
|
// Original definitions by: Eric Heikes <https://github.com/eheikes>
|
|
6
5
|
// Max Chehab <https://github.com/maxchehab>
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.createOptionalCallbackFunction = createOptionalCallbackFunction;
|
|
9
6
|
/**
|
|
10
7
|
* ### Sign
|
|
11
8
|
* #### Properties
|
|
@@ -36,7 +33,7 @@ function isErrorFirstCallback(possibleCallback) {
|
|
|
36
33
|
* This follows the factory pattern.
|
|
37
34
|
* Just call this function, passing the function that you'd like to add a callback version of.
|
|
38
35
|
*/
|
|
39
|
-
function createOptionalCallbackFunction(syncVersion) {
|
|
36
|
+
export function createOptionalCallbackFunction(syncVersion) {
|
|
40
37
|
return ((...args) => {
|
|
41
38
|
const possibleCallback = args[args.length - 1];
|
|
42
39
|
if (isErrorFirstCallback(possibleCallback)) {
|
|
@@ -53,4 +50,3 @@ function createOptionalCallbackFunction(syncVersion) {
|
|
|
53
50
|
}
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
|
-
//# sourceMappingURL=types.js.map
|
package/{lib → build}/utils.d.ts
RENAMED
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import type { NamespacePrefix } from "./types";
|
|
1
|
+
import type { NamespacePrefix } from "./types.js";
|
|
2
2
|
export declare function isArrayHasLength(array: unknown): array is unknown[];
|
|
3
|
-
export declare function findAttr(element: Element, localName: string, namespace?: string): Attr
|
|
3
|
+
export declare function findAttr(element: Element, localName: string, namespace?: string): Attr;
|
|
4
4
|
export declare function findChildren(node: Node | Document, localName: string, namespace?: string): Element[];
|
|
5
5
|
/** @deprecated */
|
|
6
6
|
export declare function findChilds(node: Node | Document, localName: string, namespace?: string): Element[];
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Encode special characters in attribute values for XML 1.0
|
|
9
|
+
*/
|
|
10
|
+
export declare function encodeSpecialCharactersInAttribute(attributeValue: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Encode special characters in text content for XML 1.0
|
|
13
|
+
*/
|
|
8
14
|
export declare function encodeSpecialCharactersInText(text: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Encode special characters in attribute values for XML 1.1
|
|
17
|
+
* XML 1.1 requires escaping additional control characters
|
|
18
|
+
* @see https://www.w3.org/TR/xml11/#charsets
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeSpecialCharactersInAttributeXml11(attributeValue: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Encode special characters in text content for XML 1.1
|
|
23
|
+
* XML 1.1 requires escaping additional control characters
|
|
24
|
+
* @see https://www.w3.org/TR/xml11/#charsets
|
|
25
|
+
*/
|
|
26
|
+
export declare function encodeSpecialCharactersInTextXml11(text: string): string;
|
|
9
27
|
/**
|
|
10
28
|
* PEM format has wide range of usages, but this library
|
|
11
29
|
* is enforcing RFC7468 which focuses on PKIX, PKCS and CMS.
|
|
@@ -61,5 +79,17 @@ export declare function derToPem(der: string | Buffer, pemLabel?: "CERTIFICATE"
|
|
|
61
79
|
* @returns i.e. [{prefix: "saml", namespaceURI: "urn:oasis:names:tc:SAML:2.0:assertion"}]
|
|
62
80
|
*/
|
|
63
81
|
export declare function findAncestorNs(doc: Document, docSubsetXpath?: string, namespaceResolver?: XPathNSResolver): NamespacePrefix[];
|
|
64
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Validate digest value with timing-safe comparison
|
|
84
|
+
*/
|
|
85
|
+
export declare function validateDigestValue(digest: string, expectedDigest: string): boolean;
|
|
65
86
|
export declare function isDescendantOf(node: Node, parent: Node): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Check if a character is valid in XML 1.1
|
|
89
|
+
* @see https://www.w3.org/TR/xml11/#charsets
|
|
90
|
+
*/
|
|
91
|
+
export declare function isValidXml11Char(char: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Validate if a string is valid XML 1.1
|
|
94
|
+
*/
|
|
95
|
+
export declare function isValidXml11String(str: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAUlD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,EAAE,CAEnE;AAaD,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