@authhero/saml 0.4.1 → 0.4.2
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 +1694 -2151
- package/dist/local-signer.cjs +1 -1
- package/dist/local-signer.mjs +26 -38
- package/dist/saml.cjs +6 -6
- package/dist/saml.mjs +1717 -2188
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -5
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/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 {
|
|
3
|
+
async signSAML(r, i, a) {
|
|
4
|
+
try {
|
|
5
|
+
let o = await import("xml-crypto"), s = o.SignedXml || o.default?.SignedXml;
|
|
6
|
+
if (!s) throw Error("SignedXml not found in xml-crypto module");
|
|
7
|
+
let c = new s({
|
|
8
|
+
privateKey: i,
|
|
9
|
+
publicCert: a
|
|
10
|
+
});
|
|
11
|
+
c.canonicalizationAlgorithm = n, c.addReference({
|
|
12
|
+
xpath: "(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",
|
|
13
|
+
digestAlgorithm: t,
|
|
14
|
+
transforms: ["http://www.w3.org/2000/09/xmldsig#enveloped-signature", n]
|
|
15
|
+
}), c.signatureAlgorithm = e;
|
|
16
|
+
let l = a.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
|
|
17
|
+
return c.keyInfoProvider = { getKeyInfo: () => `<X509Data><X509Certificate>${l}</X509Certificate></X509Data>` }, c.computeSignature(r, { location: {
|
|
18
|
+
reference: "/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",
|
|
19
|
+
action: "after"
|
|
20
|
+
} }), c.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 { r as LocalSamlSigner };
|
package/dist/saml.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
`&&
|
|
3
|
-
`||t==="\r"}function U(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const s=t.substr(n,e-n);if(e>5&&s==="xml")return p("InvalidXml","XML declaration allowed only at the start of the document.",w(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function k(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let n=1;for(e+=8;e<t.length;e++)if(t[e]==="<")n++;else if(t[e]===">"&&(n--,n===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}const Se='"',ze="'";function _e(t,e){let n="",s="",r=!1;for(;e<t.length;e++){if(t[e]===Se||t[e]===ze)s===""?s=t[e]:s!==t[e]||(s="");else if(t[e]===">"&&s===""){r=!0;break}n+=t[e]}return s!==""?!1:{value:n,index:e,tagClosed:r}}const Te=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function G(t,e){const n=F.getAllMatches(t,Te),s={};for(let r=0;r<n.length;r++){if(n[r][1].length===0)return p("InvalidAttr","Attribute '"+n[r][2]+"' has no space in starting.",I(n[r]));if(n[r][3]!==void 0&&n[r][4]===void 0)return p("InvalidAttr","Attribute '"+n[r][2]+"' is without value.",I(n[r]));if(n[r][3]===void 0&&!e.allowBooleanAttributes)return p("InvalidAttr","boolean attribute '"+n[r][2]+"' is not allowed.",I(n[r]));const o=n[r][2];if(!Ce(o))return p("InvalidAttr","Attribute '"+o+"' is an invalid name.",I(n[r]));if(!s.hasOwnProperty(o))s[o]=1;else return p("InvalidAttr","Attribute '"+o+"' is repeated.",I(n[r]))}return!0}function Ie(t,e){let n=/\d/;for(t[e]==="x"&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(n))break}return-1}function Oe(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Ie(t,e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(t[e]===";")break;return-1}return e}function p(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function Ce(t){return F.isName(t)}function Pe(t){return F.isName(t)}function w(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function I(t){return t.startIndex+t[1].length}var R={};const{DANGEROUS_PROPERTY_NAMES:Q,criticalProperties:Le}=C,D=t=>Q.includes(t)?"__"+t:t,ee={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,onDangerousProperty:D};function Me(t,e){if(typeof t!="string")return;const n=t.toLowerCase();if(Q.some(s=>n===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Le.some(s=>n===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function te(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:te(!0)}const je=function(t){const e=Object.assign({},ee,t),n=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:s,name:r}of n)s&&Me(s,r);return e.onDangerousProperty===null&&(e.onDangerousProperty=D),e.processEntities=te(e.processEntities),e};R.buildOptions=je;R.defaultOptions=ee;class ve{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,n){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:n})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}var $e=ve;const ne=C;let Ve=class{constructor(e){this.suppressValidationErr=!e,this.options=e||{}}readDocType(e,n){const s=Object.create(null);let r=0;if(e[n+3]==="O"&&e[n+4]==="C"&&e[n+5]==="T"&&e[n+6]==="Y"&&e[n+7]==="P"&&e[n+8]==="E"){n=n+9;let o=1,a=!1,c=!1,l="";for(;n<e.length;n++)if(e[n]==="<"&&!c){if(a&&S(e,"!ENTITY",n)){n+=7;let u,f;if([u,f,n]=this.readEntityExp(e,n+1,this.suppressValidationErr),f.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&r>=this.options.maxEntityCount)throw new Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const d=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[u]={regx:RegExp(`&${d};`,"g"),val:f},r++}}else if(a&&S(e,"!ELEMENT",n)){n+=8;const{index:u}=this.readElementExp(e,n+1);n=u}else if(a&&S(e,"!ATTLIST",n))n+=8;else if(a&&S(e,"!NOTATION",n)){n+=9;const{index:u}=this.readNotationExp(e,n+1,this.suppressValidationErr);n=u}else if(S(e,"!--",n))c=!0;else throw new Error("Invalid DOCTYPE");o++,l=""}else if(e[n]===">"){if(c?e[n-1]==="-"&&e[n-2]==="-"&&(c=!1,o--):o--,o===0)break}else e[n]==="["?a=!0:l+=e[n];if(o!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:n}}readEntityExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n])&&e[n]!=='"'&&e[n]!=="'";)s+=e[n],n++;if(O(s),n=E(e,n),!this.suppressValidationErr){if(e.substring(n,n+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[n]==="%")throw new Error("Parameter entities are not supported")}let r="";if([n,r]=this.readIdentifierVal(e,n,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${s}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return n--,[s,r,n]}readNotationExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;!this.suppressValidationErr&&O(s),n=E(e,n);const r=e.substring(n,n+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);n+=r.length,n=E(e,n);let o=null,a=null;if(r==="PUBLIC")[n,o]=this.readIdentifierVal(e,n,"publicIdentifier"),n=E(e,n),(e[n]==='"'||e[n]==="'")&&([n,a]=this.readIdentifierVal(e,n,"systemIdentifier"));else if(r==="SYSTEM"&&([n,a]=this.readIdentifierVal(e,n,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:s,publicIdentifier:o,systemIdentifier:a,index:--n}}readIdentifierVal(e,n,s){let r="";const o=e[n];if(o!=='"'&&o!=="'")throw new Error(`Expected quoted string, found "${o}"`);for(n++;n<e.length&&e[n]!==o;)r+=e[n],n++;if(e[n]!==o)throw new Error(`Unterminated ${s} value`);return n++,[n,r]}readElementExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;if(!this.suppressValidationErr&&!ne.isName(s))throw new Error(`Invalid element name: "${s}"`);n=E(e,n);let r="";if(e[n]==="E"&&S(e,"MPTY",n))n+=4;else if(e[n]==="A"&&S(e,"NY",n))n+=2;else if(e[n]==="("){for(n++;n<e.length&&e[n]!==")";)r+=e[n],n++;if(e[n]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[n]}"`);return{elementName:s,contentModel:r.trim(),index:n}}readAttlistExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;O(s),n=E(e,n);let r="";for(;n<e.length&&!/\s/.test(e[n]);)r+=e[n],n++;if(!O(r))throw new Error(`Invalid attribute name: "${r}"`);n=E(e,n);let o="";if(e.substring(n,n+8).toUpperCase()==="NOTATION"){if(o="NOTATION",n+=8,n=E(e,n),e[n]!=="(")throw new Error(`Expected '(', found "${e[n]}"`);n++;let c=[];for(;n<e.length&&e[n]!==")";){let l="";for(;n<e.length&&e[n]!=="|"&&e[n]!==")";)l+=e[n],n++;if(l=l.trim(),!O(l))throw new Error(`Invalid notation name: "${l}"`);c.push(l),e[n]==="|"&&(n++,n=E(e,n))}if(e[n]!==")")throw new Error("Unterminated list of notations");n++,o+=" ("+c.join("|")+")"}else{for(;n<e.length&&!/\s/.test(e[n]);)o+=e[n],n++;const c=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!c.includes(o.toUpperCase()))throw new Error(`Invalid attribute type: "${o}"`)}n=E(e,n);let a="";return e.substring(n,n+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",n+=8):e.substring(n,n+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",n+=7):[n,a]=this.readIdentifierVal(e,n,"ATTLIST"),{elementName:s,attributeName:r,attributeType:o,defaultValue:a,index:n}}};const E=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function S(t,e,n){for(let s=0;s<e.length;s++)if(e[s]!==t[n+s+1])return!1;return!0}function O(t){if(ne.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var Fe=Ve;const Re=/^[-+]?0x[a-fA-F0-9]+$/,Xe=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Be={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Ue(t,e={}){if(e=Object.assign({},Be,e),!t||typeof t!="string")return t;let n=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(n))return t;if(t==="0")return 0;if(e.hex&&Re.test(n))return Ge(n,16);if(n.search(/[eE]/)!==-1){const s=n.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(s){if(e.leadingZeros)n=(s[1]||"")+s[3];else if(!(s[2]==="0"&&s[3][0]==="."))return t;return e.eNotation?Number(n):t}else return t}else{const s=Xe.exec(n);if(s){const r=s[1],o=s[2];let a=ke(s[3]);if(!e.leadingZeros&&o.length>0&&r&&n[2]!==".")return t;if(!e.leadingZeros&&o.length>0&&!r&&n[1]!==".")return t;if(e.leadingZeros&&o===t)return 0;{const c=Number(n),l=""+c;return l.search(/[eE]/)!==-1?e.eNotation?c:t:n.indexOf(".")!==-1?l==="0"&&a===""||l===a||r&&l==="-"+a?c:t:o?a===l||r+a===l?c:t:n===l||n===r+l?c:t}}else return t}}function ke(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}function Ge(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}var Ye=Ue;function Ke(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(const n of t)if(typeof n=="string"&&e===n||n instanceof RegExp&&n.test(e))return!0}:()=>!1}var se=Ke;const P=C,T=$e,Je=Fe,qe=Ye,Ze=se;let He=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,s)=>Y(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,s)=>Y(s,16,"&#x")}},this.addExternalEntities=We,this.parseXml=nt,this.parseTextData=Qe,this.resolveNameSpace=De,this.buildAttributesMap=tt,this.isItStopNode=ot,this.replaceEntitiesValue=rt,this.readStopNodeData=lt,this.saveTextToParentTag=it,this.addChild=st,this.ignoreAttributesFn=Ze(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let n=0;n<this.options.stopNodes.length;n++){const s=this.options.stopNodes[n];typeof s=="string"&&(s.startsWith("*.")?this.stopNodesWildcard.add(s.substring(2)):this.stopNodesExact.add(s))}}}};function We(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const s=e[n],r=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+r+";","g"),val:t[s]}}}function Qe(t,e,n,s,r,o,a){if(t!==void 0&&(this.options.trimValues&&!s&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t,e,n));const c=this.options.tagValueProcessor(e,t,n,r,o);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?$(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?$(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function De(t){if(this.options.removeNSPrefix){const e=t.split(":"),n=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=n+e[1])}return t}const et=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function tt(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const s=P.getAllMatches(t,et),r=s.length,o={};for(let a=0;a<r;a++){const c=this.resolveNameSpace(s[a][1]);if(this.ignoreAttributesFn(c,e))continue;let l=s[a][4],u=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(u=this.options.transformAttributeName(u)),u=ut(u,this.options),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,n,e);const f=this.options.attributeValueProcessor(c,l,e);f==null?o[u]=l:typeof f!=typeof l||f!==l?o[u]=f:o[u]=$(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[u]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=o,a}return o}}const nt=function(t){t=t.replace(/\r\n?/g,`
|
|
4
|
-
`);
|
|
5
|
-
`;function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);let t=require("@hono/zod-openapi");var n=t.z.object({"#text":t.z.string()}),r=t.z.object({"#text":t.z.string(),"@_xmlns:saml":t.z.string().optional()}),i=t.z.object({"samlp:AuthnRequest":t.z.object({"saml:Issuer":r,"@_xmlns:samlp":t.z.string(),"@_xmlns:saml":t.z.string().optional(),"@_ForceAuthn":t.z.string().transform(e=>e.toLowerCase()===`true`).optional(),"@_ID":t.z.string(),"@_IssueInstant":t.z.string().datetime(),"@_Destination":t.z.string().url(),"@_AssertionConsumerServiceURL":t.z.string().url().optional(),"@_ProtocolBinding":t.z.string().optional(),"@_Version":t.z.string()})}),a=t.z.array(t.z.object({":@":t.z.object({"@_xmlns":t.z.string(),"@_entityID":t.z.string()}),EntityDescriptor:t.z.array(t.z.object({":@":t.z.object({"@_protocolSupportEnumeration":t.z.string()}),IDPSSODescriptor:t.z.array(t.z.union([t.z.object({KeyDescriptor:t.z.array(t.z.object({KeyInfo:t.z.array(t.z.object({X509Data:t.z.array(t.z.object({X509Certificate:t.z.array(n)}))})),":@":t.z.object({"@_xmlns":t.z.string()})})),":@":t.z.object({"@_use":t.z.string()})}),t.z.object({SingleLogoutService:t.z.array(t.z.object({})),":@":t.z.object({"@_Binding":t.z.string(),"@_Location":t.z.string()})}),t.z.object({NameIDFormat:t.z.array(n)}),t.z.object({SingleSignOnService:t.z.array(t.z.object({})),":@":t.z.object({"@_Binding":t.z.string(),"@_Location":t.z.string()})}),t.z.object({Attribute:t.z.array(t.z.object({})),":@":t.z.object({"@_Name":t.z.string(),"@_NameFormat":t.z.string(),"@_FriendlyName":t.z.string(),"@_xmlns":t.z.string()})})]))}))})),o=t.z.object({"saml:Attribute":t.z.array(t.z.object({"saml:AttributeValue":t.z.array(t.z.object({"#text":t.z.string()})),":@":t.z.object({"@_xmlns:xs":t.z.string().optional(),"@_xmlns:xsi":t.z.string(),"@_xsi:type":t.z.string()}).optional()})),":@":t.z.object({"@_Name":t.z.string(),"@_NameFormat":t.z.string(),"@_FriendlyName":t.z.string().optional()})}),s=t.z.object({"ds:Transform":t.z.array(t.z.any()),":@":t.z.object({"@_Algorithm":t.z.string()})}),c=t.z.object({"ds:Signature":t.z.array(t.z.union([t.z.object({"ds:SignedInfo":t.z.array(t.z.union([t.z.object({"ds:CanonicalizationMethod":t.z.array(t.z.object({":@":t.z.object({"@_Algorithm":t.z.string()})}))}),t.z.object({"ds:SignatureMethod":t.z.array(t.z.object({":@":t.z.object({"@_Algorithm":t.z.string()})}))}),t.z.object({"ds:Reference":t.z.array(t.z.union([t.z.object({"ds:Transforms":t.z.array(s)}),t.z.object({"ds:DigestMethod":t.z.array(t.z.object({":@":t.z.object({"@_Algorithm":t.z.string()})}))}),t.z.object({"ds:DigestValue":t.z.array(n)})])),":@":t.z.object({"@_URI":t.z.string().optional()}).optional()})]))}),t.z.object({"ds:SignatureValue":t.z.array(n)}),t.z.object({"ds:KeyInfo":t.z.array(t.z.union([t.z.object({"ds:KeyValue":t.z.array(t.z.object({"ds:RSAKeyValue":t.z.array(t.z.union([t.z.object({"ds:Modulus":t.z.array(n)}),t.z.object({"ds:Exponent":t.z.array(n)})]))}))}),t.z.object({"ds:X509Data":t.z.array(t.z.object({"ds:X509Certificate":t.z.array(n)}))}),t.z.object({"ds:KeyValue":t.z.array(t.z.object({"ds:RSAKeyValue":t.z.array(t.z.union([t.z.object({"ds:Modulus":t.z.array(n)}),t.z.object({"ds:Exponent":t.z.array(n)})]))})),"ds:X509Data":t.z.array(t.z.object({"ds:X509Certificate":t.z.array(n)}))})]))})])),":@":t.z.object({"@_xmlns:ds":t.z.string().optional()}).optional()}),l=t.z.array(t.z.object({"samlp:Response":t.z.array(t.z.union([t.z.object({"saml:Issuer":t.z.array(n)}),c,t.z.object({"samlp:Status":t.z.array(t.z.object({"samlp:StatusCode":t.z.array(n),":@":t.z.object({"@_Value":t.z.string()})}))}),t.z.object({"saml:Assertion":t.z.array(t.z.union([t.z.object({"saml:Issuer":t.z.array(n)}),c,t.z.object({"saml:Subject":t.z.array(t.z.union([t.z.object({"saml:NameID":t.z.array(n),":@":t.z.object({"@_Format":t.z.string()})}),t.z.object({"saml:SubjectConfirmation":t.z.array(t.z.object({"saml:SubjectConfirmationData":t.z.array(t.z.any()),":@":t.z.object({"@_InResponseTo":t.z.string(),"@_NotOnOrAfter":t.z.string(),"@_Recipient":t.z.string()})})),":@":t.z.object({"@_Method":t.z.string()})})]))}),t.z.object({"saml:Conditions":t.z.array(t.z.object({"saml:AudienceRestriction":t.z.array(t.z.object({"saml:Audience":t.z.array(n)}))})),":@":t.z.object({"@_NotBefore":t.z.string(),"@_NotOnOrAfter":t.z.string()})}),t.z.object({"saml:AuthnStatement":t.z.array(t.z.object({"saml:AuthnContext":t.z.array(t.z.object({"saml:AuthnContextClassRef":t.z.array(n)}))})),":@":t.z.object({"@_AuthnInstant":t.z.string(),"@_SessionIndex":t.z.string(),"@_SessionNotOnOrAfter":t.z.string()})}),t.z.object({"saml:AttributeStatement":t.z.array(o)})])),":@":t.z.object({"@_xmlns":t.z.string(),"@_ID":t.z.string(),"@_IssueInstant":t.z.string(),"@_Version":t.z.string()})})])),":@":t.z.object({"@_xmlns:samlp":t.z.string(),"@_xmlns:saml":t.z.string(),"@_Destination":t.z.string(),"@_ID":t.z.string(),"@_InResponseTo":t.z.string(),"@_IssueInstant":t.z.string(),"@_Version":t.z.string()})})),u=e((e=>{var t=`[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*`,n=RegExp(`^[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`);e.isExist=function(e){return e!==void 0},e.isEmptyObject=function(e){return Object.keys(e).length===0},e.merge=function(e,t,n){if(t){let r=Object.keys(t),i=r.length;for(let a=0;a<i;a++)n===`strict`?e[r[a]]=[t[r[a]]]:e[r[a]]=t[r[a]]}},e.getValue=function(t){return e.isExist(t)?t:``},e.isName=function(e){return n.exec(e)!=null},e.getAllMatches=function(e,t){let n=[],r=t.exec(e);for(;r;){let i=[];i.startIndex=t.lastIndex-r[0].length;let a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n},e.nameRegexp=t,e.DANGEROUS_PROPERTY_NAMES=[`hasOwnProperty`,`toString`,`valueOf`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`],e.criticalProperties=[`__proto__`,`constructor`,`prototype`]})),d=e((e=>{var t=u(),n={allowBooleanAttributes:!1,unpairedTags:[]};e.validate=function(e,t){t=Object.assign({},n,t);let o=[],s=!1,l=!1;e[0]===``&&(e=e.substr(1));for(let n=0;n<e.length;n++)if(e[n]===`<`&&e[n+1]===`?`){if(n+=2,n=i(e,n),n.err)return n}else if(e[n]===`<`){let u=n;if(n++,e[n]===`!`){n=a(e,n);continue}else{let f=!1;e[n]===`/`&&(f=!0,n++);let h=``;for(;n<e.length&&e[n]!==`>`&&e[n]!==` `&&e[n]!==` `&&e[n]!==`
|
|
2
|
+
`&&e[n]!==`\r`;n++)h+=e[n];if(h=h.trim(),h[h.length-1]===`/`&&(h=h.substring(0,h.length-1),n--),!g(h)){let t;return t=h.trim().length===0?`Invalid space after '<'.`:`Tag '`+h+`' is an invalid name.`,m(`InvalidTag`,t,_(e,n))}let v=c(e,n);if(v===!1)return m(`InvalidAttr`,`Attributes for '`+h+`' have open quote.`,_(e,n));let y=v.value;if(n=v.index,y[y.length-1]===`/`){let r=n-y.length;y=y.substring(0,y.length-1);let i=d(y,t);if(i===!0)s=!0;else return m(i.err.code,i.err.msg,_(e,r+i.err.line))}else if(f){if(!v.tagClosed)return m(`InvalidTag`,`Closing tag '`+h+`' doesn't have proper closing.`,_(e,n));if(y.trim().length>0)return m(`InvalidTag`,`Closing tag '`+h+`' can't have attributes or invalid starting.`,_(e,u));if(o.length===0)return m(`InvalidTag`,`Closing tag '`+h+`' has not been opened.`,_(e,u));{let t=o.pop();if(h!==t.tagName){let n=_(e,t.tagStartPos);return m(`InvalidTag`,`Expected closing tag '`+t.tagName+`' (opened in line `+n.line+`, col `+n.col+`) instead of closing tag '`+h+`'.`,_(e,u))}o.length==0&&(l=!0)}}else{let r=d(y,t);if(r!==!0)return m(r.err.code,r.err.msg,_(e,n-y.length+r.err.line));if(l===!0)return m(`InvalidXml`,`Multiple possible root nodes found.`,_(e,n));t.unpairedTags.indexOf(h)!==-1||o.push({tagName:h,tagStartPos:u}),s=!0}for(n++;n<e.length;n++)if(e[n]===`<`)if(e[n+1]===`!`){n++,n=a(e,n);continue}else if(e[n+1]===`?`){if(n=i(e,++n),n.err)return n}else break;else if(e[n]===`&`){let t=p(e,n);if(t==-1)return m(`InvalidChar`,`char '&' is not expected.`,_(e,n));n=t}else if(l===!0&&!r(e[n]))return m(`InvalidXml`,`Extra text at the end`,_(e,n));e[n]===`<`&&n--}}else{if(r(e[n]))continue;return m(`InvalidChar`,`char '`+e[n]+`' is not expected.`,_(e,n))}return s?o.length==1?m(`InvalidTag`,`Unclosed tag '`+o[0].tagName+`'.`,_(e,o[0].tagStartPos)):o.length>0?m(`InvalidXml`,`Invalid '`+JSON.stringify(o.map(e=>e.tagName),null,4).replace(/\r?\n/g,``)+`' found.`,{line:1,col:1}):!0:m(`InvalidXml`,`Start tag expected.`,1)};function r(e){return e===` `||e===` `||e===`
|
|
3
|
+
`||e===`\r`}function i(e,t){let n=t;for(;t<e.length;t++)if(e[t]==`?`||e[t]==` `){let r=e.substr(n,t-n);if(t>5&&r===`xml`)return m(`InvalidXml`,`XML declaration allowed only at the start of the document.`,_(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function a(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t<e.length;t++)if(e[t]===`-`&&e[t+1]===`-`&&e[t+2]===`>`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t<e.length;t++)if(e[t]===`<`)n++;else if(e[t]===`>`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t<e.length;t++)if(e[t]===`]`&&e[t+1]===`]`&&e[t+2]===`>`){t+=2;break}}return t}var o=`"`,s=`'`;function c(e,t){let n=``,r=``,i=!1;for(;t<e.length;t++){if(e[t]===o||e[t]===s)r===``?r=e[t]:r!==e[t]||(r=``);else if(e[t]===`>`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}var l=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function d(e,n){let r=t.getAllMatches(e,l),i={};for(let e=0;e<r.length;e++){if(r[e][1].length===0)return m(`InvalidAttr`,`Attribute '`+r[e][2]+`' has no space in starting.`,v(r[e]));if(r[e][3]!==void 0&&r[e][4]===void 0)return m(`InvalidAttr`,`Attribute '`+r[e][2]+`' is without value.`,v(r[e]));if(r[e][3]===void 0&&!n.allowBooleanAttributes)return m(`InvalidAttr`,`boolean attribute '`+r[e][2]+`' is not allowed.`,v(r[e]));let t=r[e][2];if(!h(t))return m(`InvalidAttr`,`Attribute '`+t+`' is an invalid name.`,v(r[e]));if(!i.hasOwnProperty(t))i[t]=1;else return m(`InvalidAttr`,`Attribute '`+t+`' is repeated.`,v(r[e]))}return!0}function f(e,t){let n=/\d/;for(e[t]===`x`&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===`;`)return t;if(!e[t].match(n))break}return-1}function p(e,t){if(t++,e[t]===`;`)return-1;if(e[t]===`#`)return t++,f(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===`;`)break;return-1}return t}function m(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function h(e){return t.isName(e)}function g(e){return t.isName(e)}function _(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function v(e){return e.startIndex+e[1].length}})),f=e((e=>{var{DANGEROUS_PROPERTY_NAMES:t,criticalProperties:n}=u(),r=e=>t.includes(e)?`__`+e:e,i={preserveOrder:!1,attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,onDangerousProperty:r};function a(e,r){if(typeof e!=`string`)return;let i=e.toLowerCase();if(t.some(e=>i===e.toLowerCase())||n.some(e=>i===e.toLowerCase()))throw Error(`[SECURITY] Invalid ${r}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function o(e){return typeof e==`boolean`?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof e==`object`&&e?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??1e3),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null}:o(!0)}e.buildOptions=function(e){let t=Object.assign({},i,e),n=[{value:t.attributeNamePrefix,name:`attributeNamePrefix`},{value:t.attributesGroupName,name:`attributesGroupName`},{value:t.textNodeName,name:`textNodeName`},{value:t.cdataPropName,name:`cdataPropName`},{value:t.commentPropName,name:`commentPropName`}];for(let{value:e,name:t}of n)e&&a(e,t);return t.onDangerousProperty===null&&(t.onDangerousProperty=r),t.processEntities=o(t.processEntities),t},e.defaultOptions=i})),p=e(((e,t)=>{t.exports=class{constructor(e){this.tagname=e,this.child=[],this[`:@`]={}}add(e,t){e===`__proto__`&&(e=`#__proto__`),this.child.push({[e]:t})}addChild(e){e.tagname===`__proto__`&&(e.tagname=`#__proto__`),e[`:@`]&&Object.keys(e[`:@`]).length>0?this.child.push({[e.tagname]:e.child,":@":e[`:@`]}):this.child.push({[e.tagname]:e.child})}}})),m=e(((e,t)=>{var n=u(),r=class{constructor(e){this.suppressValidationErr=!e,this.options=e||{}}readDocType(e,t){let n=Object.create(null),r=0;if(e[t+3]===`O`&&e[t+4]===`C`&&e[t+5]===`T`&&e[t+6]===`Y`&&e[t+7]===`P`&&e[t+8]===`E`){t+=9;let i=1,o=!1,s=!1,c=``;for(;t<e.length;t++)if(e[t]===`<`&&!s){if(o&&a(e,`!ENTITY`,t)){t+=7;let i,a;if([i,a,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),a.indexOf(`&`)===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&r>=this.options.maxEntityCount)throw Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let e=i.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n[i]={regx:RegExp(`&${e};`,`g`),val:a},r++}}else if(o&&a(e,`!ELEMENT`,t)){t+=8;let{index:n}=this.readElementExp(e,t+1);t=n}else if(o&&a(e,`!ATTLIST`,t))t+=8;else if(o&&a(e,`!NOTATION`,t)){t+=9;let{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else if(a(e,`!--`,t))s=!0;else throw Error(`Invalid DOCTYPE`);i++,c=``}else if(e[t]===`>`){if(s?e[t-1]===`-`&&e[t-2]===`-`&&(s=!1,i--):i--,i===0)break}else e[t]===`[`?o=!0:c+=e[t];if(i!==0)throw Error(`Unclosed DOCTYPE`)}else throw Error(`Invalid Tag instead of DOCTYPE`);return{entities:n,i:t}}readEntityExp(e,t){t=i(e,t);let n=``;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!==`"`&&e[t]!==`'`;)n+=e[t],t++;if(o(n),t=i(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()===`SYSTEM`)throw Error(`External entities are not supported`);if(e[t]===`%`)throw Error(`Parameter entities are not supported`)}let r=``;if([t,r]=this.readIdentifierVal(e,t,`entity`),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw Error(`Entity "${n}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[n,r,t]}readNotationExp(e,t){t=i(e,t);let n=``;for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;!this.suppressValidationErr&&o(n),t=i(e,t);let r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!==`SYSTEM`&&r!==`PUBLIC`)throw Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=i(e,t);let a=null,s=null;if(r===`PUBLIC`)[t,a]=this.readIdentifierVal(e,t,`publicIdentifier`),t=i(e,t),(e[t]===`"`||e[t]===`'`)&&([t,s]=this.readIdentifierVal(e,t,`systemIdentifier`));else if(r===`SYSTEM`&&([t,s]=this.readIdentifierVal(e,t,`systemIdentifier`),!this.suppressValidationErr&&!s))throw Error(`Missing mandatory system identifier for SYSTEM notation`);return{notationName:n,publicIdentifier:a,systemIdentifier:s,index:--t}}readIdentifierVal(e,t,n){let r=``,i=e[t];if(i!==`"`&&i!==`'`)throw Error(`Expected quoted string, found "${i}"`);for(t++;t<e.length&&e[t]!==i;)r+=e[t],t++;if(e[t]!==i)throw Error(`Unterminated ${n} value`);return t++,[t,r]}readElementExp(e,t){t=i(e,t);let r=``;for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;if(!this.suppressValidationErr&&!n.isName(r))throw Error(`Invalid element name: "${r}"`);t=i(e,t);let o=``;if(e[t]===`E`&&a(e,`MPTY`,t))t+=4;else if(e[t]===`A`&&a(e,`NY`,t))t+=2;else if(e[t]===`(`){for(t++;t<e.length&&e[t]!==`)`;)o+=e[t],t++;if(e[t]!==`)`)throw Error(`Unterminated content model`)}else if(!this.suppressValidationErr)throw Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:r,contentModel:o.trim(),index:t}}readAttlistExp(e,t){t=i(e,t);let n=``;for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;o(n),t=i(e,t);let r=``;for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;if(!o(r))throw Error(`Invalid attribute name: "${r}"`);t=i(e,t);let a=``;if(e.substring(t,t+8).toUpperCase()===`NOTATION`){if(a=`NOTATION`,t+=8,t=i(e,t),e[t]!==`(`)throw Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&e[t]!==`)`;){let r=``;for(;t<e.length&&e[t]!==`|`&&e[t]!==`)`;)r+=e[t],t++;if(r=r.trim(),!o(r))throw Error(`Invalid notation name: "${r}"`);n.push(r),e[t]===`|`&&(t++,t=i(e,t))}if(e[t]!==`)`)throw Error(`Unterminated list of notations`);t++,a+=` (`+n.join(`|`)+`)`}else{for(;t<e.length&&!/\s/.test(e[t]);)a+=e[t],t++;if(!this.suppressValidationErr&&![`CDATA`,`ID`,`IDREF`,`IDREFS`,`ENTITY`,`ENTITIES`,`NMTOKEN`,`NMTOKENS`].includes(a.toUpperCase()))throw Error(`Invalid attribute type: "${a}"`)}t=i(e,t);let s=``;return e.substring(t,t+8).toUpperCase()===`#REQUIRED`?(s=`#REQUIRED`,t+=8):e.substring(t,t+7).toUpperCase()===`#IMPLIED`?(s=`#IMPLIED`,t+=7):[t,s]=this.readIdentifierVal(e,t,`ATTLIST`),{elementName:n,attributeName:r,attributeType:a,defaultValue:s,index:t}}},i=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function a(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function o(e){if(n.isName(e))return e;throw Error(`Invalid entity name ${e}`)}t.exports=r})),h=e(((e,t)=>{var n=/^[-+]?0x[a-fA-F0-9]+$/,r=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,i={hex:!0,leadingZeros:!0,decimalPoint:`.`,eNotation:!0};function a(e,t={}){if(t=Object.assign({},i,t),!e||typeof e!=`string`)return e;let a=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(a))return e;if(e===`0`)return 0;if(t.hex&&n.test(a))return s(a,16);if(a.search(/[eE]/)!==-1){let n=a.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(n){if(t.leadingZeros)a=(n[1]||``)+n[3];else if(!(n[2]===`0`&&n[3][0]===`.`))return e;return t.eNotation?Number(a):e}else return e}else{let n=r.exec(a);if(n){let r=n[1],i=n[2],s=o(n[3]);if(!t.leadingZeros&&i.length>0&&r&&a[2]!==`.`||!t.leadingZeros&&i.length>0&&!r&&a[1]!==`.`)return e;if(t.leadingZeros&&i===e)return 0;{let n=Number(a),o=``+n;return o.search(/[eE]/)===-1?a.indexOf(`.`)===-1?i?s===o||r+s===o?n:e:a===o||a===r+o?n:e:o===`0`&&s===``||o===s||r&&o===`-`+s?n:e:t.eNotation?n:e}}else return e}}function o(e){return e&&e.indexOf(`.`)!==-1?(e=e.replace(/0+$/,``),e===`.`?e=`0`:e[0]===`.`?e=`0`+e:e[e.length-1]===`.`&&(e=e.substr(0,e.length-1)),e):e}function s(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}t.exports=a})),g=e(((e,t)=>{function n(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}t.exports=n})),_=e(((e,t)=>{var n=u(),r=p(),i=m(),a=h(),o=g(),s=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:`'`},gt:{regex:/&(gt|#62|#x3E);/g,val:`>`},lt:{regex:/&(lt|#60|#x3C);/g,val:`<`},quot:{regex:/&(quot|#34|#x22);/g,val:`"`}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:`&`},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:` `},cent:{regex:/&(cent|#162);/g,val:`¢`},pound:{regex:/&(pound|#163);/g,val:`£`},yen:{regex:/&(yen|#165);/g,val:`¥`},euro:{regex:/&(euro|#8364);/g,val:`€`},copyright:{regex:/&(copy|#169);/g,val:`©`},reg:{regex:/&(reg|#174);/g,val:`®`},inr:{regex:/&(inr|#8377);/g,val:`₹`},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>O(t,10,`&#`)},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>O(t,16,`&#x`)}},this.addExternalEntities=c,this.parseXml=v,this.parseTextData=l,this.resolveNameSpace=d,this.buildAttributesMap=_,this.isItStopNode=S,this.replaceEntitiesValue=b,this.readStopNodeData=E,this.saveTextToParentTag=x,this.addChild=y,this.ignoreAttributesFn=o(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let e=0;e<this.options.stopNodes.length;e++){let t=this.options.stopNodes[e];typeof t==`string`&&(t.startsWith(`*.`)?this.stopNodesWildcard.add(t.substring(2)):this.stopNodesExact.add(t))}}}};function c(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n],i=r.replace(/[.\-+*:]/g,`\\.`);this.lastEntities[r]={regex:RegExp(`&`+i+`;`,`g`),val:e[r]}}}function l(e,t,n,r,i,a,o){if(e!==void 0&&(this.options.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,n));let r=this.options.tagValueProcessor(t,e,n,i,a);return r==null?e:typeof r!=typeof e||r!==e?r:this.options.trimValues||e.trim()===e?D(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function d(e){if(this.options.removeNSPrefix){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}var f=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,`gm`);function _(e,t,r){if(this.options.ignoreAttributes!==!0&&typeof e==`string`){let i=n.getAllMatches(e,f),a=i.length,o={};for(let e=0;e<a;e++){let n=this.resolveNameSpace(i[e][1]);if(this.ignoreAttributesFn(n,t))continue;let a=i[e][4],s=this.options.attributeNamePrefix+n;if(n.length)if(this.options.transformAttributeName&&(s=this.options.transformAttributeName(s)),s=k(s,this.options),a!==void 0){this.options.trimValues&&(a=a.trim()),a=this.replaceEntitiesValue(a,r,t);let e=this.options.attributeValueProcessor(n,a,t);e==null?o[s]=a:typeof e!=typeof a||e!==a?o[s]=e:o[s]=D(a,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[s]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){let e={};return e[this.options.attributesGroupName]=o,e}return o}}var v=function(e){e=e.replace(/\r\n?/g,`
|
|
4
|
+
`);let t=new r(`!xml`),n=t,a=``,o=``;this.entityExpansionCount=0,this.currentExpandedLength=0;let s=new i(this.options.processEntities);for(let i=0;i<e.length;i++)if(e[i]===`<`)if(e[i+1]===`/`){let t=w(e,`>`,i,`Closing Tag is not closed.`),r=e.substring(i+2,t).trim();if(this.options.removeNSPrefix){let e=r.indexOf(`:`);e!==-1&&(r=r.substr(e+1))}this.options.transformTagName&&(r=this.options.transformTagName(r)),n&&(a=this.saveTextToParentTag(a,n,o));let s=o.substring(o.lastIndexOf(`.`)+1);if(r&&this.options.unpairedTags.indexOf(r)!==-1)throw Error(`Unpaired tag can not be used as closing tag: </${r}>`);let c=0;s&&this.options.unpairedTags.indexOf(s)!==-1?(c=o.lastIndexOf(`.`,o.lastIndexOf(`.`)-1),this.tagsNodeStack.pop()):c=o.lastIndexOf(`.`),o=o.substring(0,c),n=this.tagsNodeStack.pop(),a=``,i=t}else if(e[i+1]===`?`){let t=T(e,i,!1,`?>`);if(!t)throw Error(`Pi Tag is not closed.`);if(a=this.saveTextToParentTag(a,n,o),!(this.options.ignoreDeclaration&&t.tagName===`?xml`||this.options.ignorePiTags)){let e=new r(t.tagName);e.add(this.options.textNodeName,``),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[`:@`]=this.buildAttributesMap(t.tagExp,o,t.tagName)),this.addChild(n,e,o,i)}i=t.closeIndex+1}else if(e.substr(i+1,3)===`!--`){let t=w(e,`-->`,i+4,`Comment is not closed.`);if(this.options.commentPropName){let r=e.substring(i+4,t-2);a=this.saveTextToParentTag(a,n,o),n.add(this.options.commentPropName,[{[this.options.textNodeName]:r}])}i=t}else if(e.substr(i+1,2)===`!D`){let t=s.readDocType(e,i);this.docTypeEntities=t.entities,i=t.i}else if(e.substr(i+1,2)===`![`){let t=w(e,`]]>`,i,`CDATA is not closed.`)-2,r=e.substring(i+9,t);a=this.saveTextToParentTag(a,n,o);let s=this.parseTextData(r,n.tagname,o,!0,!1,!0,!0);s??=``,this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:r}]):n.add(this.options.textNodeName,s),i=t+2}else{let s=T(e,i,this.options.removeNSPrefix),c=s.tagName,l=s.rawTagName,u=s.tagExp,d=s.attrExpPresent,f=s.closeIndex;if(this.options.transformTagName){let e=this.options.transformTagName(c);u===c&&(u=e),c=e}if(this.options.strictReservedNames&&(c===this.options.commentPropName||c===this.options.cdataPropName||c===this.options.textNodeName||c===this.options.attributesGroupName))throw Error(`Invalid tag name: ${c}`);n&&a&&n.tagname!==`!xml`&&(a=this.saveTextToParentTag(a,n,o,!1));let p=n;p&&this.options.unpairedTags.indexOf(p.tagname)!==-1&&(n=this.tagsNodeStack.pop(),o=o.substring(0,o.lastIndexOf(`.`))),c!==t.tagname&&(o+=o?`.`+c:c);let m=i;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,o,c)){let t=``;if(u.length>0&&u.lastIndexOf(`/`)===u.length-1)c[c.length-1]===`/`?(c=c.substr(0,c.length-1),o=o.substr(0,o.length-1),u=c):u=u.substr(0,u.length-1),i=s.closeIndex;else if(this.options.unpairedTags.indexOf(c)!==-1)i=s.closeIndex;else{let n=this.readStopNodeData(e,l,f+1);if(!n)throw Error(`Unexpected end of ${l}`);i=n.i,t=n.tagContent}let a=new r(c);c!==u&&d&&(a[`:@`]=this.buildAttributesMap(u,o,c)),t&&=this.parseTextData(t,c,o,!0,d,!0,!0),o=o.substr(0,o.lastIndexOf(`.`)),a.add(this.options.textNodeName,t),this.addChild(n,a,o,m)}else{if(u.length>0&&u.lastIndexOf(`/`)===u.length-1){if(c[c.length-1]===`/`?(c=c.substr(0,c.length-1),o=o.substr(0,o.length-1),u=c):u=u.substr(0,u.length-1),this.options.transformTagName){let e=this.options.transformTagName(c);u===c&&(u=e),c=e}let e=new r(c);c!==u&&d&&(e[`:@`]=this.buildAttributesMap(u,o,c)),this.addChild(n,e,o,m),o=o.substr(0,o.lastIndexOf(`.`))}else if(this.options.unpairedTags.indexOf(c)!==-1){let e=new r(c);c!==u&&d&&(e[`:@`]=this.buildAttributesMap(u,o)),this.addChild(n,e,o,m),o=o.substr(0,o.lastIndexOf(`.`)),i=s.closeIndex;continue}else{let e=new r(c);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw Error(`Maximum nested tags exceeded`);this.tagsNodeStack.push(n),c!==u&&d&&(e[`:@`]=this.buildAttributesMap(u,o,c)),this.addChild(n,e,o),n=e}a=``,i=f}}else a+=e[i];return t.child};function y(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.updateTag(t.tagname,n,t[`:@`]);i===!1||(typeof i==`string`&&(t.tagname=i),e.addChild(t,r))}var b=function(e,t,n){if(e.indexOf(`&`)===-1)return e;let r=this.options.processEntities;if(!r.enabled||r.allowedTags&&!r.allowedTags.includes(t)||r.tagFilter&&!r.tagFilter(t,n))return e;for(let t in this.docTypeEntities){let n=this.docTypeEntities[t],i=e.match(n.regx);if(i){if(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions)throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);let t=e.length;if(e=e.replace(n.regx,n.val),r.maxExpandedLength&&(this.currentExpandedLength+=e.length-t,this.currentExpandedLength>r.maxExpandedLength))throw Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${r.maxExpandedLength}`)}}if(e.indexOf(`&`)===-1)return e;for(let t of Object.keys(this.lastEntities)){let n=this.lastEntities[t],i=e.match(n.regex);if(i&&(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);e=e.replace(n.regex,n.val)}if(e.indexOf(`&`)===-1)return e;if(this.options.htmlEntities)for(let t of Object.keys(this.htmlEntities)){let n=this.htmlEntities[t],i=e.match(n.regex);if(i&&(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);e=e.replace(n.regex,n.val)}return e=e.replace(this.ampEntity.regex,this.ampEntity.val),e};function x(e,t,n,r){return e&&=(r===void 0&&(r=t.child.length===0),e=this.parseTextData(e,t.tagname,n,!1,t[`:@`]?Object.keys(t[`:@`]).length!==0:!1,r),e!==void 0&&e!==``&&t.add(this.options.textNodeName,e),``),e}function S(e,t,n,r){return!!(t&&t.has(r)||e&&e.has(n))}function C(e,t,n=`>`){let r,i=``;for(let a=t;a<e.length;a++){let t=e[a];if(r)t===r&&(r=``);else if(t===`"`||t===`'`)r=t;else if(t===n[0])if(n[1]){if(e[a+1]===n[1])return{data:i,index:a}}else return{data:i,index:a};else t===` `&&(t=` `);i+=t}}function w(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}function T(e,t,n,r=`>`){let i=C(e,t+1,r);if(!i)return;let a=i.data,o=i.index,s=a.search(/\s/),c=a,l=!0;s!==-1&&(c=a.substring(0,s),a=a.substring(s+1).trimStart());let u=c;if(n){let e=c.indexOf(`:`);e!==-1&&(c=c.substr(e+1),l=c!==i.data.substr(e+1))}return{tagName:c,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:u}}function E(e,t,n){let r=n,i=1;for(;n<e.length;n++)if(e[n]===`<`)if(e[n+1]===`/`){let a=w(e,`>`,n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(r,n),i:a};n=a}else if(e[n+1]===`?`)n=w(e,`?>`,n+1,`StopNode is not closed.`);else if(e.substr(n+1,3)===`!--`)n=w(e,`-->`,n+3,`StopNode is not closed.`);else if(e.substr(n+1,2)===`![`)n=w(e,`]]>`,n,`StopNode is not closed.`)-2;else{let r=T(e,n,`>`);r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!==`/`&&i++,n=r.closeIndex)}}function D(e,t,r){if(t&&typeof e==`string`){let t=e.trim();return t===`true`?!0:t===`false`?!1:a(e,r)}else if(n.isExist(e))return e;else return``}function O(e,t,n){let r=Number.parseInt(e,t);return r>=0&&r<=1114111?String.fromCodePoint(r):n+e+`;`}function k(e,t){if(n.criticalProperties.includes(e))throw Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return n.DANGEROUS_PROPERTY_NAMES.includes(e)?t.onDangerousProperty(e):e}t.exports=s})),v=e((e=>{function t(e,t){return n(e,t)}function n(e,t,o){let s,c={};for(let l=0;l<e.length;l++){let u=e[l],d=r(u),f=``;if(f=o===void 0?d:o+`.`+d,d===t.textNodeName)s===void 0?s=u[d]:s+=``+u[d];else if(d===void 0)continue;else if(u[d]){let e=n(u[d],t,f),r=a(e,t);u[`:@`]?i(e,u[`:@`],f,t):Object.keys(e).length===1&&e[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?e=e[t.textNodeName]:Object.keys(e).length===0&&(t.alwaysCreateTextNode?e[t.textNodeName]=``:e=``),c[d]!==void 0&&c.hasOwnProperty(d)?(Array.isArray(c[d])||(c[d]=[c[d]]),c[d].push(e)):t.isArray(d,f,r)?c[d]=[e]:c[d]=e}}return typeof s==`string`?s.length>0&&(c[t.textNodeName]=s):s!==void 0&&(c[t.textNodeName]=s),c}function r(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let n=t[e];if(n!==`:@`)return n}}function i(e,t,n,r){if(t){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let a=i[o];r.isArray(a,n+`.`+a,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function a(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return!!(r===0||r===1&&(e[n]||typeof e[n]==`boolean`||e[n]===0))}e.prettify=t})),y=e(((e,t)=>{var{buildOptions:n}=f(),r=_(),{prettify:i}=v(),a=d();t.exports=class{constructor(e){this.externalEntities={},this.options=n(e)}parse(e,t){if(typeof e!=`string`)if(e.toString)e=e.toString();else throw Error(`XML data is accepted in String or Bytes[] form.`);if(t){t===!0&&(t={});let n=a.validate(e,t);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let n=new r(this.options);n.addExternalEntities(this.externalEntities);let o=n.parseXml(e);return this.options.preserveOrder||o===void 0?o:i(o,this.options)}addEntity(e,t){if(t.indexOf(`&`)!==-1)throw Error(`Entity value can't have '&'`);if(e.indexOf(`&`)!==-1||e.indexOf(`;`)!==-1)throw Error(`An entity must be set without '&' and ';'. Eg. use '#xD' for '
'`);if(t===`&`)throw Error(`An entity with value '&' is not permitted`);this.externalEntities[e]=t}}})),b=e(((e,t)=>{var n=`
|
|
5
|
+
`;function r(e,t){let r=``;return t.format&&t.indentBy.length>0&&(r=n),i(e,t,``,r)}function i(e,t,n,r){let l=``,u=!1;if(!Array.isArray(e)){if(e!=null){let n=e.toString();return n=c(n,t),n}return``}for(let d=0;d<e.length;d++){let f=e[d],p=a(f);if(p===void 0)continue;let m=``;if(m=n.length===0?p:`${n}.${p}`,p===t.textNodeName){let e=f[p];s(m,t)||(e=t.tagValueProcessor(p,e),e=c(e,t)),u&&(l+=r),l+=e,u=!1;continue}else if(p===t.cdataPropName){u&&(l+=r),l+=`<![CDATA[${f[p][0][t.textNodeName]}]]>`,u=!1;continue}else if(p===t.commentPropName){l+=r+`<!--${f[p][0][t.textNodeName]}-->`,u=!0;continue}else if(p[0]===`?`){let e=o(f[`:@`],t),n=p===`?xml`?``:r,i=f[p][0][t.textNodeName];i=i.length===0?``:` `+i,l+=n+`<${p}${i}${e}?>`,u=!0;continue}let h=r;h!==``&&(h+=t.indentBy);let g=r+`<${p}${o(f[`:@`],t)}`,_=i(f[p],t,m,h);t.unpairedTags.indexOf(p)===-1?(!_||_.length===0)&&t.suppressEmptyNode?l+=g+`/>`:_&&_.endsWith(`>`)?l+=g+`>${_}${r}</${p}>`:(l+=g+`>`,_&&r!==``&&(_.includes(`/>`)||_.includes(`</`))?l+=r+t.indentBy+_+r:l+=_,l+=`</${p}>`):t.suppressUnpairedNode?l+=g+`>`:l+=g+`/>`,u=!0}return l}function a(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(Object.prototype.hasOwnProperty.call(e,r)&&r!==`:@`)return r}}function o(e,t){let n=``;if(e&&!t.ignoreAttributes)for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=t.attributeValueProcessor(r,e[r]);i=c(i,t),i===!0&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${i}"`}return n}function s(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let n=e.substr(e.lastIndexOf(`.`)+1);for(let r in t.stopNodes)if(t.stopNodes[r]===e||t.stopNodes[r]===`*.`+n)return!0;return!1}function c(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){let r=t.entities[n];e=e.replace(r.regex,r.val)}return e}t.exports=r})),x=e(((e,t)=>{var n=b(),r=g(),i={attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:` `,suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:RegExp(`&`,`g`),val:`&`},{regex:RegExp(`>`,`g`),val:`>`},{regex:RegExp(`<`,`g`),val:`<`},{regex:RegExp(`'`,`g`),val:`'`},{regex:RegExp(`"`,`g`),val:`"`}],processEntities:!0,stopNodes:[],oneListGroup:!1};function a(e){this.options=Object.assign({},i,e),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=r(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=c),this.processTextOrObjNode=o,this.options.format?(this.indentate=s,this.tagEndChar=`>
|
|
6
6
|
`,this.newLine=`
|
|
7
|
-
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}x.prototype.build=function(t){return this.options.preserveOrder?_t(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};x.prototype.j2x=function(t,e,n){let s="",r="";const o=n.join(".");for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(typeof t[a]>"u")this.isAttribute(a)&&(r+="");else if(t[a]===null)this.isAttribute(a)||a===this.options.cdataPropName?r+="":a[0]==="?"?r+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)r+=this.buildTextValNode(t[a],a,"",e);else if(typeof t[a]!="object"){const c=this.isAttribute(a);if(c&&!this.ignoreAttributesFn(c,o))s+=this.buildAttrPairStr(c,""+t[a]);else if(!c)if(a===this.options.textNodeName){let l=this.options.tagValueProcessor(a,""+t[a]);r+=this.replaceEntitiesValue(l)}else r+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){const c=t[a].length;let l="",u="";for(let f=0;f<c;f++){const d=t[a][f];if(!(typeof d>"u"))if(d===null)a[0]==="?"?r+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(typeof d=="object")if(this.options.oneListGroup){const h=this.j2x(d,e+1,n.concat(a));l+=h.val,this.options.attributesGroupName&&d.hasOwnProperty(this.options.attributesGroupName)&&(u+=h.attrStr)}else l+=this.processTextOrObjNode(d,a,e,n);else if(this.options.oneListGroup){let h=this.options.tagValueProcessor(a,d);h=this.replaceEntitiesValue(h),l+=h}else l+=this.buildTextValNode(d,a,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,a,u,e)),r+=l}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const c=Object.keys(t[a]),l=c.length;for(let u=0;u<l;u++)s+=this.buildAttrPairStr(c[u],""+t[a][c[u]])}else r+=this.processTextOrObjNode(t[a],a,e,n);return{attrStr:s,val:r}};x.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function Ot(t,e,n,s){const r=this.j2x(t,n+1,s.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,r.attrStr,n):this.buildObjectNode(r.val,e,r.attrStr,n)}x.prototype.buildObjectNode=function(t,e,n,s){if(t==="")return e[0]==="?"?this.indentate(s)+"<"+e+n+"?"+this.tagEndChar:this.indentate(s)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let r="</"+e+this.tagEndChar,o="";return e[0]==="?"&&(o="?",r=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(s)+"<"+e+n+o+">"+t+r:this.options.commentPropName!==!1&&e===this.options.commentPropName&&o.length===0?this.indentate(s)+`<!--${t}-->`+this.newLine:this.indentate(s)+"<"+e+n+o+this.tagEndChar+t+this.indentate(s)+r}};x.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};x.prototype.buildTextValNode=function(t,e,n,s){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(s)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(s)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(s)+"<"+e+n+"?"+this.tagEndChar;{let r=this.options.tagValueProcessor(e,t);return r=this.replaceEntitiesValue(r),r===""?this.indentate(s)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(s)+"<"+e+n+">"+r+"</"+e+this.tagEndChar}};x.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const n=this.options.entities[e];t=t.replace(n.regex,n.val)}return t};function Ct(t){return this.options.indentBy.repeat(t)}function Pt(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var Lt=x;const Mt=Et,jt=Lt;var X={XMLParser:Mt,XMLBuilder:jt};class ae{constructor(e,n){A(this,"alphabet");A(this,"padding");A(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let s=0;s<e.length;s++)this.decodeMap.set(e[s],s)}encode(e,n){let s="",r=0,o=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],o+=8;o>=5;)o-=5,s+=this.alphabet[r>>o&31];if(o>0&&(s+=this.alphabet[r<<5-o&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-s.length%8)%8;for(let l=0;l<c;l++)s+="="}return s}decode(e,n){const s=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/8),o=[];for(let a=0;a<r;a++){let c=0;const l=[];for(let f=0;f<8;f++){const d=e[a*8+f];if(d==="="){if(a+1!==r)throw new Error(`Invalid character: ${d}`);c+=1;continue}if(d===void 0){if(s)throw new Error("Invalid data");c+=1;continue}const h=this.decodeMap.get(d)??null;if(h===null)throw new Error(`Invalid character: ${d}`);l.push(h)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const u=(l[0]<<3)+(l[1]>>2);if(o.push(u),c<6){const f=((l[1]&3)<<6)+(l[2]<<1)+(l[3]>>4);o.push(f)}if(c<4){const f=((l[3]&255)<<4)+(l[4]>>1);o.push(f)}if(c<3){const f=((l[4]&1)<<7)+(l[5]<<2)+(l[6]>>3);o.push(f)}if(c<1){const f=((l[6]&7)<<5)+l[7];o.push(f)}}return Uint8Array.from(o)}}new ae("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new ae("0123456789ABCDEFGHIJKLMNOPQRSTUV");class le{constructor(e,n){A(this,"alphabet");A(this,"padding");A(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let s=0;s<e.length;s++)this.decodeMap.set(e[s],s)}encode(e,n){let s="",r=0,o=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],o+=8;o>=6;)o+=-6,s+=this.alphabet[r>>o&63];if(o>0&&(s+=this.alphabet[r<<6-o&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-s.length%4)%4;for(let l=0;l<c;l++)s+="="}return s}decode(e,n){const s=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/4),o=[];for(let a=0;a<r;a++){let c=0,l=0;for(let u=0;u<4;u++){const f=e[a*4+u];if(f==="="){if(a+1!==r)throw new Error(`Invalid character: ${f}`);c+=1;continue}if(f===void 0){if(s)throw new Error("Invalid data");c+=1;continue}const d=this.decodeMap.get(f)??null;if(d===null)throw new Error(`Invalid character: ${f}`);l+=d<<6*(3-u)}o.push(l>>16&255),c<2&&o.push(l>>8&255),c<1&&o.push(l&255)}return Uint8Array.from(o)}}const vt=new le("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new le("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");let $t="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",J=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=$t[n[t]&63];return e};async function ue(t){const e=new DecompressionStream("deflate-raw"),n=new Uint8Array(t),s=new Blob([n]).stream().pipeThrough(e);return new Uint8Array(await new Response(s).arrayBuffer())}async function ce(t){const e=await vt.decode(t.replace(/ /g,"+"));try{const n=await ue(e);return new TextDecoder().decode(n)}catch(n){return console.warn("Decompression failed, assuming data is not compressed:",n),new TextDecoder().decode(e)}}async function Vt(t){const e=await ce(t),s=new X.XMLParser({attributeNamePrefix:"@_",alwaysCreateTextNode:!0,ignoreAttributes:!1}).parse(e);return H.parse(s)}function Ft(t){const e=t.certificates.map(r=>({"@_use":"signing",KeyInfo:{"@_xmlns":"http://www.w3.org/2000/09/xmldsig#",X509Data:{X509Certificate:r}}})),n={EntityDescriptor:{"@_entityID":t.entityId,"@_xmlns":"urn:oasis:names:tc:SAML:2.0:metadata",IDPSSODescriptor:{"@_protocolSupportEnumeration":"urn:oasis:names:tc:SAML:2.0:protocol",KeyDescriptor:e,SingleLogoutService:[{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect","@_Location":t.singleLogoutServiceUrl},{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","@_Location":t.singleLogoutServiceUrl}],NameIDFormat:["urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress","urn:oasis:names:tc:SAML:2.0:nameid-format:persistent","urn:oasis:names:tc:SAML:2.0:nameid-format:transient"],SingleSignOnService:[{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect","@_Location":t.assertionConsumerServiceUrl},{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","@_Location":t.assertionConsumerServiceUrl}],Attribute:[{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"E-Mail Address","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Given Name","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Name","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Surname","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Name ID","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"}]}}};return new X.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:"@_"}).build(n)}async function Rt(t,e){const n=t.notBefore||new Date().toISOString(),s=t.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),r=t.issueInstant||n,o=t.sessionNotOnOrAfter||s,a=t.responseId||`_${J()}`,c=t.assertionId||`_${J()}`,l=[{"samlp:Response":[{"saml:Issuer":[{"#text":t.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":t.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":t.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":t.inResponseTo,"@_NotOnOrAfter":s,"@_Recipient":t.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":t.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":s}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":r,"@_SessionIndex":t.sessionIndex,"@_SessionNotOnOrAfter":o}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":t.userId}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":t.email}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"default-roles-master"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"offline_access"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"view-profile"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"uma_authorization"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account-links"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":c,"@_IssueInstant":r,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":t.destination,"@_ID":a,"@_InResponseTo":t.inResponseTo,"@_IssueInstant":r,"@_Version":"2.0"}}];let f=new X.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(l);return t.signature&&e&&(f=await e.signSAML(f,t.signature.privateKeyPem,t.signature.cert)),t.encode===!1?f:btoa(f)}const Xt="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",Bt="http://www.w3.org/2001/04/xmlenc#sha256",q="http://www.w3.org/2001/10/xml-exc-c14n#";class Ut{async signSAML(e,n,s){var r;try{const o=await import("xml-crypto"),a=o.SignedXml||((r=o.default)==null?void 0:r.SignedXml);if(!a)throw new Error("SignedXml not found in xml-crypto module");const c=new a({privateKey:n,publicCert:s});c.canonicalizationAlgorithm=q,c.addReference({xpath:"(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",digestAlgorithm:Bt,transforms:["http://www.w3.org/2000/09/xmldsig#enveloped-signature",q]}),c.signatureAlgorithm=Xt;const l=s.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g,"").replace(/\s/g,"");return c.keyInfoProvider={getKeyInfo:()=>`<X509Data><X509Certificate>${l}</X509Certificate></X509Data>`},c.computeSignature(e,{location:{reference:"/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",action:"after"}}),c.getSignedXml()}catch(o){throw new Error(`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${o}`)}}}class kt{constructor(e){this.signUrl=e}async signSAML(e,n,s){const r=await fetch(this.signUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:e,privateKey:n,publicCert:s})});if(!r.ok)throw new Error(`Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`);return await r.text()}}exports.HttpSamlSigner=kt;exports.LocalSamlSigner=Ut;exports.createSamlMetadata=Ft;exports.createSamlResponse=Rt;exports.dsSignatureSchema=j;exports.inflateDecompress=ce;exports.inflateRaw=ue;exports.parseSamlRequestQuery=Vt;exports.samlIssuerSchema=Z;exports.samlMetadataResponseSchema=we;exports.samlRequestSchema=H;exports.samlResponseJsonSchema=xe;
|
|
7
|
+
`):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``)}a.prototype.build=function(e){return this.options.preserveOrder?n(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)},a.prototype.j2x=function(e,t,n){let r=``,i=``,a=n.join(`.`);for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o))if(e[o]===void 0)this.isAttribute(o)&&(i+=``);else if(e[o]===null)this.isAttribute(o)||o===this.options.cdataPropName?i+=``:o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(e[o]instanceof Date)i+=this.buildTextValNode(e[o],o,``,t);else if(typeof e[o]!=`object`){let n=this.isAttribute(o);if(n&&!this.ignoreAttributesFn(n,a))r+=this.buildAttrPairStr(n,``+e[o]);else if(!n)if(o===this.options.textNodeName){let t=this.options.tagValueProcessor(o,``+e[o]);i+=this.replaceEntitiesValue(t)}else i+=this.buildTextValNode(e[o],o,``,t)}else if(Array.isArray(e[o])){let r=e[o].length,a=``,s=``;for(let c=0;c<r;c++){let r=e[o][c];if(r!==void 0)if(r===null)o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(typeof r==`object`)if(this.options.oneListGroup){let e=this.j2x(r,t+1,n.concat(o));a+=e.val,this.options.attributesGroupName&&r.hasOwnProperty(this.options.attributesGroupName)&&(s+=e.attrStr)}else a+=this.processTextOrObjNode(r,o,t,n);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(o,r);e=this.replaceEntitiesValue(e),a+=e}else a+=this.buildTextValNode(r,o,``,t)}this.options.oneListGroup&&(a=this.buildObjectNode(a,o,s,t)),i+=a}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){let t=Object.keys(e[o]),n=t.length;for(let i=0;i<n;i++)r+=this.buildAttrPairStr(t[i],``+e[o][t[i]])}else i+=this.processTextOrObjNode(e[o],o,t,n);return{attrStr:r,val:i}},a.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,``+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t===`true`?` `+e:` `+e+`="`+t+`"`};function o(e,t,n,r){let i=this.j2x(e,n+1,r.concat(t));return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,i.attrStr,n):this.buildObjectNode(i.val,t,i.attrStr,n)}a.prototype.buildObjectNode=function(e,t,n,r){if(e===``)return t[0]===`?`?this.indentate(r)+`<`+t+n+`?`+this.tagEndChar:this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar;{let i=`</`+t+this.tagEndChar,a=``;return t[0]===`?`&&(a=`?`,i=``),(n||n===``)&&e.indexOf(`<`)===-1?this.indentate(r)+`<`+t+n+a+`>`+e+i:this.options.commentPropName!==!1&&t===this.options.commentPropName&&a.length===0?this.indentate(r)+`<!--${e}-->`+this.newLine:this.indentate(r)+`<`+t+n+a+this.tagEndChar+e+this.indentate(r)+i}},a.prototype.closeTag=function(e){let t=``;return this.options.unpairedTags.indexOf(e)===-1?t=this.options.suppressEmptyNode?`/`:`></${e}`:this.options.suppressUnpairedNode||(t=`/`),t},a.prototype.buildTextValNode=function(e,t,n,r){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(r)+`<!--${e}-->`+this.newLine;if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),i===``?this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+`<`+t+n+`>`+i+`</`+t+this.tagEndChar}},a.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};function s(e){return this.options.indentBy.repeat(e)}function c(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}t.exports=a})),S=e(((e,t)=>{var n=d();t.exports={XMLParser:y(),XMLValidator:n,XMLBuilder:x()}}))(),C=class{alphabet;padding;decodeMap=new Map;constructor(e,t){if(e.length!==32)throw Error(`Invalid alphabet`);if(this.alphabet=e,this.padding=t?.padding??`=`,this.alphabet.includes(this.padding)||this.padding.length!==1)throw Error(`Invalid padding`);for(let t=0;t<e.length;t++)this.decodeMap.set(e[t],t)}encode(e,t){let n=``,r=0,i=0;for(let t=0;t<e.length;t++)for(r=r<<8|e[t],i+=8;i>=5;)i-=5,n+=this.alphabet[r>>i&31];if(i>0&&(n+=this.alphabet[r<<5-i&31]),t?.includePadding??!0){let e=(8-n.length%8)%8;for(let t=0;t<e;t++)n+=`=`}return n}decode(e,t){let n=t?.strict??!0,r=Math.ceil(e.length/8),i=[];for(let t=0;t<r;t++){let a=0,o=[];for(let i=0;i<8;i++){let s=e[t*8+i];if(s===`=`){if(t+1!==r)throw Error(`Invalid character: ${s}`);a+=1;continue}if(s===void 0){if(n)throw Error(`Invalid data`);a+=1;continue}let c=this.decodeMap.get(s)??null;if(c===null)throw Error(`Invalid character: ${s}`);o.push(c)}if(a===8||a===7||a===5||a===2)throw Error(`Invalid padding`);let s=(o[0]<<3)+(o[1]>>2);if(i.push(s),a<6){let e=((o[1]&3)<<6)+(o[2]<<1)+(o[3]>>4);i.push(e)}if(a<4){let e=((o[3]&255)<<4)+(o[4]>>1);i.push(e)}if(a<3){let e=((o[4]&1)<<7)+(o[5]<<2)+(o[6]>>3);i.push(e)}if(a<1){let e=((o[6]&7)<<5)+o[7];i.push(e)}}return Uint8Array.from(i)}};new C(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),new C(`0123456789ABCDEFGHIJKLMNOPQRSTUV`);var w=class{alphabet;padding;decodeMap=new Map;constructor(e,t){if(e.length!==64)throw Error(`Invalid alphabet`);if(this.alphabet=e,this.padding=t?.padding??`=`,this.alphabet.includes(this.padding)||this.padding.length!==1)throw Error(`Invalid padding`);for(let t=0;t<e.length;t++)this.decodeMap.set(e[t],t)}encode(e,t){let n=``,r=0,i=0;for(let t=0;t<e.length;t++)for(r=r<<8|e[t],i+=8;i>=6;)i+=-6,n+=this.alphabet[r>>i&63];if(i>0&&(n+=this.alphabet[r<<6-i&63]),t?.includePadding??!0){let e=(4-n.length%4)%4;for(let t=0;t<e;t++)n+=`=`}return n}decode(e,t){let n=t?.strict??!0,r=Math.ceil(e.length/4),i=[];for(let t=0;t<r;t++){let a=0,o=0;for(let i=0;i<4;i++){let s=e[t*4+i];if(s===`=`){if(t+1!==r)throw Error(`Invalid character: ${s}`);a+=1;continue}if(s===void 0){if(n)throw Error(`Invalid data`);a+=1;continue}let c=this.decodeMap.get(s)??null;if(c===null)throw Error(`Invalid character: ${s}`);o+=c<<6*(3-i)}i.push(o>>16&255),a<2&&i.push(o>>8&255),a<1&&i.push(o&255)}return Uint8Array.from(i)}},T=new w(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`);new w(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`);var E=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,D=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=E[n[e]&63];return t};async function O(e){let t=new DecompressionStream(`deflate-raw`),n=new Uint8Array(e),r=new Blob([n]).stream().pipeThrough(t);return new Uint8Array(await new Response(r).arrayBuffer())}async function k(e){let t=await T.decode(e.replace(/ /g,`+`));try{let e=await O(t);return new TextDecoder().decode(e)}catch(e){return console.warn(`Decompression failed, assuming data is not compressed:`,e),new TextDecoder().decode(t)}}async function A(e){let t=await k(e),n=new S.XMLParser({attributeNamePrefix:`@_`,alwaysCreateTextNode:!0,ignoreAttributes:!1}).parse(t);return i.parse(n)}function j(e){let t=e.certificates.map(e=>({"@_use":`signing`,KeyInfo:{"@_xmlns":`http://www.w3.org/2000/09/xmldsig#`,X509Data:{X509Certificate:e}}})),n={EntityDescriptor:{"@_entityID":e.entityId,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:metadata`,IDPSSODescriptor:{"@_protocolSupportEnumeration":`urn:oasis:names:tc:SAML:2.0:protocol`,KeyDescriptor:t,SingleLogoutService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.singleLogoutServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.singleLogoutServiceUrl}],NameIDFormat:[`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`,`urn:oasis:names:tc:SAML:2.0:nameid-format:persistent`,`urn:oasis:names:tc:SAML:2.0:nameid-format:transient`],SingleSignOnService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.assertionConsumerServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.assertionConsumerServiceUrl}],Attribute:[{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`E-Mail Address`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Given Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Surname`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name ID`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`}]}}};return new S.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:`@_`}).build(n)}async function M(e,t){let n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+600*1e3).toISOString(),i=e.issueInstant||n,a=e.sessionNotOnOrAfter||r,o=e.responseId||`_${D()}`,s=e.assertionId||`_${D()}`,c=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":`urn:oasis:names:tc:SAML:2.0:status:Success`}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":`urn:oasis:names:tc:SAML:2.0:cm:bearer`}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":`urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified`}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":a}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_FriendlyName":`persistent`,"@_Name":`id`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`email`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`default-roles-master`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`offline_access`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`view-profile`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`uma_authorization`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account-links`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}}]}],":@":{"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_ID":s,"@_IssueInstant":i,"@_Version":`2.0`}}],":@":{"@_xmlns:samlp":`urn:oasis:names:tc:SAML:2.0:protocol`,"@_xmlns:saml":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":`2.0`}}],l=new S.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(c);return e.signature&&t&&(l=await t.signSAML(l,e.signature.privateKeyPem,e.signature.cert)),e.encode===!1?l:btoa(l)}var N=`http://www.w3.org/2001/04/xmldsig-more#rsa-sha256`,P=`http://www.w3.org/2001/04/xmlenc#sha256`,F=`http://www.w3.org/2001/10/xml-exc-c14n#`,I=class{async signSAML(e,t,n){try{let r=await import(`xml-crypto`),i=r.SignedXml||r.default?.SignedXml;if(!i)throw Error(`SignedXml not found in xml-crypto module`);let a=new i({privateKey:t,publicCert:n});a.canonicalizationAlgorithm=F,a.addReference({xpath:`(/*[local-name()='Response']/*[local-name()='Assertion'])[1]`,digestAlgorithm:P,transforms:[`http://www.w3.org/2000/09/xmldsig#enveloped-signature`,F]}),a.signatureAlgorithm=N;let o=n.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g,``).replace(/\s/g,``);return a.keyInfoProvider={getKeyInfo:()=>`<X509Data><X509Certificate>${o}</X509Certificate></X509Data>`},a.computeSignature(e,{location:{reference:`/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']`,action:`after`}}),a.getSignedXml()}catch(e){throw Error(`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${e}`)}}},L=class{signUrl;constructor(e){this.signUrl=e}async signSAML(e,t,n){let r=await fetch(this.signUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({xmlContent:e,privateKey:t,publicCert:n})});if(!r.ok)throw Error(`Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`);return await r.text()}};exports.HttpSamlSigner=L,exports.LocalSamlSigner=I,exports.createSamlMetadata=j,exports.createSamlResponse=M,exports.dsSignatureSchema=c,exports.inflateDecompress=k,exports.inflateRaw=O,exports.parseSamlRequestQuery=A,exports.samlIssuerSchema=r,exports.samlMetadataResponseSchema=a,exports.samlRequestSchema=i,exports.samlResponseJsonSchema=l;
|