@authhero/saml 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/saml.cjs CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var te=Object.create;var I=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var oe=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of se(t))!ie.call(e,i)&&i!==n&&I(e,i,{get:()=>t[i],enumerable:!(o=ne(t,i))||o.enumerable});return e};var ue=(e,t,n)=>(n=e!=null?te(re(e)):{},ae(t||!e||!e.__esModule?I(n,"default",{value:e,enumerable:!0}):n,e));var z=(e,t,n)=>oe(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@hono/zod-openapi"),b=s.z.object({"#text":s.z.string()}),k=s.z.object({"#text":s.z.string(),"@_xmlns:saml":s.z.string().optional()}),U=s.z.object({"samlp:AuthnRequest":s.z.object({"saml:Issuer":k,"@_xmlns:samlp":s.z.string(),"@_xmlns:saml":s.z.string().optional(),"@_ForceAuthn":s.z.string().transform(e=>e.toLowerCase()==="true").optional(),"@_ID":s.z.string(),"@_IssueInstant":s.z.string().datetime(),"@_Destination":s.z.string().url(),"@_AssertionConsumerServiceURL":s.z.string().url().optional(),"@_ProtocolBinding":s.z.string().optional(),"@_Version":s.z.string()})}),le=s.z.array(s.z.object({":@":s.z.object({"@_xmlns":s.z.string(),"@_entityID":s.z.string()}),EntityDescriptor:s.z.array(s.z.object({":@":s.z.object({"@_protocolSupportEnumeration":s.z.string()}),IDPSSODescriptor:s.z.array(s.z.union([s.z.object({KeyDescriptor:s.z.array(s.z.object({KeyInfo:s.z.array(s.z.object({X509Data:s.z.array(s.z.object({X509Certificate:s.z.array(b)}))})),":@":s.z.object({"@_xmlns":s.z.string()})})),":@":s.z.object({"@_use":s.z.string()})}),s.z.object({SingleLogoutService:s.z.array(s.z.object({})),":@":s.z.object({"@_Binding":s.z.string(),"@_Location":s.z.string()})}),s.z.object({NameIDFormat:s.z.array(b)}),s.z.object({SingleSignOnService:s.z.array(s.z.object({})),":@":s.z.object({"@_Binding":s.z.string(),"@_Location":s.z.string()})}),s.z.object({Attribute:s.z.array(s.z.object({})),":@":s.z.object({"@_Name":s.z.string(),"@_NameFormat":s.z.string(),"@_FriendlyName":s.z.string(),"@_xmlns":s.z.string()})})]))}))})),ce=s.z.object({":@":s.z.object({"@_Name":s.z.string(),"@_NameFormat":s.z.string(),"@_FriendlyName":s.z.string().optional()}),"saml:AttributeValue":s.z.array(s.z.object({"#text":s.z.string(),":@":s.z.object({"@_xmlns:xs":s.z.string().optional(),"@_xmlns:xsi":s.z.string(),"@_xsi:type":s.z.string()}).optional()}))}),fe=s.z.object({"ds:Transform":s.z.array(s.z.any()),":@":s.z.object({"@_Algorithm":s.z.string()})}),T=s.z.object({"ds:Signature":s.z.array(s.z.union([s.z.object({"ds:SignedInfo":s.z.array(s.z.union([s.z.object({"ds:CanonicalizationMethod":s.z.array(s.z.object({":@":s.z.object({"@_Algorithm":s.z.string()})}))}),s.z.object({"ds:SignatureMethod":s.z.array(s.z.object({":@":s.z.object({"@_Algorithm":s.z.string()})}))}),s.z.object({"ds:Reference":s.z.array(s.z.union([s.z.object({"ds:Transforms":s.z.array(fe)}),s.z.object({"ds:DigestMethod":s.z.array(s.z.object({":@":s.z.object({"@_Algorithm":s.z.string()})}))}),s.z.object({"ds:DigestValue":s.z.array(b)})])),":@":s.z.object({"@_URI":s.z.string().optional()}).optional()})]))}),s.z.object({"ds:SignatureValue":s.z.array(b)}),s.z.object({"ds:KeyInfo":s.z.array(s.z.union([s.z.object({"ds:KeyValue":s.z.array(s.z.object({"ds:RSAKeyValue":s.z.array(s.z.union([s.z.object({"ds:Modulus":s.z.array(b)}),s.z.object({"ds:Exponent":s.z.array(b)})]))}))}),s.z.object({"ds:X509Data":s.z.array(s.z.object({"ds:X509Certificate":s.z.array(b)}))}),s.z.object({"ds:KeyValue":s.z.array(s.z.object({"ds:RSAKeyValue":s.z.array(s.z.union([s.z.object({"ds:Modulus":s.z.array(b)}),s.z.object({"ds:Exponent":s.z.array(b)})]))})),"ds:X509Data":s.z.array(s.z.object({"ds:X509Certificate":s.z.array(b)}))})]))})])),":@":s.z.object({"@_xmlns:ds":s.z.string().optional()}).optional()}),de=s.z.array(s.z.object({"samlp:Response":s.z.array(s.z.union([s.z.object({"saml:Issuer":s.z.array(b)}),T,s.z.object({"samlp:Status":s.z.array(s.z.object({"samlp:StatusCode":s.z.array(b),":@":s.z.object({"@_Value":s.z.string()})}))}),s.z.object({"saml:Assertion":s.z.array(s.z.union([s.z.object({"saml:Issuer":s.z.array(b)}),T,s.z.object({"saml:Subject":s.z.array(s.z.union([s.z.object({"saml:NameID":s.z.array(b),":@":s.z.object({"@_Format":s.z.string()})}),s.z.object({"saml:SubjectConfirmation":s.z.array(s.z.object({"saml:SubjectConfirmationData":s.z.array(s.z.any()),":@":s.z.object({"@_InResponseTo":s.z.string(),"@_NotOnOrAfter":s.z.string(),"@_Recipient":s.z.string()})})),":@":s.z.object({"@_Method":s.z.string()})})]))}),s.z.object({"saml:Conditions":s.z.array(s.z.object({"saml:AudienceRestriction":s.z.array(s.z.object({"saml:Audience":s.z.array(b)}))})),":@":s.z.object({"@_NotBefore":s.z.string(),"@_NotOnOrAfter":s.z.string()})}),s.z.object({"saml:AuthnStatement":s.z.array(s.z.object({"saml:AuthnContext":s.z.array(s.z.object({"saml:AuthnContextClassRef":s.z.array(b)}))})),":@":s.z.object({"@_AuthnInstant":s.z.string(),"@_SessionIndex":s.z.string(),"@_SessionNotOnOrAfter":s.z.string()})}),s.z.object({"saml:AttributeStatement":s.z.array(s.z.object({"saml:Attribute":s.z.array(ce)}))})])),":@":s.z.object({"@_xmlns":s.z.string(),"@_ID":s.z.string(),"@_IssueInstant":s.z.string(),"@_Version":s.z.string()})})])),":@":s.z.object({"@_xmlns:samlp":s.z.string(),"@_xmlns:saml":s.z.string(),"@_Destination":s.z.string(),"@_ID":s.z.string(),"@_InResponseTo":s.z.string(),"@_IssueInstant":s.z.string(),"@_Version":s.z.string()})}));var L={},E={};(function(e){const 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",n=t+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",o="["+t+"]["+n+"]*",i=new RegExp("^"+o+"$"),r=function(u,a){const f=[];let c=a.exec(u);for(;c;){const d=[];d.startIndex=a.lastIndex-c[0].length;const g=c.length;for(let m=0;m<g;m++)d.push(c[m]);f.push(d),c=a.exec(u)}return f},l=function(u){const a=i.exec(u);return!(a===null||typeof a>"u")};e.isExist=function(u){return typeof u<"u"},e.isEmptyObject=function(u){return Object.keys(u).length===0},e.merge=function(u,a,f){if(a){const c=Object.keys(a),d=c.length;for(let g=0;g<d;g++)f==="strict"?u[c[g]]=[a[c[g]]]:u[c[g]]=a[c[g]]}},e.getValue=function(u){return e.isExist(u)?u:""},e.isName=l,e.getAllMatches=r,e.nameRegexp=o})(E);const M=E,ge={allowBooleanAttributes:!1,unpairedTags:[]};L.validate=function(e,t){t=Object.assign({},ge,t);const n=[];let o=!1,i=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let r=0;r<e.length;r++)if(e[r]==="<"&&e[r+1]==="?"){if(r+=2,r=F(e,r),r.err)return r}else if(e[r]==="<"){let l=r;if(r++,e[r]==="!"){r=V(e,r);continue}else{let u=!1;e[r]==="/"&&(u=!0,r++);let a="";for(;r<e.length&&e[r]!==">"&&e[r]!==" "&&e[r]!==" "&&e[r]!==`
2
- `&&e[r]!=="\r";r++)a+=e[r];if(a=a.trim(),a[a.length-1]==="/"&&(a=a.substring(0,a.length-1),r--),!ze(a)){let d;return a.trim().length===0?d="Invalid space after '<'.":d="Tag '"+a+"' is an invalid name.",h("InvalidTag",d,N(e,r))}const f=me(e,r);if(f===!1)return h("InvalidAttr","Attributes for '"+a+"' have open quote.",N(e,r));let c=f.value;if(r=f.index,c[c.length-1]==="/"){const d=r-c.length;c=c.substring(0,c.length-1);const g=X(c,t);if(g===!0)o=!0;else return h(g.err.code,g.err.msg,N(e,d+g.err.line))}else if(u)if(f.tagClosed){if(c.trim().length>0)return h("InvalidTag","Closing tag '"+a+"' can't have attributes or invalid starting.",N(e,l));if(n.length===0)return h("InvalidTag","Closing tag '"+a+"' has not been opened.",N(e,l));{const d=n.pop();if(a!==d.tagName){let g=N(e,d.tagStartPos);return h("InvalidTag","Expected closing tag '"+d.tagName+"' (opened in line "+g.line+", col "+g.col+") instead of closing tag '"+a+"'.",N(e,l))}n.length==0&&(i=!0)}}else return h("InvalidTag","Closing tag '"+a+"' doesn't have proper closing.",N(e,r));else{const d=X(c,t);if(d!==!0)return h(d.err.code,d.err.msg,N(e,r-c.length+d.err.line));if(i===!0)return h("InvalidXml","Multiple possible root nodes found.",N(e,r));t.unpairedTags.indexOf(a)!==-1||n.push({tagName:a,tagStartPos:l}),o=!0}for(r++;r<e.length;r++)if(e[r]==="<")if(e[r+1]==="!"){r++,r=V(e,r);continue}else if(e[r+1]==="?"){if(r=F(e,++r),r.err)return r}else break;else if(e[r]==="&"){const d=we(e,r);if(d==-1)return h("InvalidChar","char '&' is not expected.",N(e,r));r=d}else if(i===!0&&!P(e[r]))return h("InvalidXml","Extra text at the end",N(e,r));e[r]==="<"&&r--}}else{if(P(e[r]))continue;return h("InvalidChar","char '"+e[r]+"' is not expected.",N(e,r))}if(o){if(n.length==1)return h("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",N(e,n[0].tagStartPos));if(n.length>0)return h("InvalidXml","Invalid '"+JSON.stringify(n.map(r=>r.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return h("InvalidXml","Start tag expected.",1);return!0};function P(e){return e===" "||e===" "||e===`
3
- `||e==="\r"}function F(e,t){const n=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){const o=e.substr(n,t-n);if(t>5&&o==="xml")return h("InvalidXml","XML declaration allowed only at the start of the document.",N(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function V(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}const he='"',pe="'";function me(e,t){let n="",o="",i=!1;for(;t<e.length;t++){if(e[t]===he||e[t]===pe)o===""?o=e[t]:o!==e[t]||(o="");else if(e[t]===">"&&o===""){i=!0;break}n+=e[t]}return o!==""?!1:{value:n,index:t,tagClosed:i}}const be=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function X(e,t){const n=M.getAllMatches(e,be),o={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return h("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",S(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return h("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",S(n[i]));if(n[i][3]===void 0&&!t.allowBooleanAttributes)return h("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",S(n[i]));const r=n[i][2];if(!ye(r))return h("InvalidAttr","Attribute '"+r+"' is an invalid name.",S(n[i]));if(!o.hasOwnProperty(r))o[r]=1;else return h("InvalidAttr","Attribute '"+r+"' is repeated.",S(n[i]))}return!0}function Ne(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 we(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,Ne(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 h(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function ye(e){return M.isName(e)}function ze(e){return M.isName(e)}function N(e,t){const n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function S(e){return e.startIndex+e[1].length}var j={};const G={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}},Ae=function(e){return Object.assign({},G,e)};j.buildOptions=Ae;j.defaultOptions=G;class _e{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,n){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:n})}addChild(t){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child})}}var Se=_e;const xe=E;function Ee(e,t){const n={};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=t+9;let o=1,i=!1,r=!1,l="";for(;t<e.length;t++)if(e[t]==="<"&&!r){if(i&&Oe(e,t)){t+=7;let u,a;[u,a,t]=Ie(e,t+1),a.indexOf("&")===-1&&(n[je(u)]={regx:RegExp(`&${u};`,"g"),val:a})}else if(i&&Ce(e,t))t+=8;else if(i&&Le(e,t))t+=8;else if(i&&Me(e,t))t+=9;else if(Te)r=!0;else throw new Error("Invalid DOCTYPE");o++,l=""}else if(e[t]===">"){if(r?e[t-1]==="-"&&e[t-2]==="-"&&(r=!1,o--):o--,o===0)break}else e[t]==="["?i=!0:l+=e[t];if(o!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:t}}function Ie(e,t){let n="";for(;t<e.length&&e[t]!=="'"&&e[t]!=='"';t++)n+=e[t];if(n=n.trim(),n.indexOf(" ")!==-1)throw new Error("External entites are not supported");const o=e[t++];let i="";for(;t<e.length&&e[t]!==o;t++)i+=e[t];return[n,i,t]}function Te(e,t){return e[t+1]==="!"&&e[t+2]==="-"&&e[t+3]==="-"}function Oe(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="N"&&e[t+4]==="T"&&e[t+5]==="I"&&e[t+6]==="T"&&e[t+7]==="Y"}function Ce(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="L"&&e[t+4]==="E"&&e[t+5]==="M"&&e[t+6]==="E"&&e[t+7]==="N"&&e[t+8]==="T"}function Le(e,t){return e[t+1]==="!"&&e[t+2]==="A"&&e[t+3]==="T"&&e[t+4]==="T"&&e[t+5]==="L"&&e[t+6]==="I"&&e[t+7]==="S"&&e[t+8]==="T"}function Me(e,t){return e[t+1]==="!"&&e[t+2]==="N"&&e[t+3]==="O"&&e[t+4]==="T"&&e[t+5]==="A"&&e[t+6]==="T"&&e[t+7]==="I"&&e[t+8]==="O"&&e[t+9]==="N"}function je(e){if(xe.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}var ve=Ee;const Pe=/^[-+]?0x[a-fA-F0-9]+$/,Fe=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const Ve={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Xe(e,t={}){if(t=Object.assign({},Ve,t),!e||typeof e!="string")return e;let n=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(n))return e;if(t.hex&&Pe.test(n))return Number.parseInt(n,16);{const o=Fe.exec(n);if(o){const i=o[1],r=o[2];let l=$e(o[3]);const u=o[4]||o[6];if(!t.leadingZeros&&r.length>0&&i&&n[2]!==".")return e;if(!t.leadingZeros&&r.length>0&&!i&&n[1]!==".")return e;{const a=Number(n),f=""+a;return f.search(/[eE]/)!==-1||u?t.eNotation?a:e:n.indexOf(".")!==-1?f==="0"&&l===""||f===l||i&&f==="-"+l?a:e:r?l===f||i+l===f?a:e:n===f||n===i+f?a:e}}else return e}}function $e(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}var Re=Xe;function Be(e){return typeof e=="function"?e:Array.isArray(e)?t=>{for(const n of e)if(typeof n=="string"&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}var K=Be;const J=E,x=Se,ke=ve,Ue=Re,Ge=K;let Ke=class{constructor(t){this.options=t,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,o)=>String.fromCharCode(Number.parseInt(o,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,o)=>String.fromCharCode(Number.parseInt(o,16))}},this.addExternalEntities=Je,this.parseXml=Qe,this.parseTextData=qe,this.resolveNameSpace=He,this.buildAttributesMap=Ye,this.isItStopNode=tt,this.replaceEntitiesValue=De,this.readStopNodeData=st,this.saveTextToParentTag=et,this.addChild=We,this.ignoreAttributesFn=Ge(this.options.ignoreAttributes)}};function Je(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const o=t[n];this.lastEntities[o]={regex:new RegExp("&"+o+";","g"),val:e[o]}}}function qe(e,t,n,o,i,r,l){if(e!==void 0&&(this.options.trimValues&&!o&&(e=e.trim()),e.length>0)){l||(e=this.replaceEntitiesValue(e));const u=this.options.tagValueProcessor(t,e,n,i,r);return u==null?e:typeof u!=typeof e||u!==e?u:this.options.trimValues?C(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?C(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function He(e){if(this.options.removeNSPrefix){const t=e.split(":"),n=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=n+t[1])}return e}const Ze=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Ye(e,t,n){if(this.options.ignoreAttributes!==!0&&typeof e=="string"){const o=J.getAllMatches(e,Ze),i=o.length,r={};for(let l=0;l<i;l++){const u=this.resolveNameSpace(o[l][1]);if(this.ignoreAttributesFn(u,t))continue;let a=o[l][4],f=this.options.attributeNamePrefix+u;if(u.length)if(this.options.transformAttributeName&&(f=this.options.transformAttributeName(f)),f==="__proto__"&&(f="#__proto__"),a!==void 0){this.options.trimValues&&(a=a.trim()),a=this.replaceEntitiesValue(a);const c=this.options.attributeValueProcessor(u,a,t);c==null?r[f]=a:typeof c!=typeof a||c!==a?r[f]=c:r[f]=C(a,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[f]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){const l={};return l[this.options.attributesGroupName]=r,l}return r}}const Qe=function(e){e=e.replace(/\r\n?/g,`
4
- `);const t=new x("!xml");let n=t,o="",i="";for(let r=0;r<e.length;r++)if(e[r]==="<")if(e[r+1]==="/"){const u=A(e,">",r,"Closing Tag is not closed.");let a=e.substring(r+2,u).trim();if(this.options.removeNSPrefix){const d=a.indexOf(":");d!==-1&&(a=a.substr(d+1))}this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&(o=this.saveTextToParentTag(o,n,i));const f=i.substring(i.lastIndexOf(".")+1);if(a&&this.options.unpairedTags.indexOf(a)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${a}>`);let c=0;f&&this.options.unpairedTags.indexOf(f)!==-1?(c=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):c=i.lastIndexOf("."),i=i.substring(0,c),n=this.tagsNodeStack.pop(),o="",r=u}else if(e[r+1]==="?"){let u=O(e,r,!1,"?>");if(!u)throw new Error("Pi Tag is not closed.");if(o=this.saveTextToParentTag(o,n,i),!(this.options.ignoreDeclaration&&u.tagName==="?xml"||this.options.ignorePiTags)){const a=new x(u.tagName);a.add(this.options.textNodeName,""),u.tagName!==u.tagExp&&u.attrExpPresent&&(a[":@"]=this.buildAttributesMap(u.tagExp,i,u.tagName)),this.addChild(n,a,i)}r=u.closeIndex+1}else if(e.substr(r+1,3)==="!--"){const u=A(e,"-->",r+4,"Comment is not closed.");if(this.options.commentPropName){const a=e.substring(r+4,u-2);o=this.saveTextToParentTag(o,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:a}])}r=u}else if(e.substr(r+1,2)==="!D"){const u=ke(e,r);this.docTypeEntities=u.entities,r=u.i}else if(e.substr(r+1,2)==="!["){const u=A(e,"]]>",r,"CDATA is not closed.")-2,a=e.substring(r+9,u);o=this.saveTextToParentTag(o,n,i);let f=this.parseTextData(a,n.tagname,i,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:a}]):n.add(this.options.textNodeName,f),r=u+2}else{let u=O(e,r,this.options.removeNSPrefix),a=u.tagName;const f=u.rawTagName;let c=u.tagExp,d=u.attrExpPresent,g=u.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&o&&n.tagname!=="!xml"&&(o=this.saveTextToParentTag(o,n,i,!1));const m=n;if(m&&this.options.unpairedTags.indexOf(m.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),a!==t.tagname&&(i+=i?"."+a:a),this.isItStopNode(this.options.stopNodes,i,a)){let p="";if(c.length>0&&c.lastIndexOf("/")===c.length-1)a[a.length-1]==="/"?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),c=a):c=c.substr(0,c.length-1),r=u.closeIndex;else if(this.options.unpairedTags.indexOf(a)!==-1)r=u.closeIndex;else{const w=this.readStopNodeData(e,f,g+1);if(!w)throw new Error(`Unexpected end of ${f}`);r=w.i,p=w.tagContent}const _=new x(a);a!==c&&d&&(_[":@"]=this.buildAttributesMap(c,i,a)),p&&(p=this.parseTextData(p,a,i,!0,d,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,p),this.addChild(n,_,i)}else{if(c.length>0&&c.lastIndexOf("/")===c.length-1){a[a.length-1]==="/"?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),c=a):c=c.substr(0,c.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));const p=new x(a);a!==c&&d&&(p[":@"]=this.buildAttributesMap(c,i,a)),this.addChild(n,p,i),i=i.substr(0,i.lastIndexOf("."))}else{const p=new x(a);this.tagsNodeStack.push(n),a!==c&&d&&(p[":@"]=this.buildAttributesMap(c,i,a)),this.addChild(n,p,i),n=p}o="",r=g}}else o+=e[r];return t.child};function We(e,t,n){const o=this.options.updateTag(t.tagname,n,t[":@"]);o===!1||(typeof o=="string"&&(t.tagname=o),e.addChild(t))}const De=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){const n=this.docTypeEntities[t];e=e.replace(n.regx,n.val)}for(let t in this.lastEntities){const n=this.lastEntities[t];e=e.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){const n=this.htmlEntities[t];e=e.replace(n.regex,n.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function et(e,t,n,o){return e&&(o===void 0&&(o=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,n,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,o),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function tt(e,t,n){const o="*."+n;for(const i in e){const r=e[i];if(o===r||t===r)return!0}return!1}function nt(e,t,n=">"){let o,i="";for(let r=t;r<e.length;r++){let l=e[r];if(o)l===o&&(o="");else if(l==='"'||l==="'")o=l;else if(l===n[0])if(n[1]){if(e[r+1]===n[1])return{data:i,index:r}}else return{data:i,index:r};else l===" "&&(l=" ");i+=l}}function A(e,t,n,o){const i=e.indexOf(t,n);if(i===-1)throw new Error(o);return i+t.length-1}function O(e,t,n,o=">"){const i=nt(e,t+1,o);if(!i)return;let r=i.data;const l=i.index,u=r.search(/\s/);let a=r,f=!0;u!==-1&&(a=r.substring(0,u),r=r.substring(u+1).trimStart());const c=a;if(n){const d=a.indexOf(":");d!==-1&&(a=a.substr(d+1),f=a!==i.data.substr(d+1))}return{tagName:a,tagExp:r,closeIndex:l,attrExpPresent:f,rawTagName:c}}function st(e,t,n){const o=n;let i=1;for(;n<e.length;n++)if(e[n]==="<")if(e[n+1]==="/"){const r=A(e,">",n,`${t} is not closed`);if(e.substring(n+2,r).trim()===t&&(i--,i===0))return{tagContent:e.substring(o,n),i:r};n=r}else if(e[n+1]==="?")n=A(e,"?>",n+1,"StopNode is not closed.");else if(e.substr(n+1,3)==="!--")n=A(e,"-->",n+3,"StopNode is not closed.");else if(e.substr(n+1,2)==="![")n=A(e,"]]>",n,"StopNode is not closed.")-2;else{const r=O(e,n,">");r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!=="/"&&i++,n=r.closeIndex)}}function C(e,t,n){if(t&&typeof e=="string"){const o=e.trim();return o==="true"?!0:o==="false"?!1:Ue(e,n)}else return J.isExist(e)?e:""}var rt=Ke,q={};function it(e,t){return H(e,t)}function H(e,t,n){let o;const i={};for(let r=0;r<e.length;r++){const l=e[r],u=ot(l);let a="";if(n===void 0?a=u:a=n+"."+u,u===t.textNodeName)o===void 0?o=l[u]:o+=""+l[u];else{if(u===void 0)continue;if(l[u]){let f=H(l[u],t,a);const c=ut(f,t);l[":@"]?at(f,l[":@"],a,t):Object.keys(f).length===1&&f[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?f=f[t.textNodeName]:Object.keys(f).length===0&&(t.alwaysCreateTextNode?f[t.textNodeName]="":f=""),i[u]!==void 0&&i.hasOwnProperty(u)?(Array.isArray(i[u])||(i[u]=[i[u]]),i[u].push(f)):t.isArray(u,a,c)?i[u]=[f]:i[u]=f}}}return typeof o=="string"?o.length>0&&(i[t.textNodeName]=o):o!==void 0&&(i[t.textNodeName]=o),i}function ot(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const o=t[n];if(o!==":@")return o}}function at(e,t,n,o){if(t){const i=Object.keys(t),r=i.length;for(let l=0;l<r;l++){const u=i[l];o.isArray(u,n+"."+u,!0,!0)?e[u]=[t[u]]:e[u]=t[u]}}}function ut(e,t){const{textNodeName:n}=t,o=Object.keys(e).length;return!!(o===0||o===1&&(e[n]||typeof e[n]=="boolean"||e[n]===0))}q.prettify=it;const{buildOptions:lt}=j,ct=rt,{prettify:ft}=q,dt=L;let gt=class{constructor(t){this.externalEntities={},this.options=lt(t)}parse(t,n){if(typeof t!="string")if(t.toString)t=t.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});const r=dt.validate(t,n);if(r!==!0)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const o=new ct(this.options);o.addExternalEntities(this.externalEntities);const i=o.parseXml(t);return this.options.preserveOrder||i===void 0?i:ft(i,this.options)}addEntity(t,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=n}};var ht=gt;const pt=`
5
- `;function mt(e,t){let n="";return t.format&&t.indentBy.length>0&&(n=pt),Z(e,t,"",n)}function Z(e,t,n,o){let i="",r=!1;for(let l=0;l<e.length;l++){const u=e[l],a=bt(u);if(a===void 0)continue;let f="";if(n.length===0?f=a:f=`${n}.${a}`,a===t.textNodeName){let p=u[a];Nt(f,t)||(p=t.tagValueProcessor(a,p),p=Y(p,t)),r&&(i+=o),i+=p,r=!1;continue}else if(a===t.cdataPropName){r&&(i+=o),i+=`<![CDATA[${u[a][0][t.textNodeName]}]]>`,r=!1;continue}else if(a===t.commentPropName){i+=o+`<!--${u[a][0][t.textNodeName]}-->`,r=!0;continue}else if(a[0]==="?"){const p=$(u[":@"],t),_=a==="?xml"?"":o;let w=u[a][0][t.textNodeName];w=w.length!==0?" "+w:"",i+=_+`<${a}${w}${p}?>`,r=!0;continue}let c=o;c!==""&&(c+=t.indentBy);const d=$(u[":@"],t),g=o+`<${a}${d}`,m=Z(u[a],t,f,c);t.unpairedTags.indexOf(a)!==-1?t.suppressUnpairedNode?i+=g+">":i+=g+"/>":(!m||m.length===0)&&t.suppressEmptyNode?i+=g+"/>":m&&m.endsWith(">")?i+=g+`>${m}${o}</${a}>`:(i+=g+">",m&&o!==""&&(m.includes("/>")||m.includes("</"))?i+=o+t.indentBy+m+o:i+=m,i+=`</${a}>`),r=!0}return i}function bt(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const o=t[n];if(e.hasOwnProperty(o)&&o!==":@")return o}}function $(e,t){let n="";if(e&&!t.ignoreAttributes)for(let o in e){if(!e.hasOwnProperty(o))continue;let i=t.attributeValueProcessor(o,e[o]);i=Y(i,t),i===!0&&t.suppressBooleanAttributes?n+=` ${o.substr(t.attributeNamePrefix.length)}`:n+=` ${o.substr(t.attributeNamePrefix.length)}="${i}"`}return n}function Nt(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let n=e.substr(e.lastIndexOf(".")+1);for(let o in t.stopNodes)if(t.stopNodes[o]===e||t.stopNodes[o]==="*."+n)return!0;return!1}function Y(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){const o=t.entities[n];e=e.replace(o.regex,o.val)}return e}var wt=mt;const yt=wt,zt=K,At={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:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function y(e){this.options=Object.assign({},At,e),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=zt(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=xt),this.processTextOrObjNode=_t,this.options.format?(this.indentate=St,this.tagEndChar=`>
1
+ "use strict";var de=Object.create;var M=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var me=(t,e,n)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var be=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of he(e))!pe.call(t,r)&&r!==n&&M(t,r,{get:()=>e[r],enumerable:!(s=fe(e,r))||s.enumerable});return t};var Ne=(t,e,n)=>(n=t!=null?de(ge(t)):{},be(e||!t||!t.__esModule?M(n,"default",{value:t,enumerable:!0}):n,t));var A=(t,e,n)=>me(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@hono/zod-openapi"),N=i.z.object({"#text":i.z.string()}),Z=i.z.object({"#text":i.z.string(),"@_xmlns:saml":i.z.string().optional()}),H=i.z.object({"samlp:AuthnRequest":i.z.object({"saml:Issuer":Z,"@_xmlns:samlp":i.z.string(),"@_xmlns:saml":i.z.string().optional(),"@_ForceAuthn":i.z.string().transform(t=>t.toLowerCase()==="true").optional(),"@_ID":i.z.string(),"@_IssueInstant":i.z.string().datetime(),"@_Destination":i.z.string().url(),"@_AssertionConsumerServiceURL":i.z.string().url().optional(),"@_ProtocolBinding":i.z.string().optional(),"@_Version":i.z.string()})}),we=i.z.array(i.z.object({":@":i.z.object({"@_xmlns":i.z.string(),"@_entityID":i.z.string()}),EntityDescriptor:i.z.array(i.z.object({":@":i.z.object({"@_protocolSupportEnumeration":i.z.string()}),IDPSSODescriptor:i.z.array(i.z.union([i.z.object({KeyDescriptor:i.z.array(i.z.object({KeyInfo:i.z.array(i.z.object({X509Data:i.z.array(i.z.object({X509Certificate:i.z.array(N)}))})),":@":i.z.object({"@_xmlns":i.z.string()})})),":@":i.z.object({"@_use":i.z.string()})}),i.z.object({SingleLogoutService:i.z.array(i.z.object({})),":@":i.z.object({"@_Binding":i.z.string(),"@_Location":i.z.string()})}),i.z.object({NameIDFormat:i.z.array(N)}),i.z.object({SingleSignOnService:i.z.array(i.z.object({})),":@":i.z.object({"@_Binding":i.z.string(),"@_Location":i.z.string()})}),i.z.object({Attribute:i.z.array(i.z.object({})),":@":i.z.object({"@_Name":i.z.string(),"@_NameFormat":i.z.string(),"@_FriendlyName":i.z.string(),"@_xmlns":i.z.string()})})]))}))})),Ee=i.z.object({"saml:Attribute":i.z.array(i.z.object({"saml:AttributeValue":i.z.array(i.z.object({"#text":i.z.string()})),":@":i.z.object({"@_xmlns:xs":i.z.string().optional(),"@_xmlns:xsi":i.z.string(),"@_xsi:type":i.z.string()}).optional()})),":@":i.z.object({"@_Name":i.z.string(),"@_NameFormat":i.z.string(),"@_FriendlyName":i.z.string().optional()})}),ye=i.z.object({"ds:Transform":i.z.array(i.z.any()),":@":i.z.object({"@_Algorithm":i.z.string()})}),j=i.z.object({"ds:Signature":i.z.array(i.z.union([i.z.object({"ds:SignedInfo":i.z.array(i.z.union([i.z.object({"ds:CanonicalizationMethod":i.z.array(i.z.object({":@":i.z.object({"@_Algorithm":i.z.string()})}))}),i.z.object({"ds:SignatureMethod":i.z.array(i.z.object({":@":i.z.object({"@_Algorithm":i.z.string()})}))}),i.z.object({"ds:Reference":i.z.array(i.z.union([i.z.object({"ds:Transforms":i.z.array(ye)}),i.z.object({"ds:DigestMethod":i.z.array(i.z.object({":@":i.z.object({"@_Algorithm":i.z.string()})}))}),i.z.object({"ds:DigestValue":i.z.array(N)})])),":@":i.z.object({"@_URI":i.z.string().optional()}).optional()})]))}),i.z.object({"ds:SignatureValue":i.z.array(N)}),i.z.object({"ds:KeyInfo":i.z.array(i.z.union([i.z.object({"ds:KeyValue":i.z.array(i.z.object({"ds:RSAKeyValue":i.z.array(i.z.union([i.z.object({"ds:Modulus":i.z.array(N)}),i.z.object({"ds:Exponent":i.z.array(N)})]))}))}),i.z.object({"ds:X509Data":i.z.array(i.z.object({"ds:X509Certificate":i.z.array(N)}))}),i.z.object({"ds:KeyValue":i.z.array(i.z.object({"ds:RSAKeyValue":i.z.array(i.z.union([i.z.object({"ds:Modulus":i.z.array(N)}),i.z.object({"ds:Exponent":i.z.array(N)})]))})),"ds:X509Data":i.z.array(i.z.object({"ds:X509Certificate":i.z.array(N)}))})]))})])),":@":i.z.object({"@_xmlns:ds":i.z.string().optional()}).optional()}),xe=i.z.array(i.z.object({"samlp:Response":i.z.array(i.z.union([i.z.object({"saml:Issuer":i.z.array(N)}),j,i.z.object({"samlp:Status":i.z.array(i.z.object({"samlp:StatusCode":i.z.array(N),":@":i.z.object({"@_Value":i.z.string()})}))}),i.z.object({"saml:Assertion":i.z.array(i.z.union([i.z.object({"saml:Issuer":i.z.array(N)}),j,i.z.object({"saml:Subject":i.z.array(i.z.union([i.z.object({"saml:NameID":i.z.array(N),":@":i.z.object({"@_Format":i.z.string()})}),i.z.object({"saml:SubjectConfirmation":i.z.array(i.z.object({"saml:SubjectConfirmationData":i.z.array(i.z.any()),":@":i.z.object({"@_InResponseTo":i.z.string(),"@_NotOnOrAfter":i.z.string(),"@_Recipient":i.z.string()})})),":@":i.z.object({"@_Method":i.z.string()})})]))}),i.z.object({"saml:Conditions":i.z.array(i.z.object({"saml:AudienceRestriction":i.z.array(i.z.object({"saml:Audience":i.z.array(N)}))})),":@":i.z.object({"@_NotBefore":i.z.string(),"@_NotOnOrAfter":i.z.string()})}),i.z.object({"saml:AuthnStatement":i.z.array(i.z.object({"saml:AuthnContext":i.z.array(i.z.object({"saml:AuthnContextClassRef":i.z.array(N)}))})),":@":i.z.object({"@_AuthnInstant":i.z.string(),"@_SessionIndex":i.z.string(),"@_SessionNotOnOrAfter":i.z.string()})}),i.z.object({"saml:AttributeStatement":i.z.array(Ee)})])),":@":i.z.object({"@_xmlns":i.z.string(),"@_ID":i.z.string(),"@_IssueInstant":i.z.string(),"@_Version":i.z.string()})})])),":@":i.z.object({"@_xmlns:samlp":i.z.string(),"@_xmlns:saml":i.z.string(),"@_Destination":i.z.string(),"@_ID":i.z.string(),"@_InResponseTo":i.z.string(),"@_IssueInstant":i.z.string(),"@_Version":i.z.string()})}));var W={},C={};(function(t){const e=":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",n=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",s="["+e+"]["+n+"]*",r=new RegExp("^"+s+"$"),o=function(u,f){const d=[];let h=f.exec(u);for(;h;){const m=[];m.startIndex=f.lastIndex-h[0].length;const b=h.length;for(let y=0;y<b;y++)m.push(h[y]);d.push(m),h=f.exec(u)}return d},a=function(u){const f=r.exec(u);return!(f===null||typeof f>"u")};t.isExist=function(u){return typeof u<"u"},t.isEmptyObject=function(u){return Object.keys(u).length===0},t.merge=function(u,f,d){if(f){const h=Object.keys(f),m=h.length;for(let b=0;b<m;b++)d==="strict"?u[h[b]]=[f[h[b]]]:u[h[b]]=f[h[b]]}},t.getValue=function(u){return t.isExist(u)?u:""};const c=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],l=["__proto__","constructor","prototype"];t.isName=a,t.getAllMatches=o,t.nameRegexp=s,t.DANGEROUS_PROPERTY_NAMES=c,t.criticalProperties=l})(C);const F=C,Ae={allowBooleanAttributes:!1,unpairedTags:[]};W.validate=function(t,e){e=Object.assign({},Ae,e);const n=[];let s=!1,r=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let o=0;o<t.length;o++)if(t[o]==="<"&&t[o+1]==="?"){if(o+=2,o=U(t,o),o.err)return o}else if(t[o]==="<"){let a=o;if(o++,t[o]==="!"){o=k(t,o);continue}else{let c=!1;t[o]==="/"&&(c=!0,o++);let l="";for(;o<t.length&&t[o]!==">"&&t[o]!==" "&&t[o]!==" "&&t[o]!==`
2
+ `&&t[o]!=="\r";o++)l+=t[o];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),o--),!Pe(l)){let d;return l.trim().length===0?d="Invalid space after '<'.":d="Tag '"+l+"' is an invalid name.",p("InvalidTag",d,w(t,o))}const u=_e(t,o);if(u===!1)return p("InvalidAttr","Attributes for '"+l+"' have open quote.",w(t,o));let f=u.value;if(o=u.index,f[f.length-1]==="/"){const d=o-f.length;f=f.substring(0,f.length-1);const h=G(f,e);if(h===!0)s=!0;else return p(h.err.code,h.err.msg,w(t,d+h.err.line))}else if(c)if(u.tagClosed){if(f.trim().length>0)return p("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",w(t,a));if(n.length===0)return p("InvalidTag","Closing tag '"+l+"' has not been opened.",w(t,a));{const d=n.pop();if(l!==d.tagName){let h=w(t,d.tagStartPos);return p("InvalidTag","Expected closing tag '"+d.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+l+"'.",w(t,a))}n.length==0&&(r=!0)}}else return p("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",w(t,o));else{const d=G(f,e);if(d!==!0)return p(d.err.code,d.err.msg,w(t,o-f.length+d.err.line));if(r===!0)return p("InvalidXml","Multiple possible root nodes found.",w(t,o));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:a}),s=!0}for(o++;o<t.length;o++)if(t[o]==="<")if(t[o+1]==="!"){o++,o=k(t,o);continue}else if(t[o+1]==="?"){if(o=U(t,++o),o.err)return o}else break;else if(t[o]==="&"){const d=Oe(t,o);if(d==-1)return p("InvalidChar","char '&' is not expected.",w(t,o));o=d}else if(r===!0&&!B(t[o]))return p("InvalidXml","Extra text at the end",w(t,o));t[o]==="<"&&o--}}else{if(B(t[o]))continue;return p("InvalidChar","char '"+t[o]+"' is not expected.",w(t,o))}if(s){if(n.length==1)return p("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",w(t,n[0].tagStartPos));if(n.length>0)return p("InvalidXml","Invalid '"+JSON.stringify(n.map(o=>o.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return p("InvalidXml","Start tag expected.",1);return!0};function B(t){return t===" "||t===" "||t===`
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
+ `);const e=new T("!xml");let n=e,s="",r="";this.entityExpansionCount=0,this.currentExpandedLength=0;const o=new Je(this.options.processEntities);for(let a=0;a<t.length;a++)if(t[a]==="<")if(t[a+1]==="/"){const l=z(t,">",a,"Closing Tag is not closed.");let u=t.substring(a+2,l).trim();if(this.options.removeNSPrefix){const h=u.indexOf(":");h!==-1&&(u=u.substr(h+1))}this.options.transformTagName&&(u=this.options.transformTagName(u)),n&&(s=this.saveTextToParentTag(s,n,r));const f=r.substring(r.lastIndexOf(".")+1);if(u&&this.options.unpairedTags.indexOf(u)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);let d=0;f&&this.options.unpairedTags.indexOf(f)!==-1?(d=r.lastIndexOf(".",r.lastIndexOf(".")-1),this.tagsNodeStack.pop()):d=r.lastIndexOf("."),r=r.substring(0,d),n=this.tagsNodeStack.pop(),s="",a=l}else if(t[a+1]==="?"){let l=v(t,a,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,n,r),!(this.options.ignoreDeclaration&&l.tagName==="?xml"||this.options.ignorePiTags)){const u=new T(l.tagName);u.add(this.options.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&(u[":@"]=this.buildAttributesMap(l.tagExp,r,l.tagName)),this.addChild(n,u,r,a)}a=l.closeIndex+1}else if(t.substr(a+1,3)==="!--"){const l=z(t,"-->",a+4,"Comment is not closed.");if(this.options.commentPropName){const u=t.substring(a+4,l-2);s=this.saveTextToParentTag(s,n,r),n.add(this.options.commentPropName,[{[this.options.textNodeName]:u}])}a=l}else if(t.substr(a+1,2)==="!D"){const l=o.readDocType(t,a);this.docTypeEntities=l.entities,a=l.i}else if(t.substr(a+1,2)==="!["){const l=z(t,"]]>",a,"CDATA is not closed.")-2,u=t.substring(a+9,l);s=this.saveTextToParentTag(s,n,r);let f=this.parseTextData(u,n.tagname,r,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:u}]):n.add(this.options.textNodeName,f),a=l+2}else{let l=v(t,a,this.options.removeNSPrefix),u=l.tagName;const f=l.rawTagName;let d=l.tagExp,h=l.attrExpPresent,m=l.closeIndex;if(this.options.transformTagName){const g=this.options.transformTagName(u);d===u&&(d=g),u=g}if(this.options.strictReservedNames&&(u===this.options.commentPropName||u===this.options.cdataPropName||u===this.options.textNodeName||u===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${u}`);n&&s&&n.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,n,r,!1));const b=n;b&&this.options.unpairedTags.indexOf(b.tagname)!==-1&&(n=this.tagsNodeStack.pop(),r=r.substring(0,r.lastIndexOf("."))),u!==e.tagname&&(r+=r?"."+u:u);const y=a;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,r,u)){let g="";if(d.length>0&&d.lastIndexOf("/")===d.length-1)u[u.length-1]==="/"?(u=u.substr(0,u.length-1),r=r.substr(0,r.length-1),d=u):d=d.substr(0,d.length-1),a=l.closeIndex;else if(this.options.unpairedTags.indexOf(u)!==-1)a=l.closeIndex;else{const L=this.readStopNodeData(t,f,m+1);if(!L)throw new Error(`Unexpected end of ${f}`);a=L.i,g=L.tagContent}const _=new T(u);u!==d&&h&&(_[":@"]=this.buildAttributesMap(d,r,u)),g&&(g=this.parseTextData(g,u,r,!0,h,!0,!0)),r=r.substr(0,r.lastIndexOf(".")),_.add(this.options.textNodeName,g),this.addChild(n,_,r,y)}else{if(d.length>0&&d.lastIndexOf("/")===d.length-1){if(u[u.length-1]==="/"?(u=u.substr(0,u.length-1),r=r.substr(0,r.length-1),d=u):d=d.substr(0,d.length-1),this.options.transformTagName){const _=this.options.transformTagName(u);d===u&&(d=_),u=_}const g=new T(u);u!==d&&h&&(g[":@"]=this.buildAttributesMap(d,r,u)),this.addChild(n,g,r,y),r=r.substr(0,r.lastIndexOf("."))}else if(this.options.unpairedTags.indexOf(u)!==-1){const g=new T(u);u!==d&&h&&(g[":@"]=this.buildAttributesMap(d,r)),this.addChild(n,g,r,y),r=r.substr(0,r.lastIndexOf(".")),a=l.closeIndex;continue}else{const g=new T(u);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(n),u!==d&&h&&(g[":@"]=this.buildAttributesMap(d,r,u)),this.addChild(n,g,r),n=g}s="",a=m}}else s+=t[a];return e.child};function st(t,e,n,s){this.options.captureMetaData||(s=void 0);const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e,s))}const rt=function(t,e,n){if(t.indexOf("&")===-1)return t;const s=this.options.processEntities;if(!s.enabled||s.allowedTags&&!s.allowedTags.includes(e)||s.tagFilter&&!s.tagFilter(e,n))return t;for(let r in this.docTypeEntities){const o=this.docTypeEntities[r],a=t.match(o.regx);if(a){if(this.entityExpansionCount+=a.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);const c=t.length;if(t=t.replace(o.regx,o.val),s.maxExpandedLength&&(this.currentExpandedLength+=t.length-c,this.currentExpandedLength>s.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(const r of Object.keys(this.lastEntities)){const o=this.lastEntities[r],a=t.match(o.regex);if(a&&(this.entityExpansionCount+=a.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);t=t.replace(o.regex,o.val)}if(t.indexOf("&")===-1)return t;if(this.options.htmlEntities)for(const r of Object.keys(this.htmlEntities)){const o=this.htmlEntities[r],a=t.match(o.regex);if(a&&(this.entityExpansionCount+=a.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);t=t.replace(o.regex,o.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t};function it(t,e,n,s){return t&&(s===void 0&&(s=e.child.length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function ot(t,e,n,s){return!!(e&&e.has(s)||t&&t.has(n))}function at(t,e,n=">"){let s,r="";for(let o=e;o<t.length;o++){let a=t[o];if(s)a===s&&(s="");else if(a==='"'||a==="'")s=a;else if(a===n[0])if(n[1]){if(t[o+1]===n[1])return{data:r,index:o}}else return{data:r,index:o};else a===" "&&(a=" ");r+=a}}function z(t,e,n,s){const r=t.indexOf(e,n);if(r===-1)throw new Error(s);return r+e.length-1}function v(t,e,n,s=">"){const r=at(t,e+1,s);if(!r)return;let o=r.data;const a=r.index,c=o.search(/\s/);let l=o,u=!0;c!==-1&&(l=o.substring(0,c),o=o.substring(c+1).trimStart());const f=l;if(n){const d=l.indexOf(":");d!==-1&&(l=l.substr(d+1),u=l!==r.data.substr(d+1))}return{tagName:l,tagExp:o,closeIndex:a,attrExpPresent:u,rawTagName:f}}function lt(t,e,n){const s=n;let r=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const o=z(t,">",n,`${e} is not closed`);if(t.substring(n+2,o).trim()===e&&(r--,r===0))return{tagContent:t.substring(s,n),i:o};n=o}else if(t[n+1]==="?")n=z(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=z(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=z(t,"]]>",n,"StopNode is not closed.")-2;else{const o=v(t,n,">");o&&((o&&o.tagName)===e&&o.tagExp[o.tagExp.length-1]!=="/"&&r++,n=o.closeIndex)}}function $(t,e,n){if(e&&typeof t=="string"){const s=t.trim();return s==="true"?!0:s==="false"?!1:qe(t,n)}else return P.isExist(t)?t:""}function Y(t,e,n){const s=Number.parseInt(t,e);return s>=0&&s<=1114111?String.fromCodePoint(s):n+t+";"}function ut(t,e){if(P.criticalProperties.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return P.DANGEROUS_PROPERTY_NAMES.includes(t)?e.onDangerousProperty(t):t}var ct=He,re={};function dt(t,e){return ie(t,e)}function ie(t,e,n){let s;const r={};for(let o=0;o<t.length;o++){const a=t[o],c=ft(a);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)s===void 0?s=a[c]:s+=""+a[c];else{if(c===void 0)continue;if(a[c]){let u=ie(a[c],e,l);const f=gt(u,e);a[":@"]?ht(u,a[":@"],l,e):Object.keys(u).length===1&&u[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?u=u[e.textNodeName]:Object.keys(u).length===0&&(e.alwaysCreateTextNode?u[e.textNodeName]="":u=""),r[c]!==void 0&&r.hasOwnProperty(c)?(Array.isArray(r[c])||(r[c]=[r[c]]),r[c].push(u)):e.isArray(c,l,f)?r[c]=[u]:r[c]=u}}}return typeof s=="string"?s.length>0&&(r[e.textNodeName]=s):s!==void 0&&(r[e.textNodeName]=s),r}function ft(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const s=e[n];if(s!==":@")return s}}function ht(t,e,n,s){if(e){const r=Object.keys(e),o=r.length;for(let a=0;a<o;a++){const c=r[a];s.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function gt(t,e){const{textNodeName:n}=e,s=Object.keys(t).length;return!!(s===0||s===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}re.prettify=dt;const{buildOptions:pt}=R,mt=ct,{prettify:bt}=re,Nt=W;let wt=class{constructor(e){this.externalEntities={},this.options=pt(e)}parse(e,n){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});const o=Nt.validate(e,n);if(o!==!0)throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`)}const s=new mt(this.options);s.addExternalEntities(this.externalEntities);const r=s.parseXml(e);return this.options.preserveOrder||r===void 0?r:bt(r,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var Et=wt;const yt=`
5
+ `;function xt(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=yt),oe(t,e,"",n)}function oe(t,e,n,s){let r="",o=!1;if(!Array.isArray(t)){if(t!=null){let a=t.toString();return a=V(a,e),a}return""}for(let a=0;a<t.length;a++){const c=t[a],l=At(c);if(l===void 0)continue;let u="";if(n.length===0?u=l:u=`${n}.${l}`,l===e.textNodeName){let b=c[l];St(u,e)||(b=e.tagValueProcessor(l,b),b=V(b,e)),o&&(r+=s),r+=b,o=!1;continue}else if(l===e.cdataPropName){o&&(r+=s),r+=`<![CDATA[${c[l][0][e.textNodeName]}]]>`,o=!1;continue}else if(l===e.commentPropName){r+=s+`<!--${c[l][0][e.textNodeName]}-->`,o=!0;continue}else if(l[0]==="?"){const b=K(c[":@"],e),y=l==="?xml"?"":s;let g=c[l][0][e.textNodeName];g=g.length!==0?" "+g:"",r+=y+`<${l}${g}${b}?>`,o=!0;continue}let f=s;f!==""&&(f+=e.indentBy);const d=K(c[":@"],e),h=s+`<${l}${d}`,m=oe(c[l],e,u,f);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?r+=h+">":r+=h+"/>":(!m||m.length===0)&&e.suppressEmptyNode?r+=h+"/>":m&&m.endsWith(">")?r+=h+`>${m}${s}</${l}>`:(r+=h+">",m&&s!==""&&(m.includes("/>")||m.includes("</"))?r+=s+e.indentBy+m+s:r+=m,r+=`</${l}>`),o=!0}return r}function At(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const s=e[n];if(Object.prototype.hasOwnProperty.call(t,s)&&s!==":@")return s}}function K(t,e){let n="";if(t&&!e.ignoreAttributes)for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let r=e.attributeValueProcessor(s,t[s]);r=V(r,e),r===!0&&e.suppressBooleanAttributes?n+=` ${s.substr(e.attributeNamePrefix.length)}`:n+=` ${s.substr(e.attributeNamePrefix.length)}="${r}"`}return n}function St(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let s in e.stopNodes)if(e.stopNodes[s]===t||e.stopNodes[s]==="*."+n)return!0;return!1}function V(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const s=e.entities[n];t=t.replace(s.regex,s.val)}return t}var zt=xt;const _t=zt,Tt=se,It={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function x(t){this.options=Object.assign({},It,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=Tt(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Pt),this.processTextOrObjNode=Ot,this.options.format?(this.indentate=Ct,this.tagEndChar=`>
6
6
  `,this.newLine=`
7
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}y.prototype.build=function(e){return this.options.preserveOrder?yt(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)};y.prototype.j2x=function(e,t,n){let o="",i="";const r=n.join(".");for(let l in e)if(Object.prototype.hasOwnProperty.call(e,l))if(typeof e[l]>"u")this.isAttribute(l)&&(i+="");else if(e[l]===null)this.isAttribute(l)?i+="":l[0]==="?"?i+=this.indentate(t)+"<"+l+"?"+this.tagEndChar:i+=this.indentate(t)+"<"+l+"/"+this.tagEndChar;else if(e[l]instanceof Date)i+=this.buildTextValNode(e[l],l,"",t);else if(typeof e[l]!="object"){const u=this.isAttribute(l);if(u&&!this.ignoreAttributesFn(u,r))o+=this.buildAttrPairStr(u,""+e[l]);else if(!u)if(l===this.options.textNodeName){let a=this.options.tagValueProcessor(l,""+e[l]);i+=this.replaceEntitiesValue(a)}else i+=this.buildTextValNode(e[l],l,"",t)}else if(Array.isArray(e[l])){const u=e[l].length;let a="",f="";for(let c=0;c<u;c++){const d=e[l][c];if(!(typeof d>"u"))if(d===null)l[0]==="?"?i+=this.indentate(t)+"<"+l+"?"+this.tagEndChar:i+=this.indentate(t)+"<"+l+"/"+this.tagEndChar;else if(typeof d=="object")if(this.options.oneListGroup){const g=this.j2x(d,t+1,n.concat(l));a+=g.val,this.options.attributesGroupName&&d.hasOwnProperty(this.options.attributesGroupName)&&(f+=g.attrStr)}else a+=this.processTextOrObjNode(d,l,t,n);else if(this.options.oneListGroup){let g=this.options.tagValueProcessor(l,d);g=this.replaceEntitiesValue(g),a+=g}else a+=this.buildTextValNode(d,l,"",t)}this.options.oneListGroup&&(a=this.buildObjectNode(a,l,f,t)),i+=a}else if(this.options.attributesGroupName&&l===this.options.attributesGroupName){const u=Object.keys(e[l]),a=u.length;for(let f=0;f<a;f++)o+=this.buildAttrPairStr(u[f],""+e[l][u[f]])}else i+=this.processTextOrObjNode(e[l],l,t,n);return{attrStr:o,val:i}};y.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 _t(e,t,n,o){const i=this.j2x(e,n+1,o.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)}y.prototype.buildObjectNode=function(e,t,n,o){if(e==="")return t[0]==="?"?this.indentate(o)+"<"+t+n+"?"+this.tagEndChar:this.indentate(o)+"<"+t+n+this.closeTag(t)+this.tagEndChar;{let i="</"+t+this.tagEndChar,r="";return t[0]==="?"&&(r="?",i=""),(n||n==="")&&e.indexOf("<")===-1?this.indentate(o)+"<"+t+n+r+">"+e+i:this.options.commentPropName!==!1&&t===this.options.commentPropName&&r.length===0?this.indentate(o)+`<!--${e}-->`+this.newLine:this.indentate(o)+"<"+t+n+r+this.tagEndChar+e+this.indentate(o)+i}};y.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};y.prototype.buildTextValNode=function(e,t,n,o){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(o)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(o)+`<!--${e}-->`+this.newLine;if(t[0]==="?")return this.indentate(o)+"<"+t+n+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),i===""?this.indentate(o)+"<"+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(o)+"<"+t+n+">"+i+"</"+t+this.tagEndChar}};y.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){const n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};function St(e){return this.options.indentBy.repeat(e)}function xt(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}var Et=y;const It=L,Tt=ht,Ot=Et;var v={XMLParser:Tt,XMLValidator:It,XMLBuilder:Ot};class Q{constructor(t,n){z(this,"alphabet");z(this,"padding");z(this,"decodeMap",new Map);if(t.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=t,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let o=0;o<t.length;o++)this.decodeMap.set(t[o],o)}encode(t,n){let o="",i=0,r=0;for(let u=0;u<t.length;u++)for(i=i<<8|t[u],r+=8;r>=5;)r-=5,o+=this.alphabet[i>>r&31];if(r>0&&(o+=this.alphabet[i<<5-r&31]),(n==null?void 0:n.includePadding)??!0){const u=(8-o.length%8)%8;for(let a=0;a<u;a++)o+="="}return o}decode(t,n){const o=(n==null?void 0:n.strict)??!0,i=Math.ceil(t.length/8),r=[];for(let l=0;l<i;l++){let u=0;const a=[];for(let c=0;c<8;c++){const d=t[l*8+c];if(d==="="){if(l+1!==i)throw new Error(`Invalid character: ${d}`);u+=1;continue}if(d===void 0){if(o)throw new Error("Invalid data");u+=1;continue}const g=this.decodeMap.get(d)??null;if(g===null)throw new Error(`Invalid character: ${d}`);a.push(g)}if(u===8||u===7||u===5||u===2)throw new Error("Invalid padding");const f=(a[0]<<3)+(a[1]>>2);if(r.push(f),u<6){const c=((a[1]&3)<<6)+(a[2]<<1)+(a[3]>>4);r.push(c)}if(u<4){const c=((a[3]&255)<<4)+(a[4]>>1);r.push(c)}if(u<3){const c=((a[4]&1)<<7)+(a[5]<<2)+(a[6]>>3);r.push(c)}if(u<1){const c=((a[6]&7)<<5)+a[7];r.push(c)}}return Uint8Array.from(r)}}new Q("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new Q("0123456789ABCDEFGHIJKLMNOPQRSTUV");class W{constructor(t,n){z(this,"alphabet");z(this,"padding");z(this,"decodeMap",new Map);if(t.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=t,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let o=0;o<t.length;o++)this.decodeMap.set(t[o],o)}encode(t,n){let o="",i=0,r=0;for(let u=0;u<t.length;u++)for(i=i<<8|t[u],r+=8;r>=6;)r+=-6,o+=this.alphabet[i>>r&63];if(r>0&&(o+=this.alphabet[i<<6-r&63]),(n==null?void 0:n.includePadding)??!0){const u=(4-o.length%4)%4;for(let a=0;a<u;a++)o+="="}return o}decode(t,n){const o=(n==null?void 0:n.strict)??!0,i=Math.ceil(t.length/4),r=[];for(let l=0;l<i;l++){let u=0,a=0;for(let f=0;f<4;f++){const c=t[l*4+f];if(c==="="){if(l+1!==i)throw new Error(`Invalid character: ${c}`);u+=1;continue}if(c===void 0){if(o)throw new Error("Invalid data");u+=1;continue}const d=this.decodeMap.get(c)??null;if(d===null)throw new Error(`Invalid character: ${c}`);a+=d<<6*(3-f)}r.push(a>>16&255),u<2&&r.push(a>>8&255),u<1&&r.push(a&255)}return Uint8Array.from(r)}}const Ct=new W("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new W("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");const Lt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let R=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=Lt[n[e]&63];return t};async function D(e){const t=new DecompressionStream("deflate-raw"),n=new Uint8Array(e),o=new Blob([n]).stream().pipeThrough(t);return new Uint8Array(await new Response(o).arrayBuffer())}async function ee(e){const t=await Ct.decode(e.replace(/ /g,"+"));try{const n=await D(t);return new TextDecoder().decode(n)}catch(n){return console.warn("Decompression failed, assuming data is not compressed:",n),new TextDecoder().decode(t)}}async function Mt(e){const t=await ee(e),o=new v.XMLParser({attributeNamePrefix:"@_",alwaysCreateTextNode:!0,ignoreAttributes:!1}).parse(t);return U.parse(o)}function jt(e){const t=e.certificates.map(i=>({"@_use":"signing",KeyInfo:{"@_xmlns":"http://www.w3.org/2000/09/xmldsig#",X509Data:{X509Certificate:i}}})),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 v.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:"@_"}).build(n)}async function vt(e,t){const n=e.notBefore||new Date().toISOString(),o=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),i=e.issueInstant||n,r=e.sessionNotOnOrAfter||o,l=e.responseId||`_${R()}`,u=e.assertionId||`_${R()}`,a=[{"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":o,"@_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":o}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":r}},{"saml:AttributeStatement":[{"saml:Attribute":[{":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"},"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"}}]}]},{"saml:Attribute":[{":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"},"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"}}]}]},{"saml:Attribute":[{":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"},"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"}}]}]},{"saml:Attribute":[{":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"},"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"}}]}]},{"saml:Attribute":[{":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"},"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"}}]}]},{"saml:Attribute":[{":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"},"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"}}]}]},{"saml:Attribute":[{":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"},"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"}}]}]},{"saml:Attribute":[{":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"},"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"}}]}]}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":u,"@_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":l,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let c=new v.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(a);return e.signature&&t&&(c=await t.signSAML(c,e.signature.privateKeyPem,e.signature.cert)),e.encode===!1?c:btoa(c)}const Pt="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",Ft="http://www.w3.org/2001/04/xmlenc#sha256",B="http://www.w3.org/2001/10/xml-exc-c14n#";class Vt{async signSAML(t,n,o){var i;try{const r=await import("xml-crypto"),l=r.SignedXml||((i=r.default)==null?void 0:i.SignedXml);if(!l)throw new Error("SignedXml not found in xml-crypto module");const u=new l({privateKey:n,publicCert:o});u.canonicalizationAlgorithm=B,u.addReference({xpath:"(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",digestAlgorithm:Ft,transforms:["http://www.w3.org/2000/09/xmldsig#enveloped-signature",B]}),u.signatureAlgorithm=Pt;const a=o.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g,"").replace(/\s/g,"");return u.keyInfoProvider={getKeyInfo:()=>`<X509Data><X509Certificate>${a}</X509Certificate></X509Data>`},u.computeSignature(t,{location:{reference:"/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",action:"after"}}),u.getSignedXml()}catch(r){throw new Error(`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${r}`)}}}class Xt{constructor(t){this.signUrl=t}async signSAML(t,n,o){const i=await fetch(this.signUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:t,privateKey:n,publicCert:o})});if(!i.ok)throw new Error(`Failed to sign SAML via HTTP: ${i.status} ${i.statusText}`);return await i.text()}}exports.HttpSamlSigner=Xt;exports.LocalSamlSigner=Vt;exports.createSamlMetadata=jt;exports.createSamlResponse=vt;exports.dsSignatureSchema=T;exports.inflateDecompress=ee;exports.inflateRaw=D;exports.parseSamlRequestQuery=Mt;exports.samlIssuerSchema=k;exports.samlMetadataResponseSchema=le;exports.samlRequestSchema=U;exports.samlResponseJsonSchema=de;
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;