@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.
@@ -1 +1 @@
1
- "use strict";var m=Object.create;var s=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var u=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of d(t))!p.call(e,o)&&o!==r&&s(e,o,{get:()=>t[o],enumerable:!(a=w(t,o))||a.enumerable});return e};var S=(e,t,r)=>(r=e!=null?m(h(e)):{},u(t||!e||!e.__esModule?s(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",y="http://www.w3.org/2001/04/xmlenc#sha256",c="http://www.w3.org/2001/10/xml-exc-c14n#";class A{async signSAML(t,r,a){var o;try{const l=await import("xml-crypto"),i=l.SignedXml||((o=l.default)==null?void 0:o.SignedXml);if(!i)throw new Error("SignedXml not found in xml-crypto module");const n=new i({privateKey:r,publicCert:a});n.canonicalizationAlgorithm=c,n.addReference({xpath:"(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",digestAlgorithm:y,transforms:["http://www.w3.org/2000/09/xmldsig#enveloped-signature",c]}),n.signatureAlgorithm=f;const g=a.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g,"").replace(/\s/g,"");return n.keyInfoProvider={getKeyInfo:()=>`<X509Data><X509Certificate>${g}</X509Certificate></X509Data>`},n.computeSignature(t,{location:{reference:"/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",action:"after"}}),n.getSignedXml()}catch(l){throw new Error(`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${l}`)}}}exports.LocalSamlSigner=A;
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;
@@ -1,39 +1,27 @@
1
- const c = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", g = "http://www.w3.org/2001/04/xmlenc#sha256", a = "http://www.w3.org/2001/10/xml-exc-c14n#";
2
- class w {
3
- async signSAML(l, i, o) {
4
- var r;
5
- try {
6
- const t = await import("xml-crypto"), n = t.SignedXml || ((r = t.default) == null ? void 0 : r.SignedXml);
7
- if (!n)
8
- throw new Error("SignedXml not found in xml-crypto module");
9
- const e = new n({ privateKey: i, publicCert: o });
10
- e.canonicalizationAlgorithm = a, e.addReference({
11
- xpath: "(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",
12
- digestAlgorithm: g,
13
- transforms: [
14
- "http://www.w3.org/2000/09/xmldsig#enveloped-signature",
15
- a
16
- ]
17
- }), e.signatureAlgorithm = c;
18
- const s = o.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
19
- return e.keyInfoProvider = {
20
- getKeyInfo: () => `<X509Data><X509Certificate>${s}</X509Certificate></X509Data>`
21
- }, e.computeSignature(l, {
22
- // according to:
23
- // https://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd
24
- // Assertion's ds:Signature must be after Assertion/Issuer
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 };