@authhero/saml 0.3.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/core.cjs +6 -6
- package/dist/core.d.ts +229 -3933
- package/dist/core.mjs +1295 -1039
- package/dist/saml.cjs +6 -6
- package/dist/saml.d.ts +229 -3933
- package/dist/saml.mjs +1314 -1058
- package/package.json +3 -3
package/dist/core.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`&&
|
|
3
|
-
`||e==="\r"}function P(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 F(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 oe='"',ae="'";function ue(e,t){let n="",o="",i=!1;for(;t<e.length;t++){if(e[t]===oe||e[t]===ae)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 le=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function V(e,t){const n=L.getAllMatches(e,le),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(!de(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 ce(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 fe(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,ce(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 de(e){return L.isName(e)}function ge(e){return L.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 M={};const k={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}},he=function(e){return Object.assign({},k,e)};M.buildOptions=he;M.defaultOptions=k;class pe{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 me=pe;const be=E;function Ne(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&&ze(e,t)){t+=7;let u,a;[u,a,t]=ye(e,t+1),a.indexOf("&")===-1&&(n[xe(u)]={regx:RegExp(`&${u};`,"g"),val:a})}else if(i&&Ae(e,t))t+=8;else if(i&&_e(e,t))t+=8;else if(i&&Se(e,t))t+=9;else if(we)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 ye(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 we(e,t){return e[t+1]==="!"&&e[t+2]==="-"&&e[t+3]==="-"}function ze(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 Ae(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 _e(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 Se(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 xe(e){if(be.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}var Ee=Ne;const Te=/^[-+]?0x[a-fA-F0-9]+$/,Ie=/^([\-\+])?(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 Oe={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Ce(e,t={}){if(t=Object.assign({},Oe,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&&Te.test(n))return Number.parseInt(n,16);{const o=Ie.exec(n);if(o){const i=o[1],r=o[2];let l=Le(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 Le(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 Me=Ce;function je(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 U=je;const G=E,x=me,ve=Ee,Pe=Me,Fe=U;let Ve=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=$e,this.parseXml=Ue,this.parseTextData=Xe,this.resolveNameSpace=Re,this.buildAttributesMap=ke,this.isItStopNode=qe,this.replaceEntitiesValue=Ke,this.readStopNodeData=Ze,this.saveTextToParentTag=Je,this.addChild=Ge,this.ignoreAttributesFn=Fe(this.options.ignoreAttributes)}};function $e(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 Xe(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?O(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?O(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function Re(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 Be=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function ke(e,t,n){if(this.options.ignoreAttributes!==!0&&typeof e=="string"){const o=G.getAllMatches(e,Be),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]=O(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 Ue=function(e){e=e.replace(/\r\n?/g,`
|
|
4
|
-
`);const
|
|
5
|
-
`;function
|
|
1
|
+
"use strict";var le=Object.defineProperty;var ce=(t,e,n)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var z=(t,e,n)=>ce(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()}),K=i.z.object({"#text":i.z.string(),"@_xmlns:saml":i.z.string().optional()}),q=i.z.object({"samlp:AuthnRequest":i.z.object({"saml:Issuer":K,"@_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()})}),de=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()})})]))}))})),fe=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()})}),he=i.z.object({"ds:Transform":i.z.array(i.z.any()),":@":i.z.object({"@_Algorithm":i.z.string()})}),L=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(he)}),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()}),pe=i.z.array(i.z.object({"samlp:Response":i.z.array(i.z.union([i.z.object({"saml:Issuer":i.z.array(N)}),L,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)}),L,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(fe)})])),":@":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 Z={},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(l,f){const d=[];let h=f.exec(l);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(l)}return d},a=function(l){const f=r.exec(l);return!(f===null||typeof f>"u")};t.isExist=function(l){return typeof l<"u"},t.isEmptyObject=function(l){return Object.keys(l).length===0},t.merge=function(l,f,d){if(f){const h=Object.keys(f),m=h.length;for(let b=0;b<m;b++)d==="strict"?l[h[b]]=[f[h[b]]]:l[h[b]]=f[h[b]]}},t.getValue=function(l){return t.isExist(l)?l:""};const c=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],u=["__proto__","constructor","prototype"];t.isName=a,t.getAllMatches=o,t.nameRegexp=s,t.DANGEROUS_PROPERTY_NAMES=c,t.criticalProperties=u})(C);const $=C,ge={allowBooleanAttributes:!1,unpairedTags:[]};Z.validate=function(t,e){e=Object.assign({},ge,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=B(t,o),o.err)return o}else if(t[o]==="<"){let a=o;if(o++,t[o]==="!"){o=U(t,o);continue}else{let c=!1;t[o]==="/"&&(c=!0,o++);let u="";for(;o<t.length&&t[o]!==">"&&t[o]!==" "&&t[o]!==" "&&t[o]!==`
|
|
2
|
+
`&&t[o]!=="\r";o++)u+=t[o];if(u=u.trim(),u[u.length-1]==="/"&&(u=u.substring(0,u.length-1),o--),!ze(u)){let d;return u.trim().length===0?d="Invalid space after '<'.":d="Tag '"+u+"' is an invalid name.",g("InvalidTag",d,w(t,o))}const l=Ne(t,o);if(l===!1)return g("InvalidAttr","Attributes for '"+u+"' have open quote.",w(t,o));let f=l.value;if(o=l.index,f[f.length-1]==="/"){const d=o-f.length;f=f.substring(0,f.length-1);const h=k(f,e);if(h===!0)s=!0;else return g(h.err.code,h.err.msg,w(t,d+h.err.line))}else if(c)if(l.tagClosed){if(f.trim().length>0)return g("InvalidTag","Closing tag '"+u+"' can't have attributes or invalid starting.",w(t,a));if(n.length===0)return g("InvalidTag","Closing tag '"+u+"' has not been opened.",w(t,a));{const d=n.pop();if(u!==d.tagName){let h=w(t,d.tagStartPos);return g("InvalidTag","Expected closing tag '"+d.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+u+"'.",w(t,a))}n.length==0&&(r=!0)}}else return g("InvalidTag","Closing tag '"+u+"' doesn't have proper closing.",w(t,o));else{const d=k(f,e);if(d!==!0)return g(d.err.code,d.err.msg,w(t,o-f.length+d.err.line));if(r===!0)return g("InvalidXml","Multiple possible root nodes found.",w(t,o));e.unpairedTags.indexOf(u)!==-1||n.push({tagName:u,tagStartPos:a}),s=!0}for(o++;o<t.length;o++)if(t[o]==="<")if(t[o+1]==="!"){o++,o=U(t,o);continue}else if(t[o+1]==="?"){if(o=B(t,++o),o.err)return o}else break;else if(t[o]==="&"){const d=ye(t,o);if(d==-1)return g("InvalidChar","char '&' is not expected.",w(t,o));o=d}else if(r===!0&&!X(t[o]))return g("InvalidXml","Extra text at the end",w(t,o));t[o]==="<"&&o--}}else{if(X(t[o]))continue;return g("InvalidChar","char '"+t[o]+"' is not expected.",w(t,o))}if(s){if(n.length==1)return g("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",w(t,n[0].tagStartPos));if(n.length>0)return g("InvalidXml","Invalid '"+JSON.stringify(n.map(o=>o.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return g("InvalidXml","Start tag expected.",1);return!0};function X(t){return t===" "||t===" "||t===`
|
|
3
|
+
`||t==="\r"}function B(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 g("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 U(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 me='"',be="'";function Ne(t,e){let n="",s="",r=!1;for(;e<t.length;e++){if(t[e]===me||t[e]===be)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 we=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function k(t,e){const n=$.getAllMatches(t,we),s={};for(let r=0;r<n.length;r++){if(n[r][1].length===0)return g("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 g("InvalidAttr","Attribute '"+n[r][2]+"' is without value.",I(n[r]));if(n[r][3]===void 0&&!e.allowBooleanAttributes)return g("InvalidAttr","boolean attribute '"+n[r][2]+"' is not allowed.",I(n[r]));const o=n[r][2];if(!xe(o))return g("InvalidAttr","Attribute '"+o+"' is an invalid name.",I(n[r]));if(!s.hasOwnProperty(o))s[o]=1;else return g("InvalidAttr","Attribute '"+o+"' is repeated.",I(n[r]))}return!0}function Ee(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 ye(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Ee(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 g(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function xe(t){return $.isName(t)}function ze(t){return $.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 F={};const{DANGEROUS_PROPERTY_NAMES:H,criticalProperties:Ae}=C,W=t=>H.includes(t)?"__"+t:t,Q={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:W};function Se(t,e){if(typeof t!="string")return;const n=t.toLowerCase();if(H.some(s=>n===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Ae.some(s=>n===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function D(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}:D(!0)}const _e=function(t){const e=Object.assign({},Q,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&&Se(s,r);return e.onDangerousProperty===null&&(e.onDangerousProperty=W),e.processEntities=D(e.processEntities),e};F.buildOptions=_e;F.defaultOptions=Q;class Te{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 Ie=Te;const ee=C;let Oe=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,u="";for(;n<e.length;n++)if(e[n]==="<"&&!c){if(a&&A(e,"!ENTITY",n)){n+=7;let l,f;if([l,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=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[l]={regx:RegExp(`&${d};`,"g"),val:f},r++}}else if(a&&A(e,"!ELEMENT",n)){n+=8;const{index:l}=this.readElementExp(e,n+1);n=l}else if(a&&A(e,"!ATTLIST",n))n+=8;else if(a&&A(e,"!NOTATION",n)){n+=9;const{index:l}=this.readNotationExp(e,n+1,this.suppressValidationErr);n=l}else if(A(e,"!--",n))c=!0;else throw new Error("Invalid DOCTYPE");o++,u=""}else if(e[n]===">"){if(c?e[n-1]==="-"&&e[n-2]==="-"&&(c=!1,o--):o--,o===0)break}else e[n]==="["?a=!0:u+=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&&!ee.isName(s))throw new Error(`Invalid element name: "${s}"`);n=E(e,n);let r="";if(e[n]==="E"&&A(e,"MPTY",n))n+=4;else if(e[n]==="A"&&A(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 u="";for(;n<e.length&&e[n]!=="|"&&e[n]!==")";)u+=e[n],n++;if(u=u.trim(),!O(u))throw new Error(`Invalid notation name: "${u}"`);c.push(u),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 A(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(ee.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var Ce=Oe;const Pe=/^[-+]?0x[a-fA-F0-9]+$/,Me=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Le={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function je(t,e={}){if(e=Object.assign({},Le,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&&Pe.test(n))return Ve(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=Me.exec(n);if(s){const r=s[1],o=s[2];let a=ve(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),u=""+c;return u.search(/[eE]/)!==-1?e.eNotation?c:t:n.indexOf(".")!==-1?u==="0"&&a===""||u===a||r&&u==="-"+a?c:t:o?a===u||r+a===u?c:t:n===u||n===r+u?c:t}}else return t}}function ve(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 Ve(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 $e=je;function Fe(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 te=Fe;const P=C,T=Ie,Re=Ce,Xe=$e,Be=te;let Ue=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)=>G(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,s)=>G(s,16,"&#x")}},this.addExternalEntities=ke,this.parseXml=qe,this.parseTextData=Ge,this.resolveNameSpace=Ye,this.buildAttributesMap=Ke,this.isItStopNode=Qe,this.replaceEntitiesValue=He,this.readStopNodeData=et,this.saveTextToParentTag=We,this.addChild=Ze,this.ignoreAttributesFn=Be(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 ke(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 Ge(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?v(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?v(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function Ye(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 Je=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Ke(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const s=P.getAllMatches(t,Je),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 u=s[a][4],l=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l=tt(l,this.options),u!==void 0){this.options.trimValues&&(u=u.trim()),u=this.replaceEntitiesValue(u,n,e);const f=this.options.attributeValueProcessor(c,u,e);f==null?o[l]=u:typeof f!=typeof u||f!==u?o[l]=f:o[l]=v(u,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[l]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=o,a}return o}}const qe=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 Re(this.options.processEntities);for(let a=0;a<t.length;a++)if(t[a]==="<")if(t[a+1]==="/"){const u=S(t,">",a,"Closing Tag is not closed.");let l=t.substring(a+2,u).trim();if(this.options.removeNSPrefix){const h=l.indexOf(":");h!==-1&&(l=l.substr(h+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&(s=this.saveTextToParentTag(s,n,r));const f=r.substring(r.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);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=u}else if(t[a+1]==="?"){let u=j(t,a,!1,"?>");if(!u)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,n,r),!(this.options.ignoreDeclaration&&u.tagName==="?xml"||this.options.ignorePiTags)){const l=new T(u.tagName);l.add(this.options.textNodeName,""),u.tagName!==u.tagExp&&u.attrExpPresent&&(l[":@"]=this.buildAttributesMap(u.tagExp,r,u.tagName)),this.addChild(n,l,r,a)}a=u.closeIndex+1}else if(t.substr(a+1,3)==="!--"){const u=S(t,"-->",a+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(a+4,u-2);s=this.saveTextToParentTag(s,n,r),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}a=u}else if(t.substr(a+1,2)==="!D"){const u=o.readDocType(t,a);this.docTypeEntities=u.entities,a=u.i}else if(t.substr(a+1,2)==="!["){const u=S(t,"]]>",a,"CDATA is not closed.")-2,l=t.substring(a+9,u);s=this.saveTextToParentTag(s,n,r);let f=this.parseTextData(l,n.tagname,r,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,f),a=u+2}else{let u=j(t,a,this.options.removeNSPrefix),l=u.tagName;const f=u.rawTagName;let d=u.tagExp,h=u.attrExpPresent,m=u.closeIndex;if(this.options.transformTagName){const p=this.options.transformTagName(l);d===l&&(d=p),l=p}if(this.options.strictReservedNames&&(l===this.options.commentPropName||l===this.options.cdataPropName||l===this.options.textNodeName||l===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);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("."))),l!==e.tagname&&(r+=r?"."+l:l);const y=a;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,r,l)){let p="";if(d.length>0&&d.lastIndexOf("/")===d.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),r=r.substr(0,r.length-1),d=l):d=d.substr(0,d.length-1),a=u.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)a=u.closeIndex;else{const M=this.readStopNodeData(t,f,m+1);if(!M)throw new Error(`Unexpected end of ${f}`);a=M.i,p=M.tagContent}const _=new T(l);l!==d&&h&&(_[":@"]=this.buildAttributesMap(d,r,l)),p&&(p=this.parseTextData(p,l,r,!0,h,!0,!0)),r=r.substr(0,r.lastIndexOf(".")),_.add(this.options.textNodeName,p),this.addChild(n,_,r,y)}else{if(d.length>0&&d.lastIndexOf("/")===d.length-1){if(l[l.length-1]==="/"?(l=l.substr(0,l.length-1),r=r.substr(0,r.length-1),d=l):d=d.substr(0,d.length-1),this.options.transformTagName){const _=this.options.transformTagName(l);d===l&&(d=_),l=_}const p=new T(l);l!==d&&h&&(p[":@"]=this.buildAttributesMap(d,r,l)),this.addChild(n,p,r,y),r=r.substr(0,r.lastIndexOf("."))}else if(this.options.unpairedTags.indexOf(l)!==-1){const p=new T(l);l!==d&&h&&(p[":@"]=this.buildAttributesMap(d,r)),this.addChild(n,p,r,y),r=r.substr(0,r.lastIndexOf(".")),a=u.closeIndex;continue}else{const p=new T(l);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(n),l!==d&&h&&(p[":@"]=this.buildAttributesMap(d,r,l)),this.addChild(n,p,r),n=p}s="",a=m}}else s+=t[a];return e.child};function Ze(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 He=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 We(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 Qe(t,e,n,s){return!!(e&&e.has(s)||t&&t.has(n))}function De(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 S(t,e,n,s){const r=t.indexOf(e,n);if(r===-1)throw new Error(s);return r+e.length-1}function j(t,e,n,s=">"){const r=De(t,e+1,s);if(!r)return;let o=r.data;const a=r.index,c=o.search(/\s/);let u=o,l=!0;c!==-1&&(u=o.substring(0,c),o=o.substring(c+1).trimStart());const f=u;if(n){const d=u.indexOf(":");d!==-1&&(u=u.substr(d+1),l=u!==r.data.substr(d+1))}return{tagName:u,tagExp:o,closeIndex:a,attrExpPresent:l,rawTagName:f}}function et(t,e,n){const s=n;let r=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const o=S(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=S(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=S(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=S(t,"]]>",n,"StopNode is not closed.")-2;else{const o=j(t,n,">");o&&((o&&o.tagName)===e&&o.tagExp[o.tagExp.length-1]!=="/"&&r++,n=o.closeIndex)}}function v(t,e,n){if(e&&typeof t=="string"){const s=t.trim();return s==="true"?!0:s==="false"?!1:Xe(t,n)}else return P.isExist(t)?t:""}function G(t,e,n){const s=Number.parseInt(t,e);return s>=0&&s<=1114111?String.fromCodePoint(s):n+t+";"}function tt(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 nt=Ue,ne={};function st(t,e){return se(t,e)}function se(t,e,n){let s;const r={};for(let o=0;o<t.length;o++){const a=t[o],c=rt(a);let u="";if(n===void 0?u=c:u=n+"."+c,c===e.textNodeName)s===void 0?s=a[c]:s+=""+a[c];else{if(c===void 0)continue;if(a[c]){let l=se(a[c],e,u);const f=ot(l,e);a[":@"]?it(l,a[":@"],u,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),r[c]!==void 0&&r.hasOwnProperty(c)?(Array.isArray(r[c])||(r[c]=[r[c]]),r[c].push(l)):e.isArray(c,u,f)?r[c]=[l]:r[c]=l}}}return typeof s=="string"?s.length>0&&(r[e.textNodeName]=s):s!==void 0&&(r[e.textNodeName]=s),r}function rt(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const s=e[n];if(s!==":@")return s}}function it(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 ot(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))}ne.prettify=st;const{buildOptions:at}=F,ut=nt,{prettify:lt}=ne,ct=Z;let dt=class{constructor(e){this.externalEntities={},this.options=at(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=ct.validate(e,n);if(o!==!0)throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`)}const s=new ut(this.options);s.addExternalEntities(this.externalEntities);const r=s.parseXml(e);return this.options.preserveOrder||r===void 0?r:lt(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 '
'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var ft=dt;const ht=`
|
|
5
|
+
`;function pt(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=ht),re(t,e,"",n)}function re(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],u=gt(c);if(u===void 0)continue;let l="";if(n.length===0?l=u:l=`${n}.${u}`,u===e.textNodeName){let b=c[u];mt(l,e)||(b=e.tagValueProcessor(u,b),b=V(b,e)),o&&(r+=s),r+=b,o=!1;continue}else if(u===e.cdataPropName){o&&(r+=s),r+=`<![CDATA[${c[u][0][e.textNodeName]}]]>`,o=!1;continue}else if(u===e.commentPropName){r+=s+`<!--${c[u][0][e.textNodeName]}-->`,o=!0;continue}else if(u[0]==="?"){const b=Y(c[":@"],e),y=u==="?xml"?"":s;let p=c[u][0][e.textNodeName];p=p.length!==0?" "+p:"",r+=y+`<${u}${p}${b}?>`,o=!0;continue}let f=s;f!==""&&(f+=e.indentBy);const d=Y(c[":@"],e),h=s+`<${u}${d}`,m=re(c[u],e,l,f);e.unpairedTags.indexOf(u)!==-1?e.suppressUnpairedNode?r+=h+">":r+=h+"/>":(!m||m.length===0)&&e.suppressEmptyNode?r+=h+"/>":m&&m.endsWith(">")?r+=h+`>${m}${s}</${u}>`:(r+=h+">",m&&s!==""&&(m.includes("/>")||m.includes("</"))?r+=s+e.indentBy+m+s:r+=m,r+=`</${u}>`),o=!0}return r}function gt(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 Y(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 mt(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 bt=pt;const Nt=bt,wt=te,Et={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:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function x(t){this.options=Object.assign({},Et,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=wt(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=zt),this.processTextOrObjNode=yt,this.options.format?(this.indentate=xt,this.tagEndChar=`>
|
|
6
6
|
`,this.newLine=`
|
|
7
|
-
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}w.prototype.build=function(e){return this.options.preserveOrder?dt(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)};w.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}};w.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 pt(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)}w.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}};w.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};w.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}};w.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 mt(e){return this.options.indentBy.repeat(e)}function bt(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}var Nt=w;const yt=C,wt=ot,zt=Nt;var j={XMLParser:wt,XMLValidator:yt,XMLBuilder:zt};class Z{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 Z("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new Z("0123456789ABCDEFGHIJKLMNOPQRSTUV");class Y{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 At=new Y("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new Y("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");const _t="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let X=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=_t[n[e]&63];return t};async function Q(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 W(e){const t=await At.decode(e.replace(/ /g,"+"));try{const n=await Q(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 St(e){const t=await W(e),o=new j.XMLParser({attributeNamePrefix:"@_",alwaysCreateTextNode:!0,ignoreAttributes:!1}).parse(t);return B.parse(o)}function xt(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 j.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:"@_"}).build(n)}async function Et(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||`_${X()}`,u=e.assertionId||`_${X()}`,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":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"default-roles-master"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"offline_access"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"view-profile"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"uma_authorization"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account-links"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":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 j.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)}class Tt{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=Tt;exports.createSamlMetadata=xt;exports.createSamlResponse=Et;exports.dsSignatureSchema=T;exports.inflateDecompress=W;exports.inflateRaw=Q;exports.parseSamlRequestQuery=St;exports.samlIssuerSchema=R;exports.samlMetadataResponseSchema=te;exports.samlRequestSchema=B;exports.samlResponseJsonSchema=re;
|
|
7
|
+
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}x.prototype.build=function(t){return this.options.preserveOrder?Nt(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 u=this.options.tagValueProcessor(a,""+t[a]);r+=this.replaceEntitiesValue(u)}else r+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){const c=t[a].length;let u="",l="";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));u+=h.val,this.options.attributesGroupName&&d.hasOwnProperty(this.options.attributesGroupName)&&(l+=h.attrStr)}else u+=this.processTextOrObjNode(d,a,e,n);else if(this.options.oneListGroup){let h=this.options.tagValueProcessor(a,d);h=this.replaceEntitiesValue(h),u+=h}else u+=this.buildTextValNode(d,a,"",e)}this.options.oneListGroup&&(u=this.buildObjectNode(u,a,l,e)),r+=u}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const c=Object.keys(t[a]),u=c.length;for(let l=0;l<u;l++)s+=this.buildAttrPairStr(c[l],""+t[a][c[l]])}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 yt(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 xt(t){return this.options.indentBy.repeat(t)}function zt(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var At=x;const St=ft,_t=At;var R={XMLParser:St,XMLBuilder:_t};class ie{constructor(e,n){z(this,"alphabet");z(this,"padding");z(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 u=0;u<c;u++)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 u=[];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}`);u.push(h)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const l=(u[0]<<3)+(u[1]>>2);if(o.push(l),c<6){const f=((u[1]&3)<<6)+(u[2]<<1)+(u[3]>>4);o.push(f)}if(c<4){const f=((u[3]&255)<<4)+(u[4]>>1);o.push(f)}if(c<3){const f=((u[4]&1)<<7)+(u[5]<<2)+(u[6]>>3);o.push(f)}if(c<1){const f=((u[6]&7)<<5)+u[7];o.push(f)}}return Uint8Array.from(o)}}new ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new ie("0123456789ABCDEFGHIJKLMNOPQRSTUV");class oe{constructor(e,n){z(this,"alphabet");z(this,"padding");z(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 u=0;u<c;u++)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,u=0;for(let l=0;l<4;l++){const f=e[a*4+l];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}`);u+=d<<6*(3-l)}o.push(u>>16&255),c<2&&o.push(u>>8&255),c<1&&o.push(u&255)}return Uint8Array.from(o)}}const Tt=new oe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new oe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");let It="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",J=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=It[n[t]&63];return e};async function ae(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 ue(t){const e=await Tt.decode(t.replace(/ /g,"+"));try{const n=await ae(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 Ot(t){const e=await ue(t),s=new R.XMLParser({attributeNamePrefix:"@_",alwaysCreateTextNode:!0,ignoreAttributes:!1}).parse(e);return q.parse(s)}function Ct(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 R.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:"@_"}).build(n)}async function Pt(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()}`,u=[{"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 R.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(u);return t.signature&&e&&(f=await e.signSAML(f,t.signature.privateKeyPem,t.signature.cert)),t.encode===!1?f:btoa(f)}class Mt{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=Mt;exports.createSamlMetadata=Ct;exports.createSamlResponse=Pt;exports.dsSignatureSchema=L;exports.inflateDecompress=ue;exports.inflateRaw=ae;exports.parseSamlRequestQuery=Ot;exports.samlIssuerSchema=K;exports.samlMetadataResponseSchema=de;exports.samlRequestSchema=q;exports.samlResponseJsonSchema=pe;
|