@authhero/saml 0.4.1 → 0.4.3
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/dist/core.cjs +6 -6
- package/dist/core.mjs +4179 -2149
- package/dist/local-signer.cjs +1 -1
- package/dist/local-signer.mjs +26 -38
- package/dist/saml.cjs +6 -6
- package/dist/saml.mjs +4202 -2186
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +7 -6
package/dist/local-signer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`http://www.w3.org/2001/04/xmldsig-more#rsa-sha256`,t=`http://www.w3.org/2001/04/xmlenc#sha256`,n=`http://www.w3.org/2001/10/xml-exc-c14n#`,r=class{async signSAML(r,i,a){try{let o=await import(`xml-crypto`),s=o.SignedXml||o.default?.SignedXml;if(!s)throw Error(`SignedXml not found in xml-crypto module`);let c=new s({privateKey:i,publicCert:a});c.canonicalizationAlgorithm=n,c.addReference({xpath:`(/*[local-name()='Response']/*[local-name()='Assertion'])[1]`,digestAlgorithm:t,transforms:[`http://www.w3.org/2000/09/xmldsig#enveloped-signature`,n]}),c.signatureAlgorithm=e;let l=a.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g,``).replace(/\s/g,``);return c.keyInfoProvider={getKeyInfo:()=>`<X509Data><X509Certificate>${l}</X509Certificate></X509Data>`},c.computeSignature(r,{location:{reference:`/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']`,action:`after`}}),c.getSignedXml()}catch(e){throw Error(`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${e}`)}}};exports.LocalSamlSigner=r;
|
package/dist/local-signer.mjs
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
class
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
location: {
|
|
26
|
-
reference: "/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",
|
|
27
|
-
action: "after"
|
|
28
|
-
}
|
|
29
|
-
}), e.getSignedXml();
|
|
30
|
-
} catch (t) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${t}`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export {
|
|
38
|
-
w as LocalSamlSigner
|
|
1
|
+
//#region src/signers/local.ts
|
|
2
|
+
var e = "http://www.w3.org/2001/10/xml-exc-c14n#", t = class {
|
|
3
|
+
async signSAML(t, n, r) {
|
|
4
|
+
try {
|
|
5
|
+
let i = await import("xml-crypto"), a = i.SignedXml || i.default?.SignedXml;
|
|
6
|
+
if (!a) throw Error("SignedXml not found in xml-crypto module");
|
|
7
|
+
let o = new a({
|
|
8
|
+
privateKey: n,
|
|
9
|
+
publicCert: r
|
|
10
|
+
});
|
|
11
|
+
o.canonicalizationAlgorithm = e, o.addReference({
|
|
12
|
+
xpath: "(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",
|
|
13
|
+
digestAlgorithm: "http://www.w3.org/2001/04/xmlenc#sha256",
|
|
14
|
+
transforms: ["http://www.w3.org/2000/09/xmldsig#enveloped-signature", e]
|
|
15
|
+
}), o.signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
|
|
16
|
+
let s = r.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
|
|
17
|
+
return o.keyInfoProvider = { getKeyInfo: () => `<X509Data><X509Certificate>${s}</X509Certificate></X509Data>` }, o.computeSignature(t, { location: {
|
|
18
|
+
reference: "/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",
|
|
19
|
+
action: "after"
|
|
20
|
+
} }), o.getSignedXml();
|
|
21
|
+
} catch (e) {
|
|
22
|
+
throw Error(`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${e}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
39
25
|
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { t as LocalSamlSigner };
|