authhero 0.64.0 → 0.65.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/authhero.cjs +27 -27
- package/dist/authhero.d.ts +32 -2
- package/dist/authhero.mjs +1111 -1111
- package/package.json +1 -1
package/dist/authhero.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var pm=Object.defineProperty;var fm=(t,e,n)=>e in t?pm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ee=(t,e,n)=>fm(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),ne=t=>typeof t=="string",gr=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},hu=t=>t==null?"":""+t,hm=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},gm=/###/g,gu=t=>t&&t.indexOf("###")>-1?t.replace(gm,"."):t,mu=t=>!t||ne(t),br=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(mu(t))return{};const s=gu(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return mu(t)?{}:{obj:t,k:gu(r[i])}},_u=(t,e,n)=>{const{obj:r,k:i}=br(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=br(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=br(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},mm=(t,e,n,r)=>{const{obj:i,k:s}=br(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Vi=(t,e)=>{const{obj:n,k:r}=br(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},_m=(t,e,n)=>{const r=Vi(t,n);return r!==void 0?r:Vi(e,n)},qp=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ne(t[r])||t[r]instanceof String||ne(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):qp(t[r],e[r],n):t[r]=e[r]);return t},zn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ym={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const vm=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>ym[e]):t;class wm{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const bm=[" ",",","?","!",";"],km=new wm(20),xm=(t,e,n)=>{e=e||"",n=n||"";const r=bm.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=km.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},da=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let o,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],o=i[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=o}return i},Mi=t=>t==null?void 0:t.replace("_","-"),Sm={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,r;(r=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||r.call(n,console,e)}};class qi{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||Sm,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(ne(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new qi(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new qi(this.logger,e)}}var wt=new qi;class Rs{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c.apply(c,[e,...r])})}}class yu extends Rs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){var u,p;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&s?c.push(...r.split(s)):c.push(r)));const l=Vi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!o||!ne(r)?l:da((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),_u(this.data,c,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(ne(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let l=Vi(this.data,c)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?qp(l,r,s):l={...l,...r},_u(this.data,c,l),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var Dp={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,n,r,i))??e}),e}};const vu={};class Di extends Rs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),hm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=wt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const r=this.resolve(e,n);return(r==null?void 0:r.res)!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!xm(e,r,i);if(o&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ne(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:ne(s)?[s]:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const R=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${R}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${R}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const h=this.resolve(e,n);let m=h==null?void 0:h.res;const y=(h==null?void 0:h.usedKey)||o,f=(h==null?void 0:h.exactUsedKey)||o,_=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],x=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,B=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(N&&m&&B&&v.indexOf(_)<0&&!(ne(x)&&Array.isArray(m))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,m,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=R,h.usedParams=this.getUsedParamsDetails(n),h):R}if(s){const R=Array.isArray(m),te=R?[]:{},pe=R?f:y;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const Ue=`${pe}${s}${le}`;te[le]=this.translate(Ue,{...n,joinArrays:!1,ns:c}),te[le]===Ue&&(te[le]=m[le])}m=te}}else if(N&&ne(x)&&Array.isArray(m))m=m.join(x),m&&(m=this.extendTranslation(m,e,n,r));else{let R=!1,te=!1;const pe=n.count!==void 0&&!ne(n.count),le=Di.hasDefaultValue(n),Ue=pe?this.pluralResolver.getSuffix(u,n.count,n):"",ot=n.ordinal&&pe?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",We=pe&&!n.ordinal&&n.count===0,$=We&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Ue}`]||n[`defaultValue${ot}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(R=!0,m=$),this.isValidLookup(m)||(te=!0,m=o);const A=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&te?void 0:m,k=le&&$!==m&&this.options.updateMissing;if(te||R||k){if(this.logger.log(k?"updateKey":"missingKey",u,l,o,k?$:m),s){const X=this.resolve(o,{...n,keySeparator:!1});X&&X.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let b=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let X=0;X<z.length;X++)b.push(z[X]);else this.options.saveMissingTo==="all"?b=this.languageUtils.toResolveHierarchy(n.lng||this.language):b.push(n.lng||this.language);const L=(X,W,ie)=>{var D;const ce=le&&ie!==m?ie:A;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,W,ce,k,n):(D=this.backendConnector)!=null&&D.saveMissing&&this.backendConnector.saveMissing(X,l,W,ce,k,n),this.emit("missingKey",X,l,W,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&pe?b.forEach(X=>{const W=this.pluralResolver.getSuffixes(X,n);We&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ie=>{L([X],o+ie,n[`defaultValue${ie}`]||$)})}):L(b,o,$))}m=this.extendTranslation(m,e,n,h,r),te&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${o}`),(te||R)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,R?m:void 0))}return i?(h.res=m,h.usedParams=this.getUsedParamsDetails(n),h):m}extendTranslation(e,n,r,i,s){var u,p;var o=this;if((u=this.i18nFormat)!=null&&u.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const h=ne(e)&&(((p=r==null?void 0:r.interpolation)==null?void 0:p.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(h){const f=e.match(this.interpolator.nestingRegexp);m=f&&f.length}let y=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(y={...this.options.interpolation.defaultVariables,...y}),e=this.interpolator.interpolate(e,y,r.lng||this.language||i.usedLng,r),h){const f=e.match(this.interpolator.nestingRegexp),_=f&&f.length;m<_&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var f=arguments.length,_=new Array(f),v=0;v<f;v++)_[v]=arguments[v];return(s==null?void 0:s[0])===_[0]&&!r.context?(o.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):o.translate(..._,n)},r)),r.interpolation&&this.interpolator.reset()}const c=r.postProcess||this.options.postProcess,l=ne(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&r.applyPostProcessor!==!1&&(e=Dp.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,o,c;return ne(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),p=u.key;i=p;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),y=m&&!n.ordinal&&n.count===0,f=n.context!==void 0&&(ne(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(v=>{var x,N;this.isValidLookup(r)||(c=v,!vu[`${_[0]}-${v}`]&&((x=this.utils)!=null&&x.hasLoadedNamespace)&&!((N=this.utils)!=null&&N.hasLoadedNamespace(c))&&(vu[`${_[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${_.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(B=>{var pe;if(this.isValidLookup(r))return;o=B;const R=[p];if((pe=this.i18nFormat)!=null&&pe.addLookupKeys)this.i18nFormat.addLookupKeys(R,p,B,v,n);else{let le;m&&(le=this.pluralResolver.getSuffix(B,n.count,n));const Ue=`${this.options.pluralSeparator}zero`,ot=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(R.push(p+le),n.ordinal&&le.indexOf(ot)===0&&R.push(p+le.replace(ot,this.options.pluralSeparator)),y&&R.push(p+Ue)),f){const We=`${p}${this.options.contextSeparator}${n.context}`;R.push(We),m&&(R.push(We+le),n.ordinal&&le.indexOf(ot)===0&&R.push(We+le.replace(ot,this.options.pluralSeparator)),y&&R.push(We+Ue))}}let te;for(;te=R.pop();)this.isValidLookup(r)||(s=te,r=this.getResource(B,v,te,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var s;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!ne(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class wu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=wt.create("languageUtils")}getScriptPartFromCode(e){if(e=Mi(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Mi(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ne(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&(s.indexOf("-")>0&&i.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===i||s.indexOf(i)===0&&i.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),ne(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return ne(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):ne(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const bu={zero:0,one:1,two:2,few:3,many:4,other:5},ku={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Am{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=wt.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=Mi(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ku;if(!e.match(/-|_/))return ku;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>bu[i]-bu[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const xu=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=_m(t,e,n);return!s&&i&&ne(n)&&(s=da(t,n,r),s===void 0&&(s=da(e,n,r))),s},qo=t=>t.replace(/\$/g,"$$$$");class Em{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=wt.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(r=>r),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:y,nestingSuffix:f,nestingSuffixEscaped:_,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:N}=e.interpolation;this.escape=n!==void 0?n:vm,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?zn(s):o||"{{",this.suffix=c?zn(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?zn(m):y||zn("$t("),this.nestingSuffix=f?zn(f):_||zn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||1e3,this.alwaysFormat=N!==void 0?N:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>(n==null?void 0:n.source)===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,n,r,i){var y;let s,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=f=>{if(f.indexOf(this.formatSeparator)<0){const N=xu(n,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(N,void 0,r,{...i,...n,interpolationkey:f}):N}const _=f.split(this.formatSeparator),v=_.shift().trim(),x=_.join(this.formatSeparator).trim();return this.format(xu(n,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const p=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((y=i==null?void 0:i.interpolation)==null?void 0:y.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:f=>qo(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?qo(this.escape(f)):qo(f)}].forEach(f=>{for(c=0;s=f.regex.exec(e);){const _=s[1].trim();if(o=u(_),o===void 0)if(typeof p=="function"){const x=p(e,s,i);o=ne(x)?x:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!ne(o)&&!this.useRawValueToEscape&&(o=hu(o));const v=f.safeValue(o);if(e=e.replace(s[0],v),h?(f.regex.lastIndex+=o.length,f.regex.lastIndex-=s[0].length):f.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,o;const c=(l,u)=>{const p=this.nestingOptionsSeparator;if(l.indexOf(p)<0)return l;const h=l.split(new RegExp(`${p}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,o);const y=m.match(/'/g),f=m.match(/"/g);(((y==null?void 0:y.length)??0)%2===0&&!f||f.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];o={...r},o=o.replace&&!ne(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const p=i[1].split(this.formatSeparator).map(h=>h.trim());i[1]=p.shift(),l=p,u=!0}if(s=n(c.call(this,i[1].trim(),o),o),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=hu(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((p,h)=>this.format(p,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Im=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[c,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},jn=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let c=e[o];return c||(c=t(Mi(r),i),e[o]=c),c(n)}};class Cm{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=wt.create("formatter"),this.options=e,this.formats={number:jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:jn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:jn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:jn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=jn(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(c=>c.indexOf(")")>-1)){const c=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,l)=>{var h;const{formatName:u,formatOptions:p}=Im(l);if(this.formats[u]){let m=c;try{const y=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},f=y.locale||y.lng||i.locale||i.lng||r;m=this.formats[u](c,f,{...p,...i,...y})}catch(y){this.logger.warn(y)}return m}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const Nm=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class $m extends Rs{constructor(e,n,r){var s,o;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=wt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(o=(s=this.backend)==null?void 0:s.init)==null||o.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},c={},l={};return e.forEach(u=>{let p=!0;n.forEach(h=>{const m=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,p=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),l[h]===void 0&&(l[h]=!0)))}),p||(c[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(l=>{mm(l.loaded,[s],o),Nm(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{c[u]||(c[u]={});const p=l.loaded[u];p.length&&p.forEach(h=>{c[u][h]===void 0&&(c[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const c=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(u,p)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,n,c)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();ne(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ne(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,c)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,o,c)})}saveMissing(e,n,r,i,s){var l,u,p,h,m;let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(p=this.services)==null?void 0:p.utils)!=null&&h.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if((m=this.backend)!=null&&m.create){const y={...o,isUpdate:s},f=this.backend.create.bind(this.backend);if(f.length<6)try{let _;f.length===5?_=f(e,n,r,i,y):_=f(e,n,r,i),_&&typeof _.then=="function"?_.then(v=>c(null,v)).catch(c):c(null,_)}catch(_){c(_)}else f(e,n,r,i,c,y)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const Su=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ne(t[1])&&(e.defaultValue=t[1]),ne(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Au=t=>{var e,n;return ne(t.ns)&&(t.ns=[t.ns]),ne(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ne(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),((n=(e=t.supportedLngs)==null?void 0:e.indexOf)==null?void 0:n.call(e,"cimode"))<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t},vi=()=>{},zm=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Nr extends Rs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Au(e),this.services={},this.logger=wt,this.modules={external:[]},zm(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(ne(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Su();this.options={...i,...this.options,...Au(n)},this.options.interpolation={...i.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?wt.init(s(this.modules.logger),this.options):wt.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Cm;const h=new wu(this.options);this.store=new yu(this.options.resources,this.options);const m=this.services;m.logger=wt,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new Am(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=s(p),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new Em(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new $m(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(y){for(var f=arguments.length,_=new Array(f>1?f-1:0),v=1;v<f;v++)_[v-1]=arguments[v];e.emit(y,..._)}),this.modules.languageDetector&&(m.languageDetector=s(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=s(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new Di(this.services,this.options),this.translator.on("*",function(y){for(var f=arguments.length,_=new Array(f>1?f-1:0),v=1;v<f;v++)_[v-1]=arguments[v];e.emit(y,..._)}),this.modules.external.forEach(y=>{y.init&&y.init(this)})}if(this.format=this.options.interpolation.format,r||(r=vi),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return e.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return e.store[p](...arguments),e}});const l=gr(),u=()=>{const p=(h,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(m),r(h,m)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),l}loadResources(e){var s,o;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vi;const i=ne(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&c.indexOf(h)<0&&c.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.call(s,u=>l(u)),this.services.backendConnector.load(c,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(u)})}else r(null)}reloadResources(e,n,r){const i=gr();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=vi),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Dp.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=gr();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},c=l=>{var p,h;!e&&!l&&this.services.languageDetector&&(l=[]);const u=ne(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(h=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||h.call(p,u)),this.loadResources(u,m=>{o(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(e),i}getFixedT(e,n,r){var i=this;const s=function(o,c){let l;if(typeof c!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),h=2;h<u;h++)p[h-2]=arguments[h];l=i.options.overloadTranslationOptionHandler([o,c].concat(p))}else l={...c};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||s.keyPrefix);const m=i.options.keySeparator||".";let y;return l.keyPrefix&&Array.isArray(o)?y=o.map(f=>`${l.keyPrefix}${m}${f}`):y=l.keyPrefix?`${l.keyPrefix}${m}${o}`:o,i.t(y,l)};return ne(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.translate(...n)}exists(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(c,l)=>{const u=this.services.backendConnector.state[`${c}|${l}`];return u===-1||u===0||u===2};if(n.precheck){const c=n.precheck(this,o);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=gr();return this.options.ns?(ne(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=gr();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){var i,s;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=((s=this.services)==null?void 0:s.languageUtils)||new wu(Su());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new Nr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vi;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Nr(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(c=>{s[c]=this[c]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const c=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},Object.keys(l[u]).reduce((p,h)=>(p[h]={...l[u][h]},p),{})),{});s.store=new yu(c,i),s.services.resourceStore=s.store}return s.translator=new Di(s.services,i),s.translator.on("*",function(c){for(var l=arguments.length,u=new Array(l>1?l-1:0),p=1;p<l;p++)u[p-1]=arguments[p];s.emit(c,...u)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Y=Nr.createInstance();Y.createInstance=Nr.createInstance;Y.createInstance;Y.dir;Y.init;Y.loadResources;Y.reloadResources;Y.use;Y.changeLanguage;Y.getFixedT;const fe=Y.t;Y.exists;Y.setDefaultNamespace;Y.hasLoadedNamespace;Y.loadNamespaces;Y.loadLanguages;const Yt=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),Mc=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),Fp=a.z.object({email:a.z.string().optional(),email_verified:a.z.boolean().optional(),name:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),phone_number:a.z.string().optional(),phone_verified:a.z.boolean().optional(),family_name:a.z.string().optional()}).catchall(a.z.any()),Hp=a.z.object({connection:a.z.string(),user_id:a.z.string(),provider:a.z.string(),isSocial:a.z.boolean(),access_token:a.z.string().optional(),access_token_secret:a.z.string().optional(),refresh_token:a.z.string().optional(),profileData:Fp.optional()}),Ls=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),nickname:a.z.string().optional(),name:a.z.string().optional(),picture:a.z.string().optional(),locale:a.z.string().optional(),linked_to:a.z.string().optional(),profileData:a.z.string().optional(),user_id:a.z.string().optional(),app_metadata:a.z.any().default({}).optional(),user_metadata:a.z.any().default({}).optional()}),Fi=Ls.extend({email_verified:a.z.boolean().default(!1),verify_email:a.z.boolean().optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string().optional(),provider:a.z.string().default("email"),connection:a.z.string().default("email"),is_social:a.z.boolean().optional()}),qc=a.z.object({...Fi.shape,...Mc.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(Hp).optional()}),vt=qc,jm=Ls.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any()),Om="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Bm=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Om[n[t]&63];return e};const Kp=a.z.object({audience:a.z.string().optional(),recipient:a.z.string().optional(),createUpnClaim:a.z.boolean().optional(),mapUnknownClaimsAsIs:a.z.boolean().optional(),passthroughClaimsWithNoMapping:a.z.boolean().optional(),mapIdentities:a.z.boolean().optional(),signatureAlgorithm:a.z.string().optional(),digestAlgorithm:a.z.string().optional(),issuer:a.z.string().optional(),destination:a.z.string().optional(),lifetimeInSeconds:a.z.number().optional(),signResponse:a.z.boolean().optional(),nameIdentifierFormat:a.z.string().optional(),nameIdentifierProbes:a.z.array(a.z.string()).optional(),authnContextClassRef:a.z.string().optional(),mappings:a.z.record(a.z.string()).optional()}),Hi=a.z.object({id:a.z.string(),name:a.z.string(),callbacks:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:a.z.array(a.z.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:a.z.object({samlp:Kp.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:a.z.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:a.z.string().default(()=>Bm()).optional(),disable_sign_ups:a.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),on=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Hi.shape});var fn=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(fn||{}),Wt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Wt||{}),Us=(t=>(t.S256="S256",t.Plain="plain",t))(Us||{});const Dc=a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(fn).optional(),response_mode:a.z.nativeEnum(Wt).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),state:a.z.string().optional(),nonce:a.z.string().optional(),scope:a.z.string().optional(),prompt:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Us).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),pa=a.z.object({colors:a.z.object({primary:a.z.string(),page_background:a.z.object({type:a.z.string().optional(),start:a.z.string().optional(),end:a.z.string().optional(),angle_deg:a.z.number().optional()}).optional()}).optional(),logo_url:a.z.string().optional(),favicon_url:a.z.string().optional(),font:a.z.object({url:a.z.string()}).optional()}),Ki=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:a.z.object({kid:a.z.string().optional(),team_id:a.z.string().optional(),realms:a.z.string().optional(),client_id:a.z.string().optional(),client_secret:a.z.string().optional(),app_secret:a.z.string().optional(),scope:a.z.string().optional(),authorization_endpoint:a.z.string().default("").optional(),token_endpoint:a.z.string().default("").optional(),userinfo_endpoint:a.z.string().default("").optional(),jwks_uri:a.z.string().default("").optional(),discovery_url:a.z.string().default("").optional(),issuer:a.z.string().default("").optional()}).default({}).optional(),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),Mt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t)}).extend(Ki.shape),Wi=a.z.object({name:a.z.string(),audience:a.z.string(),sender_email:a.z.string().email(),sender_name:a.z.string(),support_url:a.z.string().url().optional(),logo:a.z.string().url().optional(),primary_color:a.z.string().optional(),secondary_color:a.z.string().optional(),language:a.z.string().optional(),id:a.z.string().optional()}),Rn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Wi.shape,id:a.z.string()}),Wp=a.z.object({logoUrl:a.z.string(),loginBackgroundImage:a.z.string().nullish(),style:a.z.object({primaryColor:a.z.string(),buttonTextColor:a.z.string(),primaryHoverColor:a.z.string()}),supportEmail:a.z.string().nullable(),supportUrl:a.z.string().nullable(),name:a.z.string(),showGreyishBackground:a.z.boolean().optional(),termsAndConditionsUrl:a.z.string().nullable(),companyName:a.z.string().optional(),checkoutHideSocial:a.z.boolean().optional(),siteUrl:a.z.string().nullable(),manageSubscriptionsUrl:a.z.string().optional()}),Tm=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()});a.z.object({...on.shape,domains:a.z.array(Tm),tenant:Rn,connections:a.z.array(Mt)});const Gp=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Jp=a.z.object({code_id:a.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:a.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:a.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:Gp,code_verifier:a.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:a.z.string(),used_at:a.z.string().optional(),user_id:a.z.string().optional()}),Pm=a.z.object({...Jp.shape,created_at:a.z.string()}),Zp=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()}),Rm=Mc.extend({...Zp.shape,id:a.z.string()}),Gi=a.z.object({trigger_id:a.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:a.z.boolean().default(!1),url:a.z.string(),hook_id:a.z.string().optional(),synchronous:a.z.boolean().default(!1),priority:a.z.number().optional()}),Tn=Gi.extend({...Mc.shape,hook_id:a.z.string()}),Fc=a.z.object({alg:a.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:a.z.string(),kid:a.z.string(),kty:a.z.enum(["RSA","EC","oct"]),n:a.z.string(),x5t:a.z.string().optional(),x5c:a.z.array(a.z.string()).optional(),use:a.z.enum(["sig","enc"]).optional()}),Yp=a.z.object({keys:a.z.array(Fc)}),fa=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),device_authorization_endpoint:a.z.string(),userinfo_endpoint:a.z.string(),mfa_challenge_endpoint:a.z.string(),jwks_uri:a.z.string(),registration_endpoint:a.z.string(),revocation_endpoint:a.z.string(),scopes_supported:a.z.array(a.z.string()),response_types_supported:a.z.array(a.z.string()),code_challenge_methods_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),token_endpoint_auth_methods_supported:a.z.array(a.z.string()),claims_supported:a.z.array(a.z.string()),request_uri_parameter_supported:a.z.boolean(),request_parameter_supported:a.z.boolean(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string())}),Xp=a.z.object({auth0Client:a.z.string().optional(),authParams:Dc,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),Lm=a.z.object({...Xp.shape,login_id:a.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:a.z.string(),updated_at:a.z.string()});var me=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(me||{});const Um=a.z.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Qp=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),Ji=a.z.object({type:Um,date:a.z.string(),description:a.z.string().optional(),log_id:a.z.string().optional(),_id:a.z.string().optional(),ip:a.z.string(),user_agent:a.z.string(),details:a.z.any().optional(),isMobile:a.z.boolean(),user_id:a.z.string().optional(),user_name:a.z.string().optional(),connection:a.z.string().optional(),connection_id:a.z.string().optional(),client_id:a.z.string().optional(),client_name:a.z.string().optional(),audience:a.z.string().optional(),scope:a.z.array(a.z.string()).optional(),strategy:a.z.string().optional(),strategy_type:a.z.string().optional(),hostname:a.z.string().optional(),auth0_client:Qp.optional()}),ef=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Vm=a.z.object({...ef.shape,created_at:a.z.string(),updated_at:a.z.string()}),tf=a.z.object({initial_user_agent:a.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:a.z.string().describe("First IP address associated with this session"),initial_asn:a.z.string().describe("First autonomous system number associated with this session"),last_user_agent:a.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:a.z.string().describe("Last IP address from which this user logged in"),last_asn:a.z.string().describe("Last autonomous system number from which this user logged in")}),nf=a.z.object({id:a.z.string(),revoked_at:a.z.string().optional(),used_at:a.z.string().optional(),user_id:a.z.string().describe("The user ID associated with the session"),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),device:tf.describe("Metadata related to the device used in the session"),clients:a.z.array(a.z.string()).describe("List of client details for the session")}),Vs=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...nf.shape}),ha=a.z.object({kid:a.z.string().openapi({description:"The key id of the signing key"}),cert:a.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:a.z.string().openapi({description:"The cert fingerprint"}),thumbprint:a.z.string().openapi({description:"The cert thumbprint"}),pkcs7:a.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:a.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:a.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:a.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:a.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:a.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:a.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:a.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var kr=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(kr||{});const rf=a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),scope:a.z.string().optional(),state:a.z.string().optional(),refresh_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number()});a.z.object({code:a.z.string(),state:a.z.string().optional()});const sf=a.z.object({button_border_radius:a.z.number(),button_border_weight:a.z.number(),buttons_style:a.z.enum(["pill"]),input_border_radius:a.z.number(),input_border_weight:a.z.number(),inputs_style:a.z.enum(["pill"]),show_widget_shadow:a.z.boolean(),widget_border_weight:a.z.number(),widget_corner_radius:a.z.number()}),of=a.z.object({base_focus_color:a.z.string(),base_hover_color:a.z.string(),body_text:a.z.string(),captcha_widget_theme:a.z.enum(["auto"]),error:a.z.string(),header:a.z.string(),icons:a.z.string(),input_background:a.z.string(),input_border:a.z.string(),input_filled_text:a.z.string(),input_labels_placeholders:a.z.string(),links_focused_components:a.z.string(),primary_button:a.z.string(),primary_button_label:a.z.string(),secondary_button_border:a.z.string(),secondary_button_label:a.z.string(),success:a.z.string(),widget_background:a.z.string(),widget_border:a.z.string()}),rn=a.z.object({bold:a.z.boolean(),size:a.z.number()}),af=a.z.object({body_text:rn,buttons_text:rn,font_url:a.z.string(),input_labels:rn,links:rn,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:rn,title:rn}),cf=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),lf=a.z.object({header_text_alignment:a.z.enum(["center"]),logo_height:a.z.number(),logo_position:a.z.enum(["center"]),logo_url:a.z.string(),social_buttons_layout:a.z.enum(["bottom"])}),uf=a.z.object({borders:sf,colors:of,displayName:a.z.string(),fonts:af,page_background:cf,widget:lf}),Mm=uf.extend({themeId:a.z.string()}),Ii=a.z.object({universal_login_experience:a.z.enum(["new","classic"]).default("new"),identifier_first:a.z.boolean().default(!0),password_first:a.z.boolean().default(!1),webauthn_platform_first_factor:a.z.boolean()}),Ci=a.z.object({name:a.z.string(),enabled:a.z.boolean().optional().default(!0),default_from_address:a.z.string().optional(),credentials:a.z.union([a.z.object({accessKeyId:a.z.string(),secretAccessKey:a.z.string(),region:a.z.string()}),a.z.object({smtp_host:a.z.array(a.z.string()),smtp_port:a.z.number(),smtp_user:a.z.string(),smtp_pass:a.z.string()}),a.z.object({api_key:a.z.string(),domain:a.z.string().optional()}),a.z.object({connectionString:a.z.string()}),a.z.object({tenantId:a.z.string(),clientId:a.z.string(),clientSecret:a.z.string()})]),settings:a.z.object({}).optional()}),Hc=a.z.object({id:a.z.string(),session_id:a.z.string(),user_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),last_exchanged_at:a.z.string().optional(),device:tf,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),qm=a.z.object({created_at:a.z.string(),...Hc.shape});function Dm(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const Fm=new a.OpenAPIHono().openapi(a.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pa}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.branding.get(e);return n?t.json(n):t.json({})}).openapi(a.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(pa.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.branding.set(e,n),t.text("OK")});var O=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});ee(this,"res");ee(this,"status");this.res=n==null?void 0:n.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},Zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function df(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Hm(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}function Km(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pf={exports:{}};const Wm={},Gm=Object.freeze(Object.defineProperty({__proto__:null,default:Wm},Symbol.toStringTag,{value:"Module"})),Jm=Hm(Gm);(function(t){/**
|
|
1
|
+
"use strict";var fm=Object.defineProperty;var hm=(t,e,n)=>e in t?fm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ee=(t,e,n)=>hm(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),ne=t=>typeof t=="string",gr=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},hu=t=>t==null?"":""+t,gm=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},mm=/###/g,gu=t=>t&&t.indexOf("###")>-1?t.replace(mm,"."):t,mu=t=>!t||ne(t),br=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(mu(t))return{};const s=gu(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return mu(t)?{}:{obj:t,k:gu(r[i])}},_u=(t,e,n)=>{const{obj:r,k:i}=br(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=br(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=br(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},_m=(t,e,n,r)=>{const{obj:i,k:s}=br(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Vi=(t,e)=>{const{obj:n,k:r}=br(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},ym=(t,e,n)=>{const r=Vi(t,n);return r!==void 0?r:Vi(e,n)},Dp=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ne(t[r])||t[r]instanceof String||ne(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):Dp(t[r],e[r],n):t[r]=e[r]);return t},zn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var vm={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const wm=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>vm[e]):t;class bm{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const km=[" ",",","?","!",";"],xm=new bm(20),Sm=(t,e,n)=>{e=e||"",n=n||"";const r=km.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=xm.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},da=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let o,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],o=i[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=o}return i},Mi=t=>t==null?void 0:t.replace("_","-"),Am={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,r;(r=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||r.call(n,console,e)}};class qi{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||Am,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(ne(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new qi(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new qi(this.logger,e)}}var wt=new qi;class Rs{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c.apply(c,[e,...r])})}}class yu extends Rs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){var u,p;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&s?c.push(...r.split(s)):c.push(r)));const l=Vi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!o||!ne(r)?l:da((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),_u(this.data,c,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(ne(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let l=Vi(this.data,c)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Dp(l,r,s):l={...l,...r},_u(this.data,c,l),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var Fp={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,n,r,i))??e}),e}};const vu={};class Di extends Rs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),gm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=wt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const r=this.resolve(e,n);return(r==null?void 0:r.res)!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Sm(e,r,i);if(o&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ne(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:ne(s)?[s]:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const R=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${R}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${R}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const h=this.resolve(e,n);let m=h==null?void 0:h.res;const y=(h==null?void 0:h.usedKey)||o,f=(h==null?void 0:h.exactUsedKey)||o,_=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],x=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,B=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(N&&m&&B&&v.indexOf(_)<0&&!(ne(x)&&Array.isArray(m))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,m,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=R,h.usedParams=this.getUsedParamsDetails(n),h):R}if(s){const R=Array.isArray(m),te=R?[]:{},pe=R?f:y;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const Ue=`${pe}${s}${le}`;te[le]=this.translate(Ue,{...n,joinArrays:!1,ns:c}),te[le]===Ue&&(te[le]=m[le])}m=te}}else if(N&&ne(x)&&Array.isArray(m))m=m.join(x),m&&(m=this.extendTranslation(m,e,n,r));else{let R=!1,te=!1;const pe=n.count!==void 0&&!ne(n.count),le=Di.hasDefaultValue(n),Ue=pe?this.pluralResolver.getSuffix(u,n.count,n):"",ot=n.ordinal&&pe?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",We=pe&&!n.ordinal&&n.count===0,$=We&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Ue}`]||n[`defaultValue${ot}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(R=!0,m=$),this.isValidLookup(m)||(te=!0,m=o);const A=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&te?void 0:m,k=le&&$!==m&&this.options.updateMissing;if(te||R||k){if(this.logger.log(k?"updateKey":"missingKey",u,l,o,k?$:m),s){const X=this.resolve(o,{...n,keySeparator:!1});X&&X.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let b=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let X=0;X<z.length;X++)b.push(z[X]);else this.options.saveMissingTo==="all"?b=this.languageUtils.toResolveHierarchy(n.lng||this.language):b.push(n.lng||this.language);const L=(X,W,ie)=>{var D;const ce=le&&ie!==m?ie:A;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,W,ce,k,n):(D=this.backendConnector)!=null&&D.saveMissing&&this.backendConnector.saveMissing(X,l,W,ce,k,n),this.emit("missingKey",X,l,W,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&pe?b.forEach(X=>{const W=this.pluralResolver.getSuffixes(X,n);We&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ie=>{L([X],o+ie,n[`defaultValue${ie}`]||$)})}):L(b,o,$))}m=this.extendTranslation(m,e,n,h,r),te&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${o}`),(te||R)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,R?m:void 0))}return i?(h.res=m,h.usedParams=this.getUsedParamsDetails(n),h):m}extendTranslation(e,n,r,i,s){var u,p;var o=this;if((u=this.i18nFormat)!=null&&u.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const h=ne(e)&&(((p=r==null?void 0:r.interpolation)==null?void 0:p.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(h){const f=e.match(this.interpolator.nestingRegexp);m=f&&f.length}let y=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(y={...this.options.interpolation.defaultVariables,...y}),e=this.interpolator.interpolate(e,y,r.lng||this.language||i.usedLng,r),h){const f=e.match(this.interpolator.nestingRegexp),_=f&&f.length;m<_&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var f=arguments.length,_=new Array(f),v=0;v<f;v++)_[v]=arguments[v];return(s==null?void 0:s[0])===_[0]&&!r.context?(o.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):o.translate(..._,n)},r)),r.interpolation&&this.interpolator.reset()}const c=r.postProcess||this.options.postProcess,l=ne(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&r.applyPostProcessor!==!1&&(e=Fp.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,o,c;return ne(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),p=u.key;i=p;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),y=m&&!n.ordinal&&n.count===0,f=n.context!==void 0&&(ne(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(v=>{var x,N;this.isValidLookup(r)||(c=v,!vu[`${_[0]}-${v}`]&&((x=this.utils)!=null&&x.hasLoadedNamespace)&&!((N=this.utils)!=null&&N.hasLoadedNamespace(c))&&(vu[`${_[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${_.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(B=>{var pe;if(this.isValidLookup(r))return;o=B;const R=[p];if((pe=this.i18nFormat)!=null&&pe.addLookupKeys)this.i18nFormat.addLookupKeys(R,p,B,v,n);else{let le;m&&(le=this.pluralResolver.getSuffix(B,n.count,n));const Ue=`${this.options.pluralSeparator}zero`,ot=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(R.push(p+le),n.ordinal&&le.indexOf(ot)===0&&R.push(p+le.replace(ot,this.options.pluralSeparator)),y&&R.push(p+Ue)),f){const We=`${p}${this.options.contextSeparator}${n.context}`;R.push(We),m&&(R.push(We+le),n.ordinal&&le.indexOf(ot)===0&&R.push(We+le.replace(ot,this.options.pluralSeparator)),y&&R.push(We+Ue))}}let te;for(;te=R.pop();)this.isValidLookup(r)||(s=te,r=this.getResource(B,v,te,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var s;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!ne(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class wu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=wt.create("languageUtils")}getScriptPartFromCode(e){if(e=Mi(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Mi(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ne(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&(s.indexOf("-")>0&&i.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===i||s.indexOf(i)===0&&i.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),ne(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return ne(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):ne(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const bu={zero:0,one:1,two:2,few:3,many:4,other:5},ku={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Em{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=wt.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=Mi(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ku;if(!e.match(/-|_/))return ku;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>bu[i]-bu[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const xu=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=ym(t,e,n);return!s&&i&&ne(n)&&(s=da(t,n,r),s===void 0&&(s=da(e,n,r))),s},qo=t=>t.replace(/\$/g,"$$$$");class Im{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=wt.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(r=>r),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:y,nestingSuffix:f,nestingSuffixEscaped:_,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:N}=e.interpolation;this.escape=n!==void 0?n:wm,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?zn(s):o||"{{",this.suffix=c?zn(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?zn(m):y||zn("$t("),this.nestingSuffix=f?zn(f):_||zn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||1e3,this.alwaysFormat=N!==void 0?N:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>(n==null?void 0:n.source)===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,n,r,i){var y;let s,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=f=>{if(f.indexOf(this.formatSeparator)<0){const N=xu(n,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(N,void 0,r,{...i,...n,interpolationkey:f}):N}const _=f.split(this.formatSeparator),v=_.shift().trim(),x=_.join(this.formatSeparator).trim();return this.format(xu(n,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const p=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((y=i==null?void 0:i.interpolation)==null?void 0:y.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:f=>qo(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?qo(this.escape(f)):qo(f)}].forEach(f=>{for(c=0;s=f.regex.exec(e);){const _=s[1].trim();if(o=u(_),o===void 0)if(typeof p=="function"){const x=p(e,s,i);o=ne(x)?x:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!ne(o)&&!this.useRawValueToEscape&&(o=hu(o));const v=f.safeValue(o);if(e=e.replace(s[0],v),h?(f.regex.lastIndex+=o.length,f.regex.lastIndex-=s[0].length):f.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,o;const c=(l,u)=>{const p=this.nestingOptionsSeparator;if(l.indexOf(p)<0)return l;const h=l.split(new RegExp(`${p}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,o);const y=m.match(/'/g),f=m.match(/"/g);(((y==null?void 0:y.length)??0)%2===0&&!f||f.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];o={...r},o=o.replace&&!ne(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const p=i[1].split(this.formatSeparator).map(h=>h.trim());i[1]=p.shift(),l=p,u=!0}if(s=n(c.call(this,i[1].trim(),o),o),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=hu(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((p,h)=>this.format(p,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Cm=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[c,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},jn=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let c=e[o];return c||(c=t(Mi(r),i),e[o]=c),c(n)}};class Nm{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=wt.create("formatter"),this.options=e,this.formats={number:jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:jn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:jn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:jn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=jn(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(c=>c.indexOf(")")>-1)){const c=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,l)=>{var h;const{formatName:u,formatOptions:p}=Cm(l);if(this.formats[u]){let m=c;try{const y=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},f=y.locale||y.lng||i.locale||i.lng||r;m=this.formats[u](c,f,{...p,...i,...y})}catch(y){this.logger.warn(y)}return m}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const $m=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class zm extends Rs{constructor(e,n,r){var s,o;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=wt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(o=(s=this.backend)==null?void 0:s.init)==null||o.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},c={},l={};return e.forEach(u=>{let p=!0;n.forEach(h=>{const m=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,p=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),l[h]===void 0&&(l[h]=!0)))}),p||(c[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(l=>{_m(l.loaded,[s],o),$m(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{c[u]||(c[u]={});const p=l.loaded[u];p.length&&p.forEach(h=>{c[u][h]===void 0&&(c[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const c=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(u,p)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,n,c)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();ne(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ne(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,c)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,o,c)})}saveMissing(e,n,r,i,s){var l,u,p,h,m;let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(p=this.services)==null?void 0:p.utils)!=null&&h.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if((m=this.backend)!=null&&m.create){const y={...o,isUpdate:s},f=this.backend.create.bind(this.backend);if(f.length<6)try{let _;f.length===5?_=f(e,n,r,i,y):_=f(e,n,r,i),_&&typeof _.then=="function"?_.then(v=>c(null,v)).catch(c):c(null,_)}catch(_){c(_)}else f(e,n,r,i,c,y)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const Su=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ne(t[1])&&(e.defaultValue=t[1]),ne(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Au=t=>{var e,n;return ne(t.ns)&&(t.ns=[t.ns]),ne(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ne(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),((n=(e=t.supportedLngs)==null?void 0:e.indexOf)==null?void 0:n.call(e,"cimode"))<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t},vi=()=>{},jm=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Nr extends Rs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Au(e),this.services={},this.logger=wt,this.modules={external:[]},jm(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(ne(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Su();this.options={...i,...this.options,...Au(n)},this.options.interpolation={...i.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?wt.init(s(this.modules.logger),this.options):wt.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Nm;const h=new wu(this.options);this.store=new yu(this.options.resources,this.options);const m=this.services;m.logger=wt,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new Em(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=s(p),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new Im(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new zm(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(y){for(var f=arguments.length,_=new Array(f>1?f-1:0),v=1;v<f;v++)_[v-1]=arguments[v];e.emit(y,..._)}),this.modules.languageDetector&&(m.languageDetector=s(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=s(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new Di(this.services,this.options),this.translator.on("*",function(y){for(var f=arguments.length,_=new Array(f>1?f-1:0),v=1;v<f;v++)_[v-1]=arguments[v];e.emit(y,..._)}),this.modules.external.forEach(y=>{y.init&&y.init(this)})}if(this.format=this.options.interpolation.format,r||(r=vi),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return e.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return e.store[p](...arguments),e}});const l=gr(),u=()=>{const p=(h,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(m),r(h,m)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),l}loadResources(e){var s,o;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vi;const i=ne(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&c.indexOf(h)<0&&c.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.call(s,u=>l(u)),this.services.backendConnector.load(c,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(u)})}else r(null)}reloadResources(e,n,r){const i=gr();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=vi),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Fp.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=gr();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},c=l=>{var p,h;!e&&!l&&this.services.languageDetector&&(l=[]);const u=ne(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(h=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||h.call(p,u)),this.loadResources(u,m=>{o(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(e),i}getFixedT(e,n,r){var i=this;const s=function(o,c){let l;if(typeof c!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),h=2;h<u;h++)p[h-2]=arguments[h];l=i.options.overloadTranslationOptionHandler([o,c].concat(p))}else l={...c};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||s.keyPrefix);const m=i.options.keySeparator||".";let y;return l.keyPrefix&&Array.isArray(o)?y=o.map(f=>`${l.keyPrefix}${m}${f}`):y=l.keyPrefix?`${l.keyPrefix}${m}${o}`:o,i.t(y,l)};return ne(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.translate(...n)}exists(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(c,l)=>{const u=this.services.backendConnector.state[`${c}|${l}`];return u===-1||u===0||u===2};if(n.precheck){const c=n.precheck(this,o);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=gr();return this.options.ns?(ne(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=gr();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){var i,s;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=((s=this.services)==null?void 0:s.languageUtils)||new wu(Su());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new Nr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vi;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Nr(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(c=>{s[c]=this[c]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const c=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},Object.keys(l[u]).reduce((p,h)=>(p[h]={...l[u][h]},p),{})),{});s.store=new yu(c,i),s.services.resourceStore=s.store}return s.translator=new Di(s.services,i),s.translator.on("*",function(c){for(var l=arguments.length,u=new Array(l>1?l-1:0),p=1;p<l;p++)u[p-1]=arguments[p];s.emit(c,...u)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Y=Nr.createInstance();Y.createInstance=Nr.createInstance;Y.createInstance;Y.dir;Y.init;Y.loadResources;Y.reloadResources;Y.use;Y.changeLanguage;Y.getFixedT;const fe=Y.t;Y.exists;Y.setDefaultNamespace;Y.hasLoadedNamespace;Y.loadNamespaces;Y.loadLanguages;const Yt=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),Mc=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),Hp=a.z.object({email:a.z.string().optional(),email_verified:a.z.boolean().optional(),name:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),phone_number:a.z.string().optional(),phone_verified:a.z.boolean().optional(),family_name:a.z.string().optional()}).catchall(a.z.any()),Kp=a.z.object({connection:a.z.string(),user_id:a.z.string(),provider:a.z.string(),isSocial:a.z.boolean(),access_token:a.z.string().optional(),access_token_secret:a.z.string().optional(),refresh_token:a.z.string().optional(),profileData:Hp.optional()}),Ls=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),nickname:a.z.string().optional(),name:a.z.string().optional(),picture:a.z.string().optional(),locale:a.z.string().optional(),linked_to:a.z.string().optional(),profileData:a.z.string().optional(),user_id:a.z.string().optional(),app_metadata:a.z.any().default({}).optional(),user_metadata:a.z.any().default({}).optional()}),Fi=Ls.extend({email_verified:a.z.boolean().default(!1),verify_email:a.z.boolean().optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string().optional(),provider:a.z.string().default("email"),connection:a.z.string().default("email"),is_social:a.z.boolean().optional()}),qc=a.z.object({...Fi.shape,...Mc.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(Kp).optional()}),vt=qc,Om=Ls.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any()),Bm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Tm=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Bm[n[t]&63];return e};const Wp=a.z.object({audience:a.z.string().optional(),recipient:a.z.string().optional(),createUpnClaim:a.z.boolean().optional(),mapUnknownClaimsAsIs:a.z.boolean().optional(),passthroughClaimsWithNoMapping:a.z.boolean().optional(),mapIdentities:a.z.boolean().optional(),signatureAlgorithm:a.z.string().optional(),digestAlgorithm:a.z.string().optional(),issuer:a.z.string().optional(),destination:a.z.string().optional(),lifetimeInSeconds:a.z.number().optional(),signResponse:a.z.boolean().optional(),nameIdentifierFormat:a.z.string().optional(),nameIdentifierProbes:a.z.array(a.z.string()).optional(),authnContextClassRef:a.z.string().optional(),mappings:a.z.record(a.z.string()).optional()}),Hi=a.z.object({id:a.z.string(),name:a.z.string(),callbacks:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:a.z.array(a.z.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:a.z.object({samlp:Wp.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:a.z.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:a.z.string().default(()=>Tm()).optional(),disable_sign_ups:a.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),on=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Hi.shape});var fn=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(fn||{}),Wt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Wt||{}),Us=(t=>(t.S256="S256",t.Plain="plain",t))(Us||{});const Dc=a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(fn).optional(),response_mode:a.z.nativeEnum(Wt).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),state:a.z.string().optional(),nonce:a.z.string().optional(),scope:a.z.string().optional(),prompt:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Us).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),pa=a.z.object({colors:a.z.object({primary:a.z.string(),page_background:a.z.object({type:a.z.string().optional(),start:a.z.string().optional(),end:a.z.string().optional(),angle_deg:a.z.number().optional()}).optional()}).optional(),logo_url:a.z.string().optional(),favicon_url:a.z.string().optional(),font:a.z.object({url:a.z.string()}).optional()}),Ki=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:a.z.object({kid:a.z.string().optional(),team_id:a.z.string().optional(),realms:a.z.string().optional(),client_id:a.z.string().optional(),client_secret:a.z.string().optional(),app_secret:a.z.string().optional(),scope:a.z.string().optional(),authorization_endpoint:a.z.string().default("").optional(),token_endpoint:a.z.string().default("").optional(),userinfo_endpoint:a.z.string().default("").optional(),jwks_uri:a.z.string().default("").optional(),discovery_url:a.z.string().default("").optional(),issuer:a.z.string().default("").optional()}).default({}).optional(),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),Mt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t)}).extend(Ki.shape),Wi=a.z.object({name:a.z.string(),audience:a.z.string(),sender_email:a.z.string().email(),sender_name:a.z.string(),support_url:a.z.string().url().optional(),logo:a.z.string().url().optional(),primary_color:a.z.string().optional(),secondary_color:a.z.string().optional(),language:a.z.string().optional(),id:a.z.string().optional()}),Rn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Wi.shape,id:a.z.string()}),Gp=a.z.object({logoUrl:a.z.string(),loginBackgroundImage:a.z.string().nullish(),style:a.z.object({primaryColor:a.z.string(),buttonTextColor:a.z.string(),primaryHoverColor:a.z.string()}),supportEmail:a.z.string().nullable(),supportUrl:a.z.string().nullable(),name:a.z.string(),showGreyishBackground:a.z.boolean().optional(),termsAndConditionsUrl:a.z.string().nullable(),companyName:a.z.string().optional(),checkoutHideSocial:a.z.boolean().optional(),siteUrl:a.z.string().nullable(),manageSubscriptionsUrl:a.z.string().optional()}),Pm=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()});a.z.object({...on.shape,domains:a.z.array(Pm),tenant:Rn,connections:a.z.array(Mt)});const Jp=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Zp=a.z.object({code_id:a.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:a.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:a.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:Jp,code_verifier:a.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:a.z.string(),used_at:a.z.string().optional(),user_id:a.z.string().optional()}),Rm=a.z.object({...Zp.shape,created_at:a.z.string()}),Yp=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()}),Lm=Mc.extend({...Yp.shape,id:a.z.string()}),Gi=a.z.object({trigger_id:a.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:a.z.boolean().default(!1),url:a.z.string(),hook_id:a.z.string().optional(),synchronous:a.z.boolean().default(!1),priority:a.z.number().optional()}),Tn=Gi.extend({...Mc.shape,hook_id:a.z.string()}),Fc=a.z.object({alg:a.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:a.z.string(),kid:a.z.string(),kty:a.z.enum(["RSA","EC","oct"]),n:a.z.string(),x5t:a.z.string().optional(),x5c:a.z.array(a.z.string()).optional(),use:a.z.enum(["sig","enc"]).optional()}),Xp=a.z.object({keys:a.z.array(Fc)}),fa=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),device_authorization_endpoint:a.z.string(),userinfo_endpoint:a.z.string(),mfa_challenge_endpoint:a.z.string(),jwks_uri:a.z.string(),registration_endpoint:a.z.string(),revocation_endpoint:a.z.string(),scopes_supported:a.z.array(a.z.string()),response_types_supported:a.z.array(a.z.string()),code_challenge_methods_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),token_endpoint_auth_methods_supported:a.z.array(a.z.string()),claims_supported:a.z.array(a.z.string()),request_uri_parameter_supported:a.z.boolean(),request_parameter_supported:a.z.boolean(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string())}),Qp=a.z.object({auth0Client:a.z.string().optional(),authParams:Dc,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),Um=a.z.object({...Qp.shape,login_id:a.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:a.z.string(),updated_at:a.z.string()});var me=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(me||{});const Vm=a.z.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),ef=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),Ji=a.z.object({type:Vm,date:a.z.string(),description:a.z.string().optional(),log_id:a.z.string().optional(),_id:a.z.string().optional(),ip:a.z.string(),user_agent:a.z.string(),details:a.z.any().optional(),isMobile:a.z.boolean(),user_id:a.z.string().optional(),user_name:a.z.string().optional(),connection:a.z.string().optional(),connection_id:a.z.string().optional(),client_id:a.z.string().optional(),client_name:a.z.string().optional(),audience:a.z.string().optional(),scope:a.z.array(a.z.string()).optional(),strategy:a.z.string().optional(),strategy_type:a.z.string().optional(),hostname:a.z.string().optional(),auth0_client:ef.optional()}),tf=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Mm=a.z.object({...tf.shape,created_at:a.z.string(),updated_at:a.z.string()}),nf=a.z.object({initial_user_agent:a.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:a.z.string().describe("First IP address associated with this session"),initial_asn:a.z.string().describe("First autonomous system number associated with this session"),last_user_agent:a.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:a.z.string().describe("Last IP address from which this user logged in"),last_asn:a.z.string().describe("Last autonomous system number from which this user logged in")}),rf=a.z.object({id:a.z.string(),revoked_at:a.z.string().optional(),used_at:a.z.string().optional(),user_id:a.z.string().describe("The user ID associated with the session"),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),device:nf.describe("Metadata related to the device used in the session"),clients:a.z.array(a.z.string()).describe("List of client details for the session")}),Vs=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...rf.shape}),ha=a.z.object({kid:a.z.string().openapi({description:"The key id of the signing key"}),cert:a.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:a.z.string().openapi({description:"The cert fingerprint"}),thumbprint:a.z.string().openapi({description:"The cert thumbprint"}),pkcs7:a.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:a.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:a.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:a.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:a.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:a.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:a.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:a.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var kr=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(kr||{});const sf=a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),scope:a.z.string().optional(),state:a.z.string().optional(),refresh_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number()});a.z.object({code:a.z.string(),state:a.z.string().optional()});const of=a.z.object({button_border_radius:a.z.number(),button_border_weight:a.z.number(),buttons_style:a.z.enum(["pill"]),input_border_radius:a.z.number(),input_border_weight:a.z.number(),inputs_style:a.z.enum(["pill"]),show_widget_shadow:a.z.boolean(),widget_border_weight:a.z.number(),widget_corner_radius:a.z.number()}),af=a.z.object({base_focus_color:a.z.string(),base_hover_color:a.z.string(),body_text:a.z.string(),captcha_widget_theme:a.z.enum(["auto"]),error:a.z.string(),header:a.z.string(),icons:a.z.string(),input_background:a.z.string(),input_border:a.z.string(),input_filled_text:a.z.string(),input_labels_placeholders:a.z.string(),links_focused_components:a.z.string(),primary_button:a.z.string(),primary_button_label:a.z.string(),secondary_button_border:a.z.string(),secondary_button_label:a.z.string(),success:a.z.string(),widget_background:a.z.string(),widget_border:a.z.string()}),rn=a.z.object({bold:a.z.boolean(),size:a.z.number()}),cf=a.z.object({body_text:rn,buttons_text:rn,font_url:a.z.string(),input_labels:rn,links:rn,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:rn,title:rn}),lf=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),uf=a.z.object({header_text_alignment:a.z.enum(["center"]),logo_height:a.z.number(),logo_position:a.z.enum(["center"]),logo_url:a.z.string(),social_buttons_layout:a.z.enum(["bottom"])}),df=a.z.object({borders:of,colors:af,displayName:a.z.string(),fonts:cf,page_background:lf,widget:uf}),qm=df.extend({themeId:a.z.string()}),Ii=a.z.object({universal_login_experience:a.z.enum(["new","classic"]).default("new"),identifier_first:a.z.boolean().default(!0),password_first:a.z.boolean().default(!1),webauthn_platform_first_factor:a.z.boolean()}),Ci=a.z.object({name:a.z.string(),enabled:a.z.boolean().optional().default(!0),default_from_address:a.z.string().optional(),credentials:a.z.union([a.z.object({accessKeyId:a.z.string(),secretAccessKey:a.z.string(),region:a.z.string()}),a.z.object({smtp_host:a.z.array(a.z.string()),smtp_port:a.z.number(),smtp_user:a.z.string(),smtp_pass:a.z.string()}),a.z.object({api_key:a.z.string(),domain:a.z.string().optional()}),a.z.object({connectionString:a.z.string()}),a.z.object({tenantId:a.z.string(),clientId:a.z.string(),clientSecret:a.z.string()})]),settings:a.z.object({}).optional()}),Hc=a.z.object({id:a.z.string(),session_id:a.z.string(),user_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),last_exchanged_at:a.z.string().optional(),device:nf,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),Dm=a.z.object({created_at:a.z.string(),...Hc.shape});function Fm(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const Hm=new a.OpenAPIHono().openapi(a.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pa}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.branding.get(e);return n?t.json(n):t.json({})}).openapi(a.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(pa.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.branding.set(e,n),t.text("OK")});var O=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});ee(this,"res");ee(this,"status");this.res=n==null?void 0:n.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},Zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Km(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}function Wm(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ff={exports:{}};const Gm={},Jm=Object.freeze(Object.defineProperty({__proto__:null,default:Gm},Symbol.toStringTag,{value:"Module"})),Zm=Km(Jm);(function(t){/**
|
|
2
2
|
* @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
3
3
|
* Released under the Apache License, Version 2.0
|
|
4
4
|
* see: https://github.com/dcodeIO/bcrypt.js for details
|
|
5
|
-
*/(function(e,n){typeof Km=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(Zi,function(){var e={},n=null;function r($){if(t&&t.exports)try{return Jm.randomBytes($)}catch{}try{var C;return(self.crypto||self.msCrypto).getRandomValues(C=new Uint32Array($)),Array.prototype.slice.call(C)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n($)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function($){n=$},e.genSaltSync=function($,C){if($=$||_,typeof $!="number")throw Error("Illegal arguments: "+typeof $+", "+typeof C);$<4?$=4:$>31&&($=31);var A=[];return A.push("$2a$"),$<10&&A.push("0"),A.push($.toString()),A.push("$"),A.push(h(r(f),f)),A.join("")},e.genSalt=function($,C,A){if(typeof C=="function"&&(A=C,C=void 0),typeof $=="function"&&(A=$,$=void 0),typeof $>"u")$=_;else if(typeof $!="number")throw Error("illegal arguments: "+typeof $);function k(b){o(function(){try{b(null,e.genSaltSync($))}catch(z){b(z)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);k(A)}else return new Promise(function(b,z){k(function(L,X){if(L){z(L);return}b(X)})})},e.hashSync=function($,C){if(typeof C>"u"&&(C=_),typeof C=="number"&&(C=e.genSaltSync(C)),typeof $!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof C);return We($,C)},e.hash=function($,C,A,k){function b(z){typeof $=="string"&&typeof C=="number"?e.genSalt(C,function(L,X){We($,X,z,k)}):typeof $=="string"&&typeof C=="string"?We($,C,z,k):o(z.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof C)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);b(A)}else return new Promise(function(z,L){b(function(X,W){if(X){L(X);return}z(W)})})};function s($,C){for(var A=0,k=0,b=0,z=$.length;b<z;++b)$.charCodeAt(b)===C.charCodeAt(b)?++A:++k;return A<0?!1:k===0}e.compareSync=function($,C){if(typeof $!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof C);return C.length!==60?!1:s(e.hashSync($,C.substr(0,C.length-31)),C)},e.compare=function($,C,A,k){function b(z){if(typeof $!="string"||typeof C!="string"){o(z.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof C)));return}if(C.length!==60){o(z.bind(this,null,!1));return}e.hash($,C.substr(0,29),function(L,X){L?z(L):z(null,s(X,C))},k)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);b(A)}else return new Promise(function(z,L){b(function(X,W){if(X){L(X);return}z(W)})})},e.getRounds=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);return parseInt($.split("$")[2],10)},e.getSalt=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);if($.length!==60)throw Error("Illegal hash length: "+$.length+" != 60");return $.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c($){var C=[],A=0;return y.encodeUTF16toUTF8(function(){return A>=$.length?null:$.charCodeAt(A++)},function(k){C.push(k)}),C}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],p=String.fromCharCode;function h($,C){var A=0,k=[],b,z;if(C<=0||C>$.length)throw Error("Illegal len: "+C);for(;A<C;){if(b=$[A++]&255,k.push(l[b>>2&63]),b=(b&3)<<4,A>=C){k.push(l[b&63]);break}if(z=$[A++]&255,b|=z>>4&15,k.push(l[b&63]),b=(z&15)<<2,A>=C){k.push(l[b&63]);break}z=$[A++]&255,b|=z>>6&3,k.push(l[b&63]),k.push(l[z&63])}return k.join("")}function m($,C){var A=0,k=$.length,b=0,z=[],L,X,W,ie,ce,D;if(C<=0)throw Error("Illegal len: "+C);for(;A<k-1&&b<C&&(D=$.charCodeAt(A++),L=D<u.length?u[D]:-1,D=$.charCodeAt(A++),X=D<u.length?u[D]:-1,!(L==-1||X==-1||(ce=L<<2>>>0,ce|=(X&48)>>4,z.push(p(ce)),++b>=C||A>=k)||(D=$.charCodeAt(A++),W=D<u.length?u[D]:-1,W==-1)||(ce=(X&15)<<4>>>0,ce|=(W&60)>>2,z.push(p(ce)),++b>=C||A>=k)));)D=$.charCodeAt(A++),ie=D<u.length?u[D]:-1,ce=(W&3)<<6>>>0,ce|=ie,z.push(p(ce)),++b;var Ie=[];for(A=0;A<b;A++)Ie.push(z[A].charCodeAt(0));return Ie}var y=function(){var $={};return $.MAX_CODEPOINT=1114111,$.encodeUTF8=function(C,A){var k=null;for(typeof C=="number"&&(k=C,C=function(){return null});k!==null||(k=C())!==null;)k<128?A(k&127):k<2048?(A(k>>6&31|192),A(k&63|128)):k<65536?(A(k>>12&15|224),A(k>>6&63|128),A(k&63|128)):(A(k>>18&7|240),A(k>>12&63|128),A(k>>6&63|128),A(k&63|128)),k=null},$.decodeUTF8=function(C,A){for(var k,b,z,L,X=function(W){W=W.slice(0,W.indexOf(null));var ie=Error(W.toString());throw ie.name="TruncatedError",ie.bytes=W,ie};(k=C())!==null;)if(!(k&128))A(k);else if((k&224)===192)(b=C())===null&&X([k,b]),A((k&31)<<6|b&63);else if((k&240)===224)((b=C())===null||(z=C())===null)&&X([k,b,z]),A((k&15)<<12|(b&63)<<6|z&63);else if((k&248)===240)((b=C())===null||(z=C())===null||(L=C())===null)&&X([k,b,z,L]),A((k&7)<<18|(b&63)<<12|(z&63)<<6|L&63);else throw RangeError("Illegal starting byte: "+k)},$.UTF16toUTF8=function(C,A){for(var k,b=null;(k=b!==null?b:C())!==null;){if(k>=55296&&k<=57343&&(b=C())!==null&&b>=56320&&b<=57343){A((k-55296)*1024+b-56320+65536),b=null;continue}A(k)}b!==null&&A(b)},$.UTF8toUTF16=function(C,A){var k=null;for(typeof C=="number"&&(k=C,C=function(){return null});k!==null||(k=C())!==null;)k<=65535?A(k):(k-=65536,A((k>>10)+55296),A(k%1024+56320)),k=null},$.encodeUTF16toUTF8=function(C,A){$.UTF16toUTF8(C,function(k){$.encodeUTF8(k,A)})},$.decodeUTF8toUTF16=function(C,A){$.decodeUTF8(C,function(k){$.UTF8toUTF16(k,A)})},$.calculateCodePoint=function(C){return C<128?1:C<2048?2:C<65536?3:4},$.calculateUTF8=function(C){for(var A,k=0;(A=C())!==null;)k+=$.calculateCodePoint(A);return k},$.calculateUTF16asUTF8=function(C){var A=0,k=0;return $.UTF16toUTF8(C,function(b){++A,k+=$.calculateCodePoint(b)}),[A,k]},$}();Date.now=Date.now||function(){return+new Date};var f=16,_=10,v=16,x=100,N=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],B=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],R=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function te($,C,A,k){var b,z=$[C],L=$[C+1];return z^=A[0],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[1],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[2],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[3],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[4],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[5],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[6],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[7],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[8],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[9],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[10],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[11],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[12],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[13],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[14],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[15],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[16],$[C]=L^A[v+1],$[C+1]=z,$}function pe($,C){for(var A=0,k=0;A<4;++A)k=k<<8|$[C]&255,C=(C+1)%$.length;return{key:k,offp:C}}function le($,C,A){for(var k=0,b=[0,0],z=C.length,L=A.length,X,W=0;W<z;W++)X=pe($,k),k=X.offp,C[W]=C[W]^X.key;for(W=0;W<z;W+=2)b=te(b,0,C,A),C[W]=b[0],C[W+1]=b[1];for(W=0;W<L;W+=2)b=te(b,0,C,A),A[W]=b[0],A[W+1]=b[1]}function Ue($,C,A,k){for(var b=0,z=[0,0],L=A.length,X=k.length,W,ie=0;ie<L;ie++)W=pe(C,b),b=W.offp,A[ie]=A[ie]^W.key;for(b=0,ie=0;ie<L;ie+=2)W=pe($,b),b=W.offp,z[0]^=W.key,W=pe($,b),b=W.offp,z[1]^=W.key,z=te(z,0,A,k),A[ie]=z[0],A[ie+1]=z[1];for(ie=0;ie<X;ie+=2)W=pe($,b),b=W.offp,z[0]^=W.key,W=pe($,b),b=W.offp,z[1]^=W.key,z=te(z,0,A,k),k[ie]=z[0],k[ie+1]=z[1]}function ot($,C,A,k,b){var z=R.slice(),L=z.length,X;if(A<4||A>31)if(X=Error("Illegal number of rounds (4-31): "+A),k){o(k.bind(this,X));return}else throw X;if(C.length!==f)if(X=Error("Illegal salt length: "+C.length+" != "+f),k){o(k.bind(this,X));return}else throw X;A=1<<A>>>0;var W,ie,ce=0,D;Int32Array?(W=new Int32Array(N),ie=new Int32Array(B)):(W=N.slice(),ie=B.slice()),Ue(C,$,W,ie);function Ie(){if(b&&b(ce/A),ce<A)for(var he=Date.now();ce<A&&(ce=ce+1,le($,W,ie),le(C,W,ie),!(Date.now()-he>x)););else{for(ce=0;ce<64;ce++)for(D=0;D<L>>1;D++)te(z,D<<1,W,ie);var xe=[];for(ce=0;ce<L;ce++)xe.push((z[ce]>>24&255)>>>0),xe.push((z[ce]>>16&255)>>>0),xe.push((z[ce]>>8&255)>>>0),xe.push((z[ce]&255)>>>0);if(k){k(null,xe);return}else return xe}k&&o(Ie)}if(typeof k<"u")Ie();else for(var nn;;)if(typeof(nn=Ie())<"u")return nn||[]}function We($,C,A,k){var b;if(typeof $!="string"||typeof C!="string")if(b=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,b));return}else throw b;var z,L;if(C.charAt(0)!=="$"||C.charAt(1)!=="2")if(b=Error("Invalid salt version: "+C.substring(0,2)),A){o(A.bind(this,b));return}else throw b;if(C.charAt(2)==="$")z="\0",L=3;else{if(z=C.charAt(2),z!=="a"&&z!=="b"&&z!=="y"||C.charAt(3)!=="$")if(b=Error("Invalid salt revision: "+C.substring(2,4)),A){o(A.bind(this,b));return}else throw b;L=4}if(C.charAt(L+2)>"$")if(b=Error("Missing salt rounds"),A){o(A.bind(this,b));return}else throw b;var X=parseInt(C.substring(L,L+1),10)*10,W=parseInt(C.substring(L+1,L+2),10),ie=X+W,ce=C.substring(L+3,L+25);$+=z>="a"?"\0":"";var D=c($),Ie=m(ce,f);function nn(he){var xe=[];return xe.push("$2"),z>="a"&&xe.push(z),xe.push("$"),ie<10&&xe.push("0"),xe.push(ie.toString()),xe.push("$"),xe.push(h(Ie,Ie.length)),xe.push(h(he,R.length*4-1)),xe.join("")}if(typeof A>"u")return nn(ot(D,Ie,ie));ot(D,Ie,ie,function(he,xe){he?A(he,null):A(null,nn(xe))},k)}return e.encodeBase64=h,e.decodeBase64=m,e})})(pf);var Zm=pf.exports;const Kc=df(Zm),Ym="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Xm=t=>crypto.getRandomValues(new Uint8Array(t)),Qm=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let o="";for(;;){let c=n(i),l=i;for(;l--;)if(o+=t[c[l]&r]||"",o.length===s)return o}}},e_=(t,e=21)=>Qm(t,e,Xm),qe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Ym[n[t]&63];return e};const t_=24;function Wc(){return e_("0123456789abcdef",t_)()}function Eu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}async function ff(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function Gc({userAdapter:t,tenant_id:e,email:n,provider:r}){const{users:i}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n} provider:${r}`});return i.length>1&&console.error("More than one user found for same email and provider"),i[0]||null}async function Ms({userAdapter:t,tenant_id:e,email:n}){var c;const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),i=r.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(i.length===0)return;const s=i.filter(l=>!l.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const o=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function Jr({userAdapter:t,tenant_id:e,email:n,provider:r}){const i=await Gc({userAdapter:t,tenant_id:e,email:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}const hn=a.z.object({page:a.z.string().min(0).optional().default("0").transform(t=>parseInt(t,10)).openapi({description:"The page number where 0 is the first page"}),per_page:a.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:a.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:a.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function tr(t){if(!t)return;const[e,n]=t.split(":"),r=n==="1"?"asc":"desc";if(!(!e||!r))return{sort_by:e,sort_order:r}}function be(t,e){return{type:e.type,description:e.description||"",ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:t.req.method,path:t.req.path,qs:t.req.queries(),body:e.body||t.var.body||""}},isMobile:!1,client_id:t.var.client_id,client_name:"",user_id:e.userId||t.var.user_id||"",hostname:t.req.header("host")||"",user_name:t.var.username||"",connection_id:"",connection:t.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}var n_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},r_=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(n_))if(i_(s))return i}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((r=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:r.name)==="node"?"node":"other"},i_=t=>navigator.userAgent.startsWith(t);function Xe(t,e){r_()==="workerd"&&t.executionCtx.waitUntil(e)}const Iu=Yt.extend({users:a.z.array(vt)}),s_=Yt.extend({sessions:a.z.array(Vs)}),o_=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(vt),Iu])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,q:`email:${p}`})).users.filter(_=>_.linked_to),[y]=m;if(!y)return t.json([]);const f=await t.env.data.users.get(o,y.linked_to);if(!f)throw new O(500,{message:"Primary account not found"});return t.json([vt.parse(f)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,sort:tr(i),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return r?t.json(Iu.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(a.z.array(vt).parse(u))}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:vt}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),r=await t.env.data.users.get(n,e);if(!r)throw new O(404);if(r.linked_to)throw new O(404,{message:"User is linked to another user"});return t.json(r)}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header");if(!await t.env.data.users.remove(n,e))throw new O(404);return t.text("OK")}).openapi(a.createRoute({tags:["users"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...Fi.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:vt}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:r}=n;if(!r)throw new O(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||Wc()}`;try{const o=await t.env.data.users.create(e,{email:i,user_id:s,name:n.name||i,provider:n.provider,connection:n.connection,email_verified:n.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});t.set("user_id",o.user_id);const c=be(t,{type:me.SUCCESS_API_OPERATION,description:"User created"});Xe(t,t.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:Eu(o.user_id),isSocial:o.is_social}]};return t.json(vt.parse(l),{status:201})}catch(o){throw o.message==="User already exists"?new O(409,{message:"User already exists"}):o}}).openapi(a.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...Fi.shape,verify_email:a.z.boolean(),password:a.z.string()}).partial()}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var u;const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),{verify_email:i,password:s,...o}=n,c=await t.env.data.users.get(e,r);if(!c)throw new O(404);if(o.email&&o.email!==c.email){const p=await ff(t.env.data.users,e,o.email);if(p.length&&p.some(h=>h.user_id!==r))throw new O(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new O(404,{message:"User is linked to another user"});if(await t.env.data.users.update(e,r,o),s){const p=(u=c.identities)==null?void 0:u.find(h=>h.connection==="Username-Password-Authentication");if(!p)throw new O(400,{message:"User does not have a password identity"});await t.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:Kc.hashSync(s,10),algorithm:"bcrypt"})}const l=await t.env.data.users.get(e,r);if(!l)throw new O(500);return t.json(l)}).openapi(a.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.union([a.z.object({link_with:a.z.string()}),a.z.object({user_id:a.z.string(),provider:a.z.string(),connection:a.z.string().optional()})])}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(a.z.object({connection:a.z.string(),provider:a.z.string(),user_id:a.z.string(),isSocial:a.z.boolean()}))}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),i="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,r);if(!s)throw new O(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const o=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...o.users].map(l=>({connection:l.connection,provider:l.provider,user_id:Eu(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string(),provider:a.z.string(),linked_user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(vt)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:r,linked_user_id:i}=t.req.valid("param");await t.env.data.users.unlink(e,n,r,i);const s=await t.env.data.users.get(e,n);if(!s)throw new O(404);return t.json([vt.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Vs),s_])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
|
|
5
|
+
*/(function(e,n){typeof Wm=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(Zi,function(){var e={},n=null;function r($){if(t&&t.exports)try{return Zm.randomBytes($)}catch{}try{var C;return(self.crypto||self.msCrypto).getRandomValues(C=new Uint32Array($)),Array.prototype.slice.call(C)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n($)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function($){n=$},e.genSaltSync=function($,C){if($=$||_,typeof $!="number")throw Error("Illegal arguments: "+typeof $+", "+typeof C);$<4?$=4:$>31&&($=31);var A=[];return A.push("$2a$"),$<10&&A.push("0"),A.push($.toString()),A.push("$"),A.push(h(r(f),f)),A.join("")},e.genSalt=function($,C,A){if(typeof C=="function"&&(A=C,C=void 0),typeof $=="function"&&(A=$,$=void 0),typeof $>"u")$=_;else if(typeof $!="number")throw Error("illegal arguments: "+typeof $);function k(b){o(function(){try{b(null,e.genSaltSync($))}catch(z){b(z)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);k(A)}else return new Promise(function(b,z){k(function(L,X){if(L){z(L);return}b(X)})})},e.hashSync=function($,C){if(typeof C>"u"&&(C=_),typeof C=="number"&&(C=e.genSaltSync(C)),typeof $!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof C);return We($,C)},e.hash=function($,C,A,k){function b(z){typeof $=="string"&&typeof C=="number"?e.genSalt(C,function(L,X){We($,X,z,k)}):typeof $=="string"&&typeof C=="string"?We($,C,z,k):o(z.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof C)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);b(A)}else return new Promise(function(z,L){b(function(X,W){if(X){L(X);return}z(W)})})};function s($,C){for(var A=0,k=0,b=0,z=$.length;b<z;++b)$.charCodeAt(b)===C.charCodeAt(b)?++A:++k;return A<0?!1:k===0}e.compareSync=function($,C){if(typeof $!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof C);return C.length!==60?!1:s(e.hashSync($,C.substr(0,C.length-31)),C)},e.compare=function($,C,A,k){function b(z){if(typeof $!="string"||typeof C!="string"){o(z.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof C)));return}if(C.length!==60){o(z.bind(this,null,!1));return}e.hash($,C.substr(0,29),function(L,X){L?z(L):z(null,s(X,C))},k)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);b(A)}else return new Promise(function(z,L){b(function(X,W){if(X){L(X);return}z(W)})})},e.getRounds=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);return parseInt($.split("$")[2],10)},e.getSalt=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);if($.length!==60)throw Error("Illegal hash length: "+$.length+" != 60");return $.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c($){var C=[],A=0;return y.encodeUTF16toUTF8(function(){return A>=$.length?null:$.charCodeAt(A++)},function(k){C.push(k)}),C}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],p=String.fromCharCode;function h($,C){var A=0,k=[],b,z;if(C<=0||C>$.length)throw Error("Illegal len: "+C);for(;A<C;){if(b=$[A++]&255,k.push(l[b>>2&63]),b=(b&3)<<4,A>=C){k.push(l[b&63]);break}if(z=$[A++]&255,b|=z>>4&15,k.push(l[b&63]),b=(z&15)<<2,A>=C){k.push(l[b&63]);break}z=$[A++]&255,b|=z>>6&3,k.push(l[b&63]),k.push(l[z&63])}return k.join("")}function m($,C){var A=0,k=$.length,b=0,z=[],L,X,W,ie,ce,D;if(C<=0)throw Error("Illegal len: "+C);for(;A<k-1&&b<C&&(D=$.charCodeAt(A++),L=D<u.length?u[D]:-1,D=$.charCodeAt(A++),X=D<u.length?u[D]:-1,!(L==-1||X==-1||(ce=L<<2>>>0,ce|=(X&48)>>4,z.push(p(ce)),++b>=C||A>=k)||(D=$.charCodeAt(A++),W=D<u.length?u[D]:-1,W==-1)||(ce=(X&15)<<4>>>0,ce|=(W&60)>>2,z.push(p(ce)),++b>=C||A>=k)));)D=$.charCodeAt(A++),ie=D<u.length?u[D]:-1,ce=(W&3)<<6>>>0,ce|=ie,z.push(p(ce)),++b;var Ie=[];for(A=0;A<b;A++)Ie.push(z[A].charCodeAt(0));return Ie}var y=function(){var $={};return $.MAX_CODEPOINT=1114111,$.encodeUTF8=function(C,A){var k=null;for(typeof C=="number"&&(k=C,C=function(){return null});k!==null||(k=C())!==null;)k<128?A(k&127):k<2048?(A(k>>6&31|192),A(k&63|128)):k<65536?(A(k>>12&15|224),A(k>>6&63|128),A(k&63|128)):(A(k>>18&7|240),A(k>>12&63|128),A(k>>6&63|128),A(k&63|128)),k=null},$.decodeUTF8=function(C,A){for(var k,b,z,L,X=function(W){W=W.slice(0,W.indexOf(null));var ie=Error(W.toString());throw ie.name="TruncatedError",ie.bytes=W,ie};(k=C())!==null;)if(!(k&128))A(k);else if((k&224)===192)(b=C())===null&&X([k,b]),A((k&31)<<6|b&63);else if((k&240)===224)((b=C())===null||(z=C())===null)&&X([k,b,z]),A((k&15)<<12|(b&63)<<6|z&63);else if((k&248)===240)((b=C())===null||(z=C())===null||(L=C())===null)&&X([k,b,z,L]),A((k&7)<<18|(b&63)<<12|(z&63)<<6|L&63);else throw RangeError("Illegal starting byte: "+k)},$.UTF16toUTF8=function(C,A){for(var k,b=null;(k=b!==null?b:C())!==null;){if(k>=55296&&k<=57343&&(b=C())!==null&&b>=56320&&b<=57343){A((k-55296)*1024+b-56320+65536),b=null;continue}A(k)}b!==null&&A(b)},$.UTF8toUTF16=function(C,A){var k=null;for(typeof C=="number"&&(k=C,C=function(){return null});k!==null||(k=C())!==null;)k<=65535?A(k):(k-=65536,A((k>>10)+55296),A(k%1024+56320)),k=null},$.encodeUTF16toUTF8=function(C,A){$.UTF16toUTF8(C,function(k){$.encodeUTF8(k,A)})},$.decodeUTF8toUTF16=function(C,A){$.decodeUTF8(C,function(k){$.UTF8toUTF16(k,A)})},$.calculateCodePoint=function(C){return C<128?1:C<2048?2:C<65536?3:4},$.calculateUTF8=function(C){for(var A,k=0;(A=C())!==null;)k+=$.calculateCodePoint(A);return k},$.calculateUTF16asUTF8=function(C){var A=0,k=0;return $.UTF16toUTF8(C,function(b){++A,k+=$.calculateCodePoint(b)}),[A,k]},$}();Date.now=Date.now||function(){return+new Date};var f=16,_=10,v=16,x=100,N=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],B=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],R=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function te($,C,A,k){var b,z=$[C],L=$[C+1];return z^=A[0],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[1],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[2],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[3],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[4],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[5],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[6],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[7],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[8],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[9],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[10],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[11],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[12],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[13],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[14],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[15],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[16],$[C]=L^A[v+1],$[C+1]=z,$}function pe($,C){for(var A=0,k=0;A<4;++A)k=k<<8|$[C]&255,C=(C+1)%$.length;return{key:k,offp:C}}function le($,C,A){for(var k=0,b=[0,0],z=C.length,L=A.length,X,W=0;W<z;W++)X=pe($,k),k=X.offp,C[W]=C[W]^X.key;for(W=0;W<z;W+=2)b=te(b,0,C,A),C[W]=b[0],C[W+1]=b[1];for(W=0;W<L;W+=2)b=te(b,0,C,A),A[W]=b[0],A[W+1]=b[1]}function Ue($,C,A,k){for(var b=0,z=[0,0],L=A.length,X=k.length,W,ie=0;ie<L;ie++)W=pe(C,b),b=W.offp,A[ie]=A[ie]^W.key;for(b=0,ie=0;ie<L;ie+=2)W=pe($,b),b=W.offp,z[0]^=W.key,W=pe($,b),b=W.offp,z[1]^=W.key,z=te(z,0,A,k),A[ie]=z[0],A[ie+1]=z[1];for(ie=0;ie<X;ie+=2)W=pe($,b),b=W.offp,z[0]^=W.key,W=pe($,b),b=W.offp,z[1]^=W.key,z=te(z,0,A,k),k[ie]=z[0],k[ie+1]=z[1]}function ot($,C,A,k,b){var z=R.slice(),L=z.length,X;if(A<4||A>31)if(X=Error("Illegal number of rounds (4-31): "+A),k){o(k.bind(this,X));return}else throw X;if(C.length!==f)if(X=Error("Illegal salt length: "+C.length+" != "+f),k){o(k.bind(this,X));return}else throw X;A=1<<A>>>0;var W,ie,ce=0,D;Int32Array?(W=new Int32Array(N),ie=new Int32Array(B)):(W=N.slice(),ie=B.slice()),Ue(C,$,W,ie);function Ie(){if(b&&b(ce/A),ce<A)for(var he=Date.now();ce<A&&(ce=ce+1,le($,W,ie),le(C,W,ie),!(Date.now()-he>x)););else{for(ce=0;ce<64;ce++)for(D=0;D<L>>1;D++)te(z,D<<1,W,ie);var xe=[];for(ce=0;ce<L;ce++)xe.push((z[ce]>>24&255)>>>0),xe.push((z[ce]>>16&255)>>>0),xe.push((z[ce]>>8&255)>>>0),xe.push((z[ce]&255)>>>0);if(k){k(null,xe);return}else return xe}k&&o(Ie)}if(typeof k<"u")Ie();else for(var nn;;)if(typeof(nn=Ie())<"u")return nn||[]}function We($,C,A,k){var b;if(typeof $!="string"||typeof C!="string")if(b=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,b));return}else throw b;var z,L;if(C.charAt(0)!=="$"||C.charAt(1)!=="2")if(b=Error("Invalid salt version: "+C.substring(0,2)),A){o(A.bind(this,b));return}else throw b;if(C.charAt(2)==="$")z="\0",L=3;else{if(z=C.charAt(2),z!=="a"&&z!=="b"&&z!=="y"||C.charAt(3)!=="$")if(b=Error("Invalid salt revision: "+C.substring(2,4)),A){o(A.bind(this,b));return}else throw b;L=4}if(C.charAt(L+2)>"$")if(b=Error("Missing salt rounds"),A){o(A.bind(this,b));return}else throw b;var X=parseInt(C.substring(L,L+1),10)*10,W=parseInt(C.substring(L+1,L+2),10),ie=X+W,ce=C.substring(L+3,L+25);$+=z>="a"?"\0":"";var D=c($),Ie=m(ce,f);function nn(he){var xe=[];return xe.push("$2"),z>="a"&&xe.push(z),xe.push("$"),ie<10&&xe.push("0"),xe.push(ie.toString()),xe.push("$"),xe.push(h(Ie,Ie.length)),xe.push(h(he,R.length*4-1)),xe.join("")}if(typeof A>"u")return nn(ot(D,Ie,ie));ot(D,Ie,ie,function(he,xe){he?A(he,null):A(null,nn(xe))},k)}return e.encodeBase64=h,e.decodeBase64=m,e})})(ff);var Ym=ff.exports;const Kc=pf(Ym),Xm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Qm=t=>crypto.getRandomValues(new Uint8Array(t)),e_=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let o="";for(;;){let c=n(i),l=i;for(;l--;)if(o+=t[c[l]&r]||"",o.length===s)return o}}},t_=(t,e=21)=>e_(t,e,Qm),qe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Xm[n[t]&63];return e};const n_=24;function Wc(){return t_("0123456789abcdef",n_)()}function Eu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}async function hf(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function Gc({userAdapter:t,tenant_id:e,email:n,provider:r}){const{users:i}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n} provider:${r}`});return i.length>1&&console.error("More than one user found for same email and provider"),i[0]||null}async function Ms({userAdapter:t,tenant_id:e,email:n}){var c;const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),i=r.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(i.length===0)return;const s=i.filter(l=>!l.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const o=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function Jr({userAdapter:t,tenant_id:e,email:n,provider:r}){const i=await Gc({userAdapter:t,tenant_id:e,email:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}const hn=a.z.object({page:a.z.string().min(0).optional().default("0").transform(t=>parseInt(t,10)).openapi({description:"The page number where 0 is the first page"}),per_page:a.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:a.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:a.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function tr(t){if(!t)return;const[e,n]=t.split(":"),r=n==="1"?"asc":"desc";if(!(!e||!r))return{sort_by:e,sort_order:r}}function be(t,e){return{type:e.type,description:e.description||"",ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:t.req.method,path:t.req.path,qs:t.req.queries(),body:e.body||t.var.body||""}},isMobile:!1,client_id:t.var.client_id,client_name:"",user_id:e.userId||t.var.user_id||"",hostname:t.req.header("host")||"",user_name:t.var.username||"",connection_id:"",connection:t.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}var r_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},i_=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(r_))if(s_(s))return i}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((r=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:r.name)==="node"?"node":"other"},s_=t=>navigator.userAgent.startsWith(t);function Xe(t,e){i_()==="workerd"&&t.executionCtx.waitUntil(e)}const Iu=Yt.extend({users:a.z.array(vt)}),o_=Yt.extend({sessions:a.z.array(Vs)}),a_=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(vt),Iu])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,q:`email:${p}`})).users.filter(_=>_.linked_to),[y]=m;if(!y)return t.json([]);const f=await t.env.data.users.get(o,y.linked_to);if(!f)throw new O(500,{message:"Primary account not found"});return t.json([vt.parse(f)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,sort:tr(i),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return r?t.json(Iu.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(a.z.array(vt).parse(u))}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:vt}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),r=await t.env.data.users.get(n,e);if(!r)throw new O(404);if(r.linked_to)throw new O(404,{message:"User is linked to another user"});return t.json(r)}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header");if(!await t.env.data.users.remove(n,e))throw new O(404);return t.text("OK")}).openapi(a.createRoute({tags:["users"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...Fi.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:vt}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:r}=n;if(!r)throw new O(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||Wc()}`;try{const o=await t.env.data.users.create(e,{email:i,user_id:s,name:n.name||i,provider:n.provider,connection:n.connection,email_verified:n.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});t.set("user_id",o.user_id);const c=be(t,{type:me.SUCCESS_API_OPERATION,description:"User created"});Xe(t,t.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:Eu(o.user_id),isSocial:o.is_social}]};return t.json(vt.parse(l),{status:201})}catch(o){throw o.message==="User already exists"?new O(409,{message:"User already exists"}):o}}).openapi(a.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...Fi.shape,verify_email:a.z.boolean(),password:a.z.string()}).partial()}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var u;const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),{verify_email:i,password:s,...o}=n,c=await t.env.data.users.get(e,r);if(!c)throw new O(404);if(o.email&&o.email!==c.email){const p=await hf(t.env.data.users,e,o.email);if(p.length&&p.some(h=>h.user_id!==r))throw new O(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new O(404,{message:"User is linked to another user"});if(await t.env.data.users.update(e,r,o),s){const p=(u=c.identities)==null?void 0:u.find(h=>h.connection==="Username-Password-Authentication");if(!p)throw new O(400,{message:"User does not have a password identity"});await t.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:Kc.hashSync(s,10),algorithm:"bcrypt"})}const l=await t.env.data.users.get(e,r);if(!l)throw new O(500);return t.json(l)}).openapi(a.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.union([a.z.object({link_with:a.z.string()}),a.z.object({user_id:a.z.string(),provider:a.z.string(),connection:a.z.string().optional()})])}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(a.z.object({connection:a.z.string(),provider:a.z.string(),user_id:a.z.string(),isSocial:a.z.boolean()}))}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),i="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,r);if(!s)throw new O(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const o=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...o.users].map(l=>({connection:l.connection,provider:l.provider,user_id:Eu(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string(),provider:a.z.string(),linked_user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(vt)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:r,linked_user_id:i}=t.req.valid("param");await t.env.data.users.unlink(e,n,r,i);const s=await t.env.data.users.get(e,n);if(!s)throw new O(404);return t.json([vt.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Vs),o_])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
|
|
6
6
|
Copyright (C) Microsoft. All rights reserved.
|
|
7
7
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
8
8
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -15,7 +15,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
15
15
|
|
|
16
16
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
17
17
|
and limitations under the License.
|
|
18
|
-
***************************************************************************** */var Cu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof Zi=="object"?Zi:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(t);typeof n.Reflect<"u"&&(r=i(n.Reflect,r)),e(r,n),typeof n.Reflect>"u"&&(n.Reflect=t);function i(l,u){return function(p,h){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:h}),u&&u(p,h)}}function s(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,p={create:c?function(){return Mo(Object.create(null))}:l?function(){return Mo({__proto__:null})}:function(){return Mo({})},has:u?function(S,I){return r.call(S,I)}:function(S,I){return I in S},get:u?function(S,I){return r.call(S,I)?S[I]:void 0}:function(S,I){return S[I]}},h=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:am(),y=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:cm(),f=typeof WeakMap=="function"?WeakMap:lm(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=im(),x=sm(v);function N(S,I,j,U){if(D(j)){if(!ou(S))throw new TypeError;if(!au(I))throw new TypeError;return C(S,I)}else{if(!ou(S))throw new TypeError;if(!he(I))throw new TypeError;if(!he(U)&&!D(U)&&!Ie(U))throw new TypeError;return Ie(U)&&(U=void 0),j=mt(j),A(S,I,j,U)}}e("decorate",N);function B(S,I){function j(U,Q){if(!he(U))throw new TypeError;if(!D(Q)&&!nm(Q))throw new TypeError;X(S,I,U,Q)}return j}e("metadata",B);function R(S,I,j,U){if(!he(j))throw new TypeError;return D(U)||(U=mt(U)),X(S,I,j,U)}e("defineMetadata",R);function te(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),k(S,I,j)}e("hasMetadata",te);function pe(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),b(S,I,j)}e("hasOwnMetadata",pe);function le(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),z(S,I,j)}e("getMetadata",le);function Ue(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),L(S,I,j)}e("getOwnMetadata",Ue);function ot(S,I){if(!he(S))throw new TypeError;return D(I)||(I=mt(I)),W(S,I)}e("getMetadataKeys",ot);function We(S,I){if(!he(S))throw new TypeError;return D(I)||(I=mt(I)),ie(S,I)}e("getOwnMetadataKeys",We);function $(S,I,j){if(!he(I))throw new TypeError;if(D(j)||(j=mt(j)),!he(I))throw new TypeError;D(j)||(j=mt(j));var U=hr(I,j,!1);return D(U)?!1:U.OrdinaryDeleteMetadata(S,I,j)}e("deleteMetadata",$);function C(S,I){for(var j=S.length-1;j>=0;--j){var U=S[j],Q=U(I);if(!D(Q)&&!Ie(Q)){if(!au(Q))throw new TypeError;I=Q}}return I}function A(S,I,j,U){for(var Q=S.length-1;Q>=0;--Q){var Ce=S[Q],Ae=Ce(I,j,U);if(!D(Ae)&&!Ie(Ae)){if(!he(Ae))throw new TypeError;U=Ae}}return U}function k(S,I,j){var U=b(S,I,j);if(U)return!0;var Q=Vo(I);return Ie(Q)?!1:k(S,Q,j)}function b(S,I,j){var U=hr(I,j,!1);return D(U)?!1:su(U.OrdinaryHasOwnMetadata(S,I,j))}function z(S,I,j){var U=b(S,I,j);if(U)return L(S,I,j);var Q=Vo(I);if(!Ie(Q))return z(S,Q,j)}function L(S,I,j){var U=hr(I,j,!1);if(!D(U))return U.OrdinaryGetOwnMetadata(S,I,j)}function X(S,I,j,U){var Q=hr(j,U,!0);Q.OrdinaryDefineOwnMetadata(S,I,j,U)}function W(S,I){var j=ie(S,I),U=Vo(S);if(U===null)return j;var Q=W(U,I);if(Q.length<=0)return j;if(j.length<=0)return Q;for(var Ce=new y,Ae=[],se=0,q=j;se<q.length;se++){var K=q[se],J=Ce.has(K);J||(Ce.add(K),Ae.push(K))}for(var Z=0,oe=Q;Z<oe.length;Z++){var K=oe[Z],J=Ce.has(K);J||(Ce.add(K),Ae.push(K))}return Ae}function ie(S,I){var j=hr(S,I,!1);return j?j.OrdinaryOwnMetadataKeys(S,I):[]}function ce(S){if(S===null)return 1;switch(typeof S){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return S===null?1:6;default:return 6}}function D(S){return S===void 0}function Ie(S){return S===null}function nn(S){return typeof S=="symbol"}function he(S){return typeof S=="object"?S!==null:typeof S=="function"}function xe(S,I){switch(ce(S)){case 0:return S;case 1:return S;case 2:return S;case 3:return S;case 4:return S;case 5:return S}var j="string",U=cu(S,s);if(U!==void 0){var Q=U.call(S,j);if(he(Q))throw new TypeError;return Q}return em(S)}function em(S,I){var j,U;{var Q=S.toString;if(yi(Q)){var U=Q.call(S);if(!he(U))return U}var j=S.valueOf;if(yi(j)){var U=j.call(S);if(!he(U))return U}}throw new TypeError}function su(S){return!!S}function tm(S){return""+S}function mt(S){var I=xe(S);return nn(I)?I:tm(I)}function ou(S){return Array.isArray?Array.isArray(S):S instanceof Object?S instanceof Array:Object.prototype.toString.call(S)==="[object Array]"}function yi(S){return typeof S=="function"}function au(S){return typeof S=="function"}function nm(S){switch(ce(S)){case 3:return!0;case 4:return!0;default:return!1}}function Uo(S,I){return S===I||S!==S&&I!==I}function cu(S,I){var j=S[I];if(j!=null){if(!yi(j))throw new TypeError;return j}}function lu(S){var I=cu(S,o);if(!yi(I))throw new TypeError;var j=I.call(S);if(!he(j))throw new TypeError;return j}function uu(S){return S.value}function du(S){var I=S.next();return I.done?!1:I}function pu(S){var I=S.return;I&&I.call(S)}function Vo(S){var I=Object.getPrototypeOf(S);if(typeof S!="function"||S===h||I!==h)return I;var j=S.prototype,U=j&&Object.getPrototypeOf(j);if(U==null||U===Object.prototype)return I;var Q=U.constructor;return typeof Q!="function"||Q===S?I:Q}function rm(){var S;!D(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(S=om(n.Reflect));var I,j,U,Q=new f,Ce={registerProvider:Ae,getProvider:q,setProvider:J};return Ce;function Ae(Z){if(!Object.isExtensible(Ce))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case S===Z:break;case D(I):I=Z;break;case I===Z:break;case D(j):j=Z;break;case j===Z:break;default:U===void 0&&(U=new y),U.add(Z);break}}function se(Z,oe){if(!D(I)){if(I.isProviderFor(Z,oe))return I;if(!D(j)){if(j.isProviderFor(Z,oe))return I;if(!D(U))for(var ge=lu(U);;){var ve=du(ge);if(!ve)return;var at=uu(ve);if(at.isProviderFor(Z,oe))return pu(ge),at}}}if(!D(S)&&S.isProviderFor(Z,oe))return S}function q(Z,oe){var ge=Q.get(Z),ve;return D(ge)||(ve=ge.get(oe)),D(ve)&&(ve=se(Z,oe),D(ve)||(D(ge)&&(ge=new m,Q.set(Z,ge)),ge.set(oe,ve))),ve}function K(Z){if(D(Z))throw new TypeError;return I===Z||j===Z||!D(U)&&U.has(Z)}function J(Z,oe,ge){if(!K(ge))throw new Error("Metadata provider not registered.");var ve=q(Z,oe);if(ve!==ge){if(!D(ve))return!1;var at=Q.get(Z);D(at)&&(at=new m,Q.set(Z,at)),at.set(oe,ge)}return!0}}function im(){var S;return!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(S=n.Reflect[_]),D(S)&&(S=rm()),!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:S}),S}function sm(S){var I=new f,j={isProviderFor:function(K,J){var Z=I.get(K);return D(Z)?!1:Z.has(J)},OrdinaryDefineOwnMetadata:Ae,OrdinaryHasOwnMetadata:Q,OrdinaryGetOwnMetadata:Ce,OrdinaryOwnMetadataKeys:se,OrdinaryDeleteMetadata:q};return v.registerProvider(j),j;function U(K,J,Z){var oe=I.get(K),ge=!1;if(D(oe)){if(!Z)return;oe=new m,I.set(K,oe),ge=!0}var ve=oe.get(J);if(D(ve)){if(!Z)return;if(ve=new m,oe.set(J,ve),!S.setProvider(K,J,j))throw oe.delete(J),ge&&I.delete(K),new Error("Wrong provider for target.")}return ve}function Q(K,J,Z){var oe=U(J,Z,!1);return D(oe)?!1:su(oe.has(K))}function Ce(K,J,Z){var oe=U(J,Z,!1);if(!D(oe))return oe.get(K)}function Ae(K,J,Z,oe){var ge=U(Z,oe,!0);ge.set(K,J)}function se(K,J){var Z=[],oe=U(K,J,!1);if(D(oe))return Z;for(var ge=oe.keys(),ve=lu(ge),at=0;;){var fu=du(ve);if(!fu)return Z.length=at,Z;var um=uu(fu);try{Z[at]=um}catch(dm){try{pu(ve)}finally{throw dm}}at++}}function q(K,J,Z){var oe=U(J,Z,!1);if(D(oe)||!oe.delete(K))return!1;if(oe.size===0){var ge=I.get(J);D(ge)||(ge.delete(Z),ge.size===0&&I.delete(ge))}return!0}}function om(S){var I=S.defineMetadata,j=S.hasOwnMetadata,U=S.getOwnMetadata,Q=S.getOwnMetadataKeys,Ce=S.deleteMetadata,Ae=new f,se={isProviderFor:function(q,K){var J=Ae.get(q);return!D(J)&&J.has(K)?!0:Q(q,K).length?(D(J)&&(J=new y,Ae.set(q,J)),J.add(K),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:j,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:Q,OrdinaryDeleteMetadata:Ce};return se}function hr(S,I,j){var U=v.getProvider(S,I);if(!D(U))return U;if(j){if(v.setProvider(S,I,x))return x;throw new Error("Illegal state.")}}function am(){var S={},I=[],j=function(){function se(q,K,J){this._index=0,this._keys=q,this._values=K,this._selector=J}return se.prototype["@@iterator"]=function(){return this},se.prototype[o]=function(){return this},se.prototype.next=function(){var q=this._index;if(q>=0&&q<this._keys.length){var K=this._selector(this._keys[q],this._values[q]);return q+1>=this._keys.length?(this._index=-1,this._keys=I,this._values=I):this._index++,{value:K,done:!1}}return{value:void 0,done:!0}},se.prototype.throw=function(q){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),q},se.prototype.return=function(q){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:q,done:!0}},se}(),U=function(){function se(){this._keys=[],this._values=[],this._cacheKey=S,this._cacheIndex=-2}return Object.defineProperty(se.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),se.prototype.has=function(q){return this._find(q,!1)>=0},se.prototype.get=function(q){var K=this._find(q,!1);return K>=0?this._values[K]:void 0},se.prototype.set=function(q,K){var J=this._find(q,!0);return this._values[J]=K,this},se.prototype.delete=function(q){var K=this._find(q,!1);if(K>=0){for(var J=this._keys.length,Z=K+1;Z<J;Z++)this._keys[Z-1]=this._keys[Z],this._values[Z-1]=this._values[Z];return this._keys.length--,this._values.length--,Uo(q,this._cacheKey)&&(this._cacheKey=S,this._cacheIndex=-2),!0}return!1},se.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=S,this._cacheIndex=-2},se.prototype.keys=function(){return new j(this._keys,this._values,Q)},se.prototype.values=function(){return new j(this._keys,this._values,Ce)},se.prototype.entries=function(){return new j(this._keys,this._values,Ae)},se.prototype["@@iterator"]=function(){return this.entries()},se.prototype[o]=function(){return this.entries()},se.prototype._find=function(q,K){if(!Uo(this._cacheKey,q)){this._cacheIndex=-1;for(var J=0;J<this._keys.length;J++)if(Uo(this._keys[J],q)){this._cacheIndex=J;break}}return this._cacheIndex<0&&K&&(this._cacheIndex=this._keys.length,this._keys.push(q),this._values.push(void 0)),this._cacheIndex},se}();return U;function Q(se,q){return se}function Ce(se,q){return q}function Ae(se,q){return[se,q]}}function cm(){var S=function(){function I(){this._map=new m}return Object.defineProperty(I.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),I.prototype.has=function(j){return this._map.has(j)},I.prototype.add=function(j){return this._map.set(j,j),this},I.prototype.delete=function(j){return this._map.delete(j)},I.prototype.clear=function(){this._map.clear()},I.prototype.keys=function(){return this._map.keys()},I.prototype.values=function(){return this._map.keys()},I.prototype.entries=function(){return this._map.entries()},I.prototype["@@iterator"]=function(){return this.keys()},I.prototype[o]=function(){return this.keys()},I}();return S}function lm(){var S=16,I=p.create(),j=U();return function(){function q(){this._key=U()}return q.prototype.has=function(K){var J=Q(K,!1);return J!==void 0?p.has(J,this._key):!1},q.prototype.get=function(K){var J=Q(K,!1);return J!==void 0?p.get(J,this._key):void 0},q.prototype.set=function(K,J){var Z=Q(K,!0);return Z[this._key]=J,this},q.prototype.delete=function(K){var J=Q(K,!1);return J!==void 0?delete J[this._key]:!1},q.prototype.clear=function(){this._key=U()},q}();function U(){var q;do q="@@WeakMap@@"+se();while(p.has(I,q));return I[q]=!0,q}function Q(q,K){if(!r.call(q,j)){if(!K)return;Object.defineProperty(q,j,{value:p.create()})}return q[j]}function Ce(q,K){for(var J=0;J<K;++J)q[J]=Math.random()*255|0;return q}function Ae(q){if(typeof Uint8Array=="function"){var K=new Uint8Array(q);return typeof crypto<"u"?crypto.getRandomValues(K):typeof msCrypto<"u"?msCrypto.getRandomValues(K):Ce(K,q),K}return Ce(new Array(q),q)}function se(){var q=Ae(S);q[6]=q[6]&79|64,q[8]=q[8]&191|128;for(var K="",J=0;J<S;++J){var Z=q[J];(J===4||J===6||J===8)&&(K+="-"),Z<16&&(K+="0"),K+=Z.toString(16).toLowerCase()}return K}}function Mo(S){return S.__=void 0,delete S.__,S}})})(Cu||(Cu={}));/*!
|
|
18
|
+
***************************************************************************** */var Cu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof Zi=="object"?Zi:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(t);typeof n.Reflect<"u"&&(r=i(n.Reflect,r)),e(r,n),typeof n.Reflect>"u"&&(n.Reflect=t);function i(l,u){return function(p,h){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:h}),u&&u(p,h)}}function s(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,p={create:c?function(){return Mo(Object.create(null))}:l?function(){return Mo({__proto__:null})}:function(){return Mo({})},has:u?function(S,I){return r.call(S,I)}:function(S,I){return I in S},get:u?function(S,I){return r.call(S,I)?S[I]:void 0}:function(S,I){return S[I]}},h=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:cm(),y=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:lm(),f=typeof WeakMap=="function"?WeakMap:um(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=sm(),x=om(v);function N(S,I,j,U){if(D(j)){if(!ou(S))throw new TypeError;if(!au(I))throw new TypeError;return C(S,I)}else{if(!ou(S))throw new TypeError;if(!he(I))throw new TypeError;if(!he(U)&&!D(U)&&!Ie(U))throw new TypeError;return Ie(U)&&(U=void 0),j=mt(j),A(S,I,j,U)}}e("decorate",N);function B(S,I){function j(U,Q){if(!he(U))throw new TypeError;if(!D(Q)&&!rm(Q))throw new TypeError;X(S,I,U,Q)}return j}e("metadata",B);function R(S,I,j,U){if(!he(j))throw new TypeError;return D(U)||(U=mt(U)),X(S,I,j,U)}e("defineMetadata",R);function te(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),k(S,I,j)}e("hasMetadata",te);function pe(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),b(S,I,j)}e("hasOwnMetadata",pe);function le(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),z(S,I,j)}e("getMetadata",le);function Ue(S,I,j){if(!he(I))throw new TypeError;return D(j)||(j=mt(j)),L(S,I,j)}e("getOwnMetadata",Ue);function ot(S,I){if(!he(S))throw new TypeError;return D(I)||(I=mt(I)),W(S,I)}e("getMetadataKeys",ot);function We(S,I){if(!he(S))throw new TypeError;return D(I)||(I=mt(I)),ie(S,I)}e("getOwnMetadataKeys",We);function $(S,I,j){if(!he(I))throw new TypeError;if(D(j)||(j=mt(j)),!he(I))throw new TypeError;D(j)||(j=mt(j));var U=hr(I,j,!1);return D(U)?!1:U.OrdinaryDeleteMetadata(S,I,j)}e("deleteMetadata",$);function C(S,I){for(var j=S.length-1;j>=0;--j){var U=S[j],Q=U(I);if(!D(Q)&&!Ie(Q)){if(!au(Q))throw new TypeError;I=Q}}return I}function A(S,I,j,U){for(var Q=S.length-1;Q>=0;--Q){var Ce=S[Q],Ae=Ce(I,j,U);if(!D(Ae)&&!Ie(Ae)){if(!he(Ae))throw new TypeError;U=Ae}}return U}function k(S,I,j){var U=b(S,I,j);if(U)return!0;var Q=Vo(I);return Ie(Q)?!1:k(S,Q,j)}function b(S,I,j){var U=hr(I,j,!1);return D(U)?!1:su(U.OrdinaryHasOwnMetadata(S,I,j))}function z(S,I,j){var U=b(S,I,j);if(U)return L(S,I,j);var Q=Vo(I);if(!Ie(Q))return z(S,Q,j)}function L(S,I,j){var U=hr(I,j,!1);if(!D(U))return U.OrdinaryGetOwnMetadata(S,I,j)}function X(S,I,j,U){var Q=hr(j,U,!0);Q.OrdinaryDefineOwnMetadata(S,I,j,U)}function W(S,I){var j=ie(S,I),U=Vo(S);if(U===null)return j;var Q=W(U,I);if(Q.length<=0)return j;if(j.length<=0)return Q;for(var Ce=new y,Ae=[],se=0,q=j;se<q.length;se++){var K=q[se],J=Ce.has(K);J||(Ce.add(K),Ae.push(K))}for(var Z=0,oe=Q;Z<oe.length;Z++){var K=oe[Z],J=Ce.has(K);J||(Ce.add(K),Ae.push(K))}return Ae}function ie(S,I){var j=hr(S,I,!1);return j?j.OrdinaryOwnMetadataKeys(S,I):[]}function ce(S){if(S===null)return 1;switch(typeof S){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return S===null?1:6;default:return 6}}function D(S){return S===void 0}function Ie(S){return S===null}function nn(S){return typeof S=="symbol"}function he(S){return typeof S=="object"?S!==null:typeof S=="function"}function xe(S,I){switch(ce(S)){case 0:return S;case 1:return S;case 2:return S;case 3:return S;case 4:return S;case 5:return S}var j="string",U=cu(S,s);if(U!==void 0){var Q=U.call(S,j);if(he(Q))throw new TypeError;return Q}return tm(S)}function tm(S,I){var j,U;{var Q=S.toString;if(yi(Q)){var U=Q.call(S);if(!he(U))return U}var j=S.valueOf;if(yi(j)){var U=j.call(S);if(!he(U))return U}}throw new TypeError}function su(S){return!!S}function nm(S){return""+S}function mt(S){var I=xe(S);return nn(I)?I:nm(I)}function ou(S){return Array.isArray?Array.isArray(S):S instanceof Object?S instanceof Array:Object.prototype.toString.call(S)==="[object Array]"}function yi(S){return typeof S=="function"}function au(S){return typeof S=="function"}function rm(S){switch(ce(S)){case 3:return!0;case 4:return!0;default:return!1}}function Uo(S,I){return S===I||S!==S&&I!==I}function cu(S,I){var j=S[I];if(j!=null){if(!yi(j))throw new TypeError;return j}}function lu(S){var I=cu(S,o);if(!yi(I))throw new TypeError;var j=I.call(S);if(!he(j))throw new TypeError;return j}function uu(S){return S.value}function du(S){var I=S.next();return I.done?!1:I}function pu(S){var I=S.return;I&&I.call(S)}function Vo(S){var I=Object.getPrototypeOf(S);if(typeof S!="function"||S===h||I!==h)return I;var j=S.prototype,U=j&&Object.getPrototypeOf(j);if(U==null||U===Object.prototype)return I;var Q=U.constructor;return typeof Q!="function"||Q===S?I:Q}function im(){var S;!D(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(S=am(n.Reflect));var I,j,U,Q=new f,Ce={registerProvider:Ae,getProvider:q,setProvider:J};return Ce;function Ae(Z){if(!Object.isExtensible(Ce))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case S===Z:break;case D(I):I=Z;break;case I===Z:break;case D(j):j=Z;break;case j===Z:break;default:U===void 0&&(U=new y),U.add(Z);break}}function se(Z,oe){if(!D(I)){if(I.isProviderFor(Z,oe))return I;if(!D(j)){if(j.isProviderFor(Z,oe))return I;if(!D(U))for(var ge=lu(U);;){var ve=du(ge);if(!ve)return;var at=uu(ve);if(at.isProviderFor(Z,oe))return pu(ge),at}}}if(!D(S)&&S.isProviderFor(Z,oe))return S}function q(Z,oe){var ge=Q.get(Z),ve;return D(ge)||(ve=ge.get(oe)),D(ve)&&(ve=se(Z,oe),D(ve)||(D(ge)&&(ge=new m,Q.set(Z,ge)),ge.set(oe,ve))),ve}function K(Z){if(D(Z))throw new TypeError;return I===Z||j===Z||!D(U)&&U.has(Z)}function J(Z,oe,ge){if(!K(ge))throw new Error("Metadata provider not registered.");var ve=q(Z,oe);if(ve!==ge){if(!D(ve))return!1;var at=Q.get(Z);D(at)&&(at=new m,Q.set(Z,at)),at.set(oe,ge)}return!0}}function sm(){var S;return!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(S=n.Reflect[_]),D(S)&&(S=im()),!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:S}),S}function om(S){var I=new f,j={isProviderFor:function(K,J){var Z=I.get(K);return D(Z)?!1:Z.has(J)},OrdinaryDefineOwnMetadata:Ae,OrdinaryHasOwnMetadata:Q,OrdinaryGetOwnMetadata:Ce,OrdinaryOwnMetadataKeys:se,OrdinaryDeleteMetadata:q};return v.registerProvider(j),j;function U(K,J,Z){var oe=I.get(K),ge=!1;if(D(oe)){if(!Z)return;oe=new m,I.set(K,oe),ge=!0}var ve=oe.get(J);if(D(ve)){if(!Z)return;if(ve=new m,oe.set(J,ve),!S.setProvider(K,J,j))throw oe.delete(J),ge&&I.delete(K),new Error("Wrong provider for target.")}return ve}function Q(K,J,Z){var oe=U(J,Z,!1);return D(oe)?!1:su(oe.has(K))}function Ce(K,J,Z){var oe=U(J,Z,!1);if(!D(oe))return oe.get(K)}function Ae(K,J,Z,oe){var ge=U(Z,oe,!0);ge.set(K,J)}function se(K,J){var Z=[],oe=U(K,J,!1);if(D(oe))return Z;for(var ge=oe.keys(),ve=lu(ge),at=0;;){var fu=du(ve);if(!fu)return Z.length=at,Z;var dm=uu(fu);try{Z[at]=dm}catch(pm){try{pu(ve)}finally{throw pm}}at++}}function q(K,J,Z){var oe=U(J,Z,!1);if(D(oe)||!oe.delete(K))return!1;if(oe.size===0){var ge=I.get(J);D(ge)||(ge.delete(Z),ge.size===0&&I.delete(ge))}return!0}}function am(S){var I=S.defineMetadata,j=S.hasOwnMetadata,U=S.getOwnMetadata,Q=S.getOwnMetadataKeys,Ce=S.deleteMetadata,Ae=new f,se={isProviderFor:function(q,K){var J=Ae.get(q);return!D(J)&&J.has(K)?!0:Q(q,K).length?(D(J)&&(J=new y,Ae.set(q,J)),J.add(K),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:j,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:Q,OrdinaryDeleteMetadata:Ce};return se}function hr(S,I,j){var U=v.getProvider(S,I);if(!D(U))return U;if(j){if(v.setProvider(S,I,x))return x;throw new Error("Illegal state.")}}function cm(){var S={},I=[],j=function(){function se(q,K,J){this._index=0,this._keys=q,this._values=K,this._selector=J}return se.prototype["@@iterator"]=function(){return this},se.prototype[o]=function(){return this},se.prototype.next=function(){var q=this._index;if(q>=0&&q<this._keys.length){var K=this._selector(this._keys[q],this._values[q]);return q+1>=this._keys.length?(this._index=-1,this._keys=I,this._values=I):this._index++,{value:K,done:!1}}return{value:void 0,done:!0}},se.prototype.throw=function(q){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),q},se.prototype.return=function(q){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:q,done:!0}},se}(),U=function(){function se(){this._keys=[],this._values=[],this._cacheKey=S,this._cacheIndex=-2}return Object.defineProperty(se.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),se.prototype.has=function(q){return this._find(q,!1)>=0},se.prototype.get=function(q){var K=this._find(q,!1);return K>=0?this._values[K]:void 0},se.prototype.set=function(q,K){var J=this._find(q,!0);return this._values[J]=K,this},se.prototype.delete=function(q){var K=this._find(q,!1);if(K>=0){for(var J=this._keys.length,Z=K+1;Z<J;Z++)this._keys[Z-1]=this._keys[Z],this._values[Z-1]=this._values[Z];return this._keys.length--,this._values.length--,Uo(q,this._cacheKey)&&(this._cacheKey=S,this._cacheIndex=-2),!0}return!1},se.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=S,this._cacheIndex=-2},se.prototype.keys=function(){return new j(this._keys,this._values,Q)},se.prototype.values=function(){return new j(this._keys,this._values,Ce)},se.prototype.entries=function(){return new j(this._keys,this._values,Ae)},se.prototype["@@iterator"]=function(){return this.entries()},se.prototype[o]=function(){return this.entries()},se.prototype._find=function(q,K){if(!Uo(this._cacheKey,q)){this._cacheIndex=-1;for(var J=0;J<this._keys.length;J++)if(Uo(this._keys[J],q)){this._cacheIndex=J;break}}return this._cacheIndex<0&&K&&(this._cacheIndex=this._keys.length,this._keys.push(q),this._values.push(void 0)),this._cacheIndex},se}();return U;function Q(se,q){return se}function Ce(se,q){return q}function Ae(se,q){return[se,q]}}function lm(){var S=function(){function I(){this._map=new m}return Object.defineProperty(I.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),I.prototype.has=function(j){return this._map.has(j)},I.prototype.add=function(j){return this._map.set(j,j),this},I.prototype.delete=function(j){return this._map.delete(j)},I.prototype.clear=function(){this._map.clear()},I.prototype.keys=function(){return this._map.keys()},I.prototype.values=function(){return this._map.keys()},I.prototype.entries=function(){return this._map.entries()},I.prototype["@@iterator"]=function(){return this.keys()},I.prototype[o]=function(){return this.keys()},I}();return S}function um(){var S=16,I=p.create(),j=U();return function(){function q(){this._key=U()}return q.prototype.has=function(K){var J=Q(K,!1);return J!==void 0?p.has(J,this._key):!1},q.prototype.get=function(K){var J=Q(K,!1);return J!==void 0?p.get(J,this._key):void 0},q.prototype.set=function(K,J){var Z=Q(K,!0);return Z[this._key]=J,this},q.prototype.delete=function(K){var J=Q(K,!1);return J!==void 0?delete J[this._key]:!1},q.prototype.clear=function(){this._key=U()},q}();function U(){var q;do q="@@WeakMap@@"+se();while(p.has(I,q));return I[q]=!0,q}function Q(q,K){if(!r.call(q,j)){if(!K)return;Object.defineProperty(q,j,{value:p.create()})}return q[j]}function Ce(q,K){for(var J=0;J<K;++J)q[J]=Math.random()*255|0;return q}function Ae(q){if(typeof Uint8Array=="function"){var K=new Uint8Array(q);return typeof crypto<"u"?crypto.getRandomValues(K):typeof msCrypto<"u"?msCrypto.getRandomValues(K):Ce(K,q),K}return Ce(new Array(q),q)}function se(){var q=Ae(S);q[6]=q[6]&79|64,q[8]=q[8]&191|128;for(var K="",J=0;J<S;++J){var Z=q[J];(J===4||J===6||J===8)&&(K+="-"),Z<16&&(K+="0"),K+=Z.toString(16).toLowerCase()}return K}}function Mo(S){return S.__=void 0,delete S.__,S}})})(Cu||(Cu={}));/*!
|
|
19
19
|
* MIT License
|
|
20
20
|
*
|
|
21
21
|
* Copyright (c) 2017-2022 Peculiar Ventures, LLC
|
|
@@ -38,9 +38,9 @@ and limitations under the License.
|
|
|
38
38
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
39
|
* SOFTWARE.
|
|
40
40
|
*
|
|
41
|
-
*/const
|
|
41
|
+
*/const c_="[object ArrayBuffer]";class M{static isArrayBuffer(e){return Object.prototype.toString.call(e)===c_}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,n){if(e.constructor===n)return e;if(this.isArrayBuffer(e))return new n(e);if(this.isArrayBufferView(e))return new n(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,n){const r=M.toUint8Array(e),i=M.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let s=0;s<r.length;s++)if(r[s]!==i[s])return!1;return!0}static concat(...e){let n;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?n=e[0]:e[e.length-1]instanceof Function?n=e.slice(0,e.length-1):n=e;let r=0;for(const o of n)r+=o.byteLength;const i=new Uint8Array(r);let s=0;for(const o of n){const c=this.toUint8Array(o);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const Do="string",l_=/^[0-9a-f]+$/i,u_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,d_=/^[a-zA-Z0-9-_]+$/;class Nu{static fromString(e){const n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r.buffer}static toString(e){const n=M.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class _t{static toString(e,n=!1){const r=M.toArrayBuffer(e),i=new DataView(r);let s="";for(let o=0;o<r.byteLength;o+=2){const c=i.getUint16(o,n);s+=String.fromCharCode(c)}return s}static fromString(e,n=!1){const r=new ArrayBuffer(e.length*2),i=new DataView(r);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),n);return r}}class G{static isHex(e){return typeof e===Do&&l_.test(e)}static isBase64(e){return typeof e===Do&&u_.test(e)}static isBase64Url(e){return typeof e===Do&&d_.test(e)}static ToString(e,n="utf8"){const r=M.toUint8Array(e);switch(n.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return _t.toString(r,!0);case"utf16":case"utf16be":return _t.toString(r);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromString(e,n="utf8"){if(!e)return new ArrayBuffer(0);switch(n.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return _t.fromString(e,!0);case"utf16":case"utf16be":return _t.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=M.toUint8Array(e);if(typeof btoa<"u"){const r=this.ToString(n,"binary");return btoa(r)}else return Buffer.from(n).toString("base64")}static FromBase64(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!G.isBase64(n))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,"base64")).buffer}static FromBase64Url(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!G.isBase64Url(n))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(n.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,n=G.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.FromBinary(e);case"utf8":return Nu.fromString(e);case"utf16":case"utf16be":return _t.fromString(e);case"utf16le":case"usc2":return _t.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(e,n=G.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.ToBinary(e);case"utf8":return Nu.toString(e);case"utf16":case"utf16be":return _t.toString(e);case"utf16le":case"usc2":return _t.toString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){const n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);return r.buffer}static ToBinary(e){const n=M.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=M.toUint8Array(e);let r="";const i=n.length;for(let s=0;s<i;s++){const o=n[s];o<16&&(r+="0"),r+=o.toString(16)}return r}static FromHex(e){let n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!G.isHex(n))throw new TypeError("Argument 'hexString' is not HEX encoded");n.length%2&&(n=`0${n}`);const r=new Uint8Array(n.length/2);for(let i=0;i<n.length;i=i+2){const s=n.slice(i,i+2);r[i/2]=parseInt(s,16)}return r.buffer}static ToUtf16String(e,n=!1){return _t.toString(e,n)}static FromUtf16String(e,n=!1){return _t.fromString(e,n)}static Base64Padding(e){const n=4-e.length%4;if(n<4)for(let r=0;r<n;r++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}G.DEFAULT_UTF8_ENCODING="utf8";function p_(...t){const e=t.map(i=>i.byteLength).reduce((i,s)=>i+s),n=new Uint8Array(e);let r=0;return t.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)n[r++]=s}),n.buffer}function gf(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}/*!
|
|
42
42
|
Copyright (c) Peculiar Ventures, LLC
|
|
43
|
-
*/function Mn(t,e){let n=0;if(t.length===1)return t[0];for(let r=t.length-1;r>=0;r--)n+=t[t.length-1-r]*Math.pow(2,e*r);return n}function gn(t,e,n=-1){const r=n;let i=t,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(t<o){let l;if(r<0)l=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);l=new ArrayBuffer(r),s=r}const u=new Uint8Array(l);for(let p=c-1;p>=0;p--){const h=Math.pow(2,p*e);u[s-p-1]=Math.floor(i/h),i-=u[s-p-1]*h}return l}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function ga(...t){let e=0,n=0;for(const s of t)e+=s.length;const r=new ArrayBuffer(e),i=new Uint8Array(r);for(const s of t)i.set(s,n),n+=s.length;return i}function
|
|
43
|
+
*/function Mn(t,e){let n=0;if(t.length===1)return t[0];for(let r=t.length-1;r>=0;r--)n+=t[t.length-1-r]*Math.pow(2,e*r);return n}function gn(t,e,n=-1){const r=n;let i=t,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(t<o){let l;if(r<0)l=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);l=new ArrayBuffer(r),s=r}const u=new Uint8Array(l);for(let p=c-1;p>=0;p--){const h=Math.pow(2,p*e);u[s-p-1]=Math.floor(i/h),i-=u[s-p-1]*h}return l}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function ga(...t){let e=0,n=0;for(const s of t)e+=s.length;const r=new ArrayBuffer(e),i=new Uint8Array(r);for(const s of t)i.set(s,n),n+=s.length;return i}function mf(){const t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=t[0]===255&&t[1]&128,l=t[0]===0&&(t[1]&128)===0;(c||l)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)n[c]=0;n[0]=t[0]&128;const r=Mn(n,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,Mn(s,8)-r}function f_(t){const e=t<0?t*-1:t;let n=128;for(let r=1;r<8;r++){if(e<=n){if(t<0){const o=n-e,c=gn(o,8,r),l=new Uint8Array(c);return l[0]|=128,c}let i=gn(e,8,r),s=new Uint8Array(i);if(s[0]&128){const o=i.slice(0),c=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let l=0;l<o.byteLength;l++)s[l+1]=c[l];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function h_(t,e){if(t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<n.length;i++)if(n[i]!==r[i])return!1;return!0}function Ge(t,e){const n=t.toString(10);if(e<n.length)return"";const r=e-n.length,i=new Array(r);for(let o=0;o<r;o++)i[o]="0";return i.join("").concat(n)}/*!
|
|
44
44
|
* Copyright (c) 2014, GMO GlobalSign
|
|
45
45
|
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
46
46
|
* All rights reserved.
|
|
@@ -72,11 +72,11 @@ and limitations under the License.
|
|
|
72
72
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
73
73
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
74
|
*
|
|
75
|
-
*/function Yi(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Jc(t){let e=0,n=0;for(let i=0;i<t.length;i++){const s=t[i];e+=s.byteLength}const r=new Uint8Array(e);for(let i=0;i<t.length;i++){const s=t[i];r.set(new Uint8Array(s),n),n+=s.byteLength}return r.buffer}function Lt(t,e,n,r){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):r<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-r<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class qs{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Jc(this.items)}}const mr=[new Uint8Array([1])],$u="0123456789",Fo="name",zu="valueHexView",h_="isHexOnly",g_="idBlock",m_="tagClass",__="tagNumber",y_="isConstructed",v_="fromBER",w_="toBER",b_="local",Me="",ht=new ArrayBuffer(0),Ds=new Uint8Array(0),$r="EndOfContent",mf="OCTET STRING",_f="BIT STRING";function Et(t){var e;return e=class extends t{constructor(...r){var i;super(...r);const s=r[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?M.toUint8Array(s.valueHex):Ds}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const o=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Lt(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(r=!1){return this.isHexOnly?r?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",ht)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class In{constructor({blockLength:e=0,error:n=Me,warnings:r=[],valueBeforeDecode:i=Ds}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=M.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.ToHex(this.valueBeforeDecodeView)}}}In.NAME="baseBlock";class Le extends In{fromBER(e,n,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Le.NAME="valueBlock";class yf extends Et(In){constructor({idBlock:e={}}={}){var n,r,i,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?M.toUint8Array(e.valueHex):Ds,this.tagClass=(r=e.tagClass)!==null&&r!==void 0?r:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",ht}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,i[0]=n}return i.buffer}if(!this.isHexOnly){const i=gn(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let l=0;l<o-1;l++)c[l+1]=s[l]|128;c[o]=s[o-1]}return c.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=n|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)r[s+1]=i[s]|128;r[this.valueHexView.byteLength]=i[i.length-1]}return r.buffer}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,u=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(u[l-1]=s[l]&127,l++,l>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const m=new Uint8Array(p);for(let y=0;y<u.length;y++)m[y]=u[y];u=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,u[l-1]=s[l]&127;const h=new Uint8Array(l);for(let m=0;m<l;m++)h[m]=u[m];u=this.valueHexView=new Uint8Array(l),u.set(h),this.blockLength<=9?this.tagNumber=Mn(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}yf.NAME="identificationBlock";class vf extends In{constructor({lenBlock:e={}}={}){var n,r,i;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(r=e.longFormUsed)!==null&&r!==void 0?r:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;const o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=i.subarray(c,c+o);return l[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Mn(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,n+this.blockLength}toBER(e=!1){let n,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=128),n;if(this.longFormUsed){const i=gn(this.length,8);if(i.byteLength>127)return this.error="Too big length",ht;if(n=new ArrayBuffer(i.byteLength+1),e)return n;const s=new Uint8Array(i);r=new Uint8Array(n),r[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)r[o+1]=s[o];return n}return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}vf.NAME="lengthBlock";const H={};class je extends In{constructor({name:e=Me,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new yf(i),this.lenBlock=new vf(i),this.valueBlock=s?new s(i):new Le(i)}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,n){const r=n||new qs;n||wf(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);r.write(o),r.write(s)}return n?ht:r.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),r=e.toBER();return f_(n,r)}}je.NAME="BaseBlock";function wf(t){if(t instanceof H.Constructed)for(const e of t.valueBlock.value)wf(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class Zc extends je{constructor({value:e=Me,...n}={},r){super(n,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}Zc.NAME="BaseStringBlock";class bf extends Et(Le){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}bf.NAME="PrimitiveValueBlock";var kf;class Zr extends je{constructor(e={}){super(e,bf),this.idBlock.isConstructed=!1}}kf=Zr;H.Primitive=kf;Zr.NAME="PRIMITIVE";function k_(t,e){if(t instanceof e)return t;const n=new e;return n.idBlock=t.idBlock,n.lenBlock=t.lenBlock,n.warnings=t.warnings,n.valueBeforeDecodeView=t.valueBeforeDecodeView,n}function nr(t,e=0,n=t.length){const r=e;let i=new je({},Le);const s=new In;if(!Lt(s,t,e,n))return i.error=s.error,{offset:-1,result:i};if(!t.subarray(e,e+n).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(t,e,n);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,n-=i.idBlock.blockLength,c=i.lenBlock.fromBER(t,e,n),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,n-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let l=je;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};l=H.EndOfContent;break;case 1:l=H.Boolean;break;case 2:l=H.Integer;break;case 3:l=H.BitString;break;case 4:l=H.OctetString;break;case 5:l=H.Null;break;case 6:l=H.ObjectIdentifier;break;case 10:l=H.Enumerated;break;case 12:l=H.Utf8String;break;case 13:l=H.RelativeObjectIdentifier;break;case 14:l=H.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:l=H.Sequence;break;case 17:l=H.Set;break;case 18:l=H.NumericString;break;case 19:l=H.PrintableString;break;case 20:l=H.TeletexString;break;case 21:l=H.VideotexString;break;case 22:l=H.IA5String;break;case 23:l=H.UTCTime;break;case 24:l=H.GeneralizedTime;break;case 25:l=H.GraphicString;break;case 26:l=H.VisibleString;break;case 27:l=H.GeneralString;break;case 28:l=H.UniversalString;break;case 29:l=H.CharacterString;break;case 30:l=H.BmpString;break;case 31:l=H.DATE;break;case 32:l=H.TimeOfDay;break;case 33:l=H.DateTime;break;case 34:l=H.Duration;break;default:{const u=i.idBlock.isConstructed?new H.Constructed:new H.Primitive;u.idBlock=i.idBlock,u.lenBlock=i.lenBlock,u.warnings=i.warnings,i=u}}break;case 2:case 3:case 4:default:l=i.idBlock.isConstructed?H.Constructed:H.Primitive}return i=k_(i,l),c=i.fromBER(t,e,i.lenBlock.isIndefiniteForm?n:i.lenBlock.length),i.valueBeforeDecodeView=t.subarray(r,r+i.blockLength),{offset:c,result:i}}function Ln(t){if(!t.byteLength){const e=new je({},Le);return e.error="Input buffer has zero length",{offset:-1,result:e}}return nr(M.toUint8Array(t).slice(),0,t.byteLength)}function x_(t,e){return t?1:e}class Ft extends Le{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;if(this.valueBeforeDecodeView=i.subarray(n,n+r),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;x_(this.isIndefiniteForm,r)>0;){const o=nr(i,s,r);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,r-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===$r)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===$r?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new qs;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?ht:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Ft.NAME="ConstructedValueBlock";var xf;class De extends je{constructor(e={}){super(e,Ft),this.idBlock.isConstructed=!0}fromBER(e,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split(`
|
|
75
|
+
*/function Yi(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Jc(t){let e=0,n=0;for(let i=0;i<t.length;i++){const s=t[i];e+=s.byteLength}const r=new Uint8Array(e);for(let i=0;i<t.length;i++){const s=t[i];r.set(new Uint8Array(s),n),n+=s.byteLength}return r.buffer}function Lt(t,e,n,r){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):r<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-r<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class qs{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Jc(this.items)}}const mr=[new Uint8Array([1])],$u="0123456789",Fo="name",zu="valueHexView",g_="isHexOnly",m_="idBlock",__="tagClass",y_="tagNumber",v_="isConstructed",w_="fromBER",b_="toBER",k_="local",Me="",ht=new ArrayBuffer(0),Ds=new Uint8Array(0),$r="EndOfContent",_f="OCTET STRING",yf="BIT STRING";function Et(t){var e;return e=class extends t{constructor(...r){var i;super(...r);const s=r[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?M.toUint8Array(s.valueHex):Ds}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const o=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Lt(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(r=!1){return this.isHexOnly?r?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",ht)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class In{constructor({blockLength:e=0,error:n=Me,warnings:r=[],valueBeforeDecode:i=Ds}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=M.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.ToHex(this.valueBeforeDecodeView)}}}In.NAME="baseBlock";class Le extends In{fromBER(e,n,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Le.NAME="valueBlock";class vf extends Et(In){constructor({idBlock:e={}}={}){var n,r,i,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?M.toUint8Array(e.valueHex):Ds,this.tagClass=(r=e.tagClass)!==null&&r!==void 0?r:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",ht}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,i[0]=n}return i.buffer}if(!this.isHexOnly){const i=gn(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let l=0;l<o-1;l++)c[l+1]=s[l]|128;c[o]=s[o-1]}return c.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=n|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)r[s+1]=i[s]|128;r[this.valueHexView.byteLength]=i[i.length-1]}return r.buffer}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,u=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(u[l-1]=s[l]&127,l++,l>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const m=new Uint8Array(p);for(let y=0;y<u.length;y++)m[y]=u[y];u=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,u[l-1]=s[l]&127;const h=new Uint8Array(l);for(let m=0;m<l;m++)h[m]=u[m];u=this.valueHexView=new Uint8Array(l),u.set(h),this.blockLength<=9?this.tagNumber=Mn(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}vf.NAME="identificationBlock";class wf extends In{constructor({lenBlock:e={}}={}){var n,r,i;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(r=e.longFormUsed)!==null&&r!==void 0?r:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;const o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=i.subarray(c,c+o);return l[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Mn(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,n+this.blockLength}toBER(e=!1){let n,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=128),n;if(this.longFormUsed){const i=gn(this.length,8);if(i.byteLength>127)return this.error="Too big length",ht;if(n=new ArrayBuffer(i.byteLength+1),e)return n;const s=new Uint8Array(i);r=new Uint8Array(n),r[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)r[o+1]=s[o];return n}return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}wf.NAME="lengthBlock";const H={};class je extends In{constructor({name:e=Me,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new vf(i),this.lenBlock=new wf(i),this.valueBlock=s?new s(i):new Le(i)}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,n){const r=n||new qs;n||bf(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);r.write(o),r.write(s)}return n?ht:r.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),r=e.toBER();return h_(n,r)}}je.NAME="BaseBlock";function bf(t){if(t instanceof H.Constructed)for(const e of t.valueBlock.value)bf(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class Zc extends je{constructor({value:e=Me,...n}={},r){super(n,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}Zc.NAME="BaseStringBlock";class kf extends Et(Le){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}kf.NAME="PrimitiveValueBlock";var xf;class Zr extends je{constructor(e={}){super(e,kf),this.idBlock.isConstructed=!1}}xf=Zr;H.Primitive=xf;Zr.NAME="PRIMITIVE";function x_(t,e){if(t instanceof e)return t;const n=new e;return n.idBlock=t.idBlock,n.lenBlock=t.lenBlock,n.warnings=t.warnings,n.valueBeforeDecodeView=t.valueBeforeDecodeView,n}function nr(t,e=0,n=t.length){const r=e;let i=new je({},Le);const s=new In;if(!Lt(s,t,e,n))return i.error=s.error,{offset:-1,result:i};if(!t.subarray(e,e+n).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(t,e,n);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,n-=i.idBlock.blockLength,c=i.lenBlock.fromBER(t,e,n),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,n-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let l=je;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};l=H.EndOfContent;break;case 1:l=H.Boolean;break;case 2:l=H.Integer;break;case 3:l=H.BitString;break;case 4:l=H.OctetString;break;case 5:l=H.Null;break;case 6:l=H.ObjectIdentifier;break;case 10:l=H.Enumerated;break;case 12:l=H.Utf8String;break;case 13:l=H.RelativeObjectIdentifier;break;case 14:l=H.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:l=H.Sequence;break;case 17:l=H.Set;break;case 18:l=H.NumericString;break;case 19:l=H.PrintableString;break;case 20:l=H.TeletexString;break;case 21:l=H.VideotexString;break;case 22:l=H.IA5String;break;case 23:l=H.UTCTime;break;case 24:l=H.GeneralizedTime;break;case 25:l=H.GraphicString;break;case 26:l=H.VisibleString;break;case 27:l=H.GeneralString;break;case 28:l=H.UniversalString;break;case 29:l=H.CharacterString;break;case 30:l=H.BmpString;break;case 31:l=H.DATE;break;case 32:l=H.TimeOfDay;break;case 33:l=H.DateTime;break;case 34:l=H.Duration;break;default:{const u=i.idBlock.isConstructed?new H.Constructed:new H.Primitive;u.idBlock=i.idBlock,u.lenBlock=i.lenBlock,u.warnings=i.warnings,i=u}}break;case 2:case 3:case 4:default:l=i.idBlock.isConstructed?H.Constructed:H.Primitive}return i=x_(i,l),c=i.fromBER(t,e,i.lenBlock.isIndefiniteForm?n:i.lenBlock.length),i.valueBeforeDecodeView=t.subarray(r,r+i.blockLength),{offset:c,result:i}}function Ln(t){if(!t.byteLength){const e=new je({},Le);return e.error="Input buffer has zero length",{offset:-1,result:e}}return nr(M.toUint8Array(t).slice(),0,t.byteLength)}function S_(t,e){return t?1:e}class Ft extends Le{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;if(this.valueBeforeDecodeView=i.subarray(n,n+r),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;S_(this.isIndefiniteForm,r)>0;){const o=nr(i,s,r);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,r-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===$r)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===$r?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new qs;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?ht:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Ft.NAME="ConstructedValueBlock";var Sf;class De extends je{constructor(e={}){super(e,Ft),this.idBlock.isConstructed=!0}fromBER(e,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split(`
|
|
76
76
|
`).map(i=>` ${i}`).join(`
|
|
77
77
|
`));const n=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${n} :
|
|
78
78
|
${e.join(`
|
|
79
|
-
`)}`:`${n} :`}}xf=De;H.Constructed=xf;De.NAME="CONSTRUCTED";class Sf extends Le{fromBER(e,n,r){return n}toBER(e){return ht}}Sf.override="EndOfContentValueBlock";var Af;class Yc extends je{constructor(e={}){super(e,Sf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Af=Yc;H.EndOfContent=Af;Yc.NAME=$r;var Ef;class mn extends je{constructor(e={}){super(e,Le),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,n+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+r}toBER(e,n){const r=new ArrayBuffer(2);if(!e){const i=new Uint8Array(r);i[0]=5,i[1]=0}return n&&n.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}Ef=mn;H.Null=Ef;mn.NAME="NULL";class If extends Et(Le){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=M.toUint8Array(n.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,n,r){const i=M.toUint8Array(e);return Lt(this,i,n,r)?(this.valueHexView=i.subarray(n,n+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,gf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}If.NAME="BooleanValueBlock";var Cf;class Fs extends je{constructor(e={}){super(e,If),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}Cf=Fs;H.Boolean=Cf;Fs.NAME="BOOLEAN";class Nf extends Et(Ft){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Ft.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===$r){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==mf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,n,r),this.blockLength=r;return i}toBER(e,n){return this.isConstructed?Ft.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Nf.NAME="OctetStringValueBlock";var $f;let un=class zf extends je{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},Nf),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,r===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),n;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(n,n+r);try{if(s.byteLength){const o=nr(s,0,s.byteLength);o.offset!==-1&&o.offset===r&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?De.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const n of this.valueBlock.value)n instanceof zf&&e.push(n.valueBlock.valueHexView);return M.concat(e)}};$f=un;H.OctetString=$f;un.NAME=mf;class jf extends Et(Ft){constructor({unusedBits:e=0,isConstructed:n=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,r){if(!r)return n;let i=-1;if(this.isConstructed){if(i=Ft.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const l=c.constructor.NAME;if(l===$r){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==_f)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=c.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return i}const s=M.toUint8Array(e);if(!Lt(this,s,n,r))return-1;const o=s.subarray(n,n+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const l=nr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,n+r}toBER(e,n){if(this.isConstructed)return Ft.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ht;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}jf.NAME="BitStringValueBlock";var Of;let dn=class extends je{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},jf),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return De.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const i of n)e.push(i.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};Of=dn;H.BitString=Of;dn.NAME=_f;var Bf;function S_(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const o=s.length-1,c=i.slice(0),l=c.length-1;let u=0;const p=l<o?o:l;let h=0;for(let m=p;m>=0;m--,h++){switch(!0){case h<c.length:u=s[o-h]+c[l-h]+n[0];break;default:u=s[o-h]+n[0]}switch(n[0]=u/10,!0){case h>=s.length:s=ga(new Uint8Array([u%10]),s);break;default:s[o-h]=u%10}}return n[0]>0&&(s=ga(n,s)),s}function ju(t){if(t>=mr.length)for(let e=mr.length;e<=t;e++){const n=new Uint8Array([0]);let r=mr[e-1].slice(0);for(let i=r.length-1;i>=0;i--){const s=new Uint8Array([(r[i]<<1)+n[0]]);n[0]=s[0]/10,r[i]=s[0]%10}n[0]>0&&(r=ga(n,r)),mr.push(r)}return mr[t]}function A_(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),o=s.length-1,c=i.slice(0),l=c.length-1;let u,p=0;for(let h=l;h>=0;h--,p++)switch(u=s[o-p]-c[l-p]-n,!0){case u<0:n=1,s[o-p]=u+10;break;default:n=0,s[o-p]=u}if(n>0)for(let h=o-l+1;h>=0;h--,p++)if(u=s[o-p]-n,u<0)n=1,s[o-p]=u+10;else{n=0,s[o-p]=u;break}return s.slice()}class Xc extends Et(Le){constructor({value:e,...n}={}){super(n),this._valueDec=0,n.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=gf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(p_(e))}get valueDec(){return this._valueDec}fromDER(e,n,r,i=0){const s=this.fromBER(e,n,r);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.length)),s}toDER(e=!1){const n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(n,1),this.valueHexView=r}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,r){const i=super.fromBER(e,n,r);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let n=new Uint8Array(this.valueHexView.length*8/3),r=0,i;const s=this.valueHexView;let o="",c=!1;for(let l=s.byteLength-1;l>=0;l--){i=s[l];for(let u=0;u<8;u++){if((i&1)===1)switch(r){case e:n=A_(ju(r),n),o="-";break;default:n=S_(n,ju(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(o+=$u.charAt(n[l]));return c===!1&&(o+=$u.charAt(0)),o}}Bf=Xc;Xc.NAME="IntegerValueBlock";Object.defineProperty(Bf.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Tf;class bt extends je{constructor(e={}){super(e,Xc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Yi(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Yi();const n=BigInt(e),r=new qs,i=n.toString(16).replace(/^-/,""),s=new Uint8Array(G.FromHex(i));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${G.ToHex(c)}`)+n,p=M.toUint8Array(G.FromHex(u.toString(16)));p[0]|=128,r.write(p)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new bt({valueHex:r.final()})}convertToDER(){const e=new bt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new bt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Tf=bt;H.Integer=Tf;bt.NAME="INTEGER";var Pf;class Hs extends bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Pf=Hs;H.Enumerated=Pf;Hs.NAME="ENUMERATED";class ma extends Et(Le){constructor({valueDec:e=-1,isFirstSid:n=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,r){if(!r)return n;const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Mn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){Yi();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const r=new Uint8Array(n.length/7);for(let i=0;i<r.length;i++)r[i]=parseInt(n.slice(i*7,i*7+7),2)+(i+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=gn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ht;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|128;r[s]=i[s]}return r}toString(){let e="";if(this.isHexOnly)e=G.ToHex(this.valueHexView);else if(this.isFirstSid){let n=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",n-=40):(e="2.",n-=80),e+=n.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}ma.NAME="sidBlock";class Rf extends Le{constructor({value:e=Me,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new ma;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e){const n=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(i.byteLength===0)return this.error=this.value[r].error,ht;n.push(i)}return Jc(n)}fromString(e){this.value=[];let n=0,r=0,i="",s=!1;do if(r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(i,10);if(isNaN(l))return;o.valueDec=l+c,s=!1}else{const o=new ma;if(i>Number.MAX_SAFE_INTEGER){Yi();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(r!==-1)}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}Rf.NAME="ObjectIdentifierValueBlock";var Lf;class Ks extends je{constructor(e={}){super(e,Rf),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}Lf=Ks;H.ObjectIdentifier=Lf;Ks.NAME="OBJECT IDENTIFIER";class _a extends Et(In){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Mn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=gn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ht;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|128;r[s]=i[s]}return r.buffer}toString(){let e="";return this.isHexOnly?e=G.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}_a.NAME="relativeSidBlock";class Uf extends Le{constructor({value:e=Me,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new _a;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e,n){const r=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,ht;r.push(s)}return Jc(r)}fromString(e){this.value=[];let n=0,r=0,i="";do{r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1;const s=new _a;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(r!==-1);return!0}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}Uf.NAME="RelativeObjectIdentifierValueBlock";var Vf;class Qc extends je{constructor(e={}){super(e,Uf),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}Vf=Qc;H.RelativeObjectIdentifier=Vf;Qc.NAME="RelativeObjectIdentifier";var Mf;class zt extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}Mf=zt;H.Sequence=Mf;zt.NAME="SEQUENCE";var qf;let jt=class extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};qf=jt;H.Set=qf;jt.NAME="SET";class Df extends Et(Le){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Me}toJSON(){return{...super.toJSON(),value:this.value}}}Df.NAME="StringValueBlock";class Ff extends Df{}Ff.NAME="SimpleStringValueBlock";class Ze extends Zc{constructor({...e}={}){super(e,Ff)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.toUint8Array(e))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}Ze.NAME="SIMPLE STRING";class Hf extends Ze{fromBuffer(e){this.valueBlock.valueHexView=M.toUint8Array(e);try{this.valueBlock.value=G.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=G.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.FromUtf8String(e)),this.valueBlock.value=e}}Hf.NAME="Utf8StringValueBlock";var Kf;class Ut extends Hf{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Kf=Ut;H.Utf8String=Kf;Ut.NAME="UTF8String";class Wf extends Ze{fromBuffer(e){this.valueBlock.value=G.ToUtf16String(e),this.valueBlock.valueHexView=M.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.FromUtf16String(e))}}Wf.NAME="BmpStringValueBlock";var Gf;class Ws extends Wf{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Gf=Ws;H.BmpString=Gf;Ws.NAME="BMPString";class Jf extends Ze{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(n);for(let i=0;i<r.length;i+=4)r[i]=r[i+3],r[i+1]=r[i+2],r[i+2]=0,r[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let i=0;i<n;i++){const s=gn(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let l=o.length-1;l>=0;l--)r[i*4+l+c]=o[l]}this.valueBlock.value=e}}Jf.NAME="UniversalStringValueBlock";var Zf;class Gs extends Jf{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Zf=Gs;H.UniversalString=Zf;Gs.NAME="UniversalString";var Yf;class Js extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Yf=Js;H.NumericString=Yf;Js.NAME="NumericString";var Xf;class Zs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Xf=Zs;H.PrintableString=Xf;Zs.NAME="PrintableString";var Qf;class Ys extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Qf=Ys;H.TeletexString=Qf;Ys.NAME="TeletexString";var eh;class Xs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}eh=Xs;H.VideotexString=eh;Xs.NAME="VideotexString";var th;class Qs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}th=Qs;H.IA5String=th;Qs.NAME="IA5String";var nh;class eo extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}nh=eo;H.GraphicString=nh;eo.NAME="GraphicString";var rh;class Yr extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}rh=Yr;H.VisibleString=rh;Yr.NAME="VisibleString";var ih;class to extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}ih=to;H.GeneralString=ih;to.NAME="GeneralString";var sh;class no extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}sh=no;H.CharacterString=sh;no.NAME="CharacterString";var oh;class Xr extends Yr{constructor({value:e,valueDate:n,...r}={}){if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}n&&(this.fromDate(n),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.toUint8Array(e)))}toBuffer(){const e=this.toString(),n=new ArrayBuffer(e.length),r=new Uint8Array(n);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return n}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const r=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(r===null){this.error="Wrong input string for conversion";return}const i=parseInt(r[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(r[2],10),this.day=parseInt(r[3],10),this.hour=parseInt(r[4],10),this.minute=parseInt(r[5],10),this.second=parseInt(r[6],10)}toString(e="iso"){if(e==="iso"){const n=new Array(7);return n[0]=Ge(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Ge(this.month,2),n[2]=Ge(this.day,2),n[3]=Ge(this.hour,2),n[4]=Ge(this.minute,2),n[5]=Ge(this.second,2),n[6]="Z",n.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}oh=Xr;H.UTCTime=oh;Xr.NAME="UTCTime";var ah;class ro extends Xr{constructor(e={}){var n;super(e),(n=this.millisecond)!==null&&n!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let n=!1,r="",i="",s=0,o,c=0,l=0;if(e[e.length-1]==="Z")r=e.substring(0,e.length-1),n=!0;else{const h=new Number(e[e.length-1]);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");r=e}if(n){if(r.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(r.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let h=1,m=r.indexOf("+"),y="";if(m===-1&&(m=r.indexOf("-"),h=-1),m!==-1){if(y=r.substring(m+1),r=r.substring(0,m),y.length!==2&&y.length!==4)throw new Error("Wrong input string for conversion");let f=parseInt(y.substring(0,2),10);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");if(c=h*f,y.length===4){if(f=parseInt(y.substring(2,4),10),isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");l=h*f}}}let u=r.indexOf(".");if(u===-1&&(u=r.indexOf(",")),u!==-1){const h=new Number(`0${r.substring(u)}`);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");s=h.valueOf(),i=r.substring(0,u)}else i=r;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.minute=Math.floor(h),h=60*(h-this.minute),this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const h=1e3*s;this.millisecond=Math.floor(h)}break;default:throw new Error("Wrong input string for conversion")}const p=o.exec(i);if(p===null)throw new Error("Wrong input string for conversion");for(let h=1;h<p.length;h++)switch(h){case 1:this.year=parseInt(p[h],10);break;case 2:this.month=parseInt(p[h],10);break;case 3:this.day=parseInt(p[h],10);break;case 4:this.hour=parseInt(p[h],10)+c;break;case 5:this.minute=parseInt(p[h],10)+l;break;case 6:this.second=parseInt(p[h],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const h=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=h.getUTCFullYear(),this.month=h.getUTCMonth(),this.day=h.getUTCDay(),this.hour=h.getUTCHours(),this.minute=h.getUTCMinutes(),this.second=h.getUTCSeconds(),this.millisecond=h.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const n=[];return n.push(Ge(this.year,4)),n.push(Ge(this.month,2)),n.push(Ge(this.day,2)),n.push(Ge(this.hour,2)),n.push(Ge(this.minute,2)),n.push(Ge(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Ge(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}ah=ro;H.GeneralizedTime=ah;ro.NAME="GeneralizedTime";var ch;class el extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}ch=el;H.DATE=ch;el.NAME="DATE";var lh;class tl extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}lh=tl;H.TimeOfDay=lh;tl.NAME="TimeOfDay";var uh;class nl extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}uh=nl;H.DateTime=uh;nl.NAME="DateTime";var dh;class rl extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}dh=rl;H.Duration=dh;rl.NAME="Duration";var ph;class il extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}ph=il;H.TIME=ph;il.NAME="TIME";class _n{constructor({name:e=Me,optional:n=!1}={}){this.name=e,this.optional=n}}class sl extends _n{constructor({value:e=[],...n}={}){super(n),this.value=e}}class Xi extends _n{constructor({value:e=new _n,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class E_{constructor({data:e=Ds}={}){this.dataView=M.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=M.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function an(t,e,n){if(n instanceof sl){for(let s=0;s<n.value.length;s++)if(an(t,e,n.value[s]).verified)return{verified:!0,result:t};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return n.hasOwnProperty(Fo)&&(s.name=n.name),s}}if(n instanceof _n)return n.hasOwnProperty(Fo)&&(t[n.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(g_ in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(v_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(w_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(m_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(__)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(y_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(h_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(n.idBlock.isHexOnly){if(!(zu in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(t[n.name]=e)),n instanceof H.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof Xi&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let l=!0;for(let u=0;u<n.valueBlock.value.length;u++)l=l&&(n.valueBlock.value[u].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(n.valueBlock.value[l].optional===!1){const u={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof Xi){if(o=an(t,e.valueBlock.value[l],n.valueBlock.value[0].value),o.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(Fo in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};b_ in n.valueBlock.value[0]&&n.valueBlock.value[0].local?u=e:u=t,typeof u[n.valueBlock.value[0].name]>"u"&&(u[n.valueBlock.value[0].name]=[]),u[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(o=an(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),o.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(o.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&zu in e.valueBlock){const s=nr(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],o.name=n.name)),o}return an(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function I_(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=nr(M.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:an(n.result,n.result,e)}const fh=Object.freeze(Object.defineProperty({__proto__:null,Any:_n,BaseBlock:je,BaseStringBlock:Zc,BitString:dn,BmpString:Ws,Boolean:Fs,CharacterString:no,Choice:sl,Constructed:De,DATE:el,DateTime:nl,Duration:rl,EndOfContent:Yc,Enumerated:Hs,GeneralString:to,GeneralizedTime:ro,GraphicString:eo,HexBlock:Et,IA5String:Qs,Integer:bt,Null:mn,NumericString:Js,ObjectIdentifier:Ks,OctetString:un,Primitive:Zr,PrintableString:Zs,RawData:E_,RelativeObjectIdentifier:Qc,Repeated:Xi,Sequence:zt,Set:jt,TIME:il,TeletexString:Ys,TimeOfDay:tl,UTCTime:Xr,UniversalString:Gs,Utf8String:Ut,ValueBlock:Le,VideotexString:Xs,ViewWriter:qs,VisibleString:Yr,compareSchema:an,fromBER:Ln,verifySchema:I_},Symbol.toStringTag,{value:"Module"}));var T;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(T||(T={}));var w;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(w||(w={}));class io{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(M.isBufferSource(e))this.unusedBits=n,this.value=M.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof dn))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new dn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new dn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const r of n)e+=r.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let n=e.toString(2);const r=n.length+7>>3;this.unusedBits=(r<<3)-n.length;const i=new Uint8Array(r);n=n.padStart(r<<3,"0").split("").reverse().join("");let s=0;for(;s<r;)i[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class ae{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):M.isBufferSource(e)?this.buffer=M.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof un))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new un({valueHex:this.buffer})}toSchema(e){return new un({name:e})}}const C_={fromASN:t=>t instanceof mn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new mn;const e=Ln(t);if(e.result.error)throw new Error(e.result.error);return e.result}},N_={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new bt({value:+t})},$_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new Hs({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new bt({valueHex:t})},z_={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new dn({valueHex:t})},j_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new Ks({value:t})},O_={fromASN:t=>t.valueBlock.value,toASN:t=>new Fs({value:t})},Qi={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new un({valueHex:t})},B_={fromASN:t=>new ae(t.getValue()),toASN:t=>t.toASN()};function rt(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const hh=rt(Ut),T_=rt(Ws),P_=rt(Gs),R_=rt(Js),L_=rt(Zs),U_=rt(Ys),V_=rt(Xs),M_=rt(Qs),q_=rt(eo),D_=rt(Yr),F_=rt(to),H_=rt(no),K_={fromASN:t=>t.toDate(),toASN:t=>new Xr({valueDate:t})},W_={fromASN:t=>t.toDate(),toASN:t=>new ro({valueDate:t})},G_={fromASN:()=>null,toASN:()=>new mn};function ol(t){switch(t){case w.Any:return C_;case w.BitString:return z_;case w.BmpString:return T_;case w.Boolean:return O_;case w.CharacterString:return H_;case w.Enumerated:return $_;case w.GeneralString:return F_;case w.GeneralizedTime:return W_;case w.GraphicString:return q_;case w.IA5String:return M_;case w.Integer:return N_;case w.Null:return G_;case w.NumericString:return R_;case w.ObjectIdentifier:return j_;case w.OctetString:return Qi;case w.PrintableString:return L_;case w.TeletexString:return U_;case w.UTCTime:return K_;case w.UniversalString:return P_;case w.Utf8String:return hh;case w.VideotexString:return V_;case w.VisibleString:return D_;default:return null}}function $t(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:$t(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function gh(t){var e;if(t){const n=Object.getPrototypeOf(t);return((e=n==null?void 0:n.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:gh(n)}return!1}function J_(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}class Z_{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:T.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(n,r),n.items=Object.assign({},n.items,r.items)),n}create(e,n){const r=this.items.get(e)||this.createDefault(e),i=[];for(const s in r.items){const o=r.items[s],c=n?s:"";let l;if(typeof o.type=="number"){const p=w[o.type],h=fh[p];if(!h)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new h({name:c})}else $t(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===T.Choice?l=new _n({name:c}):(l=this.create(o.type,!1),l.name=c):l=new _n({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?jt:zt;l=new p({name:"",value:[new Xi({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||$t(o.type)){const p=o.repeated?De:Zr;i.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const p=!!o.repeated;let h=p?l:this.get(o.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,i.push(new De({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:h}))}else i.push(new De({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,i.push(l)}switch(r.type){case T.Sequence:return new zt({value:i,name:""});case T.Set:return new jt({value:i,name:""});case T.Choice:return new sl({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,n){return this.items.set(e,n),this}findParentSchema(e){const n=Object.getPrototypeOf(e);return n?this.items.get(n)||this.findParentSchema(n):null}}const Qe=new Z_,P=t=>e=>{let n;Qe.has(e)?n=Qe.get(e):(n=Qe.createDefault(e),Qe.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;Qe.has(e.constructor)?r=Qe.get(e.constructor):(r=Qe.createDefault(e.constructor),Qe.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=ol(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);i.converter=s}r.items[n]=i};class Ou extends Error{constructor(){super(...arguments),this.schemas=[]}}class Y_{static parse(e,n){const r=Ln(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,n)}static fromASN(e,n){var r;try{if($t(n))return new n().fromASN(e);const i=Qe.get(n);Qe.cache(n);let s=i.schema;if(e.constructor===De&&i.type!==T.Choice){s=new De({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const o=an({},e,s);if(!o.verified)throw new Ou(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if(gh(n)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const l=i.itemType;if(typeof l=="number"){const u=ol(l);if(!u)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>u.fromASN(p))}else return n.from(e.valueBlock.value,u=>this.fromASN(u,l))}for(const l in i.items){const u=o.result[l];if(!u)continue;const p=i.items[l],h=p.type;if(typeof h=="number"||$t(h)){const m=(r=p.converter)!==null&&r!==void 0?r:$t(h)?new h:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const y=p.repeated==="sequence"?zt:jt,f=new y;f.valueBlock=u.valueBlock;const _=Ln(f.toBER(!1));if(_.offset===-1)throw new Error(`Cannot parse the child item. ${_.result.error}`);if(!("value"in _.result.valueBlock&&Array.isArray(_.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const v=_.result.valueBlock.value;c[l]=Array.from(v,x=>m.fromASN(x))}else c[l]=Array.from(u,y=>m.fromASN(y));else{let y=u;if(p.implicit){let f;if($t(h))f=new h().toSchema("");else{const _=w[h],v=fh[_];if(!v)throw new Error(`Cannot get '${_}' class from asn1js module`);f=new v}f.valueBlock=y.valueBlock,y=Ln(f.toBER(!1)).result}c[l]=m.fromASN(y)}}else if(p.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(u,m=>this.fromASN(m,h))}else c[l]=this.fromASN(u,h)}return c}catch(i){throw i instanceof Ou&&i.schemas.push(n.name),i}}}class al{static serialize(e){return e instanceof je?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&$t(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=Qe.get(n);Qe.cache(n);let i=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof r.itemType=="number"){const o=ol(r.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:r.itemType},"[]",n,o))}else for(const o in r.items){const c=r.items[o],l=e[o];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&J_(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=al.toAsnItem(c,o,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||$t(c.type))){const p={};p.valueHex=u instanceof mn?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new Zr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new De({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else i.push(new De({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[u]}));else c.repeated?i=i.concat(u):i.push(u)}let s;switch(r.type){case T.Sequence:s=new zt({value:i});break;case T.Set:s=new jt({value:i});break;case T.Choice:if(!i[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,n,r,i){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${n}' doesn't have converter for type ${w[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,u=>o.toASN(u)),l=e.repeated==="sequence"?zt:jt;s=new l({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?zt:jt;s=new c({value:o})}else s=this.toASN(i);return s}}class de extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class V{static serialize(e){return al.serialize(e)}static parse(e,n){return Y_.parse(e,n)}static toString(e){const n=M.isBufferSource(e)?M.toArrayBuffer(e):V.serialize(e),r=Ln(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function d(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var mh={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,"i"),threeOctet:new RegExp(`^${n}\\.${n}\\.${n}$`,"i"),twoOctet:new RegExp(`^${n}\\.${n}$`,"i"),longValue:new RegExp(`^${n}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,"i")};function u(f,_){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let v=0,x=-1,N=(f.match(l.zoneIndex)||[])[0],B,R;for(N&&(N=N.substring(1),f=f.replace(/%.+$/,""));(x=f.indexOf(":",x+1))>=0;)v++;if(f.substr(0,2)==="::"&&v--,f.substr(-2,2)==="::"&&v--,v>_)return null;for(R=_-v,B=":";R--;)B+="0:";return f=f.replace("::",B),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),_=function(){const te=f.split(":"),pe=[];for(let le=0;le<te.length;le++)pe.push(parseInt(te[le],16));return pe}(),{parts:_,zoneId:N}}function p(f,_,v,x){if(f.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let N=0,B;for(;x>0;){if(B=v-x,B<0&&(B=0),f[N]>>B!==_[N]>>B)return!1;x-=v,N+=1}return!0}function h(f){if(s.test(f))return parseInt(f,16);if(f[0]==="0"&&!isNaN(parseInt(f[1],10))){if(i.test(f))return parseInt(f,8);throw new Error(`ipaddr: cannot parse ${f} as octal`)}return parseInt(f,10)}function m(f,_){for(;f.length<_;)f=`0${f}`;return f}const y={};y.IPv4=function(){function f(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let v,x;for(v=0;v<_.length;v++)if(x=_[v],!(0<=x&&x<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return f.prototype.SpecialRanges={unspecified:[[new f([0,0,0,0]),8]],broadcast:[[new f([255,255,255,255]),32]],multicast:[[new f([224,0,0,0]),4]],linkLocal:[[new f([169,254,0,0]),16]],loopback:[[new f([127,0,0,0]),8]],carrierGradeNat:[[new f([100,64,0,0]),10]],private:[[new f([10,0,0,0]),8],[new f([172,16,0,0]),12],[new f([192,168,0,0]),16]],reserved:[[new f([192,0,0,0]),24],[new f([192,0,2,0]),24],[new f([192,88,99,0]),24],[new f([198,18,0,0]),15],[new f([198,51,100,0]),24],[new f([203,0,113,0]),24],[new f([240,0,0,0]),4]],as112:[[new f([192,175,48,0]),24],[new f([192,31,196,0]),24]],amt:[[new f([192,52,193,0]),24]]},f.prototype.kind=function(){return"ipv4"},f.prototype.match=function(_,v){let x;if(v===void 0&&(x=_,_=x[0],v=x[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,v)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const x={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let N,B,R;for(N=3;N>=0;N-=1)if(B=this.octets[N],B in x){if(R=x[B],v&&R!==0)return null;R!==8&&(v=!0),_+=R}else return null;return 32-_},f.prototype.range=function(){return y.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){return this.octets.slice(0)},f.prototype.toIPv4MappedAddress=function(){return y.IPv6.parse(`::ffff:${this.toString()}`)},f.prototype.toNormalizedString=function(){return this.toString()},f.prototype.toString=function(){return this.octets.join(".")},f}(),y.IPv4.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),v=_[0].toByteArray(),x=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let B=0;for(;B<4;)N.push(parseInt(v[B],10)|parseInt(x[B],10)^255),B++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},y.IPv4.isIPv4=function(f){return this.parser(f)!==null},y.IPv4.isValid=function(f){try{return new this(this.parser(f)),!0}catch{return!1}},y.IPv4.isValidCIDR=function(f){try{return this.parseCIDR(f),!0}catch{return!1}},y.IPv4.isValidFourPartDecimal=function(f){return!!(y.IPv4.isValid(f)&&f.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},y.IPv4.networkAddressFromCIDR=function(f){let _,v,x,N,B;try{for(_=this.parseCIDR(f),x=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],v=0;v<4;)N.push(parseInt(x[v],10)&parseInt(B[v],10)),v++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},y.IPv4.parse=function(f){const _=this.parser(f);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},y.IPv4.parseCIDR=function(f){let _;if(_=f.match(/^(.+)\/(\d+)$/)){const v=parseInt(_[2]);if(v>=0&&v<=32){const x=[this.parse(_[1]),v];return Object.defineProperty(x,"toString",{value:function(){return this.join("/")}}),x}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},y.IPv4.parser=function(f){let _,v,x;if(_=f.match(r.fourOctet))return function(){const N=_.slice(1,6),B=[];for(let R=0;R<N.length;R++)v=N[R],B.push(h(v));return B}();if(_=f.match(r.longValue)){if(x=h(_[1]),x>4294967295||x<0)throw new Error("ipaddr: address outside defined range");return function(){const N=[];let B;for(B=0;B<=24;B+=8)N.push(x>>B&255);return N}().reverse()}else return(_=f.match(r.twoOctet))?function(){const N=_.slice(1,4),B=[];if(x=h(N[1]),x>16777215||x<0)throw new Error("ipaddr: address outside defined range");return B.push(h(N[0])),B.push(x>>16&255),B.push(x>>8&255),B.push(x&255),B}():(_=f.match(r.threeOctet))?function(){const N=_.slice(1,5),B=[];if(x=h(N[2]),x>65535||x<0)throw new Error("ipaddr: address outside defined range");return B.push(h(N[0])),B.push(h(N[1])),B.push(x>>8&255),B.push(x&255),B}():null},y.IPv4.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let v=0;const x=Math.floor(f/8);for(;v<x;)_[v]=255,v++;return x<4&&(_[x]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},y.IPv6=function(){function f(_,v){let x,N;if(_.length===16)for(this.parts=[],x=0;x<=14;x+=2)this.parts.push(_[x]<<8|_[x+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(x=0;x<this.parts.length;x++)if(N=this.parts[x],!(0<=N&&N<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");v&&(this.zoneId=v)}return f.prototype.SpecialRanges={unspecified:[new f([0,0,0,0,0,0,0,0]),128],linkLocal:[new f([65152,0,0,0,0,0,0,0]),10],multicast:[new f([65280,0,0,0,0,0,0,0]),8],loopback:[new f([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new f([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new f([0,0,0,0,0,65535,0,0]),96],discard:[new f([256,0,0,0,0,0,0,0]),64],rfc6145:[new f([0,0,0,0,65535,0,0,0]),96],rfc6052:[new f([100,65435,0,0,0,0,0,0]),96],"6to4":[new f([8194,0,0,0,0,0,0,0]),16],teredo:[new f([8193,0,0,0,0,0,0,0]),32],benchmarking:[new f([8193,2,0,0,0,0,0,0]),48],amt:[new f([8193,3,0,0,0,0,0,0]),32],as112v6:[[new f([8193,4,274,0,0,0,0,0]),48],[new f([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new f([8193,16,0,0,0,0,0,0]),28],orchid2:[new f([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new f([8193,48,0,0,0,0,0,0]),28],reserved:[[new f([8193,0,0,0,0,0,0,0]),23],[new f([8193,3512,0,0,0,0,0,0]),32]]},f.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},f.prototype.kind=function(){return"ipv6"},f.prototype.match=function(_,v){let x;if(v===void 0&&(x=_,_=x[0],v=x[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,v)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const x={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let N,B;for(let R=7;R>=0;R-=1)if(N=this.parts[R],N in x){if(B=x[N],v&&B!==0)return null;B!==16&&(v=!0),_+=B}else return null;return 128-_},f.prototype.range=function(){return y.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){let _;const v=[],x=this.parts;for(let N=0;N<x.length;N++)_=x[N],v.push(_>>8),v.push(_&255);return v},f.prototype.toFixedLengthString=function(){const _=(function(){const x=[];for(let N=0;N<this.parts.length;N++)x.push(m(this.parts[N].toString(16),4));return x}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},f.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),v=_[0],x=_[1];return new y.IPv4([v>>8,v&255,x>>8,x&255])},f.prototype.toNormalizedString=function(){const _=(function(){const x=[];for(let N=0;N<this.parts.length;N++)x.push(this.parts[N].toString(16));return x}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},f.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,v=this.toNormalizedString();let x=0,N=-1,B;for(;B=_.exec(v);)B[0].length>N&&(x=B.index,N=B[0].length);return N<0?v:`${v.substring(0,x)}::${v.substring(x+N)}`},f.prototype.toString=function(){return this.toRFC5952String()},f}(),y.IPv6.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),v=_[0].toByteArray(),x=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let B=0;for(;B<16;)N.push(parseInt(v[B],10)|parseInt(x[B],10)^255),B++;return new this(N)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},y.IPv6.isIPv6=function(f){return this.parser(f)!==null},y.IPv6.isValid=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{const _=this.parser(f);return new this(_.parts,_.zoneId),!0}catch{return!1}},y.IPv6.isValidCIDR=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{return this.parseCIDR(f),!0}catch{return!1}},y.IPv6.networkAddressFromCIDR=function(f){let _,v,x,N,B;try{for(_=this.parseCIDR(f),x=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],v=0;v<16;)N.push(parseInt(x[v],10)&parseInt(B[v],10)),v++;return new this(N)}catch(R){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${R})`)}},y.IPv6.parse=function(f){const _=this.parser(f);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},y.IPv6.parseCIDR=function(f){let _,v,x;if((v=f.match(/^(.+)\/(\d+)$/))&&(_=parseInt(v[2]),_>=0&&_<=128))return x=[this.parse(v[1]),_],Object.defineProperty(x,"toString",{value:function(){return this.join("/")}}),x;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},y.IPv6.parser=function(f){let _,v,x,N,B,R;if(x=f.match(l.deprecatedTransitional))return this.parser(`::ffff:${x[1]}`);if(l.native.test(f))return u(f,8);if((x=f.match(l.transitional))&&(R=x[6]||"",_=x[1],x[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+R,6),_.parts)){for(B=[parseInt(x[2]),parseInt(x[3]),parseInt(x[4]),parseInt(x[5])],v=0;v<B.length;v++)if(N=B[v],!(0<=N&&N<=255))return null;return _.parts.push(B[0]<<8|B[1]),_.parts.push(B[2]<<8|B[3]),{parts:_.parts,zoneId:_.zoneId}}return null},y.IPv6.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>128)throw new Error("ipaddr: invalid IPv6 prefix length");const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let v=0;const x=Math.floor(f/8);for(;v<x;)_[v]=255,v++;return x<16&&(_[x]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},y.fromByteArray=function(f){const _=f.length;if(_===4)return new y.IPv4(f);if(_===16)return new y.IPv6(f);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},y.isValid=function(f){return y.IPv6.isValid(f)||y.IPv4.isValid(f)},y.isValidCIDR=function(f){return y.IPv6.isValidCIDR(f)||y.IPv4.isValidCIDR(f)},y.parse=function(f){if(y.IPv6.isValid(f))return y.IPv6.parse(f);if(y.IPv4.isValid(f))return y.IPv4.parse(f);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},y.parseCIDR=function(f){try{return y.IPv6.parseCIDR(f)}catch{try{return y.IPv4.parseCIDR(f)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},y.process=function(f){const _=this.parse(f);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},y.subnetMatch=function(f,_,v){let x,N,B,R;v==null&&(v="unicast");for(N in _)if(Object.prototype.hasOwnProperty.call(_,N)){for(B=_[N],B[0]&&!(B[0]instanceof Array)&&(B=[B]),x=0;x<B.length;x++)if(R=B[x],f.kind()===R[0].kind()&&f.match.apply(f,R))return N}return v},t.exports?t.exports=y:e.ipaddr=y})(Zi)})(mh);var Bu=mh.exports;class Tu{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const n=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let r=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return r=r.slice(0,-1),`${r}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return Bu.fromByteArray(Array.from(n)).toString()}return this.decodeIP(G.ToHex(e))}static fromString(e){const n=Bu.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var ya,va,wa;let Oe=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([g({type:w.TeletexString})],Oe.prototype,"teletexString",void 0);d([g({type:w.PrintableString})],Oe.prototype,"printableString",void 0);d([g({type:w.UniversalString})],Oe.prototype,"universalString",void 0);d([g({type:w.Utf8String})],Oe.prototype,"utf8String",void 0);d([g({type:w.BmpString})],Oe.prototype,"bmpString",void 0);Oe=d([P({type:T.Choice})],Oe);let qn=class extends Oe{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?G.ToHex(this.anyValue):super.toString())}};d([g({type:w.IA5String})],qn.prototype,"ia5String",void 0);d([g({type:w.Any})],qn.prototype,"anyValue",void 0);qn=d([P({type:T.Choice})],qn);class so{constructor(e={}){this.type="",this.value=new qn,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],so.prototype,"type",void 0);d([g({type:qn})],so.prototype,"value",void 0);let Dn=ya=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ya.prototype)}};Dn=ya=d([P({type:T.Set,itemType:so})],Dn);let ba=va=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,va.prototype)}};ba=va=d([P({type:T.Sequence,itemType:Dn})],ba);let ke=wa=class extends ba{constructor(e){super(e),Object.setPrototypeOf(this,wa.prototype)}};ke=wa=d([P({type:T.Sequence})],ke);const X_={fromASN:t=>Tu.toString(Qi.fromASN(t)),toASN:t=>Qi.toASN(Tu.fromString(t))};class zr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],zr.prototype,"typeId",void 0);d([g({type:w.Any,context:0})],zr.prototype,"value",void 0);class cl{constructor(e={}){this.partyName=new Oe,Object.assign(this,e)}}d([g({type:Oe,optional:!0,context:0,implicit:!0})],cl.prototype,"nameAssigner",void 0);d([g({type:Oe,context:1,implicit:!0})],cl.prototype,"partyName",void 0);let re=class{constructor(e={}){Object.assign(this,e)}};d([g({type:zr,context:0,implicit:!0})],re.prototype,"otherName",void 0);d([g({type:w.IA5String,context:1,implicit:!0})],re.prototype,"rfc822Name",void 0);d([g({type:w.IA5String,context:2,implicit:!0})],re.prototype,"dNSName",void 0);d([g({type:w.Any,context:3,implicit:!0})],re.prototype,"x400Address",void 0);d([g({type:ke,context:4,implicit:!1})],re.prototype,"directoryName",void 0);d([g({type:cl,context:5})],re.prototype,"ediPartyName",void 0);d([g({type:w.IA5String,context:6,implicit:!0})],re.prototype,"uniformResourceIdentifier",void 0);d([g({type:w.OctetString,context:7,implicit:!0,converter:X_})],re.prototype,"iPAddress",void 0);d([g({type:w.ObjectIdentifier,context:8,implicit:!0})],re.prototype,"registeredID",void 0);re=d([P({type:T.Choice})],re);const ll="1.3.6.1.5.5.7",Q_=`${ll}.1`,rr=`${ll}.3`,oo=`${ll}.48`,Pu=`${oo}.1`,Ru=`${oo}.2`,Lu=`${oo}.3`,Uu=`${oo}.5`,Xt="2.5.29";var ka;const xa=`${Q_}.1`;class Qr{constructor(e={}){this.accessMethod="",this.accessLocation=new re,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Qr.prototype,"accessMethod",void 0);d([g({type:re})],Qr.prototype,"accessLocation",void 0);let Pn=ka=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ka.prototype)}};Pn=ka=d([P({type:T.Sequence,itemType:Qr})],Pn);const Sa=`${Xt}.35`;class ul extends ae{}class cn{constructor(e={}){e&&Object.assign(this,e)}}d([g({type:ul,context:0,optional:!0,implicit:!0})],cn.prototype,"keyIdentifier",void 0);d([g({type:re,context:1,optional:!0,implicit:!0,repeated:"sequence"})],cn.prototype,"authorityCertIssuer",void 0);d([g({type:w.Integer,context:2,optional:!0,implicit:!0,converter:_e})],cn.prototype,"authorityCertSerialNumber",void 0);const _h=`${Xt}.19`;class es{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([g({type:w.Boolean,defaultValue:!1})],es.prototype,"cA",void 0);d([g({type:w.Integer,optional:!0})],es.prototype,"pathLenConstraint",void 0);var Aa;let Re=Aa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Aa.prototype)}};Re=Aa=d([P({type:T.Sequence,itemType:re})],Re);var Ea;let Vu=Ea=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,Ea.prototype)}};Vu=Ea=d([P({type:T.Sequence})],Vu);var Ia;const yh=`${Xt}.32`;let Ot=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([g({type:w.IA5String})],Ot.prototype,"ia5String",void 0);d([g({type:w.VisibleString})],Ot.prototype,"visibleString",void 0);d([g({type:w.BmpString})],Ot.prototype,"bmpString",void 0);d([g({type:w.Utf8String})],Ot.prototype,"utf8String",void 0);Ot=d([P({type:T.Choice})],Ot);class dl{constructor(e={}){this.organization=new Ot,this.noticeNumbers=[],Object.assign(this,e)}}d([g({type:Ot})],dl.prototype,"organization",void 0);d([g({type:w.Integer,repeated:"sequence"})],dl.prototype,"noticeNumbers",void 0);class pl{constructor(e={}){Object.assign(this,e)}}d([g({type:dl,optional:!0})],pl.prototype,"noticeRef",void 0);d([g({type:Ot,optional:!0})],pl.prototype,"explicitText",void 0);let ts=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.IA5String})],ts.prototype,"cPSuri",void 0);d([g({type:pl})],ts.prototype,"userNotice",void 0);ts=d([P({type:T.Choice})],ts);class fl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],fl.prototype,"policyQualifierId",void 0);d([g({type:w.Any})],fl.prototype,"qualifier",void 0);class ao{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ao.prototype,"policyIdentifier",void 0);d([g({type:fl,repeated:"sequence",optional:!0})],ao.prototype,"policyQualifiers",void 0);let ns=Ia=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ia.prototype)}};ns=Ia=d([P({type:T.Sequence,itemType:ao})],ns);let rs=class{constructor(e=0){this.value=e}};d([g({type:w.Integer})],rs.prototype,"value",void 0);rs=d([P({type:T.Choice})],rs);let Mu=class extends rs{};Mu=d([P({type:T.Choice})],Mu);var Ca;const Na=`${Xt}.31`;var ct;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(ct||(ct={}));class vh extends io{toJSON(){const e=[],n=this.toNumber();return n&ct.aACompromise&&e.push("aACompromise"),n&ct.affiliationChanged&&e.push("affiliationChanged"),n&ct.cACompromise&&e.push("cACompromise"),n&ct.certificateHold&&e.push("certificateHold"),n&ct.cessationOfOperation&&e.push("cessationOfOperation"),n&ct.keyCompromise&&e.push("keyCompromise"),n&ct.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&ct.superseded&&e.push("superseded"),n&ct.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let yn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,repeated:"sequence",implicit:!0})],yn.prototype,"fullName",void 0);d([g({type:Dn,context:1,implicit:!0})],yn.prototype,"nameRelativeToCRLIssuer",void 0);yn=d([P({type:T.Choice})],yn);class ir{constructor(e={}){Object.assign(this,e)}}d([g({type:yn,context:0,optional:!0})],ir.prototype,"distributionPoint",void 0);d([g({type:vh,context:1,optional:!0,implicit:!0})],ir.prototype,"reasons",void 0);d([g({type:re,context:2,optional:!0,repeated:"sequence",implicit:!0})],ir.prototype,"cRLIssuer",void 0);let Un=Ca=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ca.prototype)}};Un=Ca=d([P({type:T.Sequence,itemType:ir})],Un);var $a;let qu=$a=class extends Un{constructor(e){super(e),Object.setPrototypeOf(this,$a.prototype)}};qu=$a=d([P({type:T.Sequence,itemType:ir})],qu);class Te{constructor(e={}){this.onlyContainsUserCerts=Te.ONLY,this.onlyContainsCACerts=Te.ONLY,this.indirectCRL=Te.ONLY,this.onlyContainsAttributeCerts=Te.ONLY,Object.assign(this,e)}}Te.ONLY=!1;d([g({type:yn,context:0,optional:!0})],Te.prototype,"distributionPoint",void 0);d([g({type:w.Boolean,context:1,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsUserCerts",void 0);d([g({type:w.Boolean,context:2,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsCACerts",void 0);d([g({type:vh,context:3,optional:!0,implicit:!0})],Te.prototype,"onlySomeReasons",void 0);d([g({type:w.Boolean,context:4,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"indirectCRL",void 0);d([g({type:w.Boolean,context:5,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsAttributeCerts",void 0);var xr;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(xr||(xr={}));let za=class{constructor(e=xr.unspecified){this.reason=xr.unspecified,this.reason=e}toJSON(){return xr[this.reason]}toString(){return this.toJSON()}};d([g({type:w.Enumerated})],za.prototype,"reason",void 0);za=d([P({type:T.Choice})],za);var ja;const wh=`${Xt}.37`;let is=ja=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ja.prototype)}};is=ja=d([P({type:T.Sequence,itemType:w.ObjectIdentifier})],is);const e0=`${rr}.1`,t0=`${rr}.2`,n0=`${rr}.3`,r0=`${rr}.4`,i0=`${rr}.8`,s0=`${rr}.9`;let Oa=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([g({type:w.Integer,converter:_e})],Oa.prototype,"value",void 0);Oa=d([P({type:T.Choice})],Oa);let Ba=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([g({type:w.GeneralizedTime})],Ba.prototype,"value",void 0);Ba=d([P({type:T.Choice})],Ba);var Ta;let Du=Ta=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,Ta.prototype)}};Du=Ta=d([P({type:T.Sequence})],Du);const bh=`${Xt}.15`;var lt;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(lt||(lt={}));class Ho extends io{toJSON(){const e=this.toNumber(),n=[];return e<.cRLSign&&n.push("crlSign"),e<.dataEncipherment&&n.push("dataEncipherment"),e<.decipherOnly&&n.push("decipherOnly"),e<.digitalSignature&&n.push("digitalSignature"),e<.encipherOnly&&n.push("encipherOnly"),e<.keyAgreement&&n.push("keyAgreement"),e<.keyCertSign&&n.push("keyCertSign"),e<.keyEncipherment&&n.push("keyEncipherment"),e<.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var Pa;class co{constructor(e={}){this.base=new re,this.minimum=0,Object.assign(this,e)}}d([g({type:re})],co.prototype,"base",void 0);d([g({type:w.Integer,context:0,defaultValue:0,implicit:!0})],co.prototype,"minimum",void 0);d([g({type:w.Integer,context:1,optional:!0,implicit:!0})],co.prototype,"maximum",void 0);let ss=Pa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Pa.prototype)}};ss=Pa=d([P({type:T.Sequence,itemType:co})],ss);class kh{constructor(e={}){Object.assign(this,e)}}d([g({type:ss,context:0,optional:!0,implicit:!0})],kh.prototype,"permittedSubtrees",void 0);d([g({type:ss,context:1,optional:!0,implicit:!0})],kh.prototype,"excludedSubtrees",void 0);class xh{constructor(e={}){Object.assign(this,e)}}d([g({type:w.Integer,context:0,implicit:!0,optional:!0,converter:_e})],xh.prototype,"requireExplicitPolicy",void 0);d([g({type:w.Integer,context:1,implicit:!0,optional:!0,converter:_e})],xh.prototype,"inhibitPolicyMapping",void 0);var Ra;class hl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],hl.prototype,"issuerDomainPolicy",void 0);d([g({type:w.ObjectIdentifier})],hl.prototype,"subjectDomainPolicy",void 0);let Fu=Ra=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};Fu=Ra=d([P({type:T.Sequence,itemType:hl})],Fu);var La;const Sh=`${Xt}.17`;let Ua=La=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,La.prototype)}};Ua=La=d([P({type:T.Sequence})],Ua);let Bt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Bt.prototype,"type",void 0);d([g({type:w.Any,repeated:"set"})],Bt.prototype,"values",void 0);var Va;let Hu=Va=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Va.prototype)}};Hu=Va=d([P({type:T.Sequence,itemType:Bt})],Hu);const Ah=`${Xt}.14`;class Ht extends ul{}class Eh{constructor(e={}){Object.assign(this,e)}}d([g({type:w.GeneralizedTime,context:0,implicit:!0,optional:!0})],Eh.prototype,"notBefore",void 0);d([g({type:w.GeneralizedTime,context:1,implicit:!0,optional:!0})],Eh.prototype,"notAfter",void 0);var Sr;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Sr||(Sr={}));class Ih extends io{toJSON(){const e=[],n=this.toNumber();return n&Sr.pKIXCertificate&&e.push("pKIXCertificate"),n&Sr.newExtensions&&e.push("newExtensions"),n&Sr.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Ch{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Ih,Object.assign(this,e)}}d([g({type:w.GeneralString})],Ch.prototype,"entrustVers",void 0);d([g({type:Ih})],Ch.prototype,"entrustInfoFlags",void 0);var Ma;let Ku=Ma=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}};Ku=Ma=d([P({type:T.Sequence,itemType:Qr})],Ku);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&hf(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([g({type:w.ObjectIdentifier})],F.prototype,"algorithm",void 0);d([g({type:w.Any,optional:!0})],F.prototype,"parameters",void 0);class ut{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],ut.prototype,"algorithm",void 0);d([g({type:w.BitString})],ut.prototype,"subjectPublicKey",void 0);let ze=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const n=new Date(e);n.getUTCFullYear()>2049?this.generalTime=n:this.utcTime=n}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};d([g({type:w.UTCTime})],ze.prototype,"utcTime",void 0);d([g({type:w.GeneralizedTime})],ze.prototype,"generalTime",void 0);ze=d([P({type:T.Choice})],ze);class ei{constructor(e){this.notBefore=new ze(new Date),this.notAfter=new ze(new Date),e&&(this.notBefore=new ze(e.notBefore),this.notAfter=new ze(e.notAfter))}}d([g({type:ze})],ei.prototype,"notBefore",void 0);d([g({type:ze})],ei.prototype,"notAfter",void 0);var qa;let nt=class Nh{constructor(e={}){this.extnID="",this.critical=Nh.CRITICAL,this.extnValue=new ae,Object.assign(this,e)}};nt.CRITICAL=!1;d([g({type:w.ObjectIdentifier})],nt.prototype,"extnID",void 0);d([g({type:w.Boolean,defaultValue:nt.CRITICAL})],nt.prototype,"critical",void 0);d([g({type:ae})],nt.prototype,"extnValue",void 0);let Gt=qa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,qa.prototype)}};Gt=qa=d([P({type:T.Sequence,itemType:nt})],Gt);var vn;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(vn||(vn={}));class Ye{constructor(e={}){this.version=vn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new ke,this.validity=new ei,this.subject=new ke,this.subjectPublicKeyInfo=new ut,Object.assign(this,e)}}d([g({type:w.Integer,context:0,defaultValue:vn.v1})],Ye.prototype,"version",void 0);d([g({type:w.Integer,converter:_e})],Ye.prototype,"serialNumber",void 0);d([g({type:F})],Ye.prototype,"signature",void 0);d([g({type:ke})],Ye.prototype,"issuer",void 0);d([g({type:ei})],Ye.prototype,"validity",void 0);d([g({type:ke})],Ye.prototype,"subject",void 0);d([g({type:ut})],Ye.prototype,"subjectPublicKeyInfo",void 0);d([g({type:w.BitString,context:1,implicit:!0,optional:!0})],Ye.prototype,"issuerUniqueID",void 0);d([g({type:w.BitString,context:2,implicit:!0,optional:!0})],Ye.prototype,"subjectUniqueID",void 0);d([g({type:Gt,context:3,optional:!0})],Ye.prototype,"extensions",void 0);class wn{constructor(e={}){this.tbsCertificate=new Ye,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Ye})],wn.prototype,"tbsCertificate",void 0);d([g({type:F})],wn.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],wn.prototype,"signatureValue",void 0);class lo{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new ze,Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],lo.prototype,"userCertificate",void 0);d([g({type:ze})],lo.prototype,"revocationDate",void 0);d([g({type:nt,optional:!0,repeated:"sequence"})],lo.prototype,"crlEntryExtensions",void 0);class Vt{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new ze,Object.assign(this,e)}}d([g({type:w.Integer,optional:!0})],Vt.prototype,"version",void 0);d([g({type:F})],Vt.prototype,"signature",void 0);d([g({type:ke})],Vt.prototype,"issuer",void 0);d([g({type:ze})],Vt.prototype,"thisUpdate",void 0);d([g({type:ze,optional:!0})],Vt.prototype,"nextUpdate",void 0);d([g({type:lo,repeated:"sequence",optional:!0})],Vt.prototype,"revokedCertificates",void 0);d([g({type:nt,optional:!0,context:0,repeated:"sequence"})],Vt.prototype,"crlExtensions",void 0);class gl{constructor(e={}){this.tbsCertList=new Vt,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Vt})],gl.prototype,"tbsCertList",void 0);d([g({type:F})],gl.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],gl.prototype,"signature",void 0);class sr{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ke})],sr.prototype,"issuer",void 0);d([g({type:w.Integer,converter:_e})],sr.prototype,"serialNumber",void 0);let Fn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ht,context:0,implicit:!0})],Fn.prototype,"subjectKeyIdentifier",void 0);d([g({type:sr})],Fn.prototype,"issuerAndSerialNumber",void 0);Fn=d([P({type:T.Choice})],Fn);var Tt;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(Tt||(Tt={}));let jr=class extends F{};jr=d([P({type:T.Sequence})],jr);let os=class extends F{};os=d([P({type:T.Sequence})],os);let xt=class extends F{};xt=d([P({type:T.Sequence})],xt);let as=class extends F{};as=d([P({type:T.Sequence})],as);let Wu=class extends F{};Wu=d([P({type:T.Sequence})],Wu);let Da=class extends F{};Da=d([P({type:T.Sequence})],Da);let or=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],or.prototype,"attrType",void 0);d([g({type:w.Any,repeated:"set"})],or.prototype,"attrValues",void 0);var Fa;class It{constructor(e={}){this.version=Tt.v0,this.sid=new Fn,this.digestAlgorithm=new jr,this.signatureAlgorithm=new os,this.signature=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],It.prototype,"version",void 0);d([g({type:Fn})],It.prototype,"sid",void 0);d([g({type:jr})],It.prototype,"digestAlgorithm",void 0);d([g({type:or,repeated:"set",context:0,implicit:!0,optional:!0})],It.prototype,"signedAttrs",void 0);d([g({type:os})],It.prototype,"signatureAlgorithm",void 0);d([g({type:ae})],It.prototype,"signature",void 0);d([g({type:or,repeated:"set",context:1,implicit:!0,optional:!0})],It.prototype,"unsignedAttrs",void 0);let cs=Fa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Fa.prototype)}};cs=Fa=d([P({type:T.Set,itemType:It})],cs);let Gu=class extends ze{};Gu=d([P({type:T.Choice})],Gu);let Ju=class extends It{};Ju=d([P({type:T.Sequence})],Ju);class ml{constructor(e={}){this.acIssuer=new re,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([g({type:re})],ml.prototype,"acIssuer",void 0);d([g({type:w.Integer})],ml.prototype,"acSerial",void 0);d([g({type:Bt,repeated:"sequence"})],ml.prototype,"attrs",void 0);var Ha;let ls=Ha=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};ls=Ha=d([P({type:T.Sequence,itemType:w.ObjectIdentifier})],ls);class uo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([g({type:w.Integer,optional:!0})],uo.prototype,"pathLenConstraint",void 0);d([g({type:ls,implicit:!0,context:0,optional:!0})],uo.prototype,"permittedAttrs",void 0);d([g({type:ls,implicit:!0,context:1,optional:!0})],uo.prototype,"excludedAttrs",void 0);d([g({type:w.Boolean,defaultValue:!0})],uo.prototype,"permitUnSpecified",void 0);class Cn{constructor(e={}){this.issuer=new Re,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Re})],Cn.prototype,"issuer",void 0);d([g({type:w.Integer,converter:_e})],Cn.prototype,"serial",void 0);d([g({type:w.BitString,optional:!0})],Cn.prototype,"issuerUID",void 0);var Ka;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(Ka||(Ka={}));class Nn{constructor(e={}){this.digestedObjectType=Ka.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Enumerated})],Nn.prototype,"digestedObjectType",void 0);d([g({type:w.ObjectIdentifier,optional:!0})],Nn.prototype,"otherObjectTypeID",void 0);d([g({type:F})],Nn.prototype,"digestAlgorithm",void 0);d([g({type:w.BitString})],Nn.prototype,"objectDigest",void 0);class po{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,optional:!0})],po.prototype,"issuerName",void 0);d([g({type:Cn,context:0,implicit:!0,optional:!0})],po.prototype,"baseCertificateID",void 0);d([g({type:Nn,context:1,implicit:!0,optional:!0})],po.prototype,"objectDigestInfo",void 0);let Hn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,repeated:"sequence"})],Hn.prototype,"v1Form",void 0);d([g({type:po,context:0,implicit:!0})],Hn.prototype,"v2Form",void 0);Hn=d([P({type:T.Choice})],Hn);class fo{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([g({type:w.GeneralizedTime})],fo.prototype,"notBeforeTime",void 0);d([g({type:w.GeneralizedTime})],fo.prototype,"notAfterTime",void 0);class ti{constructor(e={}){Object.assign(this,e)}}d([g({type:Cn,implicit:!0,context:0,optional:!0})],ti.prototype,"baseCertificateID",void 0);d([g({type:Re,implicit:!0,context:1,optional:!0})],ti.prototype,"entityName",void 0);d([g({type:Nn,implicit:!0,context:2,optional:!0})],ti.prototype,"objectDigestInfo",void 0);var Wa;(function(t){t[t.v2=1]="v2"})(Wa||(Wa={}));class gt{constructor(e={}){this.version=Wa.v2,this.holder=new ti,this.issuer=new Hn,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new fo,this.attributes=[],Object.assign(this,e)}}d([g({type:w.Integer})],gt.prototype,"version",void 0);d([g({type:ti})],gt.prototype,"holder",void 0);d([g({type:Hn})],gt.prototype,"issuer",void 0);d([g({type:F})],gt.prototype,"signature",void 0);d([g({type:w.Integer,converter:_e})],gt.prototype,"serialNumber",void 0);d([g({type:fo})],gt.prototype,"attrCertValidityPeriod",void 0);d([g({type:Bt,repeated:"sequence"})],gt.prototype,"attributes",void 0);d([g({type:w.BitString,optional:!0})],gt.prototype,"issuerUniqueID",void 0);d([g({type:Gt,optional:!0})],gt.prototype,"extensions",void 0);class ho{constructor(e={}){this.acinfo=new gt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:gt})],ho.prototype,"acinfo",void 0);d([g({type:F})],ho.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],ho.prototype,"signatureValue",void 0);var us;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(us||(us={}));class Ga extends io{}class _l{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier,implicit:!0,context:0})],_l.prototype,"type",void 0);d([g({type:w.Any,implicit:!0,context:1})],_l.prototype,"value",void 0);class yl{constructor(e={}){this.policyId="",this.classList=new Ga(us.unclassified),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],yl.prototype,"policyId",void 0);d([g({type:Ga,defaultValue:new Ga(us.unclassified)})],yl.prototype,"classList",void 0);d([g({type:_l,repeated:"set"})],yl.prototype,"securityCategories",void 0);class go{constructor(e={}){Object.assign(this,e)}}d([g({type:ae})],go.prototype,"cotets",void 0);d([g({type:w.ObjectIdentifier})],go.prototype,"oid",void 0);d([g({type:w.Utf8String})],go.prototype,"string",void 0);class $h{constructor(e={}){this.values=[],Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],$h.prototype,"policyAuthority",void 0);d([g({type:go,repeated:"sequence"})],$h.prototype,"values",void 0);var Ja;class mo{constructor(e={}){this.targetCertificate=new Cn,Object.assign(this,e)}}d([g({type:Cn})],mo.prototype,"targetCertificate",void 0);d([g({type:re,optional:!0})],mo.prototype,"targetName",void 0);d([g({type:Nn,optional:!0})],mo.prototype,"certDigestInfo",void 0);let Kn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,implicit:!0})],Kn.prototype,"targetName",void 0);d([g({type:re,context:1,implicit:!0})],Kn.prototype,"targetGroup",void 0);d([g({type:mo,context:2,implicit:!0})],Kn.prototype,"targetCert",void 0);Kn=d([P({type:T.Choice})],Kn);let Za=Ja=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ja.prototype)}};Za=Ja=d([P({type:T.Sequence,itemType:Kn})],Za);var Ya;let Zu=Ya=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ya.prototype)}};Zu=Ya=d([P({type:T.Sequence,itemType:Za})],Zu);class zh{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],zh.prototype,"roleAuthority",void 0);d([g({type:re,implicit:!0,context:1})],zh.prototype,"roleName",void 0);class vl{constructor(e={}){this.service=new re,this.ident=new re,Object.assign(this,e)}}d([g({type:re})],vl.prototype,"service",void 0);d([g({type:re})],vl.prototype,"ident",void 0);d([g({type:ae,optional:!0})],vl.prototype,"authInfo",void 0);var Xa;class wl{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],wl.prototype,"otherCertFormat",void 0);d([g({type:w.Any})],wl.prototype,"otherCert",void 0);let Wn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:wn})],Wn.prototype,"certificate",void 0);d([g({type:ho,context:2,implicit:!0})],Wn.prototype,"v2AttrCert",void 0);d([g({type:wl,context:3,implicit:!0})],Wn.prototype,"other",void 0);Wn=d([P({type:T.Choice})],Wn);let ds=Xa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Xa.prototype)}};ds=Xa=d([P({type:T.Set,itemType:Wn})],ds);class ar{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ar.prototype,"contentType",void 0);d([g({type:w.Any,context:0})],ar.prototype,"content",void 0);let Or=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae})],Or.prototype,"single",void 0);d([g({type:w.Any})],Or.prototype,"any",void 0);Or=d([P({type:T.Choice})],Or);class _o{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],_o.prototype,"eContentType",void 0);d([g({type:Or,context:0,optional:!0})],_o.prototype,"eContent",void 0);let Br=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae,context:0,implicit:!0,optional:!0})],Br.prototype,"value",void 0);d([g({type:ae,converter:B_,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Br.prototype,"constructedValue",void 0);Br=d([P({type:T.Choice})],Br);class ni{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new as,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ni.prototype,"contentType",void 0);d([g({type:as})],ni.prototype,"contentEncryptionAlgorithm",void 0);d([g({type:Br,optional:!0})],ni.prototype,"encryptedContent",void 0);class yo{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],yo.prototype,"keyAttrId",void 0);d([g({type:w.Any,optional:!0})],yo.prototype,"keyAttr",void 0);var Qa;class vo{constructor(e={}){this.subjectKeyIdentifier=new Ht,Object.assign(this,e)}}d([g({type:Ht})],vo.prototype,"subjectKeyIdentifier",void 0);d([g({type:w.GeneralizedTime,optional:!0})],vo.prototype,"date",void 0);d([g({type:yo,optional:!0})],vo.prototype,"other",void 0);let Gn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:vo,context:0,implicit:!0,optional:!0})],Gn.prototype,"rKeyId",void 0);d([g({type:sr,optional:!0})],Gn.prototype,"issuerAndSerialNumber",void 0);Gn=d([P({type:T.Choice})],Gn);class bl{constructor(e={}){this.rid=new Gn,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:Gn})],bl.prototype,"rid",void 0);d([g({type:ae})],bl.prototype,"encryptedKey",void 0);let ps=Qa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};ps=Qa=d([P({type:T.Sequence,itemType:bl})],ps);class kl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],kl.prototype,"algorithm",void 0);d([g({type:w.BitString})],kl.prototype,"publicKey",void 0);let bn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ht,context:0,implicit:!0,optional:!0})],bn.prototype,"subjectKeyIdentifier",void 0);d([g({type:kl,context:1,implicit:!0,optional:!0})],bn.prototype,"originatorKey",void 0);d([g({type:sr,optional:!0})],bn.prototype,"issuerAndSerialNumber",void 0);bn=d([P({type:T.Choice})],bn);class cr{constructor(e={}){this.version=Tt.v3,this.originator=new bn,this.keyEncryptionAlgorithm=new xt,this.recipientEncryptedKeys=new ps,Object.assign(this,e)}}d([g({type:w.Integer})],cr.prototype,"version",void 0);d([g({type:bn,context:0})],cr.prototype,"originator",void 0);d([g({type:ae,context:1,optional:!0})],cr.prototype,"ukm",void 0);d([g({type:xt})],cr.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ps})],cr.prototype,"recipientEncryptedKeys",void 0);let Jn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ht,context:0,implicit:!0})],Jn.prototype,"subjectKeyIdentifier",void 0);d([g({type:sr})],Jn.prototype,"issuerAndSerialNumber",void 0);Jn=d([P({type:T.Choice})],Jn);class ri{constructor(e={}){this.version=Tt.v0,this.rid=new Jn,this.keyEncryptionAlgorithm=new xt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],ri.prototype,"version",void 0);d([g({type:Jn})],ri.prototype,"rid",void 0);d([g({type:xt})],ri.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],ri.prototype,"encryptedKey",void 0);class ii{constructor(e={}){this.keyIdentifier=new ae,Object.assign(this,e)}}d([g({type:ae})],ii.prototype,"keyIdentifier",void 0);d([g({type:w.GeneralizedTime,optional:!0})],ii.prototype,"date",void 0);d([g({type:yo,optional:!0})],ii.prototype,"other",void 0);class si{constructor(e={}){this.version=Tt.v4,this.kekid=new ii,this.keyEncryptionAlgorithm=new xt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],si.prototype,"version",void 0);d([g({type:ii})],si.prototype,"kekid",void 0);d([g({type:xt})],si.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],si.prototype,"encryptedKey",void 0);class oi{constructor(e={}){this.version=Tt.v0,this.keyEncryptionAlgorithm=new xt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],oi.prototype,"version",void 0);d([g({type:Da,context:0,optional:!0})],oi.prototype,"keyDerivationAlgorithm",void 0);d([g({type:xt})],oi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],oi.prototype,"encryptedKey",void 0);class xl{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],xl.prototype,"oriType",void 0);d([g({type:w.Any})],xl.prototype,"oriValue",void 0);let Jt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ri,optional:!0})],Jt.prototype,"ktri",void 0);d([g({type:cr,context:1,implicit:!0,optional:!0})],Jt.prototype,"kari",void 0);d([g({type:si,context:2,implicit:!0,optional:!0})],Jt.prototype,"kekri",void 0);d([g({type:oi,context:3,implicit:!0,optional:!0})],Jt.prototype,"pwri",void 0);d([g({type:xl,context:4,implicit:!0,optional:!0})],Jt.prototype,"ori",void 0);Jt=d([P({type:T.Choice})],Jt);var ec;let fs=ec=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};fs=ec=d([P({type:T.Set,itemType:Jt})],fs);var tc;class wo{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],wo.prototype,"otherRevInfoFormat",void 0);d([g({type:w.Any})],wo.prototype,"otherRevInfo",void 0);let hs=class{constructor(e={}){this.other=new wo,Object.assign(this,e)}};d([g({type:wo,context:1,implicit:!0})],hs.prototype,"other",void 0);hs=d([P({type:T.Choice})],hs);let gs=tc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};gs=tc=d([P({type:T.Set,itemType:hs})],gs);class Sl{constructor(e={}){Object.assign(this,e)}}d([g({type:ds,context:0,implicit:!0,optional:!0})],Sl.prototype,"certs",void 0);d([g({type:gs,context:1,implicit:!0,optional:!0})],Sl.prototype,"crls",void 0);var nc;let rc=nc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};rc=nc=d([P({type:T.Set,itemType:or})],rc);class ai{constructor(e={}){this.version=Tt.v0,this.recipientInfos=new fs,this.encryptedContentInfo=new ni,Object.assign(this,e)}}d([g({type:w.Integer})],ai.prototype,"version",void 0);d([g({type:Sl,context:0,implicit:!0,optional:!0})],ai.prototype,"originatorInfo",void 0);d([g({type:fs})],ai.prototype,"recipientInfos",void 0);d([g({type:ni})],ai.prototype,"encryptedContentInfo",void 0);d([g({type:rc,context:1,implicit:!0,optional:!0})],ai.prototype,"unprotectedAttrs",void 0);const o0="1.2.840.113549.1.7.2";var ic;let ms=ic=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};ms=ic=d([P({type:T.Set,itemType:jr})],ms);class lr{constructor(e={}){this.version=Tt.v0,this.digestAlgorithms=new ms,this.encapContentInfo=new _o,this.signerInfos=new cs,Object.assign(this,e)}}d([g({type:w.Integer})],lr.prototype,"version",void 0);d([g({type:ms})],lr.prototype,"digestAlgorithms",void 0);d([g({type:_o})],lr.prototype,"encapContentInfo",void 0);d([g({type:ds,context:0,implicit:!0,optional:!0})],lr.prototype,"certificates",void 0);d([g({type:gs,context:1,implicit:!0,optional:!0})],lr.prototype,"crls",void 0);d([g({type:cs})],lr.prototype,"signerInfos",void 0);const Tr="1.2.840.10045.2.1",Al="1.2.840.10045.4.1",jh="1.2.840.10045.4.3.1",El="1.2.840.10045.4.3.2",Il="1.2.840.10045.4.3.3",Cl="1.2.840.10045.4.3.4",Yu="1.2.840.10045.3.1.7",Xu="1.3.132.0.34",Qu="1.3.132.0.35";function ci(t){return new F({algorithm:t})}const a0=ci(Al);ci(jh);const c0=ci(El),l0=ci(Il),u0=ci(Cl);let Pr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Pr.prototype,"fieldType",void 0);d([g({type:w.Any})],Pr.prototype,"parameters",void 0);Pr=d([P({type:T.Sequence})],Pr);class d0 extends ae{}let Zn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.OctetString})],Zn.prototype,"a",void 0);d([g({type:w.OctetString})],Zn.prototype,"b",void 0);d([g({type:w.BitString,optional:!0})],Zn.prototype,"seed",void 0);Zn=d([P({type:T.Sequence})],Zn);var sc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(sc||(sc={}));let Pt=class{constructor(e={}){this.version=sc.ecpVer1,Object.assign(this,e)}};d([g({type:w.Integer})],Pt.prototype,"version",void 0);d([g({type:Pr})],Pt.prototype,"fieldID",void 0);d([g({type:Zn})],Pt.prototype,"curve",void 0);d([g({type:d0})],Pt.prototype,"base",void 0);d([g({type:w.Integer,converter:_e})],Pt.prototype,"order",void 0);d([g({type:w.Integer,optional:!0})],Pt.prototype,"cofactor",void 0);Pt=d([P({type:T.Sequence})],Pt);let Zt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Zt.prototype,"namedCurve",void 0);d([g({type:w.Null})],Zt.prototype,"implicitCurve",void 0);d([g({type:Pt})],Zt.prototype,"specifiedCurve",void 0);Zt=d([P({type:T.Choice})],Zt);class bo{constructor(e={}){this.version=1,this.privateKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],bo.prototype,"version",void 0);d([g({type:ae})],bo.prototype,"privateKey",void 0);d([g({type:Zt,context:0,optional:!0})],bo.prototype,"parameters",void 0);d([g({type:w.BitString,context:1,optional:!0})],bo.prototype,"publicKey",void 0);class _s{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],_s.prototype,"r",void 0);d([g({type:w.Integer,converter:_e})],_s.prototype,"s",void 0);const He="1.2.840.113549.1.1",kn=`${He}.1`,p0=`${He}.7`,f0=`${He}.9`,Ar=`${He}.10`,h0=`${He}.2`,g0=`${He}.4`,ys=`${He}.5`,m0=`${He}.14`,oc=`${He}.11`,vs=`${He}.12`,ws=`${He}.13`,Oh=`${He}.15`,Bh=`${He}.16`,bs="1.3.14.3.2.26",Th="2.16.840.1.101.3.4.2.4",ks="2.16.840.1.101.3.4.2.1",xs="2.16.840.1.101.3.4.2.2",Ss="2.16.840.1.101.3.4.2.3",_0="2.16.840.1.101.3.4.2.5",y0="2.16.840.1.101.3.4.2.6",v0="1.2.840.113549.2.2",w0="1.2.840.113549.2.5",ko=`${He}.8`;function Ee(t){return new F({algorithm:t,parameters:null})}Ee(v0);Ee(w0);const xn=Ee(bs);Ee(Th);Ee(ks);Ee(xs);Ee(Ss);Ee(_0);Ee(y0);const Ph=new F({algorithm:ko,parameters:V.serialize(xn)}),Rh=new F({algorithm:f0,parameters:V.serialize(Qi.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ee(kn);Ee(h0);Ee(g0);Ee(ys);Ee(Oh);Ee(Bh);Ee(vs);Ee(ws);Ee(Oh);Ee(Bh);class xo{constructor(e={}){this.hashAlgorithm=new F(xn),this.maskGenAlgorithm=new F({algorithm:ko,parameters:V.serialize(xn)}),this.pSourceAlgorithm=new F(Rh),Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:xn})],xo.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Ph})],xo.prototype,"maskGenAlgorithm",void 0);d([g({type:F,context:2,defaultValue:Rh})],xo.prototype,"pSourceAlgorithm",void 0);new F({algorithm:p0,parameters:V.serialize(new xo)});class Sn{constructor(e={}){this.hashAlgorithm=new F(xn),this.maskGenAlgorithm=new F({algorithm:ko,parameters:V.serialize(xn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:xn})],Sn.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Ph})],Sn.prototype,"maskGenAlgorithm",void 0);d([g({type:w.Integer,context:2,defaultValue:20})],Sn.prototype,"saltLength",void 0);d([g({type:w.Integer,context:3,defaultValue:1})],Sn.prototype,"trailerField",void 0);new F({algorithm:Ar,parameters:V.serialize(new Sn)});class So{constructor(e={}){this.digestAlgorithm=new F,this.digest=new ae,Object.assign(this,e)}}d([g({type:F})],So.prototype,"digestAlgorithm",void 0);d([g({type:ae})],So.prototype,"digest",void 0);var ac;class Ao{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],Ao.prototype,"prime",void 0);d([g({type:w.Integer,converter:_e})],Ao.prototype,"exponent",void 0);d([g({type:w.Integer,converter:_e})],Ao.prototype,"coefficient",void 0);let cc=ac=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};cc=ac=d([P({type:T.Sequence,itemType:Ao})],cc);class Ct{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer})],Ct.prototype,"version",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"modulus",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"publicExponent",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"privateExponent",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"prime1",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"prime2",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"exponent1",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"exponent2",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"coefficient",void 0);d([g({type:cc,optional:!0})],Ct.prototype,"otherPrimeInfos",void 0);class Nl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],Nl.prototype,"modulus",void 0);d([g({type:w.Integer,converter:_e})],Nl.prototype,"publicExponent",void 0);var lc;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(lc||(lc={}));const Ve=lc;/*! *****************************************************************************
|
|
79
|
+
`)}`:`${n} :`}}Sf=De;H.Constructed=Sf;De.NAME="CONSTRUCTED";class Af extends Le{fromBER(e,n,r){return n}toBER(e){return ht}}Af.override="EndOfContentValueBlock";var Ef;class Yc extends je{constructor(e={}){super(e,Af),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Ef=Yc;H.EndOfContent=Ef;Yc.NAME=$r;var If;class mn extends je{constructor(e={}){super(e,Le),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,n+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+r}toBER(e,n){const r=new ArrayBuffer(2);if(!e){const i=new Uint8Array(r);i[0]=5,i[1]=0}return n&&n.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}If=mn;H.Null=If;mn.NAME="NULL";class Cf extends Et(Le){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=M.toUint8Array(n.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,n,r){const i=M.toUint8Array(e);return Lt(this,i,n,r)?(this.valueHexView=i.subarray(n,n+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,mf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Cf.NAME="BooleanValueBlock";var Nf;class Fs extends je{constructor(e={}){super(e,Cf),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}Nf=Fs;H.Boolean=Nf;Fs.NAME="BOOLEAN";class $f extends Et(Ft){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Ft.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===$r){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==_f)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,n,r),this.blockLength=r;return i}toBER(e,n){return this.isConstructed?Ft.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}$f.NAME="OctetStringValueBlock";var zf;let un=class jf extends je{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},$f),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,r===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),n;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(n,n+r);try{if(s.byteLength){const o=nr(s,0,s.byteLength);o.offset!==-1&&o.offset===r&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?De.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const n of this.valueBlock.value)n instanceof jf&&e.push(n.valueBlock.valueHexView);return M.concat(e)}};zf=un;H.OctetString=zf;un.NAME=_f;class Of extends Et(Ft){constructor({unusedBits:e=0,isConstructed:n=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,r){if(!r)return n;let i=-1;if(this.isConstructed){if(i=Ft.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const l=c.constructor.NAME;if(l===$r){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==yf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=c.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return i}const s=M.toUint8Array(e);if(!Lt(this,s,n,r))return-1;const o=s.subarray(n,n+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const l=nr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,n+r}toBER(e,n){if(this.isConstructed)return Ft.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ht;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}Of.NAME="BitStringValueBlock";var Bf;let dn=class extends je{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},Of),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return De.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const i of n)e.push(i.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};Bf=dn;H.BitString=Bf;dn.NAME=yf;var Tf;function A_(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const o=s.length-1,c=i.slice(0),l=c.length-1;let u=0;const p=l<o?o:l;let h=0;for(let m=p;m>=0;m--,h++){switch(!0){case h<c.length:u=s[o-h]+c[l-h]+n[0];break;default:u=s[o-h]+n[0]}switch(n[0]=u/10,!0){case h>=s.length:s=ga(new Uint8Array([u%10]),s);break;default:s[o-h]=u%10}}return n[0]>0&&(s=ga(n,s)),s}function ju(t){if(t>=mr.length)for(let e=mr.length;e<=t;e++){const n=new Uint8Array([0]);let r=mr[e-1].slice(0);for(let i=r.length-1;i>=0;i--){const s=new Uint8Array([(r[i]<<1)+n[0]]);n[0]=s[0]/10,r[i]=s[0]%10}n[0]>0&&(r=ga(n,r)),mr.push(r)}return mr[t]}function E_(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),o=s.length-1,c=i.slice(0),l=c.length-1;let u,p=0;for(let h=l;h>=0;h--,p++)switch(u=s[o-p]-c[l-p]-n,!0){case u<0:n=1,s[o-p]=u+10;break;default:n=0,s[o-p]=u}if(n>0)for(let h=o-l+1;h>=0;h--,p++)if(u=s[o-p]-n,u<0)n=1,s[o-p]=u+10;else{n=0,s[o-p]=u;break}return s.slice()}class Xc extends Et(Le){constructor({value:e,...n}={}){super(n),this._valueDec=0,n.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=mf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(f_(e))}get valueDec(){return this._valueDec}fromDER(e,n,r,i=0){const s=this.fromBER(e,n,r);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.length)),s}toDER(e=!1){const n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(n,1),this.valueHexView=r}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,r){const i=super.fromBER(e,n,r);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let n=new Uint8Array(this.valueHexView.length*8/3),r=0,i;const s=this.valueHexView;let o="",c=!1;for(let l=s.byteLength-1;l>=0;l--){i=s[l];for(let u=0;u<8;u++){if((i&1)===1)switch(r){case e:n=E_(ju(r),n),o="-";break;default:n=A_(n,ju(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(o+=$u.charAt(n[l]));return c===!1&&(o+=$u.charAt(0)),o}}Tf=Xc;Xc.NAME="IntegerValueBlock";Object.defineProperty(Tf.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Pf;class bt extends je{constructor(e={}){super(e,Xc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Yi(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Yi();const n=BigInt(e),r=new qs,i=n.toString(16).replace(/^-/,""),s=new Uint8Array(G.FromHex(i));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${G.ToHex(c)}`)+n,p=M.toUint8Array(G.FromHex(u.toString(16)));p[0]|=128,r.write(p)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new bt({valueHex:r.final()})}convertToDER(){const e=new bt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new bt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Pf=bt;H.Integer=Pf;bt.NAME="INTEGER";var Rf;class Hs extends bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Rf=Hs;H.Enumerated=Rf;Hs.NAME="ENUMERATED";class ma extends Et(Le){constructor({valueDec:e=-1,isFirstSid:n=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,r){if(!r)return n;const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Mn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){Yi();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const r=new Uint8Array(n.length/7);for(let i=0;i<r.length;i++)r[i]=parseInt(n.slice(i*7,i*7+7),2)+(i+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=gn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ht;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|128;r[s]=i[s]}return r}toString(){let e="";if(this.isHexOnly)e=G.ToHex(this.valueHexView);else if(this.isFirstSid){let n=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",n-=40):(e="2.",n-=80),e+=n.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}ma.NAME="sidBlock";class Lf extends Le{constructor({value:e=Me,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new ma;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e){const n=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(i.byteLength===0)return this.error=this.value[r].error,ht;n.push(i)}return Jc(n)}fromString(e){this.value=[];let n=0,r=0,i="",s=!1;do if(r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(i,10);if(isNaN(l))return;o.valueDec=l+c,s=!1}else{const o=new ma;if(i>Number.MAX_SAFE_INTEGER){Yi();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(r!==-1)}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}Lf.NAME="ObjectIdentifierValueBlock";var Uf;class Ks extends je{constructor(e={}){super(e,Lf),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}Uf=Ks;H.ObjectIdentifier=Uf;Ks.NAME="OBJECT IDENTIFIER";class _a extends Et(In){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=M.toUint8Array(e);if(!Lt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Mn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=gn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ht;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|128;r[s]=i[s]}return r.buffer}toString(){let e="";return this.isHexOnly?e=G.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}_a.NAME="relativeSidBlock";class Vf extends Le{constructor({value:e=Me,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new _a;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e,n){const r=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,ht;r.push(s)}return Jc(r)}fromString(e){this.value=[];let n=0,r=0,i="";do{r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1;const s=new _a;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(r!==-1);return!0}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}Vf.NAME="RelativeObjectIdentifierValueBlock";var Mf;class Qc extends je{constructor(e={}){super(e,Vf),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}Mf=Qc;H.RelativeObjectIdentifier=Mf;Qc.NAME="RelativeObjectIdentifier";var qf;class zt extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}qf=zt;H.Sequence=qf;zt.NAME="SEQUENCE";var Df;let jt=class extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Df=jt;H.Set=Df;jt.NAME="SET";class Ff extends Et(Le){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Me}toJSON(){return{...super.toJSON(),value:this.value}}}Ff.NAME="StringValueBlock";class Hf extends Ff{}Hf.NAME="SimpleStringValueBlock";class Ze extends Zc{constructor({...e}={}){super(e,Hf)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.toUint8Array(e))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}Ze.NAME="SIMPLE STRING";class Kf extends Ze{fromBuffer(e){this.valueBlock.valueHexView=M.toUint8Array(e);try{this.valueBlock.value=G.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=G.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.FromUtf8String(e)),this.valueBlock.value=e}}Kf.NAME="Utf8StringValueBlock";var Wf;class Ut extends Kf{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Wf=Ut;H.Utf8String=Wf;Ut.NAME="UTF8String";class Gf extends Ze{fromBuffer(e){this.valueBlock.value=G.ToUtf16String(e),this.valueBlock.valueHexView=M.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.FromUtf16String(e))}}Gf.NAME="BmpStringValueBlock";var Jf;class Ws extends Gf{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Jf=Ws;H.BmpString=Jf;Ws.NAME="BMPString";class Zf extends Ze{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(n);for(let i=0;i<r.length;i+=4)r[i]=r[i+3],r[i+1]=r[i+2],r[i+2]=0,r[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let i=0;i<n;i++){const s=gn(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let l=o.length-1;l>=0;l--)r[i*4+l+c]=o[l]}this.valueBlock.value=e}}Zf.NAME="UniversalStringValueBlock";var Yf;class Gs extends Zf{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Yf=Gs;H.UniversalString=Yf;Gs.NAME="UniversalString";var Xf;class Js extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Xf=Js;H.NumericString=Xf;Js.NAME="NumericString";var Qf;class Zs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Qf=Zs;H.PrintableString=Qf;Zs.NAME="PrintableString";var eh;class Ys extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}eh=Ys;H.TeletexString=eh;Ys.NAME="TeletexString";var th;class Xs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}th=Xs;H.VideotexString=th;Xs.NAME="VideotexString";var nh;class Qs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}nh=Qs;H.IA5String=nh;Qs.NAME="IA5String";var rh;class eo extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}rh=eo;H.GraphicString=rh;eo.NAME="GraphicString";var ih;class Yr extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}ih=Yr;H.VisibleString=ih;Yr.NAME="VisibleString";var sh;class to extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}sh=to;H.GeneralString=sh;to.NAME="GeneralString";var oh;class no extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}oh=no;H.CharacterString=oh;no.NAME="CharacterString";var ah;class Xr extends Yr{constructor({value:e,valueDate:n,...r}={}){if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}n&&(this.fromDate(n),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.toUint8Array(e)))}toBuffer(){const e=this.toString(),n=new ArrayBuffer(e.length),r=new Uint8Array(n);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return n}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const r=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(r===null){this.error="Wrong input string for conversion";return}const i=parseInt(r[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(r[2],10),this.day=parseInt(r[3],10),this.hour=parseInt(r[4],10),this.minute=parseInt(r[5],10),this.second=parseInt(r[6],10)}toString(e="iso"){if(e==="iso"){const n=new Array(7);return n[0]=Ge(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Ge(this.month,2),n[2]=Ge(this.day,2),n[3]=Ge(this.hour,2),n[4]=Ge(this.minute,2),n[5]=Ge(this.second,2),n[6]="Z",n.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}ah=Xr;H.UTCTime=ah;Xr.NAME="UTCTime";var ch;class ro extends Xr{constructor(e={}){var n;super(e),(n=this.millisecond)!==null&&n!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let n=!1,r="",i="",s=0,o,c=0,l=0;if(e[e.length-1]==="Z")r=e.substring(0,e.length-1),n=!0;else{const h=new Number(e[e.length-1]);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");r=e}if(n){if(r.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(r.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let h=1,m=r.indexOf("+"),y="";if(m===-1&&(m=r.indexOf("-"),h=-1),m!==-1){if(y=r.substring(m+1),r=r.substring(0,m),y.length!==2&&y.length!==4)throw new Error("Wrong input string for conversion");let f=parseInt(y.substring(0,2),10);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");if(c=h*f,y.length===4){if(f=parseInt(y.substring(2,4),10),isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");l=h*f}}}let u=r.indexOf(".");if(u===-1&&(u=r.indexOf(",")),u!==-1){const h=new Number(`0${r.substring(u)}`);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");s=h.valueOf(),i=r.substring(0,u)}else i=r;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.minute=Math.floor(h),h=60*(h-this.minute),this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const h=1e3*s;this.millisecond=Math.floor(h)}break;default:throw new Error("Wrong input string for conversion")}const p=o.exec(i);if(p===null)throw new Error("Wrong input string for conversion");for(let h=1;h<p.length;h++)switch(h){case 1:this.year=parseInt(p[h],10);break;case 2:this.month=parseInt(p[h],10);break;case 3:this.day=parseInt(p[h],10);break;case 4:this.hour=parseInt(p[h],10)+c;break;case 5:this.minute=parseInt(p[h],10)+l;break;case 6:this.second=parseInt(p[h],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const h=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=h.getUTCFullYear(),this.month=h.getUTCMonth(),this.day=h.getUTCDay(),this.hour=h.getUTCHours(),this.minute=h.getUTCMinutes(),this.second=h.getUTCSeconds(),this.millisecond=h.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const n=[];return n.push(Ge(this.year,4)),n.push(Ge(this.month,2)),n.push(Ge(this.day,2)),n.push(Ge(this.hour,2)),n.push(Ge(this.minute,2)),n.push(Ge(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Ge(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}ch=ro;H.GeneralizedTime=ch;ro.NAME="GeneralizedTime";var lh;class el extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}lh=el;H.DATE=lh;el.NAME="DATE";var uh;class tl extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}uh=tl;H.TimeOfDay=uh;tl.NAME="TimeOfDay";var dh;class nl extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}dh=nl;H.DateTime=dh;nl.NAME="DateTime";var ph;class rl extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}ph=rl;H.Duration=ph;rl.NAME="Duration";var fh;class il extends Ut{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}fh=il;H.TIME=fh;il.NAME="TIME";class _n{constructor({name:e=Me,optional:n=!1}={}){this.name=e,this.optional=n}}class sl extends _n{constructor({value:e=[],...n}={}){super(n),this.value=e}}class Xi extends _n{constructor({value:e=new _n,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class I_{constructor({data:e=Ds}={}){this.dataView=M.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=M.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function an(t,e,n){if(n instanceof sl){for(let s=0;s<n.value.length;s++)if(an(t,e,n.value[s]).verified)return{verified:!0,result:t};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return n.hasOwnProperty(Fo)&&(s.name=n.name),s}}if(n instanceof _n)return n.hasOwnProperty(Fo)&&(t[n.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(m_ in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(w_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(b_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(__)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(y_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(v_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(g_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(n.idBlock.isHexOnly){if(!(zu in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(t[n.name]=e)),n instanceof H.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof Xi&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let l=!0;for(let u=0;u<n.valueBlock.value.length;u++)l=l&&(n.valueBlock.value[u].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(n.valueBlock.value[l].optional===!1){const u={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof Xi){if(o=an(t,e.valueBlock.value[l],n.valueBlock.value[0].value),o.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(Fo in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};k_ in n.valueBlock.value[0]&&n.valueBlock.value[0].local?u=e:u=t,typeof u[n.valueBlock.value[0].name]>"u"&&(u[n.valueBlock.value[0].name]=[]),u[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(o=an(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),o.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(o.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&zu in e.valueBlock){const s=nr(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],o.name=n.name)),o}return an(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function C_(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=nr(M.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:an(n.result,n.result,e)}const hh=Object.freeze(Object.defineProperty({__proto__:null,Any:_n,BaseBlock:je,BaseStringBlock:Zc,BitString:dn,BmpString:Ws,Boolean:Fs,CharacterString:no,Choice:sl,Constructed:De,DATE:el,DateTime:nl,Duration:rl,EndOfContent:Yc,Enumerated:Hs,GeneralString:to,GeneralizedTime:ro,GraphicString:eo,HexBlock:Et,IA5String:Qs,Integer:bt,Null:mn,NumericString:Js,ObjectIdentifier:Ks,OctetString:un,Primitive:Zr,PrintableString:Zs,RawData:I_,RelativeObjectIdentifier:Qc,Repeated:Xi,Sequence:zt,Set:jt,TIME:il,TeletexString:Ys,TimeOfDay:tl,UTCTime:Xr,UniversalString:Gs,Utf8String:Ut,ValueBlock:Le,VideotexString:Xs,ViewWriter:qs,VisibleString:Yr,compareSchema:an,fromBER:Ln,verifySchema:C_},Symbol.toStringTag,{value:"Module"}));var T;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(T||(T={}));var w;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(w||(w={}));class io{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(M.isBufferSource(e))this.unusedBits=n,this.value=M.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof dn))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new dn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new dn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const r of n)e+=r.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let n=e.toString(2);const r=n.length+7>>3;this.unusedBits=(r<<3)-n.length;const i=new Uint8Array(r);n=n.padStart(r<<3,"0").split("").reverse().join("");let s=0;for(;s<r;)i[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class ae{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):M.isBufferSource(e)?this.buffer=M.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof un))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new un({valueHex:this.buffer})}toSchema(e){return new un({name:e})}}const N_={fromASN:t=>t instanceof mn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new mn;const e=Ln(t);if(e.result.error)throw new Error(e.result.error);return e.result}},$_={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new bt({value:+t})},z_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new Hs({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new bt({valueHex:t})},j_={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new dn({valueHex:t})},O_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new Ks({value:t})},B_={fromASN:t=>t.valueBlock.value,toASN:t=>new Fs({value:t})},Qi={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new un({valueHex:t})},T_={fromASN:t=>new ae(t.getValue()),toASN:t=>t.toASN()};function rt(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const gh=rt(Ut),P_=rt(Ws),R_=rt(Gs),L_=rt(Js),U_=rt(Zs),V_=rt(Ys),M_=rt(Xs),q_=rt(Qs),D_=rt(eo),F_=rt(Yr),H_=rt(to),K_=rt(no),W_={fromASN:t=>t.toDate(),toASN:t=>new Xr({valueDate:t})},G_={fromASN:t=>t.toDate(),toASN:t=>new ro({valueDate:t})},J_={fromASN:()=>null,toASN:()=>new mn};function ol(t){switch(t){case w.Any:return N_;case w.BitString:return j_;case w.BmpString:return P_;case w.Boolean:return B_;case w.CharacterString:return K_;case w.Enumerated:return z_;case w.GeneralString:return H_;case w.GeneralizedTime:return G_;case w.GraphicString:return D_;case w.IA5String:return q_;case w.Integer:return $_;case w.Null:return J_;case w.NumericString:return L_;case w.ObjectIdentifier:return O_;case w.OctetString:return Qi;case w.PrintableString:return U_;case w.TeletexString:return V_;case w.UTCTime:return W_;case w.UniversalString:return R_;case w.Utf8String:return gh;case w.VideotexString:return M_;case w.VisibleString:return F_;default:return null}}function $t(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:$t(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function mh(t){var e;if(t){const n=Object.getPrototypeOf(t);return((e=n==null?void 0:n.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:mh(n)}return!1}function Z_(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}class Y_{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:T.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(n,r),n.items=Object.assign({},n.items,r.items)),n}create(e,n){const r=this.items.get(e)||this.createDefault(e),i=[];for(const s in r.items){const o=r.items[s],c=n?s:"";let l;if(typeof o.type=="number"){const p=w[o.type],h=hh[p];if(!h)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new h({name:c})}else $t(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===T.Choice?l=new _n({name:c}):(l=this.create(o.type,!1),l.name=c):l=new _n({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?jt:zt;l=new p({name:"",value:[new Xi({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||$t(o.type)){const p=o.repeated?De:Zr;i.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const p=!!o.repeated;let h=p?l:this.get(o.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,i.push(new De({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:h}))}else i.push(new De({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,i.push(l)}switch(r.type){case T.Sequence:return new zt({value:i,name:""});case T.Set:return new jt({value:i,name:""});case T.Choice:return new sl({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,n){return this.items.set(e,n),this}findParentSchema(e){const n=Object.getPrototypeOf(e);return n?this.items.get(n)||this.findParentSchema(n):null}}const Qe=new Y_,P=t=>e=>{let n;Qe.has(e)?n=Qe.get(e):(n=Qe.createDefault(e),Qe.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;Qe.has(e.constructor)?r=Qe.get(e.constructor):(r=Qe.createDefault(e.constructor),Qe.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=ol(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);i.converter=s}r.items[n]=i};class Ou extends Error{constructor(){super(...arguments),this.schemas=[]}}class X_{static parse(e,n){const r=Ln(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,n)}static fromASN(e,n){var r;try{if($t(n))return new n().fromASN(e);const i=Qe.get(n);Qe.cache(n);let s=i.schema;if(e.constructor===De&&i.type!==T.Choice){s=new De({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const o=an({},e,s);if(!o.verified)throw new Ou(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if(mh(n)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const l=i.itemType;if(typeof l=="number"){const u=ol(l);if(!u)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>u.fromASN(p))}else return n.from(e.valueBlock.value,u=>this.fromASN(u,l))}for(const l in i.items){const u=o.result[l];if(!u)continue;const p=i.items[l],h=p.type;if(typeof h=="number"||$t(h)){const m=(r=p.converter)!==null&&r!==void 0?r:$t(h)?new h:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const y=p.repeated==="sequence"?zt:jt,f=new y;f.valueBlock=u.valueBlock;const _=Ln(f.toBER(!1));if(_.offset===-1)throw new Error(`Cannot parse the child item. ${_.result.error}`);if(!("value"in _.result.valueBlock&&Array.isArray(_.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const v=_.result.valueBlock.value;c[l]=Array.from(v,x=>m.fromASN(x))}else c[l]=Array.from(u,y=>m.fromASN(y));else{let y=u;if(p.implicit){let f;if($t(h))f=new h().toSchema("");else{const _=w[h],v=hh[_];if(!v)throw new Error(`Cannot get '${_}' class from asn1js module`);f=new v}f.valueBlock=y.valueBlock,y=Ln(f.toBER(!1)).result}c[l]=m.fromASN(y)}}else if(p.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(u,m=>this.fromASN(m,h))}else c[l]=this.fromASN(u,h)}return c}catch(i){throw i instanceof Ou&&i.schemas.push(n.name),i}}}class al{static serialize(e){return e instanceof je?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&$t(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=Qe.get(n);Qe.cache(n);let i=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof r.itemType=="number"){const o=ol(r.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:r.itemType},"[]",n,o))}else for(const o in r.items){const c=r.items[o],l=e[o];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&Z_(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=al.toAsnItem(c,o,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||$t(c.type))){const p={};p.valueHex=u instanceof mn?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new Zr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new De({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else i.push(new De({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[u]}));else c.repeated?i=i.concat(u):i.push(u)}let s;switch(r.type){case T.Sequence:s=new zt({value:i});break;case T.Set:s=new jt({value:i});break;case T.Choice:if(!i[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,n,r,i){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${n}' doesn't have converter for type ${w[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,u=>o.toASN(u)),l=e.repeated==="sequence"?zt:jt;s=new l({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?zt:jt;s=new c({value:o})}else s=this.toASN(i);return s}}class de extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class V{static serialize(e){return al.serialize(e)}static parse(e,n){return X_.parse(e,n)}static toString(e){const n=M.isBufferSource(e)?M.toArrayBuffer(e):V.serialize(e),r=Ln(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function d(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var _h={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,"i"),threeOctet:new RegExp(`^${n}\\.${n}\\.${n}$`,"i"),twoOctet:new RegExp(`^${n}\\.${n}$`,"i"),longValue:new RegExp(`^${n}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,"i")};function u(f,_){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let v=0,x=-1,N=(f.match(l.zoneIndex)||[])[0],B,R;for(N&&(N=N.substring(1),f=f.replace(/%.+$/,""));(x=f.indexOf(":",x+1))>=0;)v++;if(f.substr(0,2)==="::"&&v--,f.substr(-2,2)==="::"&&v--,v>_)return null;for(R=_-v,B=":";R--;)B+="0:";return f=f.replace("::",B),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),_=function(){const te=f.split(":"),pe=[];for(let le=0;le<te.length;le++)pe.push(parseInt(te[le],16));return pe}(),{parts:_,zoneId:N}}function p(f,_,v,x){if(f.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let N=0,B;for(;x>0;){if(B=v-x,B<0&&(B=0),f[N]>>B!==_[N]>>B)return!1;x-=v,N+=1}return!0}function h(f){if(s.test(f))return parseInt(f,16);if(f[0]==="0"&&!isNaN(parseInt(f[1],10))){if(i.test(f))return parseInt(f,8);throw new Error(`ipaddr: cannot parse ${f} as octal`)}return parseInt(f,10)}function m(f,_){for(;f.length<_;)f=`0${f}`;return f}const y={};y.IPv4=function(){function f(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let v,x;for(v=0;v<_.length;v++)if(x=_[v],!(0<=x&&x<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return f.prototype.SpecialRanges={unspecified:[[new f([0,0,0,0]),8]],broadcast:[[new f([255,255,255,255]),32]],multicast:[[new f([224,0,0,0]),4]],linkLocal:[[new f([169,254,0,0]),16]],loopback:[[new f([127,0,0,0]),8]],carrierGradeNat:[[new f([100,64,0,0]),10]],private:[[new f([10,0,0,0]),8],[new f([172,16,0,0]),12],[new f([192,168,0,0]),16]],reserved:[[new f([192,0,0,0]),24],[new f([192,0,2,0]),24],[new f([192,88,99,0]),24],[new f([198,18,0,0]),15],[new f([198,51,100,0]),24],[new f([203,0,113,0]),24],[new f([240,0,0,0]),4]],as112:[[new f([192,175,48,0]),24],[new f([192,31,196,0]),24]],amt:[[new f([192,52,193,0]),24]]},f.prototype.kind=function(){return"ipv4"},f.prototype.match=function(_,v){let x;if(v===void 0&&(x=_,_=x[0],v=x[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,v)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const x={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let N,B,R;for(N=3;N>=0;N-=1)if(B=this.octets[N],B in x){if(R=x[B],v&&R!==0)return null;R!==8&&(v=!0),_+=R}else return null;return 32-_},f.prototype.range=function(){return y.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){return this.octets.slice(0)},f.prototype.toIPv4MappedAddress=function(){return y.IPv6.parse(`::ffff:${this.toString()}`)},f.prototype.toNormalizedString=function(){return this.toString()},f.prototype.toString=function(){return this.octets.join(".")},f}(),y.IPv4.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),v=_[0].toByteArray(),x=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let B=0;for(;B<4;)N.push(parseInt(v[B],10)|parseInt(x[B],10)^255),B++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},y.IPv4.isIPv4=function(f){return this.parser(f)!==null},y.IPv4.isValid=function(f){try{return new this(this.parser(f)),!0}catch{return!1}},y.IPv4.isValidCIDR=function(f){try{return this.parseCIDR(f),!0}catch{return!1}},y.IPv4.isValidFourPartDecimal=function(f){return!!(y.IPv4.isValid(f)&&f.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},y.IPv4.networkAddressFromCIDR=function(f){let _,v,x,N,B;try{for(_=this.parseCIDR(f),x=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],v=0;v<4;)N.push(parseInt(x[v],10)&parseInt(B[v],10)),v++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},y.IPv4.parse=function(f){const _=this.parser(f);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},y.IPv4.parseCIDR=function(f){let _;if(_=f.match(/^(.+)\/(\d+)$/)){const v=parseInt(_[2]);if(v>=0&&v<=32){const x=[this.parse(_[1]),v];return Object.defineProperty(x,"toString",{value:function(){return this.join("/")}}),x}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},y.IPv4.parser=function(f){let _,v,x;if(_=f.match(r.fourOctet))return function(){const N=_.slice(1,6),B=[];for(let R=0;R<N.length;R++)v=N[R],B.push(h(v));return B}();if(_=f.match(r.longValue)){if(x=h(_[1]),x>4294967295||x<0)throw new Error("ipaddr: address outside defined range");return function(){const N=[];let B;for(B=0;B<=24;B+=8)N.push(x>>B&255);return N}().reverse()}else return(_=f.match(r.twoOctet))?function(){const N=_.slice(1,4),B=[];if(x=h(N[1]),x>16777215||x<0)throw new Error("ipaddr: address outside defined range");return B.push(h(N[0])),B.push(x>>16&255),B.push(x>>8&255),B.push(x&255),B}():(_=f.match(r.threeOctet))?function(){const N=_.slice(1,5),B=[];if(x=h(N[2]),x>65535||x<0)throw new Error("ipaddr: address outside defined range");return B.push(h(N[0])),B.push(h(N[1])),B.push(x>>8&255),B.push(x&255),B}():null},y.IPv4.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let v=0;const x=Math.floor(f/8);for(;v<x;)_[v]=255,v++;return x<4&&(_[x]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},y.IPv6=function(){function f(_,v){let x,N;if(_.length===16)for(this.parts=[],x=0;x<=14;x+=2)this.parts.push(_[x]<<8|_[x+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(x=0;x<this.parts.length;x++)if(N=this.parts[x],!(0<=N&&N<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");v&&(this.zoneId=v)}return f.prototype.SpecialRanges={unspecified:[new f([0,0,0,0,0,0,0,0]),128],linkLocal:[new f([65152,0,0,0,0,0,0,0]),10],multicast:[new f([65280,0,0,0,0,0,0,0]),8],loopback:[new f([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new f([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new f([0,0,0,0,0,65535,0,0]),96],discard:[new f([256,0,0,0,0,0,0,0]),64],rfc6145:[new f([0,0,0,0,65535,0,0,0]),96],rfc6052:[new f([100,65435,0,0,0,0,0,0]),96],"6to4":[new f([8194,0,0,0,0,0,0,0]),16],teredo:[new f([8193,0,0,0,0,0,0,0]),32],benchmarking:[new f([8193,2,0,0,0,0,0,0]),48],amt:[new f([8193,3,0,0,0,0,0,0]),32],as112v6:[[new f([8193,4,274,0,0,0,0,0]),48],[new f([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new f([8193,16,0,0,0,0,0,0]),28],orchid2:[new f([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new f([8193,48,0,0,0,0,0,0]),28],reserved:[[new f([8193,0,0,0,0,0,0,0]),23],[new f([8193,3512,0,0,0,0,0,0]),32]]},f.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},f.prototype.kind=function(){return"ipv6"},f.prototype.match=function(_,v){let x;if(v===void 0&&(x=_,_=x[0],v=x[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,v)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const x={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let N,B;for(let R=7;R>=0;R-=1)if(N=this.parts[R],N in x){if(B=x[N],v&&B!==0)return null;B!==16&&(v=!0),_+=B}else return null;return 128-_},f.prototype.range=function(){return y.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){let _;const v=[],x=this.parts;for(let N=0;N<x.length;N++)_=x[N],v.push(_>>8),v.push(_&255);return v},f.prototype.toFixedLengthString=function(){const _=(function(){const x=[];for(let N=0;N<this.parts.length;N++)x.push(m(this.parts[N].toString(16),4));return x}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},f.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),v=_[0],x=_[1];return new y.IPv4([v>>8,v&255,x>>8,x&255])},f.prototype.toNormalizedString=function(){const _=(function(){const x=[];for(let N=0;N<this.parts.length;N++)x.push(this.parts[N].toString(16));return x}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},f.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,v=this.toNormalizedString();let x=0,N=-1,B;for(;B=_.exec(v);)B[0].length>N&&(x=B.index,N=B[0].length);return N<0?v:`${v.substring(0,x)}::${v.substring(x+N)}`},f.prototype.toString=function(){return this.toRFC5952String()},f}(),y.IPv6.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),v=_[0].toByteArray(),x=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let B=0;for(;B<16;)N.push(parseInt(v[B],10)|parseInt(x[B],10)^255),B++;return new this(N)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},y.IPv6.isIPv6=function(f){return this.parser(f)!==null},y.IPv6.isValid=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{const _=this.parser(f);return new this(_.parts,_.zoneId),!0}catch{return!1}},y.IPv6.isValidCIDR=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{return this.parseCIDR(f),!0}catch{return!1}},y.IPv6.networkAddressFromCIDR=function(f){let _,v,x,N,B;try{for(_=this.parseCIDR(f),x=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],v=0;v<16;)N.push(parseInt(x[v],10)&parseInt(B[v],10)),v++;return new this(N)}catch(R){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${R})`)}},y.IPv6.parse=function(f){const _=this.parser(f);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},y.IPv6.parseCIDR=function(f){let _,v,x;if((v=f.match(/^(.+)\/(\d+)$/))&&(_=parseInt(v[2]),_>=0&&_<=128))return x=[this.parse(v[1]),_],Object.defineProperty(x,"toString",{value:function(){return this.join("/")}}),x;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},y.IPv6.parser=function(f){let _,v,x,N,B,R;if(x=f.match(l.deprecatedTransitional))return this.parser(`::ffff:${x[1]}`);if(l.native.test(f))return u(f,8);if((x=f.match(l.transitional))&&(R=x[6]||"",_=x[1],x[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+R,6),_.parts)){for(B=[parseInt(x[2]),parseInt(x[3]),parseInt(x[4]),parseInt(x[5])],v=0;v<B.length;v++)if(N=B[v],!(0<=N&&N<=255))return null;return _.parts.push(B[0]<<8|B[1]),_.parts.push(B[2]<<8|B[3]),{parts:_.parts,zoneId:_.zoneId}}return null},y.IPv6.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>128)throw new Error("ipaddr: invalid IPv6 prefix length");const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let v=0;const x=Math.floor(f/8);for(;v<x;)_[v]=255,v++;return x<16&&(_[x]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},y.fromByteArray=function(f){const _=f.length;if(_===4)return new y.IPv4(f);if(_===16)return new y.IPv6(f);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},y.isValid=function(f){return y.IPv6.isValid(f)||y.IPv4.isValid(f)},y.isValidCIDR=function(f){return y.IPv6.isValidCIDR(f)||y.IPv4.isValidCIDR(f)},y.parse=function(f){if(y.IPv6.isValid(f))return y.IPv6.parse(f);if(y.IPv4.isValid(f))return y.IPv4.parse(f);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},y.parseCIDR=function(f){try{return y.IPv6.parseCIDR(f)}catch{try{return y.IPv4.parseCIDR(f)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},y.process=function(f){const _=this.parse(f);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},y.subnetMatch=function(f,_,v){let x,N,B,R;v==null&&(v="unicast");for(N in _)if(Object.prototype.hasOwnProperty.call(_,N)){for(B=_[N],B[0]&&!(B[0]instanceof Array)&&(B=[B]),x=0;x<B.length;x++)if(R=B[x],f.kind()===R[0].kind()&&f.match.apply(f,R))return N}return v},t.exports?t.exports=y:e.ipaddr=y})(Zi)})(_h);var Bu=_h.exports;class Tu{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const n=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let r=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return r=r.slice(0,-1),`${r}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return Bu.fromByteArray(Array.from(n)).toString()}return this.decodeIP(G.ToHex(e))}static fromString(e){const n=Bu.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var ya,va,wa;let Oe=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([g({type:w.TeletexString})],Oe.prototype,"teletexString",void 0);d([g({type:w.PrintableString})],Oe.prototype,"printableString",void 0);d([g({type:w.UniversalString})],Oe.prototype,"universalString",void 0);d([g({type:w.Utf8String})],Oe.prototype,"utf8String",void 0);d([g({type:w.BmpString})],Oe.prototype,"bmpString",void 0);Oe=d([P({type:T.Choice})],Oe);let qn=class extends Oe{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?G.ToHex(this.anyValue):super.toString())}};d([g({type:w.IA5String})],qn.prototype,"ia5String",void 0);d([g({type:w.Any})],qn.prototype,"anyValue",void 0);qn=d([P({type:T.Choice})],qn);class so{constructor(e={}){this.type="",this.value=new qn,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],so.prototype,"type",void 0);d([g({type:qn})],so.prototype,"value",void 0);let Dn=ya=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ya.prototype)}};Dn=ya=d([P({type:T.Set,itemType:so})],Dn);let ba=va=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,va.prototype)}};ba=va=d([P({type:T.Sequence,itemType:Dn})],ba);let ke=wa=class extends ba{constructor(e){super(e),Object.setPrototypeOf(this,wa.prototype)}};ke=wa=d([P({type:T.Sequence})],ke);const Q_={fromASN:t=>Tu.toString(Qi.fromASN(t)),toASN:t=>Qi.toASN(Tu.fromString(t))};class zr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],zr.prototype,"typeId",void 0);d([g({type:w.Any,context:0})],zr.prototype,"value",void 0);class cl{constructor(e={}){this.partyName=new Oe,Object.assign(this,e)}}d([g({type:Oe,optional:!0,context:0,implicit:!0})],cl.prototype,"nameAssigner",void 0);d([g({type:Oe,context:1,implicit:!0})],cl.prototype,"partyName",void 0);let re=class{constructor(e={}){Object.assign(this,e)}};d([g({type:zr,context:0,implicit:!0})],re.prototype,"otherName",void 0);d([g({type:w.IA5String,context:1,implicit:!0})],re.prototype,"rfc822Name",void 0);d([g({type:w.IA5String,context:2,implicit:!0})],re.prototype,"dNSName",void 0);d([g({type:w.Any,context:3,implicit:!0})],re.prototype,"x400Address",void 0);d([g({type:ke,context:4,implicit:!1})],re.prototype,"directoryName",void 0);d([g({type:cl,context:5})],re.prototype,"ediPartyName",void 0);d([g({type:w.IA5String,context:6,implicit:!0})],re.prototype,"uniformResourceIdentifier",void 0);d([g({type:w.OctetString,context:7,implicit:!0,converter:Q_})],re.prototype,"iPAddress",void 0);d([g({type:w.ObjectIdentifier,context:8,implicit:!0})],re.prototype,"registeredID",void 0);re=d([P({type:T.Choice})],re);const ll="1.3.6.1.5.5.7",e0=`${ll}.1`,rr=`${ll}.3`,oo=`${ll}.48`,Pu=`${oo}.1`,Ru=`${oo}.2`,Lu=`${oo}.3`,Uu=`${oo}.5`,Xt="2.5.29";var ka;const xa=`${e0}.1`;class Qr{constructor(e={}){this.accessMethod="",this.accessLocation=new re,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Qr.prototype,"accessMethod",void 0);d([g({type:re})],Qr.prototype,"accessLocation",void 0);let Pn=ka=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ka.prototype)}};Pn=ka=d([P({type:T.Sequence,itemType:Qr})],Pn);const Sa=`${Xt}.35`;class ul extends ae{}class cn{constructor(e={}){e&&Object.assign(this,e)}}d([g({type:ul,context:0,optional:!0,implicit:!0})],cn.prototype,"keyIdentifier",void 0);d([g({type:re,context:1,optional:!0,implicit:!0,repeated:"sequence"})],cn.prototype,"authorityCertIssuer",void 0);d([g({type:w.Integer,context:2,optional:!0,implicit:!0,converter:_e})],cn.prototype,"authorityCertSerialNumber",void 0);const yh=`${Xt}.19`;class es{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([g({type:w.Boolean,defaultValue:!1})],es.prototype,"cA",void 0);d([g({type:w.Integer,optional:!0})],es.prototype,"pathLenConstraint",void 0);var Aa;let Re=Aa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Aa.prototype)}};Re=Aa=d([P({type:T.Sequence,itemType:re})],Re);var Ea;let Vu=Ea=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,Ea.prototype)}};Vu=Ea=d([P({type:T.Sequence})],Vu);var Ia;const vh=`${Xt}.32`;let Ot=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([g({type:w.IA5String})],Ot.prototype,"ia5String",void 0);d([g({type:w.VisibleString})],Ot.prototype,"visibleString",void 0);d([g({type:w.BmpString})],Ot.prototype,"bmpString",void 0);d([g({type:w.Utf8String})],Ot.prototype,"utf8String",void 0);Ot=d([P({type:T.Choice})],Ot);class dl{constructor(e={}){this.organization=new Ot,this.noticeNumbers=[],Object.assign(this,e)}}d([g({type:Ot})],dl.prototype,"organization",void 0);d([g({type:w.Integer,repeated:"sequence"})],dl.prototype,"noticeNumbers",void 0);class pl{constructor(e={}){Object.assign(this,e)}}d([g({type:dl,optional:!0})],pl.prototype,"noticeRef",void 0);d([g({type:Ot,optional:!0})],pl.prototype,"explicitText",void 0);let ts=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.IA5String})],ts.prototype,"cPSuri",void 0);d([g({type:pl})],ts.prototype,"userNotice",void 0);ts=d([P({type:T.Choice})],ts);class fl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],fl.prototype,"policyQualifierId",void 0);d([g({type:w.Any})],fl.prototype,"qualifier",void 0);class ao{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ao.prototype,"policyIdentifier",void 0);d([g({type:fl,repeated:"sequence",optional:!0})],ao.prototype,"policyQualifiers",void 0);let ns=Ia=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ia.prototype)}};ns=Ia=d([P({type:T.Sequence,itemType:ao})],ns);let rs=class{constructor(e=0){this.value=e}};d([g({type:w.Integer})],rs.prototype,"value",void 0);rs=d([P({type:T.Choice})],rs);let Mu=class extends rs{};Mu=d([P({type:T.Choice})],Mu);var Ca;const Na=`${Xt}.31`;var ct;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(ct||(ct={}));class wh extends io{toJSON(){const e=[],n=this.toNumber();return n&ct.aACompromise&&e.push("aACompromise"),n&ct.affiliationChanged&&e.push("affiliationChanged"),n&ct.cACompromise&&e.push("cACompromise"),n&ct.certificateHold&&e.push("certificateHold"),n&ct.cessationOfOperation&&e.push("cessationOfOperation"),n&ct.keyCompromise&&e.push("keyCompromise"),n&ct.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&ct.superseded&&e.push("superseded"),n&ct.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let yn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,repeated:"sequence",implicit:!0})],yn.prototype,"fullName",void 0);d([g({type:Dn,context:1,implicit:!0})],yn.prototype,"nameRelativeToCRLIssuer",void 0);yn=d([P({type:T.Choice})],yn);class ir{constructor(e={}){Object.assign(this,e)}}d([g({type:yn,context:0,optional:!0})],ir.prototype,"distributionPoint",void 0);d([g({type:wh,context:1,optional:!0,implicit:!0})],ir.prototype,"reasons",void 0);d([g({type:re,context:2,optional:!0,repeated:"sequence",implicit:!0})],ir.prototype,"cRLIssuer",void 0);let Un=Ca=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ca.prototype)}};Un=Ca=d([P({type:T.Sequence,itemType:ir})],Un);var $a;let qu=$a=class extends Un{constructor(e){super(e),Object.setPrototypeOf(this,$a.prototype)}};qu=$a=d([P({type:T.Sequence,itemType:ir})],qu);class Te{constructor(e={}){this.onlyContainsUserCerts=Te.ONLY,this.onlyContainsCACerts=Te.ONLY,this.indirectCRL=Te.ONLY,this.onlyContainsAttributeCerts=Te.ONLY,Object.assign(this,e)}}Te.ONLY=!1;d([g({type:yn,context:0,optional:!0})],Te.prototype,"distributionPoint",void 0);d([g({type:w.Boolean,context:1,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsUserCerts",void 0);d([g({type:w.Boolean,context:2,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsCACerts",void 0);d([g({type:wh,context:3,optional:!0,implicit:!0})],Te.prototype,"onlySomeReasons",void 0);d([g({type:w.Boolean,context:4,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"indirectCRL",void 0);d([g({type:w.Boolean,context:5,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsAttributeCerts",void 0);var xr;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(xr||(xr={}));let za=class{constructor(e=xr.unspecified){this.reason=xr.unspecified,this.reason=e}toJSON(){return xr[this.reason]}toString(){return this.toJSON()}};d([g({type:w.Enumerated})],za.prototype,"reason",void 0);za=d([P({type:T.Choice})],za);var ja;const bh=`${Xt}.37`;let is=ja=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ja.prototype)}};is=ja=d([P({type:T.Sequence,itemType:w.ObjectIdentifier})],is);const t0=`${rr}.1`,n0=`${rr}.2`,r0=`${rr}.3`,i0=`${rr}.4`,s0=`${rr}.8`,o0=`${rr}.9`;let Oa=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([g({type:w.Integer,converter:_e})],Oa.prototype,"value",void 0);Oa=d([P({type:T.Choice})],Oa);let Ba=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([g({type:w.GeneralizedTime})],Ba.prototype,"value",void 0);Ba=d([P({type:T.Choice})],Ba);var Ta;let Du=Ta=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,Ta.prototype)}};Du=Ta=d([P({type:T.Sequence})],Du);const kh=`${Xt}.15`;var lt;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(lt||(lt={}));class Ho extends io{toJSON(){const e=this.toNumber(),n=[];return e<.cRLSign&&n.push("crlSign"),e<.dataEncipherment&&n.push("dataEncipherment"),e<.decipherOnly&&n.push("decipherOnly"),e<.digitalSignature&&n.push("digitalSignature"),e<.encipherOnly&&n.push("encipherOnly"),e<.keyAgreement&&n.push("keyAgreement"),e<.keyCertSign&&n.push("keyCertSign"),e<.keyEncipherment&&n.push("keyEncipherment"),e<.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var Pa;class co{constructor(e={}){this.base=new re,this.minimum=0,Object.assign(this,e)}}d([g({type:re})],co.prototype,"base",void 0);d([g({type:w.Integer,context:0,defaultValue:0,implicit:!0})],co.prototype,"minimum",void 0);d([g({type:w.Integer,context:1,optional:!0,implicit:!0})],co.prototype,"maximum",void 0);let ss=Pa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Pa.prototype)}};ss=Pa=d([P({type:T.Sequence,itemType:co})],ss);class xh{constructor(e={}){Object.assign(this,e)}}d([g({type:ss,context:0,optional:!0,implicit:!0})],xh.prototype,"permittedSubtrees",void 0);d([g({type:ss,context:1,optional:!0,implicit:!0})],xh.prototype,"excludedSubtrees",void 0);class Sh{constructor(e={}){Object.assign(this,e)}}d([g({type:w.Integer,context:0,implicit:!0,optional:!0,converter:_e})],Sh.prototype,"requireExplicitPolicy",void 0);d([g({type:w.Integer,context:1,implicit:!0,optional:!0,converter:_e})],Sh.prototype,"inhibitPolicyMapping",void 0);var Ra;class hl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],hl.prototype,"issuerDomainPolicy",void 0);d([g({type:w.ObjectIdentifier})],hl.prototype,"subjectDomainPolicy",void 0);let Fu=Ra=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};Fu=Ra=d([P({type:T.Sequence,itemType:hl})],Fu);var La;const Ah=`${Xt}.17`;let Ua=La=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,La.prototype)}};Ua=La=d([P({type:T.Sequence})],Ua);let Bt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Bt.prototype,"type",void 0);d([g({type:w.Any,repeated:"set"})],Bt.prototype,"values",void 0);var Va;let Hu=Va=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Va.prototype)}};Hu=Va=d([P({type:T.Sequence,itemType:Bt})],Hu);const Eh=`${Xt}.14`;class Ht extends ul{}class Ih{constructor(e={}){Object.assign(this,e)}}d([g({type:w.GeneralizedTime,context:0,implicit:!0,optional:!0})],Ih.prototype,"notBefore",void 0);d([g({type:w.GeneralizedTime,context:1,implicit:!0,optional:!0})],Ih.prototype,"notAfter",void 0);var Sr;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Sr||(Sr={}));class Ch extends io{toJSON(){const e=[],n=this.toNumber();return n&Sr.pKIXCertificate&&e.push("pKIXCertificate"),n&Sr.newExtensions&&e.push("newExtensions"),n&Sr.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Nh{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Ch,Object.assign(this,e)}}d([g({type:w.GeneralString})],Nh.prototype,"entrustVers",void 0);d([g({type:Ch})],Nh.prototype,"entrustInfoFlags",void 0);var Ma;let Ku=Ma=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}};Ku=Ma=d([P({type:T.Sequence,itemType:Qr})],Ku);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&gf(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([g({type:w.ObjectIdentifier})],F.prototype,"algorithm",void 0);d([g({type:w.Any,optional:!0})],F.prototype,"parameters",void 0);class ut{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],ut.prototype,"algorithm",void 0);d([g({type:w.BitString})],ut.prototype,"subjectPublicKey",void 0);let ze=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const n=new Date(e);n.getUTCFullYear()>2049?this.generalTime=n:this.utcTime=n}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};d([g({type:w.UTCTime})],ze.prototype,"utcTime",void 0);d([g({type:w.GeneralizedTime})],ze.prototype,"generalTime",void 0);ze=d([P({type:T.Choice})],ze);class ei{constructor(e){this.notBefore=new ze(new Date),this.notAfter=new ze(new Date),e&&(this.notBefore=new ze(e.notBefore),this.notAfter=new ze(e.notAfter))}}d([g({type:ze})],ei.prototype,"notBefore",void 0);d([g({type:ze})],ei.prototype,"notAfter",void 0);var qa;let nt=class $h{constructor(e={}){this.extnID="",this.critical=$h.CRITICAL,this.extnValue=new ae,Object.assign(this,e)}};nt.CRITICAL=!1;d([g({type:w.ObjectIdentifier})],nt.prototype,"extnID",void 0);d([g({type:w.Boolean,defaultValue:nt.CRITICAL})],nt.prototype,"critical",void 0);d([g({type:ae})],nt.prototype,"extnValue",void 0);let Gt=qa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,qa.prototype)}};Gt=qa=d([P({type:T.Sequence,itemType:nt})],Gt);var vn;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(vn||(vn={}));class Ye{constructor(e={}){this.version=vn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new ke,this.validity=new ei,this.subject=new ke,this.subjectPublicKeyInfo=new ut,Object.assign(this,e)}}d([g({type:w.Integer,context:0,defaultValue:vn.v1})],Ye.prototype,"version",void 0);d([g({type:w.Integer,converter:_e})],Ye.prototype,"serialNumber",void 0);d([g({type:F})],Ye.prototype,"signature",void 0);d([g({type:ke})],Ye.prototype,"issuer",void 0);d([g({type:ei})],Ye.prototype,"validity",void 0);d([g({type:ke})],Ye.prototype,"subject",void 0);d([g({type:ut})],Ye.prototype,"subjectPublicKeyInfo",void 0);d([g({type:w.BitString,context:1,implicit:!0,optional:!0})],Ye.prototype,"issuerUniqueID",void 0);d([g({type:w.BitString,context:2,implicit:!0,optional:!0})],Ye.prototype,"subjectUniqueID",void 0);d([g({type:Gt,context:3,optional:!0})],Ye.prototype,"extensions",void 0);class wn{constructor(e={}){this.tbsCertificate=new Ye,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Ye})],wn.prototype,"tbsCertificate",void 0);d([g({type:F})],wn.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],wn.prototype,"signatureValue",void 0);class lo{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new ze,Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],lo.prototype,"userCertificate",void 0);d([g({type:ze})],lo.prototype,"revocationDate",void 0);d([g({type:nt,optional:!0,repeated:"sequence"})],lo.prototype,"crlEntryExtensions",void 0);class Vt{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new ze,Object.assign(this,e)}}d([g({type:w.Integer,optional:!0})],Vt.prototype,"version",void 0);d([g({type:F})],Vt.prototype,"signature",void 0);d([g({type:ke})],Vt.prototype,"issuer",void 0);d([g({type:ze})],Vt.prototype,"thisUpdate",void 0);d([g({type:ze,optional:!0})],Vt.prototype,"nextUpdate",void 0);d([g({type:lo,repeated:"sequence",optional:!0})],Vt.prototype,"revokedCertificates",void 0);d([g({type:nt,optional:!0,context:0,repeated:"sequence"})],Vt.prototype,"crlExtensions",void 0);class gl{constructor(e={}){this.tbsCertList=new Vt,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Vt})],gl.prototype,"tbsCertList",void 0);d([g({type:F})],gl.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],gl.prototype,"signature",void 0);class sr{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ke})],sr.prototype,"issuer",void 0);d([g({type:w.Integer,converter:_e})],sr.prototype,"serialNumber",void 0);let Fn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ht,context:0,implicit:!0})],Fn.prototype,"subjectKeyIdentifier",void 0);d([g({type:sr})],Fn.prototype,"issuerAndSerialNumber",void 0);Fn=d([P({type:T.Choice})],Fn);var Tt;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(Tt||(Tt={}));let jr=class extends F{};jr=d([P({type:T.Sequence})],jr);let os=class extends F{};os=d([P({type:T.Sequence})],os);let xt=class extends F{};xt=d([P({type:T.Sequence})],xt);let as=class extends F{};as=d([P({type:T.Sequence})],as);let Wu=class extends F{};Wu=d([P({type:T.Sequence})],Wu);let Da=class extends F{};Da=d([P({type:T.Sequence})],Da);let or=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],or.prototype,"attrType",void 0);d([g({type:w.Any,repeated:"set"})],or.prototype,"attrValues",void 0);var Fa;class It{constructor(e={}){this.version=Tt.v0,this.sid=new Fn,this.digestAlgorithm=new jr,this.signatureAlgorithm=new os,this.signature=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],It.prototype,"version",void 0);d([g({type:Fn})],It.prototype,"sid",void 0);d([g({type:jr})],It.prototype,"digestAlgorithm",void 0);d([g({type:or,repeated:"set",context:0,implicit:!0,optional:!0})],It.prototype,"signedAttrs",void 0);d([g({type:os})],It.prototype,"signatureAlgorithm",void 0);d([g({type:ae})],It.prototype,"signature",void 0);d([g({type:or,repeated:"set",context:1,implicit:!0,optional:!0})],It.prototype,"unsignedAttrs",void 0);let cs=Fa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Fa.prototype)}};cs=Fa=d([P({type:T.Set,itemType:It})],cs);let Gu=class extends ze{};Gu=d([P({type:T.Choice})],Gu);let Ju=class extends It{};Ju=d([P({type:T.Sequence})],Ju);class ml{constructor(e={}){this.acIssuer=new re,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([g({type:re})],ml.prototype,"acIssuer",void 0);d([g({type:w.Integer})],ml.prototype,"acSerial",void 0);d([g({type:Bt,repeated:"sequence"})],ml.prototype,"attrs",void 0);var Ha;let ls=Ha=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};ls=Ha=d([P({type:T.Sequence,itemType:w.ObjectIdentifier})],ls);class uo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([g({type:w.Integer,optional:!0})],uo.prototype,"pathLenConstraint",void 0);d([g({type:ls,implicit:!0,context:0,optional:!0})],uo.prototype,"permittedAttrs",void 0);d([g({type:ls,implicit:!0,context:1,optional:!0})],uo.prototype,"excludedAttrs",void 0);d([g({type:w.Boolean,defaultValue:!0})],uo.prototype,"permitUnSpecified",void 0);class Cn{constructor(e={}){this.issuer=new Re,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Re})],Cn.prototype,"issuer",void 0);d([g({type:w.Integer,converter:_e})],Cn.prototype,"serial",void 0);d([g({type:w.BitString,optional:!0})],Cn.prototype,"issuerUID",void 0);var Ka;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(Ka||(Ka={}));class Nn{constructor(e={}){this.digestedObjectType=Ka.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Enumerated})],Nn.prototype,"digestedObjectType",void 0);d([g({type:w.ObjectIdentifier,optional:!0})],Nn.prototype,"otherObjectTypeID",void 0);d([g({type:F})],Nn.prototype,"digestAlgorithm",void 0);d([g({type:w.BitString})],Nn.prototype,"objectDigest",void 0);class po{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,optional:!0})],po.prototype,"issuerName",void 0);d([g({type:Cn,context:0,implicit:!0,optional:!0})],po.prototype,"baseCertificateID",void 0);d([g({type:Nn,context:1,implicit:!0,optional:!0})],po.prototype,"objectDigestInfo",void 0);let Hn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,repeated:"sequence"})],Hn.prototype,"v1Form",void 0);d([g({type:po,context:0,implicit:!0})],Hn.prototype,"v2Form",void 0);Hn=d([P({type:T.Choice})],Hn);class fo{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([g({type:w.GeneralizedTime})],fo.prototype,"notBeforeTime",void 0);d([g({type:w.GeneralizedTime})],fo.prototype,"notAfterTime",void 0);class ti{constructor(e={}){Object.assign(this,e)}}d([g({type:Cn,implicit:!0,context:0,optional:!0})],ti.prototype,"baseCertificateID",void 0);d([g({type:Re,implicit:!0,context:1,optional:!0})],ti.prototype,"entityName",void 0);d([g({type:Nn,implicit:!0,context:2,optional:!0})],ti.prototype,"objectDigestInfo",void 0);var Wa;(function(t){t[t.v2=1]="v2"})(Wa||(Wa={}));class gt{constructor(e={}){this.version=Wa.v2,this.holder=new ti,this.issuer=new Hn,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new fo,this.attributes=[],Object.assign(this,e)}}d([g({type:w.Integer})],gt.prototype,"version",void 0);d([g({type:ti})],gt.prototype,"holder",void 0);d([g({type:Hn})],gt.prototype,"issuer",void 0);d([g({type:F})],gt.prototype,"signature",void 0);d([g({type:w.Integer,converter:_e})],gt.prototype,"serialNumber",void 0);d([g({type:fo})],gt.prototype,"attrCertValidityPeriod",void 0);d([g({type:Bt,repeated:"sequence"})],gt.prototype,"attributes",void 0);d([g({type:w.BitString,optional:!0})],gt.prototype,"issuerUniqueID",void 0);d([g({type:Gt,optional:!0})],gt.prototype,"extensions",void 0);class ho{constructor(e={}){this.acinfo=new gt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:gt})],ho.prototype,"acinfo",void 0);d([g({type:F})],ho.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],ho.prototype,"signatureValue",void 0);var us;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(us||(us={}));class Ga extends io{}class _l{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier,implicit:!0,context:0})],_l.prototype,"type",void 0);d([g({type:w.Any,implicit:!0,context:1})],_l.prototype,"value",void 0);class yl{constructor(e={}){this.policyId="",this.classList=new Ga(us.unclassified),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],yl.prototype,"policyId",void 0);d([g({type:Ga,defaultValue:new Ga(us.unclassified)})],yl.prototype,"classList",void 0);d([g({type:_l,repeated:"set"})],yl.prototype,"securityCategories",void 0);class go{constructor(e={}){Object.assign(this,e)}}d([g({type:ae})],go.prototype,"cotets",void 0);d([g({type:w.ObjectIdentifier})],go.prototype,"oid",void 0);d([g({type:w.Utf8String})],go.prototype,"string",void 0);class zh{constructor(e={}){this.values=[],Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],zh.prototype,"policyAuthority",void 0);d([g({type:go,repeated:"sequence"})],zh.prototype,"values",void 0);var Ja;class mo{constructor(e={}){this.targetCertificate=new Cn,Object.assign(this,e)}}d([g({type:Cn})],mo.prototype,"targetCertificate",void 0);d([g({type:re,optional:!0})],mo.prototype,"targetName",void 0);d([g({type:Nn,optional:!0})],mo.prototype,"certDigestInfo",void 0);let Kn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,implicit:!0})],Kn.prototype,"targetName",void 0);d([g({type:re,context:1,implicit:!0})],Kn.prototype,"targetGroup",void 0);d([g({type:mo,context:2,implicit:!0})],Kn.prototype,"targetCert",void 0);Kn=d([P({type:T.Choice})],Kn);let Za=Ja=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ja.prototype)}};Za=Ja=d([P({type:T.Sequence,itemType:Kn})],Za);var Ya;let Zu=Ya=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ya.prototype)}};Zu=Ya=d([P({type:T.Sequence,itemType:Za})],Zu);class jh{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],jh.prototype,"roleAuthority",void 0);d([g({type:re,implicit:!0,context:1})],jh.prototype,"roleName",void 0);class vl{constructor(e={}){this.service=new re,this.ident=new re,Object.assign(this,e)}}d([g({type:re})],vl.prototype,"service",void 0);d([g({type:re})],vl.prototype,"ident",void 0);d([g({type:ae,optional:!0})],vl.prototype,"authInfo",void 0);var Xa;class wl{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],wl.prototype,"otherCertFormat",void 0);d([g({type:w.Any})],wl.prototype,"otherCert",void 0);let Wn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:wn})],Wn.prototype,"certificate",void 0);d([g({type:ho,context:2,implicit:!0})],Wn.prototype,"v2AttrCert",void 0);d([g({type:wl,context:3,implicit:!0})],Wn.prototype,"other",void 0);Wn=d([P({type:T.Choice})],Wn);let ds=Xa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Xa.prototype)}};ds=Xa=d([P({type:T.Set,itemType:Wn})],ds);class ar{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ar.prototype,"contentType",void 0);d([g({type:w.Any,context:0})],ar.prototype,"content",void 0);let Or=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae})],Or.prototype,"single",void 0);d([g({type:w.Any})],Or.prototype,"any",void 0);Or=d([P({type:T.Choice})],Or);class _o{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],_o.prototype,"eContentType",void 0);d([g({type:Or,context:0,optional:!0})],_o.prototype,"eContent",void 0);let Br=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae,context:0,implicit:!0,optional:!0})],Br.prototype,"value",void 0);d([g({type:ae,converter:T_,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Br.prototype,"constructedValue",void 0);Br=d([P({type:T.Choice})],Br);class ni{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new as,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ni.prototype,"contentType",void 0);d([g({type:as})],ni.prototype,"contentEncryptionAlgorithm",void 0);d([g({type:Br,optional:!0})],ni.prototype,"encryptedContent",void 0);class yo{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],yo.prototype,"keyAttrId",void 0);d([g({type:w.Any,optional:!0})],yo.prototype,"keyAttr",void 0);var Qa;class vo{constructor(e={}){this.subjectKeyIdentifier=new Ht,Object.assign(this,e)}}d([g({type:Ht})],vo.prototype,"subjectKeyIdentifier",void 0);d([g({type:w.GeneralizedTime,optional:!0})],vo.prototype,"date",void 0);d([g({type:yo,optional:!0})],vo.prototype,"other",void 0);let Gn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:vo,context:0,implicit:!0,optional:!0})],Gn.prototype,"rKeyId",void 0);d([g({type:sr,optional:!0})],Gn.prototype,"issuerAndSerialNumber",void 0);Gn=d([P({type:T.Choice})],Gn);class bl{constructor(e={}){this.rid=new Gn,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:Gn})],bl.prototype,"rid",void 0);d([g({type:ae})],bl.prototype,"encryptedKey",void 0);let ps=Qa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};ps=Qa=d([P({type:T.Sequence,itemType:bl})],ps);class kl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],kl.prototype,"algorithm",void 0);d([g({type:w.BitString})],kl.prototype,"publicKey",void 0);let bn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ht,context:0,implicit:!0,optional:!0})],bn.prototype,"subjectKeyIdentifier",void 0);d([g({type:kl,context:1,implicit:!0,optional:!0})],bn.prototype,"originatorKey",void 0);d([g({type:sr,optional:!0})],bn.prototype,"issuerAndSerialNumber",void 0);bn=d([P({type:T.Choice})],bn);class cr{constructor(e={}){this.version=Tt.v3,this.originator=new bn,this.keyEncryptionAlgorithm=new xt,this.recipientEncryptedKeys=new ps,Object.assign(this,e)}}d([g({type:w.Integer})],cr.prototype,"version",void 0);d([g({type:bn,context:0})],cr.prototype,"originator",void 0);d([g({type:ae,context:1,optional:!0})],cr.prototype,"ukm",void 0);d([g({type:xt})],cr.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ps})],cr.prototype,"recipientEncryptedKeys",void 0);let Jn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ht,context:0,implicit:!0})],Jn.prototype,"subjectKeyIdentifier",void 0);d([g({type:sr})],Jn.prototype,"issuerAndSerialNumber",void 0);Jn=d([P({type:T.Choice})],Jn);class ri{constructor(e={}){this.version=Tt.v0,this.rid=new Jn,this.keyEncryptionAlgorithm=new xt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],ri.prototype,"version",void 0);d([g({type:Jn})],ri.prototype,"rid",void 0);d([g({type:xt})],ri.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],ri.prototype,"encryptedKey",void 0);class ii{constructor(e={}){this.keyIdentifier=new ae,Object.assign(this,e)}}d([g({type:ae})],ii.prototype,"keyIdentifier",void 0);d([g({type:w.GeneralizedTime,optional:!0})],ii.prototype,"date",void 0);d([g({type:yo,optional:!0})],ii.prototype,"other",void 0);class si{constructor(e={}){this.version=Tt.v4,this.kekid=new ii,this.keyEncryptionAlgorithm=new xt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],si.prototype,"version",void 0);d([g({type:ii})],si.prototype,"kekid",void 0);d([g({type:xt})],si.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],si.prototype,"encryptedKey",void 0);class oi{constructor(e={}){this.version=Tt.v0,this.keyEncryptionAlgorithm=new xt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],oi.prototype,"version",void 0);d([g({type:Da,context:0,optional:!0})],oi.prototype,"keyDerivationAlgorithm",void 0);d([g({type:xt})],oi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],oi.prototype,"encryptedKey",void 0);class xl{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],xl.prototype,"oriType",void 0);d([g({type:w.Any})],xl.prototype,"oriValue",void 0);let Jt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ri,optional:!0})],Jt.prototype,"ktri",void 0);d([g({type:cr,context:1,implicit:!0,optional:!0})],Jt.prototype,"kari",void 0);d([g({type:si,context:2,implicit:!0,optional:!0})],Jt.prototype,"kekri",void 0);d([g({type:oi,context:3,implicit:!0,optional:!0})],Jt.prototype,"pwri",void 0);d([g({type:xl,context:4,implicit:!0,optional:!0})],Jt.prototype,"ori",void 0);Jt=d([P({type:T.Choice})],Jt);var ec;let fs=ec=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};fs=ec=d([P({type:T.Set,itemType:Jt})],fs);var tc;class wo{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],wo.prototype,"otherRevInfoFormat",void 0);d([g({type:w.Any})],wo.prototype,"otherRevInfo",void 0);let hs=class{constructor(e={}){this.other=new wo,Object.assign(this,e)}};d([g({type:wo,context:1,implicit:!0})],hs.prototype,"other",void 0);hs=d([P({type:T.Choice})],hs);let gs=tc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};gs=tc=d([P({type:T.Set,itemType:hs})],gs);class Sl{constructor(e={}){Object.assign(this,e)}}d([g({type:ds,context:0,implicit:!0,optional:!0})],Sl.prototype,"certs",void 0);d([g({type:gs,context:1,implicit:!0,optional:!0})],Sl.prototype,"crls",void 0);var nc;let rc=nc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};rc=nc=d([P({type:T.Set,itemType:or})],rc);class ai{constructor(e={}){this.version=Tt.v0,this.recipientInfos=new fs,this.encryptedContentInfo=new ni,Object.assign(this,e)}}d([g({type:w.Integer})],ai.prototype,"version",void 0);d([g({type:Sl,context:0,implicit:!0,optional:!0})],ai.prototype,"originatorInfo",void 0);d([g({type:fs})],ai.prototype,"recipientInfos",void 0);d([g({type:ni})],ai.prototype,"encryptedContentInfo",void 0);d([g({type:rc,context:1,implicit:!0,optional:!0})],ai.prototype,"unprotectedAttrs",void 0);const a0="1.2.840.113549.1.7.2";var ic;let ms=ic=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};ms=ic=d([P({type:T.Set,itemType:jr})],ms);class lr{constructor(e={}){this.version=Tt.v0,this.digestAlgorithms=new ms,this.encapContentInfo=new _o,this.signerInfos=new cs,Object.assign(this,e)}}d([g({type:w.Integer})],lr.prototype,"version",void 0);d([g({type:ms})],lr.prototype,"digestAlgorithms",void 0);d([g({type:_o})],lr.prototype,"encapContentInfo",void 0);d([g({type:ds,context:0,implicit:!0,optional:!0})],lr.prototype,"certificates",void 0);d([g({type:gs,context:1,implicit:!0,optional:!0})],lr.prototype,"crls",void 0);d([g({type:cs})],lr.prototype,"signerInfos",void 0);const Tr="1.2.840.10045.2.1",Al="1.2.840.10045.4.1",Oh="1.2.840.10045.4.3.1",El="1.2.840.10045.4.3.2",Il="1.2.840.10045.4.3.3",Cl="1.2.840.10045.4.3.4",Yu="1.2.840.10045.3.1.7",Xu="1.3.132.0.34",Qu="1.3.132.0.35";function ci(t){return new F({algorithm:t})}const c0=ci(Al);ci(Oh);const l0=ci(El),u0=ci(Il),d0=ci(Cl);let Pr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Pr.prototype,"fieldType",void 0);d([g({type:w.Any})],Pr.prototype,"parameters",void 0);Pr=d([P({type:T.Sequence})],Pr);class p0 extends ae{}let Zn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.OctetString})],Zn.prototype,"a",void 0);d([g({type:w.OctetString})],Zn.prototype,"b",void 0);d([g({type:w.BitString,optional:!0})],Zn.prototype,"seed",void 0);Zn=d([P({type:T.Sequence})],Zn);var sc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(sc||(sc={}));let Pt=class{constructor(e={}){this.version=sc.ecpVer1,Object.assign(this,e)}};d([g({type:w.Integer})],Pt.prototype,"version",void 0);d([g({type:Pr})],Pt.prototype,"fieldID",void 0);d([g({type:Zn})],Pt.prototype,"curve",void 0);d([g({type:p0})],Pt.prototype,"base",void 0);d([g({type:w.Integer,converter:_e})],Pt.prototype,"order",void 0);d([g({type:w.Integer,optional:!0})],Pt.prototype,"cofactor",void 0);Pt=d([P({type:T.Sequence})],Pt);let Zt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Zt.prototype,"namedCurve",void 0);d([g({type:w.Null})],Zt.prototype,"implicitCurve",void 0);d([g({type:Pt})],Zt.prototype,"specifiedCurve",void 0);Zt=d([P({type:T.Choice})],Zt);class bo{constructor(e={}){this.version=1,this.privateKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],bo.prototype,"version",void 0);d([g({type:ae})],bo.prototype,"privateKey",void 0);d([g({type:Zt,context:0,optional:!0})],bo.prototype,"parameters",void 0);d([g({type:w.BitString,context:1,optional:!0})],bo.prototype,"publicKey",void 0);class _s{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],_s.prototype,"r",void 0);d([g({type:w.Integer,converter:_e})],_s.prototype,"s",void 0);const He="1.2.840.113549.1.1",kn=`${He}.1`,f0=`${He}.7`,h0=`${He}.9`,Ar=`${He}.10`,g0=`${He}.2`,m0=`${He}.4`,ys=`${He}.5`,_0=`${He}.14`,oc=`${He}.11`,vs=`${He}.12`,ws=`${He}.13`,Bh=`${He}.15`,Th=`${He}.16`,bs="1.3.14.3.2.26",Ph="2.16.840.1.101.3.4.2.4",ks="2.16.840.1.101.3.4.2.1",xs="2.16.840.1.101.3.4.2.2",Ss="2.16.840.1.101.3.4.2.3",y0="2.16.840.1.101.3.4.2.5",v0="2.16.840.1.101.3.4.2.6",w0="1.2.840.113549.2.2",b0="1.2.840.113549.2.5",ko=`${He}.8`;function Ee(t){return new F({algorithm:t,parameters:null})}Ee(w0);Ee(b0);const xn=Ee(bs);Ee(Ph);Ee(ks);Ee(xs);Ee(Ss);Ee(y0);Ee(v0);const Rh=new F({algorithm:ko,parameters:V.serialize(xn)}),Lh=new F({algorithm:h0,parameters:V.serialize(Qi.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ee(kn);Ee(g0);Ee(m0);Ee(ys);Ee(Bh);Ee(Th);Ee(vs);Ee(ws);Ee(Bh);Ee(Th);class xo{constructor(e={}){this.hashAlgorithm=new F(xn),this.maskGenAlgorithm=new F({algorithm:ko,parameters:V.serialize(xn)}),this.pSourceAlgorithm=new F(Lh),Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:xn})],xo.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Rh})],xo.prototype,"maskGenAlgorithm",void 0);d([g({type:F,context:2,defaultValue:Lh})],xo.prototype,"pSourceAlgorithm",void 0);new F({algorithm:f0,parameters:V.serialize(new xo)});class Sn{constructor(e={}){this.hashAlgorithm=new F(xn),this.maskGenAlgorithm=new F({algorithm:ko,parameters:V.serialize(xn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:xn})],Sn.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Rh})],Sn.prototype,"maskGenAlgorithm",void 0);d([g({type:w.Integer,context:2,defaultValue:20})],Sn.prototype,"saltLength",void 0);d([g({type:w.Integer,context:3,defaultValue:1})],Sn.prototype,"trailerField",void 0);new F({algorithm:Ar,parameters:V.serialize(new Sn)});class So{constructor(e={}){this.digestAlgorithm=new F,this.digest=new ae,Object.assign(this,e)}}d([g({type:F})],So.prototype,"digestAlgorithm",void 0);d([g({type:ae})],So.prototype,"digest",void 0);var ac;class Ao{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],Ao.prototype,"prime",void 0);d([g({type:w.Integer,converter:_e})],Ao.prototype,"exponent",void 0);d([g({type:w.Integer,converter:_e})],Ao.prototype,"coefficient",void 0);let cc=ac=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};cc=ac=d([P({type:T.Sequence,itemType:Ao})],cc);class Ct{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer})],Ct.prototype,"version",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"modulus",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"publicExponent",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"privateExponent",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"prime1",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"prime2",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"exponent1",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"exponent2",void 0);d([g({type:w.Integer,converter:_e})],Ct.prototype,"coefficient",void 0);d([g({type:cc,optional:!0})],Ct.prototype,"otherPrimeInfos",void 0);class Nl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],Nl.prototype,"modulus",void 0);d([g({type:w.Integer,converter:_e})],Nl.prototype,"publicExponent",void 0);var lc;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(lc||(lc={}));const Ve=lc;/*! *****************************************************************************
|
|
80
80
|
Copyright (c) Microsoft Corporation.
|
|
81
81
|
|
|
82
82
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -89,9 +89,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
89
89
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
90
90
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
91
91
|
PERFORMANCE OF THIS SOFTWARE.
|
|
92
|
-
***************************************************************************** */var uc=function(t,e){return uc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},uc(t,e)};function $l(t,e){uc(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function
|
|
92
|
+
***************************************************************************** */var uc=function(t,e){return uc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},uc(t,e)};function $l(t,e){uc(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function k0(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function c(p){try{u(r.next(p))}catch(h){o(h)}}function l(p){try{u(r.throw(p))}catch(h){o(h)}}function u(p){p.done?s(p.value):i(p.value).then(c,l)}u((r=r.apply(t,[])).next())})}function x0(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(p){return l([u,p])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1],s=u;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(u);break}s[2]&&n.ops.pop(),n.trys.pop();continue}u=e.call(t,n)}catch(p){u=[6,p],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function wi(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function As(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function sn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(As(arguments[e]));return t}var S0="injectionTokens";function A0(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(S0,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function Uh(t){return!!t.useClass}function dc(t){return!!t.useFactory}var Vh=function(){function t(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return t.prototype.createProxy=function(e){var n=this,r={},i=!1,s,o=function(){return i||(s=e(n.wrap()),i=!0),s};return new Proxy(r,this.createHandler(o))},t.prototype.createHandler=function(e){var n={},r=function(i){n[i]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var c=Reflect[i];return c.apply(void 0,sn(s))}};return this.reflectMethods.forEach(r),n},t}();function On(t){return typeof t=="string"||typeof t=="symbol"}function E0(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function ed(t){return typeof t=="object"&&"token"in t&&"transform"in t}function I0(t){return typeof t=="function"||t instanceof Vh}function Ni(t){return!!t.useToken}function $i(t){return t.useValue!=null}function C0(t){return Uh(t)||$i(t)||Ni(t)||dc(t)}var zl=function(){function t(){this._registryMap=new Map}return t.prototype.entries=function(){return this._registryMap.entries()},t.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},t.prototype.get=function(e){this.ensure(e);var n=this._registryMap.get(e);return n[n.length-1]||null},t.prototype.set=function(e,n){this.ensure(e),this._registryMap.get(e).push(n)},t.prototype.setAll=function(e,n){this._registryMap.set(e,n)},t.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},t.prototype.clear=function(){this._registryMap.clear()},t.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},t}(),N0=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(zl),td=function(){function t(){this.scopedResolutions=new Map}return t}();function $0(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function z0(t,e,n){return n===void 0&&(n=" "),sn([t],e.message.split(`
|
|
93
93
|
`).map(function(r){return n+r})).join(`
|
|
94
|
-
`)}function z0(t,e,n){var r=As(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,o=N0(s,e);return $0("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function j0(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var O0=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(zl),B0=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(zl),T0=function(){function t(){this.preResolution=new O0,this.postResolution=new B0}return t}(),Vh=new Map,P0=function(){function t(e){this.parent=e,this._registry=new C0,this.interceptors=new T0,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Ve.Transient}),this.ensureNotDisposed();var i;if(I0(n)?i=n:i={useClass:n},Ni(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+sn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&Ni(l.provider)?o=l.provider:o=null}if((r.lifecycle===Ve.Singleton||r.lifecycle==Ve.ContainerScoped||r.lifecycle==Ve.ResolutionScoped)&&($i(i)||dc(i)))throw new Error('Cannot use lifecycle "'+Ve[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),On(n)?this.register(e,{useToken:n}):this.register(e,{useClass:n})},t.prototype.registerInstance=function(e,n){return this.ensureNotDisposed(),this.register(e,{useValue:n})},t.prototype.registerSingleton=function(e,n){if(this.ensureNotDisposed(),On(e)){if(On(n))return this.register(e,{useToken:n},{lifecycle:Ve.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Ve.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!On(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Ve.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new td),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&On(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var i=this.resolveRegistration(r,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(E0(e)){var i=this.construct(e,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(e,n){var r,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=wi(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,r){var i,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=wi(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var u=l.value;u.options.frequency!="Once"&&o.push(u),u.callback(e,n,r)}}catch(p){i={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,o)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Ve.Singleton,i=e.options.lifecycle===Ve.ContainerScoped,s=r||i,o;return $i(e.provider)?o=e.provider.useValue:Ni(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):Lh(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):dc(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new td),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&On(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return r.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,o,"All"),o},t.prototype.isRegistered=function(e,n){return n===void 0&&(n=!1),this.ensureNotDisposed(),this._registry.has(e)||n&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var e,n;this.ensureNotDisposed();try{for(var r=wi(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=As(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(l){return!$i(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var r=new t(this);try{for(var i=wi(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=As(s.value,2),c=o[0],l=o[1];l.some(function(u){var p=u.options;return p.lifecycle===Ve.ContainerScoped})&&r._registry.setAll(c,l.map(function(u){return u.options.lifecycle===Ve.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.prototype.beforeResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:r})},t.prototype.afterResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:r})},t.prototype.dispose=function(){return b0(this,void 0,void 0,function(){var e;return k0(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(r){var i=r.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return n.sent(),[2]}})})},t.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},t.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},t.prototype.construct=function(e,n){var r=this;if(e instanceof Uh)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=Vh.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,sn([void 0],o)))}();return j0(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var o,c,l;try{return A0(i)?ed(i)?i.multiple?(o=r.resolve(i.transform)).transform.apply(o,sn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,sn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):ed(i)?(l=r.resolve(i.transform,e)).transform.apply(l,sn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(u){throw new Error(z0(n,s,u))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Be=new P0;function Eo(){return function(t){Vh.set(t,S0(t))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var pc;class Io{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([g({type:w.ObjectIdentifier})],Io.prototype,"attrId",void 0);d([g({type:w.Any,repeated:"set"})],Io.prototype,"attrValues",void 0);let nd=pc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,pc.prototype)}};nd=pc=d([P({type:T.Sequence,itemType:Io})],nd);var fc;let rd=fc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};rd=fc=d([P({type:T.Sequence,itemType:ar})],rd);class Mh{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Mh.prototype,"certId",void 0);d([g({type:w.Any,context:0})],Mh.prototype,"certValue",void 0);class qh{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],qh.prototype,"crlId",void 0);d([g({type:w.Any,context:0})],qh.prototype,"crltValue",void 0);class Dh extends ae{}let Co=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new Dh,Object.assign(this,e)}};d([g({type:F})],Co.prototype,"encryptionAlgorithm",void 0);d([g({type:Dh})],Co.prototype,"encryptedData",void 0);var hc,gc;(function(t){t[t.v1=0]="v1"})(gc||(gc={}));class Fh extends ae{}let mc=hc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};mc=hc=d([P({type:T.Sequence,itemType:Bt})],mc);class li{constructor(e={}){this.version=gc.v1,this.privateKeyAlgorithm=new F,this.privateKey=new Fh,Object.assign(this,e)}}d([g({type:w.Integer})],li.prototype,"version",void 0);d([g({type:F})],li.prototype,"privateKeyAlgorithm",void 0);d([g({type:Fh})],li.prototype,"privateKey",void 0);d([g({type:mc,implicit:!0,context:0,optional:!0})],li.prototype,"attributes",void 0);let id=class extends li{};id=d([P({type:T.Sequence})],id);let sd=class extends Co{};sd=d([P({type:T.Sequence})],sd);class Hh{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Hh.prototype,"secretTypeId",void 0);d([g({type:w.Any,context:0})],Hh.prototype,"secretValue",void 0);class ui{constructor(e={}){this.mac=new So,this.macSalt=new ae,this.iterations=1,Object.assign(this,e)}}d([g({type:So})],ui.prototype,"mac",void 0);d([g({type:ae})],ui.prototype,"macSalt",void 0);d([g({type:w.Integer,defaultValue:1})],ui.prototype,"iterations",void 0);class No{constructor(e={}){this.version=3,this.authSafe=new ar,this.macData=new ui,Object.assign(this,e)}}d([g({type:w.Integer})],No.prototype,"version",void 0);d([g({type:ar})],No.prototype,"authSafe",void 0);d([g({type:ui,optional:!0})],No.prototype,"macData",void 0);var _c;class $o{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],$o.prototype,"bagId",void 0);d([g({type:w.Any,context:0})],$o.prototype,"bagValue",void 0);d([g({type:Io,repeated:"set",optional:!0})],$o.prototype,"bagAttributes",void 0);let od=_c=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};od=_c=d([P({type:T.Sequence,itemType:$o})],od);var yc,vc,wc;const Kh="1.2.840.113549.1.9",Wh=`${Kh}.7`,jl=`${Kh}.14`;let Es=class extends Oe{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([g({type:w.IA5String})],Es.prototype,"ia5String",void 0);Es=d([P({type:T.Choice})],Es);let ad=class extends ar{};ad=d([P({type:T.Sequence})],ad);let cd=class extends No{};cd=d([P({type:T.Sequence})],cd);let ld=class extends Co{};ld=d([P({type:T.Sequence})],ld);let bc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.IA5String})],bc.prototype,"value",void 0);bc=d([P({type:T.Choice})],bc);let ud=class extends Es{};ud=d([P({type:T.Choice})],ud);let dd=class extends Oe{};dd=d([P({type:T.Choice})],dd);let kc=class{constructor(e=new Date){this.value=e}};d([g({type:w.GeneralizedTime})],kc.prototype,"value",void 0);kc=d([P({type:T.Choice})],kc);let pd=class extends Oe{};pd=d([P({type:T.Choice})],pd);let xc=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([g({type:w.PrintableString})],xc.prototype,"value",void 0);xc=d([P({type:T.Choice})],xc);let Is=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.PrintableString})],Is.prototype,"value",void 0);Is=d([P({type:T.Choice})],Is);let fd=class extends Is{};fd=d([P({type:T.Choice})],fd);let hd=class extends Oe{};hd=d([P({type:T.Choice})],hd);let Sc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.ObjectIdentifier})],Sc.prototype,"value",void 0);Sc=d([P({type:T.Choice})],Sc);let gd=class extends ze{};gd=d([P({type:T.Choice})],gd);let Ac=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([g({type:w.Integer})],Ac.prototype,"value",void 0);Ac=d([P({type:T.Choice})],Ac);let md=class extends It{};md=d([P({type:T.Sequence})],md);let Cs=class extends Oe{};Cs=d([P({type:T.Choice})],Cs);let _d=yc=class extends Gt{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};_d=yc=d([P({type:T.Sequence})],_d);let yd=vc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};yd=vc=d([P({type:T.Set,itemType:or})],yd);let Ec=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.BmpString})],Ec.prototype,"value",void 0);Ec=d([P({type:T.Choice})],Ec);let Ic=class extends F{};Ic=d([P({type:T.Sequence})],Ic);let vd=wc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,wc.prototype)}};vd=wc=d([P({type:T.Sequence,itemType:Ic})],vd);var Cc;let Ns=Cc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Cc.prototype)}};Ns=Cc=d([P({type:T.Sequence,itemType:Bt})],Ns);class ur{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new ut,this.attributes=new Ns,Object.assign(this,e)}}d([g({type:w.Integer})],ur.prototype,"version",void 0);d([g({type:ke})],ur.prototype,"subject",void 0);d([g({type:ut})],ur.prototype,"subjectPKInfo",void 0);d([g({type:Ns,implicit:!0,context:0})],ur.prototype,"attributes",void 0);class Rr{constructor(e={}){this.certificationRequestInfo=new ur,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ur})],Rr.prototype,"certificationRequestInfo",void 0);d([g({type:F})],Rr.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],Rr.prototype,"signature",void 0);/*!
|
|
94
|
+
`)}function j0(t,e,n){var r=As(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,o=$0(s,e);return z0("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function O0(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var B0=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(zl),T0=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(zl),P0=function(){function t(){this.preResolution=new B0,this.postResolution=new T0}return t}(),Mh=new Map,R0=function(){function t(e){this.parent=e,this._registry=new N0,this.interceptors=new P0,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Ve.Transient}),this.ensureNotDisposed();var i;if(C0(n)?i=n:i={useClass:n},Ni(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+sn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&Ni(l.provider)?o=l.provider:o=null}if((r.lifecycle===Ve.Singleton||r.lifecycle==Ve.ContainerScoped||r.lifecycle==Ve.ResolutionScoped)&&($i(i)||dc(i)))throw new Error('Cannot use lifecycle "'+Ve[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),On(n)?this.register(e,{useToken:n}):this.register(e,{useClass:n})},t.prototype.registerInstance=function(e,n){return this.ensureNotDisposed(),this.register(e,{useValue:n})},t.prototype.registerSingleton=function(e,n){if(this.ensureNotDisposed(),On(e)){if(On(n))return this.register(e,{useToken:n},{lifecycle:Ve.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Ve.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!On(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Ve.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new td),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&On(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var i=this.resolveRegistration(r,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(I0(e)){var i=this.construct(e,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(e,n){var r,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=wi(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,r){var i,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=wi(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var u=l.value;u.options.frequency!="Once"&&o.push(u),u.callback(e,n,r)}}catch(p){i={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,o)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Ve.Singleton,i=e.options.lifecycle===Ve.ContainerScoped,s=r||i,o;return $i(e.provider)?o=e.provider.useValue:Ni(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):Uh(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):dc(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new td),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&On(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return r.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,o,"All"),o},t.prototype.isRegistered=function(e,n){return n===void 0&&(n=!1),this.ensureNotDisposed(),this._registry.has(e)||n&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var e,n;this.ensureNotDisposed();try{for(var r=wi(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=As(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(l){return!$i(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var r=new t(this);try{for(var i=wi(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=As(s.value,2),c=o[0],l=o[1];l.some(function(u){var p=u.options;return p.lifecycle===Ve.ContainerScoped})&&r._registry.setAll(c,l.map(function(u){return u.options.lifecycle===Ve.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.prototype.beforeResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:r})},t.prototype.afterResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:r})},t.prototype.dispose=function(){return k0(this,void 0,void 0,function(){var e;return x0(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(r){var i=r.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return n.sent(),[2]}})})},t.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},t.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},t.prototype.construct=function(e,n){var r=this;if(e instanceof Vh)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=Mh.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,sn([void 0],o)))}();return O0(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var o,c,l;try{return E0(i)?ed(i)?i.multiple?(o=r.resolve(i.transform)).transform.apply(o,sn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,sn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):ed(i)?(l=r.resolve(i.transform,e)).transform.apply(l,sn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(u){throw new Error(j0(n,s,u))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Be=new R0;function Eo(){return function(t){Mh.set(t,A0(t))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var pc;class Io{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([g({type:w.ObjectIdentifier})],Io.prototype,"attrId",void 0);d([g({type:w.Any,repeated:"set"})],Io.prototype,"attrValues",void 0);let nd=pc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,pc.prototype)}};nd=pc=d([P({type:T.Sequence,itemType:Io})],nd);var fc;let rd=fc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};rd=fc=d([P({type:T.Sequence,itemType:ar})],rd);class qh{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],qh.prototype,"certId",void 0);d([g({type:w.Any,context:0})],qh.prototype,"certValue",void 0);class Dh{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Dh.prototype,"crlId",void 0);d([g({type:w.Any,context:0})],Dh.prototype,"crltValue",void 0);class Fh extends ae{}let Co=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new Fh,Object.assign(this,e)}};d([g({type:F})],Co.prototype,"encryptionAlgorithm",void 0);d([g({type:Fh})],Co.prototype,"encryptedData",void 0);var hc,gc;(function(t){t[t.v1=0]="v1"})(gc||(gc={}));class Hh extends ae{}let mc=hc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};mc=hc=d([P({type:T.Sequence,itemType:Bt})],mc);class li{constructor(e={}){this.version=gc.v1,this.privateKeyAlgorithm=new F,this.privateKey=new Hh,Object.assign(this,e)}}d([g({type:w.Integer})],li.prototype,"version",void 0);d([g({type:F})],li.prototype,"privateKeyAlgorithm",void 0);d([g({type:Hh})],li.prototype,"privateKey",void 0);d([g({type:mc,implicit:!0,context:0,optional:!0})],li.prototype,"attributes",void 0);let id=class extends li{};id=d([P({type:T.Sequence})],id);let sd=class extends Co{};sd=d([P({type:T.Sequence})],sd);class Kh{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Kh.prototype,"secretTypeId",void 0);d([g({type:w.Any,context:0})],Kh.prototype,"secretValue",void 0);class ui{constructor(e={}){this.mac=new So,this.macSalt=new ae,this.iterations=1,Object.assign(this,e)}}d([g({type:So})],ui.prototype,"mac",void 0);d([g({type:ae})],ui.prototype,"macSalt",void 0);d([g({type:w.Integer,defaultValue:1})],ui.prototype,"iterations",void 0);class No{constructor(e={}){this.version=3,this.authSafe=new ar,this.macData=new ui,Object.assign(this,e)}}d([g({type:w.Integer})],No.prototype,"version",void 0);d([g({type:ar})],No.prototype,"authSafe",void 0);d([g({type:ui,optional:!0})],No.prototype,"macData",void 0);var _c;class $o{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],$o.prototype,"bagId",void 0);d([g({type:w.Any,context:0})],$o.prototype,"bagValue",void 0);d([g({type:Io,repeated:"set",optional:!0})],$o.prototype,"bagAttributes",void 0);let od=_c=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};od=_c=d([P({type:T.Sequence,itemType:$o})],od);var yc,vc,wc;const Wh="1.2.840.113549.1.9",Gh=`${Wh}.7`,jl=`${Wh}.14`;let Es=class extends Oe{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([g({type:w.IA5String})],Es.prototype,"ia5String",void 0);Es=d([P({type:T.Choice})],Es);let ad=class extends ar{};ad=d([P({type:T.Sequence})],ad);let cd=class extends No{};cd=d([P({type:T.Sequence})],cd);let ld=class extends Co{};ld=d([P({type:T.Sequence})],ld);let bc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.IA5String})],bc.prototype,"value",void 0);bc=d([P({type:T.Choice})],bc);let ud=class extends Es{};ud=d([P({type:T.Choice})],ud);let dd=class extends Oe{};dd=d([P({type:T.Choice})],dd);let kc=class{constructor(e=new Date){this.value=e}};d([g({type:w.GeneralizedTime})],kc.prototype,"value",void 0);kc=d([P({type:T.Choice})],kc);let pd=class extends Oe{};pd=d([P({type:T.Choice})],pd);let xc=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([g({type:w.PrintableString})],xc.prototype,"value",void 0);xc=d([P({type:T.Choice})],xc);let Is=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.PrintableString})],Is.prototype,"value",void 0);Is=d([P({type:T.Choice})],Is);let fd=class extends Is{};fd=d([P({type:T.Choice})],fd);let hd=class extends Oe{};hd=d([P({type:T.Choice})],hd);let Sc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.ObjectIdentifier})],Sc.prototype,"value",void 0);Sc=d([P({type:T.Choice})],Sc);let gd=class extends ze{};gd=d([P({type:T.Choice})],gd);let Ac=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([g({type:w.Integer})],Ac.prototype,"value",void 0);Ac=d([P({type:T.Choice})],Ac);let md=class extends It{};md=d([P({type:T.Sequence})],md);let Cs=class extends Oe{};Cs=d([P({type:T.Choice})],Cs);let _d=yc=class extends Gt{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};_d=yc=d([P({type:T.Sequence})],_d);let yd=vc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};yd=vc=d([P({type:T.Set,itemType:or})],yd);let Ec=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.BmpString})],Ec.prototype,"value",void 0);Ec=d([P({type:T.Choice})],Ec);let Ic=class extends F{};Ic=d([P({type:T.Sequence})],Ic);let vd=wc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,wc.prototype)}};vd=wc=d([P({type:T.Sequence,itemType:Ic})],vd);var Cc;let Ns=Cc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Cc.prototype)}};Ns=Cc=d([P({type:T.Sequence,itemType:Bt})],Ns);class ur{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new ut,this.attributes=new Ns,Object.assign(this,e)}}d([g({type:w.Integer})],ur.prototype,"version",void 0);d([g({type:ke})],ur.prototype,"subject",void 0);d([g({type:ut})],ur.prototype,"subjectPKInfo",void 0);d([g({type:Ns,implicit:!0,context:0})],ur.prototype,"attributes",void 0);class Rr{constructor(e={}){this.certificationRequestInfo=new ur,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ur})],Rr.prototype,"certificationRequestInfo",void 0);d([g({type:F})],Rr.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],Rr.prototype,"signature",void 0);/*!
|
|
95
95
|
* MIT License
|
|
96
96
|
*
|
|
97
97
|
* Copyright (c) Peculiar Ventures. All rights reserved.
|
|
@@ -114,21 +114,21 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
114
114
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
115
115
|
* SOFTWARE.
|
|
116
116
|
*
|
|
117
|
-
*/const di="crypto.algorithm";class
|
|
118
|
-
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const r=[];let i=this.pad(n++),s="";const o=e[ue.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[ue.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const l=e[c],u=c?`${c}: `:"";if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")r.push(`${i}${u}${l}`);else if(l instanceof Date)r.push(`${i}${u}${l.toUTCString()}`);else if(Array.isArray(l))for(const p of l)p[ue.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof ue)l[ue.NAME]=c,r.push(...this.serializeObj(l,n));else if(M.isBufferSource(l))c?(r.push(`${i}${u}`),r.push(...this.serializeBufferSource(l,n+1))):r.push(...this.serializeBufferSource(l,n));else if("toTextObject"in l){const p=l.toTextObject();p[ue.NAME]=c,r.push(...this.serializeObj(p,n))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return r}static serializeBufferSource(e,n=0){const r=this.pad(n),i=M.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let l=0;l<16&&o<i.length;l++){l===8&&c.push("");const u=i[o++].toString(16).padStart(2,"0");c.push(u)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}En.oidSerializer=Qt;En.algorithmSerializer=
|
|
119
|
-
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return V.serialize(this.asn)}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const
|
|
117
|
+
*/const di="crypto.algorithm";class L0{getAlgorithms(){return Be.resolveAll(di)}toAsnAlgorithm(e){({...e});for(const n of this.getAlgorithms()){const r=n.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const n=new F({algorithm:e.name});if("parameters"in e){const r=e;n.parameters=r.parameters}return n}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const r of this.getAlgorithms()){const i=r.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const An="crypto.algorithmProvider";Be.registerSingleton(An,L0);var zi;const Ke="1.3.36.3.3.2.8.1.1",wd=`${Ke}.1`,bd=`${Ke}.2`,kd=`${Ke}.3`,xd=`${Ke}.4`,Sd=`${Ke}.5`,Ad=`${Ke}.6`,Ed=`${Ke}.7`,Id=`${Ke}.8`,Cd=`${Ke}.9`,Nd=`${Ke}.10`,$d=`${Ke}.11`,zd=`${Ke}.12`,jd=`${Ke}.13`,Od=`${Ke}.14`,Bd="brainpoolP160r1",Td="brainpoolP160t1",Pd="brainpoolP192r1",Rd="brainpoolP192t1",Ld="brainpoolP224r1",Ud="brainpoolP224t1",Vd="brainpoolP256r1",Md="brainpoolP256t1",qd="brainpoolP320r1",Dd="brainpoolP320t1",Fd="brainpoolP384r1",Hd="brainpoolP384t1",Kd="brainpoolP512r1",Wd="brainpoolP512t1",ye="ECDSA";let Lr=zi=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ye.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return c0;case"sha-256":return l0;case"sha-384":return u0;case"sha-512":return d0}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=Yu;break;case"K-256":n=zi.SECP256K1;break;case"P-384":n=Xu;break;case"P-521":n=Qu;break;case Bd:n=wd;break;case Td:n=bd;break;case Pd:n=kd;break;case Rd:n=xd;break;case Ld:n=Sd;break;case Ud:n=Ad;break;case Vd:n=Ed;break;case Md:n=Id;break;case qd:n=Cd;break;case Dd:n=Nd;break;case Fd:n=$d;break;case Hd:n=zd;break;case Kd:n=jd;break;case Wd:n=Od;break}if(n)return new F({algorithm:Tr,parameters:V.serialize(new Zt({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Al:return{name:ye,hash:{name:"SHA-1"}};case El:return{name:ye,hash:{name:"SHA-256"}};case Il:return{name:ye,hash:{name:"SHA-384"}};case Cl:return{name:ye,hash:{name:"SHA-512"}};case Tr:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(V.parse(e.parameters,Zt).namedCurve){case Yu:return{name:ye,namedCurve:"P-256"};case zi.SECP256K1:return{name:ye,namedCurve:"K-256"};case Xu:return{name:ye,namedCurve:"P-384"};case Qu:return{name:ye,namedCurve:"P-521"};case wd:return{name:ye,namedCurve:Bd};case bd:return{name:ye,namedCurve:Td};case kd:return{name:ye,namedCurve:Pd};case xd:return{name:ye,namedCurve:Rd};case Sd:return{name:ye,namedCurve:Ld};case Ad:return{name:ye,namedCurve:Ud};case Ed:return{name:ye,namedCurve:Vd};case Id:return{name:ye,namedCurve:Md};case Cd:return{name:ye,namedCurve:qd};case Nd:return{name:ye,namedCurve:Dd};case $d:return{name:ye,namedCurve:Fd};case zd:return{name:ye,namedCurve:Hd};case jd:return{name:ye,namedCurve:Kd};case Od:return{name:ye,namedCurve:Wd}}}}return null}};Lr.SECP256K1="1.3.132.0.10";Lr=zi=d([Eo()],Lr);Be.registerSingleton(di,Lr);const Jh=Symbol("name"),Zh=Symbol("value");class ue{constructor(e,n={},r=""){this[Jh]=e,this[Zh]=r;for(const i in n)this[i]=n[i]}}ue.NAME=Jh;ue.VALUE=Zh;class U0{static toTextObject(e){const n=new ue("Algorithm Identifier",{},Qt.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Tr:{const r=new Lr().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class Qt{static toString(e){const n=this.items[e];return n||e}}Qt.items={[bs]:"sha1",[Ph]:"sha224",[ks]:"sha256",[xs]:"sha384",[Ss]:"sha512",[kn]:"rsaEncryption",[ys]:"sha1WithRSAEncryption",[_0]:"sha224WithRSAEncryption",[oc]:"sha256WithRSAEncryption",[vs]:"sha384WithRSAEncryption",[ws]:"sha512WithRSAEncryption",[Tr]:"ecPublicKey",[Al]:"ecdsaWithSHA1",[Oh]:"ecdsaWithSHA224",[El]:"ecdsaWithSHA256",[Il]:"ecdsaWithSHA384",[Cl]:"ecdsaWithSHA512",[t0]:"TLS WWW server authentication",[n0]:"TLS WWW client authentication",[r0]:"Code Signing",[i0]:"E-mail Protection",[s0]:"Time Stamping",[o0]:"OCSP Signing",[a0]:"Signed Data"};class En{static serialize(e){return this.serializeObj(e).join(`
|
|
118
|
+
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const r=[];let i=this.pad(n++),s="";const o=e[ue.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[ue.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const l=e[c],u=c?`${c}: `:"";if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")r.push(`${i}${u}${l}`);else if(l instanceof Date)r.push(`${i}${u}${l.toUTCString()}`);else if(Array.isArray(l))for(const p of l)p[ue.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof ue)l[ue.NAME]=c,r.push(...this.serializeObj(l,n));else if(M.isBufferSource(l))c?(r.push(`${i}${u}`),r.push(...this.serializeBufferSource(l,n+1))):r.push(...this.serializeBufferSource(l,n));else if("toTextObject"in l){const p=l.toTextObject();p[ue.NAME]=c,r.push(...this.serializeObj(p,n))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return r}static serializeBufferSource(e,n=0){const r=this.pad(n),i=M.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let l=0;l<16&&o<i.length;l++){l===8&&c.push("");const u=i[o++].toString(16).padStart(2,"0");c.push(u)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}En.oidSerializer=Qt;En.algorithmSerializer=U0;class en{constructor(...e){if(e.length===1){const n=e[0];this.rawData=V.serialize(n),this.onInit(n)}else{const n=V.parse(e[0],e[1]);this.rawData=M.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof en?gf(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return V.toString(this.rawData);case"text":return En.serialize(this.toTextObject());case"hex":return G.ToHex(this.rawData);case"base64":return G.ToBase64(this.rawData);case"base64url":return G.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new ue(this.getTextName(),{},e)}}en.NAME="ASN";class it extends en{constructor(...e){let n;M.isBufferSource(e[0])?n=M.toArrayBuffer(e[0]):n=V.serialize(new nt({extnID:e[0],critical:e[1],extnValue:new ae(M.toArrayBuffer(e[2]))})),super(n,nt)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[ue.NAME]===it.NAME&&(e[ue.NAME]=Qt.toString(this.type)),e}}var Yh;class qt{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Yh]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(qt.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(qt.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,n){return this.items.forEach(e,n)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=qt.DEFAULT){const n=this.items.get(e.toLowerCase());if(!n)throw new Error(`Cannot get Crypto by name '${e}'`);return n}set(e,n){if(typeof e=="string"){if(!n)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),n)}else this.items.set(qt.DEFAULT,e);return this}}Yh=Symbol.toStringTag;qt.DEFAULT="default";const $e=new qt,V0=/^[0-2](?:\.[1-9][0-9]*)+$/;function M0(t){return new RegExp(V0).test(t)}class Xh{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return M0(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const Fe=new Xh;Fe.register("CN","2.5.4.3");Fe.register("L","2.5.4.7");Fe.register("ST","2.5.4.8");Fe.register("O","2.5.4.10");Fe.register("OU","2.5.4.11");Fe.register("C","2.5.4.6");Fe.register("DC","0.9.2342.19200300.100.1.25");Fe.register("E","1.2.840.113549.1.9.1");Fe.register("G","2.5.4.42");Fe.register("I","2.5.4.43");Fe.register("SN","2.5.4.4");Fe.register("T","2.5.4.12");function q0(t,e){return`\\${G.ToHex(G.FromUtf8String(e)).toUpperCase()}`}function D0(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,q0)}class et{static isASCII(e){for(let n=0;n<e.length;n++)if(e.charCodeAt(n)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,n={}){this.extraNames=new Xh,this.asn=new ke;for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const i=n[r];this.extraNames.register(r,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof ke?this.asn=e:M.isBufferSource(e)?this.asn=V.parse(e,ke):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||Fe.findId(e),r=[];for(const i of this.asn)for(const s of i)s.type===n&&r.push(s.value.toString());return r}getName(e){return this.extraNames.get(e)||Fe.get(e)}toString(){return this.asn.map(e=>e.map(n=>{const r=this.getName(n.type)||n.type,i=n.value.anyValue?`#${G.ToHex(n.value.anyValue)}`:D0(n.value.toString());return`${r}=${i}`}).join("+")).join(", ")}toJSON(){var e;const n=[];for(const r of this.asn){const i={};for(const s of r){const o=this.getName(s.type)||s.type;(e=i[o])!==null&&e!==void 0||(i[o]=[]),i[o].push(s.value.anyValue?`#${G.ToHex(s.value.anyValue)}`:s.value.toString())}n.push(i)}return n}fromString(e){const n=new ke,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=r.exec(`${e},`);){let[,o,c]=i;const l=c[c.length-1];(l===","||l==="+")&&(c=c.slice(0,c.length-1),i[3]=l);const u=i[3];o=this.getTypeOid(o);const p=this.createAttribute(o,c);s==="+"?n[n.length-1].push(p):n.push(new Dn([p])),s=u}return n}fromJSON(e){const n=new ke;for(const r of e){const i=new Dn;for(const s in r){const o=this.getTypeOid(s),c=r[s];for(const l of c){const u=this.createAttribute(o,l);i.push(u)}}n.push(i)}return n}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,n){const r=new so({type:e});if(typeof n=="object")for(const i in n)switch(i){case"ia5String":r.value.ia5String=n[i];break;case"utf8String":r.value.utf8String=n[i];break;case"universalString":r.value.universalString=n[i];break;case"bmpString":r.value.bmpString=n[i];break;case"printableString":r.value.printableString=n[i];break}else if(n[0]==="#")r.value.anyValue=G.FromHex(n.slice(1));else{const i=this.processStringValue(n);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=i:et.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){const n=/"(.*?[^\\])?"/.exec(e);return n&&(e=n[1]),e.replace(/\\0a/ig,`
|
|
119
|
+
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return V.serialize(this.asn)}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Qh="Cannot initialize GeneralName from ASN.1 data.",Gd=`${Qh} Unsupported string format in use.`,F0=`${Qh} Value doesn't match to GUID regular expression.`,Jd=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Zd="1.3.6.1.4.1.311.25.1",Yd="1.3.6.1.4.1.311.20.2.3",Ko="dns",Wo="dn",Go="email",Jo="ip",Zo="url",Yo="guid",Xo="upn",bi="id";class Dt extends en{constructor(...e){let n;if(e.length===2)switch(e[0]){case Wo:{const r=new et(e[1]).toArrayBuffer(),i=V.parse(r,ke);n=new re({directoryName:i});break}case Ko:n=new re({dNSName:e[1]});break;case Go:n=new re({rfc822Name:e[1]});break;case Yo:{const r=new RegExp(Jd,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map((s,o)=>o<3?G.ToHex(new Uint8Array(G.FromHex(s)).reverse()):s).join("");n=new re({otherName:new zr({typeId:Zd,value:V.serialize(new ae(G.FromHex(i)))})});break}case Jo:n=new re({iPAddress:e[1]});break;case bi:n=new re({registeredID:e[1]});break;case Xo:{n=new re({otherName:new zr({typeId:Yd,value:V.serialize(gh.toASN(e[1]))})});break}case Zo:n=new re({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else M.isBufferSource(e[0])?n=V.parse(e[0],re):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=Ko,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Go,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Jo,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Zo,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=bi,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Wo,this.value=new et(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Zd){this.type=Yo;const n=V.parse(e.otherName.value,ae),r=new RegExp(Jd,"i").exec(G.ToHex(n));if(!r)throw new Error(F0);this.value=r.slice(1).map((i,s)=>s<3?G.ToHex(new Uint8Array(G.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===Yd)this.type=Xo,this.value=V.parse(e.otherName.value,Oe).toString();else throw new Error(Gd);else throw new Error(Gd)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Wo:case Ko:case Yo:case Jo:case bi:case Xo:case Zo:e=this.type.toUpperCase();break;case Go:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===bi&&(n=Qt.toString(n)),new ue(e,void 0,n)}}class Ur extends en{constructor(e){let n;if(e instanceof Re)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof re)r.push(i);else{const s=V.parse(new Dt(i.type,i.value).rawData,re);r.push(s)}n=new Re(r)}else if(M.isBufferSource(e))n=V.parse(e,Re);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(n)}onInit(e){const n=[];for(const r of e){let i=null;try{i=new Dt(r)}catch{continue}n.push(i)}this.items=n}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const n of this.items){const r=n.toTextObject();let i=e[r[ue.NAME]];Array.isArray(i)||(i=[],e[r[ue.NAME]]=i),i.push(r)}return e}}Ur.NAME="GeneralNames";const Er="-{5}",Vr="\\n",H0=`[^${Vr}]+`,K0=`${Er}BEGIN (${H0}(?=${Er}))${Er}`,W0=`${Er}END \\1${Er}`,Yn="\\n",G0=`[^:${Vr}]+`,J0=`(?:[^${Vr}]+${Yn}(?: +[^${Vr}]+${Yn})*)`,Z0="[a-zA-Z0-9=+/]+",Y0=`(?:${Z0}${Yn})+`,Xd=`${K0}${Yn}(?:((?:${G0}: ${J0})+))?${Yn}?(${Y0})${W0}`;class Je{static isPem(e){return typeof e=="string"&&new RegExp(Xd,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(Xd,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${Vr}]+`,"g"),""),o={type:i[1],headers:[],rawData:G.FromBase64(s)},c=i[2];if(c){const l=c.split(new RegExp(Yn,"g"));let u=null;for(const p of l){const[h,m]=p.split(/:(.*)/);if(m===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=h.trim()}else u&&o.headers.push(u),u={key:h,value:m.trim()}}u&&o.headers.push(u)}r.push(o)}return r}static decode(e){return this.decodeWithHeaders(e).map(r=>r.rawData)}static decodeFirst(e){const n=this.decode(e);if(!n.length)throw new RangeError("PEM string doesn't contain any objects");return n[0]}static encode(e,n){if(Array.isArray(e)){const r=new Array;return n?e.forEach(i=>{if(!M.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:n,rawData:M.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(i))}),r.join(`
|
|
120
120
|
`)}else{if(!n)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:n,rawData:M.toArrayBuffer(e)})}}static encodeStruct(e){var n;const r=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),!((n=e.headers)===null||n===void 0)&&n.length){for(const u of e.headers)i.push(`${u.key}: ${u.value}`);i.push("")}const s=G.ToBase64(e.rawData);let o,c=0;const l=Array();for(;c<s.length&&(s.length-c<64?o=s.substring(c):(o=s.substring(c,c+64),c+=64),o.length!==0);)if(l.push(o),o.length<64)break;return i.push(...l),i.push(`-----END ${r}-----`),i.join(`
|
|
121
|
-
`)}}Je.CertificateTag="CERTIFICATE";Je.CrlTag="CRL";Je.CertificateRequestTag="CERTIFICATE REQUEST";Je.PublicKeyTag="PUBLIC KEY";Je.PrivateKeyTag="PRIVATE KEY";class Rt extends en{static isAsnEncoded(e){return M.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Je.isPem(e))return Je.decode(e)[0];if(G.isHex(e))return G.FromHex(e);if(G.isBase64(e))return G.FromBase64(e);if(G.isBase64Url(e))return G.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=G.ToBinary(e);return Je.isPem(n)?Je.decode(n)[0]:G.isHex(n)?G.FromHex(n):G.isBase64(n)?G.FromBase64(n):G.isBase64Url(n)?G.FromBase64Url(n):M.toArrayBuffer(e)}}constructor(...e){Rt.isAsnEncoded(e[0])?super(Rt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Je.encode(this.rawData,this.tag);default:return super.toString(e)}}}class dt extends Rt{static async create(e,n=$e.get()){if(e instanceof dt)return e;if(qt.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new dt(r)}else{if(e.publicKey)return e.publicKey;if(M.isBufferSource(e))return new dt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Rt.isAsnEncoded(e)?super(e,ut):super(e),this.tag=Je.PublicKeyTag}async export(...e){let n,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,n=e[2]||$e.get()):n=e[0]||$e.get();let s=this.rawData;const o=V.parse(this.rawData,ut);return o.algorithm.algorithm===Ar&&(s=Y0(o,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Be.resolve(An),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case kn:{const i=V.parse(e.subjectPublicKey,Nl),s=M.toUint8Array(i.modulus);r.publicExponent=M.toUint8Array(i.publicExponent),r.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let n,r="SHA-1";e.length===1?typeof e[0]=="string"?(r=e[0],n=$e.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=$e.get();const i=V.parse(this.rawData,ut);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,ut);switch(e.Algorithm=En.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Tr:e["EC Point"]=n.subjectPublicKey;break;case kn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function Y0(t,e){return t.algorithm=new F({algorithm:kn,parameters:null}),e=V.serialize(t),e}class Mr extends it{static async create(e,n=!1,r=$e.get()){if("name"in e&&"serialNumber"in e)return new Mr(e,n);const s=await(await dt.create(e,r)).getKeyIdentifier(r);return new Mr(G.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new cn({keyIdentifier:new ul(G.FromHex(e[0]))});super(Sa,e[1],V.serialize(n))}else{const n=e[0],r=n.name instanceof Ur?V.parse(n.name.rawData,Re):n.name,i=new cn({authorityCertIssuer:r,authorityCertSerialNumber:G.FromHex(n.serialNumber)});super(Sa,e[1],V.serialize(i))}}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,cn);n.keyIdentifier&&(this.keyId=G.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?G.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,cn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Ur(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Mr.NAME="Authority Key Identifier";class Ol extends it{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,es);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new es({cA:e[0],pathLenConstraint:e[1]});super(_h,e[2],V.serialize(n)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Ol.NAME="Basic Constraints";var Qd;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(Qd||(Qd={}));class Bl extends it{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,is);this.usages=n.map(r=>r)}else{const n=new is(e[0]);super(wh,e[1],V.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>Qt.toString(n)).join(", "),e}}Bl.NAME="Extended Key Usages";var $s;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})($s||($s={}));class Tl extends it{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,Ho);this.usages=n.toNumber()}else{const n=new Ho(e[0]);super(bh,e[1],V.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,Ho);return e[""]=n.toJSON().join(", "),e}}Tl.NAME="Key Usages";class pi extends it{static async create(e,n=!1,r=$e.get()){const s=await(await dt.create(e,r)).getKeyIdentifier(r);return new pi(G.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,Ht);this.keyId=G.ToHex(n)}else{const n=typeof e[0]=="string"?G.FromHex(e[0]):e[0],r=new Ht(n);super(Ah,e[1],V.serialize(r)),this.keyId=G.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,Ht);return e[""]=n,e}}pi.NAME="Subject Key Identifier";class Qh extends it{constructor(...e){M.isBufferSource(e[0])?super(e[0]):super(Sh,e[1],new Ur(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,Ua);this.names=new Ur(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}Qh.NAME="Subject Alternative Name";class st{static register(e,n){this.items.set(e,n)}static create(e){const n=new it(e),r=this.items.get(n.type);return r?new r(e):n}}st.items=new Map;class eg extends it{constructor(...e){var n;if(M.isBufferSource(e[0])){super(e[0]);const r=V.parse(this.value,ns);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new ns(r.map(o=>new ao({policyIdentifier:o})));super(yh,i,V.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new ue("",{},Qt.toString(n))),e}}eg.NAME="Certificate Policies";st.register(yh,eg);class tg extends it{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new ir({distributionPoint:new yn({fullName:[new re({uniformResourceIdentifier:o})]})})),s=new Un(i);super(Na,e[1],V.serialize(s))}else{const r=new Un(e[0]);super(Na,e[1],V.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,Un);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var r;const i={};return n.distributionPoint&&(i[""]=(r=n.distributionPoint.fullName)===null||r===void 0?void 0:r.map(s=>new Dt(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}tg.NAME="CRL Distribution Points";class ng extends it{constructor(...e){var n,r,i,s;if(M.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Pn){const o=new Pn(e[0]);super(xa,e[1],V.serialize(o))}else{const o=e[0],c=new Pn;xi(c,o,Pu,"ocsp"),xi(c,o,Ru,"caIssuers"),xi(c,o,Lu,"timeStamping"),xi(c,o,Uu,"caRepository"),super(xa,e[1],V.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(r=this.caIssuers)!==null&&r!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],V.parse(e.extnValue,Pn).forEach(r=>{switch(r.accessMethod){case Pu:this.ocsp.push(new Dt(r.accessLocation));break;case Ru:this.caIssuers.push(new Dt(r.accessLocation));break;case Lu:this.timeStamping.push(new Dt(r.accessLocation));break;case Uu:this.caRepository.push(new Dt(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&ki(e,"OCSP",this.ocsp),this.caIssuers.length&&ki(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&ki(e,"Time Stamping",this.timeStamping),this.caRepository.length&&ki(e,"CA Repository",this.caRepository),e}}ng.NAME="Authority Info Access";function ki(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new ue("");n.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[ue.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(o)}),t[e]=r}}function xi(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Dt("url",o)),t.push(new Qr({accessMethod:n,accessLocation:V.parse(o.rawData,re)}))})}class dr extends en{constructor(...e){let n;if(M.isBufferSource(e[0]))n=M.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>M.toArrayBuffer(s)):[];n=V.serialize(new Bt({type:r,values:i}))}super(n,Bt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new ue("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[ue.NAME]===dr.NAME&&(e[ue.NAME]=Qt.toString(this.type)),e}}dr.NAME="Attribute";class rg extends dr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=new Cs({printableString:e[0]});super(Wh,[V.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=V.parse(this.values[0],Cs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[ue.VALUE]=this.password,e}}rg.NAME="Challenge Password";class Pl extends dr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new Gt;for(const s of r)i.push(V.parse(s.rawData,nt));super(jl,[V.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=V.parse(this.values[0],Gt);this.items=n.map(r=>st.create(V.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[ue.NAME]]=r;return e}}Pl.NAME="Extensions";class zo{static register(e,n){this.items.set(e,n)}static create(e){const n=new dr(e),r=this.items.get(n.type);return r?new r(e):n}}zo.items=new Map;const fi="crypto.signatureFormatter";class X0{toAsnSignature(e,n){return M.toArrayBuffer(n)}toWebSignature(e,n){return M.toArrayBuffer(n)}}var ji;let Nc=ji=class{static createPssParams(e,n){const r=ji.getHashAlgorithm(e);return r?new Sn({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:ko,parameters:V.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Be.resolve(An);return typeof e=="string"?n.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?n.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let n;if(typeof e.hash=="string")n=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")n=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(n.toLowerCase()){case"sha-1":return new F({algorithm:ys,parameters:null});case"sha-256":return new F({algorithm:oc,parameters:null});case"sha-384":return new F({algorithm:vs,parameters:null});case"sha-512":return new F({algorithm:ws,parameters:null})}}else return new F({algorithm:kn,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const n=ji.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Ar,parameters:V.serialize(n)})}else return new F({algorithm:Ar,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case kn:return{name:"RSASSA-PKCS1-v1_5"};case ys:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case oc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case vs:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case ws:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Ar:if(e.parameters){const n=V.parse(e.parameters,Sn);return{name:"RSA-PSS",hash:Be.resolve(An).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Nc=ji=d([Eo()],Nc);Be.registerSingleton(di,Nc);let $c=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:bs});case"sha-256":return new F({algorithm:ks});case"sha-384":return new F({algorithm:xs});case"sha-512":return new F({algorithm:Ss})}return null}toWebAlgorithm(e){switch(e.algorithm){case bs:return{name:"SHA-1"};case ks:return{name:"SHA-256"};case xs:return{name:"SHA-384"};case Ss:return{name:"SHA-512"}}return null}};$c=d([Eo()],$c);Be.registerSingleton(di,$c);class tt{addPadding(e,n){const r=M.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=M.toUint8Array(e);for(let i=0;i<r.length;i++)if(r[i]){r=r.slice(i);break}if(n&&r[0]>127){const i=new Uint8Array(r.length+1);return i.set(r,1),i.buffer}return r.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const r=e.namedCurve,i=tt.namedCurveSize.get(r)||tt.defaultNamedCurveSize,s=new _s,o=M.toUint8Array(n);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),V.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=V.parse(n,_s),i=e.namedCurve,s=tt.namedCurveSize.get(i)||tt.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return d_(o,c)}return null}}tt.namedCurveSize=new Map;tt.defaultNamedCurveSize=32;const Qo="1.3.101.110",ep="1.3.101.111",ea="1.3.101.112",tp="1.3.101.113";let zc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=ea;break;case"x25519":n=Qo;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=ea;break;case"ed448":n=tp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=Qo;break;case"x448":n=ep;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case ea:return{name:"Ed25519"};case tp:return{name:"EdDSA",namedCurve:"Ed448"};case Qo:return{name:"X25519"};case ep:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};zc=d([Eo()],zc);Be.registerSingleton(di,zc);class Q0 extends Rt{constructor(e){Rt.isAsnEncoded(e)?super(e,Rr):super(e),this.tag=Je.CertificateRequestTag}onInit(e){this.tbs=V.serialize(e.certificationRequestInfo),this.publicKey=new dt(e.certificationRequestInfo.subjectPKInfo);const n=Be.resolve(An);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>zo.create(V.serialize(i)));const r=this.getAttribute(jl);this.extensions=[],r instanceof Pl&&(this.extensions=r.items),this.subjectName=new et(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const n of this.attributes)if(n.type===e)return n;return null}getAttributes(e){return this.attributes.filter(n=>n.type===e)}getExtension(e){for(const n of this.extensions)if(n.type===e)return n;return null}getExtensions(e){return this.extensions.filter(n=>n.type===e)}async verify(e=$e.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Be.resolveAll(fi).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(n,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,r,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,Rr),r=n.certificationRequestInfo,i=new ue("",{Version:`${vn[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new ue("");for(const o of this.attributes){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new ue("",{Algorithm:En.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}Q0.NAME="PKCS#10 Certificate Request";class Rl extends Rt{constructor(e){Rt.isAsnEncoded(e)?super(e,wn):super(e),this.tag=Je.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=V.serialize(n),this.serialNumber=G.ToHex(n.serialNumber),this.subjectName=new et(n.subject),this.subject=new et(n.subject).toString(),this.issuerName=new et(n.issuer),this.issuer=this.issuerName.toString();const r=Be.resolve(An);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(o=>st.create(V.serialize(o)))),this.publicKey=new dt(n.subjectPublicKeyInfo)}getExtension(e){for(const n of this.extensions)if(typeof e=="string"){if(n.type===e)return n}else if(n instanceof e)return n;return null}getExtensions(e){return this.extensions.filter(n=>typeof e=="string"?n.type===e:n instanceof e)}async verify(e={},n=$e.get()){let r,i;const s=e.publicKey;try{if(!s)r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],n);else if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],n);else if(s instanceof dt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(M.isBufferSource(s)){const u=new dt(s);r={...u.algorithm,...this.signatureAlgorithm},i=await u.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=Be.resolveAll(fi).reverse();let c=null;for(const u of o)if(c=u.toWebSignature(r,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const l=await n.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return l;{const p=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let n,r="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(r=e[0]||r,n=e[1])),n??(n=$e.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=$e.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,wn),r=n.tbsCertificate,i=new ue("",{Version:`${vn[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":En.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new ue("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const s=new ue("");for(const o of this.extensions){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new ue("",{Algorithm:En.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}Rl.NAME="Certificate";class ey{static async createSelfSigned(e,n=$e.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},n)}static async create(e,n=$e.get()){var r;let i;e.publicKey instanceof dt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:M.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?M.toUint8Array(G.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const o=e.notBefore||new Date,c=e.notAfter||new Date(o.getTime()+31536e6),l=new wn({tbsCertificate:new Ye({version:vn.v3,serialNumber:s,validity:new ei({notBefore:o,notAfter:c}),extensions:new Gt(((r=e.extensions)===null||r===void 0?void 0:r.map(v=>V.parse(v.rawData,nt)))||[]),subjectPublicKeyInfo:V.parse(i,ut)})});if(e.subject){const v=e.subject instanceof et?e.subject:new et(e.subject);l.tbsCertificate.subject=V.parse(v.toArrayBuffer(),ke)}if(e.issuer){const v=e.issuer instanceof et?e.issuer:new et(e.issuer);l.tbsCertificate.issuer=V.parse(v.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=Be.resolve(An);l.tbsCertificate.signature=l.signatureAlgorithm=h.toAsnAlgorithm(p);const m=V.serialize(l.tbsCertificate),y="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,f=Be.resolveAll(fi).reverse();let _=null;for(const v of f)if(_=v.toAsnSignature(p,y),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=_,new Rl(V.serialize(l))}}var np;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(np||(np={}));st.register(_h,Ol);st.register(wh,Bl);st.register(bh,Tl);st.register(Ah,pi);st.register(Sa,Mr);st.register(Sh,Qh);st.register(Na,tg);st.register(xa,ng);zo.register(Wh,rg);zo.register(jl,Pl);Be.registerSingleton(fi,X0);Be.registerSingleton(fi,tt);tt.namedCurveSize.set("P-256",32);tt.namedCurveSize.set("K-256",32);tt.namedCurveSize.set("P-384",48);tt.namedCurveSize.set("P-521",66);const rp="0123456789abcdef";function jc(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=rp[i];const s=e[r]&15;n+=rp[s]}return n}class ig{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let o=0;o<i;o++){let c=0;const l=[];for(let p=0;p<8;p++){const h=e[o*8+p];if(h==="="){if(o+1!==i)throw new Error(`Invalid character: ${h}`);c+=1;continue}if(h===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const m=this.decodeMap.get(h)??null;if(m===null)throw new Error(`Invalid character: ${h}`);l.push(m)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const u=(l[0]<<3)+(l[1]>>2);if(s.push(u),c<6){const p=((l[1]&3)<<6)+(l[2]<<1)+(l[3]>>4);s.push(p)}if(c<4){const p=((l[3]&255)<<4)+(l[4]>>1);s.push(p)}if(c<3){const p=((l[4]&1)<<7)+(l[5]<<2)+(l[6]>>3);s.push(p)}if(c<1){const p=((l[6]&7)<<5)+l[7];s.push(p)}}return Uint8Array.from(s)}}new ig("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new ig("0123456789ABCDEFGHIJKLMNOPQRSTUV");class sg{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let o=0;o<i;o++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[o*4+u];if(p==="="){if(o+1!==i)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const h=this.decodeMap.get(p)??null;if(h===null)throw new Error(`Invalid character: ${p}`);l+=h<<6*(3-u)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const ty=new sg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),pn=new sg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class ny{constructor(e){ee(this,"hash");this.hash=e}async verify(e,n,r){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,n,r)}async sign(e,n){const r=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",r,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function og(t){return await crypto.subtle.digest("SHA-256",t)}async function Oc(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),r=qe(),i=jc(new TextEncoder().encode(r)),s=await ey.createSelfSigned({serialNumber:i,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new Ol(!0,2,!0),new Bl(["1.3.6.1.5.5.7.3.1"],!0),new Tl($s.keyCertSign|$s.cRLSign,!0),await pi.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await iy(s),u=jc(await s.getThumbprint()),p=ry("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function ry(t,e){const n=ty.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
|
|
121
|
+
`)}}Je.CertificateTag="CERTIFICATE";Je.CrlTag="CRL";Je.CertificateRequestTag="CERTIFICATE REQUEST";Je.PublicKeyTag="PUBLIC KEY";Je.PrivateKeyTag="PRIVATE KEY";class Rt extends en{static isAsnEncoded(e){return M.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Je.isPem(e))return Je.decode(e)[0];if(G.isHex(e))return G.FromHex(e);if(G.isBase64(e))return G.FromBase64(e);if(G.isBase64Url(e))return G.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=G.ToBinary(e);return Je.isPem(n)?Je.decode(n)[0]:G.isHex(n)?G.FromHex(n):G.isBase64(n)?G.FromBase64(n):G.isBase64Url(n)?G.FromBase64Url(n):M.toArrayBuffer(e)}}constructor(...e){Rt.isAsnEncoded(e[0])?super(Rt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Je.encode(this.rawData,this.tag);default:return super.toString(e)}}}class dt extends Rt{static async create(e,n=$e.get()){if(e instanceof dt)return e;if(qt.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new dt(r)}else{if(e.publicKey)return e.publicKey;if(M.isBufferSource(e))return new dt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Rt.isAsnEncoded(e)?super(e,ut):super(e),this.tag=Je.PublicKeyTag}async export(...e){let n,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,n=e[2]||$e.get()):n=e[0]||$e.get();let s=this.rawData;const o=V.parse(this.rawData,ut);return o.algorithm.algorithm===Ar&&(s=X0(o,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Be.resolve(An),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case kn:{const i=V.parse(e.subjectPublicKey,Nl),s=M.toUint8Array(i.modulus);r.publicExponent=M.toUint8Array(i.publicExponent),r.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let n,r="SHA-1";e.length===1?typeof e[0]=="string"?(r=e[0],n=$e.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=$e.get();const i=V.parse(this.rawData,ut);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,ut);switch(e.Algorithm=En.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Tr:e["EC Point"]=n.subjectPublicKey;break;case kn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function X0(t,e){return t.algorithm=new F({algorithm:kn,parameters:null}),e=V.serialize(t),e}class Mr extends it{static async create(e,n=!1,r=$e.get()){if("name"in e&&"serialNumber"in e)return new Mr(e,n);const s=await(await dt.create(e,r)).getKeyIdentifier(r);return new Mr(G.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new cn({keyIdentifier:new ul(G.FromHex(e[0]))});super(Sa,e[1],V.serialize(n))}else{const n=e[0],r=n.name instanceof Ur?V.parse(n.name.rawData,Re):n.name,i=new cn({authorityCertIssuer:r,authorityCertSerialNumber:G.FromHex(n.serialNumber)});super(Sa,e[1],V.serialize(i))}}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,cn);n.keyIdentifier&&(this.keyId=G.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?G.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,cn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Ur(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Mr.NAME="Authority Key Identifier";class Ol extends it{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,es);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new es({cA:e[0],pathLenConstraint:e[1]});super(yh,e[2],V.serialize(n)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Ol.NAME="Basic Constraints";var Qd;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(Qd||(Qd={}));class Bl extends it{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,is);this.usages=n.map(r=>r)}else{const n=new is(e[0]);super(bh,e[1],V.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>Qt.toString(n)).join(", "),e}}Bl.NAME="Extended Key Usages";var $s;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})($s||($s={}));class Tl extends it{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,Ho);this.usages=n.toNumber()}else{const n=new Ho(e[0]);super(kh,e[1],V.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,Ho);return e[""]=n.toJSON().join(", "),e}}Tl.NAME="Key Usages";class pi extends it{static async create(e,n=!1,r=$e.get()){const s=await(await dt.create(e,r)).getKeyIdentifier(r);return new pi(G.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,Ht);this.keyId=G.ToHex(n)}else{const n=typeof e[0]=="string"?G.FromHex(e[0]):e[0],r=new Ht(n);super(Eh,e[1],V.serialize(r)),this.keyId=G.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,Ht);return e[""]=n,e}}pi.NAME="Subject Key Identifier";class eg extends it{constructor(...e){M.isBufferSource(e[0])?super(e[0]):super(Ah,e[1],new Ur(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,Ua);this.names=new Ur(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}eg.NAME="Subject Alternative Name";class st{static register(e,n){this.items.set(e,n)}static create(e){const n=new it(e),r=this.items.get(n.type);return r?new r(e):n}}st.items=new Map;class tg extends it{constructor(...e){var n;if(M.isBufferSource(e[0])){super(e[0]);const r=V.parse(this.value,ns);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new ns(r.map(o=>new ao({policyIdentifier:o})));super(vh,i,V.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new ue("",{},Qt.toString(n))),e}}tg.NAME="Certificate Policies";st.register(vh,tg);class ng extends it{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new ir({distributionPoint:new yn({fullName:[new re({uniformResourceIdentifier:o})]})})),s=new Un(i);super(Na,e[1],V.serialize(s))}else{const r=new Un(e[0]);super(Na,e[1],V.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,Un);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var r;const i={};return n.distributionPoint&&(i[""]=(r=n.distributionPoint.fullName)===null||r===void 0?void 0:r.map(s=>new Dt(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}ng.NAME="CRL Distribution Points";class rg extends it{constructor(...e){var n,r,i,s;if(M.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Pn){const o=new Pn(e[0]);super(xa,e[1],V.serialize(o))}else{const o=e[0],c=new Pn;xi(c,o,Pu,"ocsp"),xi(c,o,Ru,"caIssuers"),xi(c,o,Lu,"timeStamping"),xi(c,o,Uu,"caRepository"),super(xa,e[1],V.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(r=this.caIssuers)!==null&&r!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],V.parse(e.extnValue,Pn).forEach(r=>{switch(r.accessMethod){case Pu:this.ocsp.push(new Dt(r.accessLocation));break;case Ru:this.caIssuers.push(new Dt(r.accessLocation));break;case Lu:this.timeStamping.push(new Dt(r.accessLocation));break;case Uu:this.caRepository.push(new Dt(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&ki(e,"OCSP",this.ocsp),this.caIssuers.length&&ki(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&ki(e,"Time Stamping",this.timeStamping),this.caRepository.length&&ki(e,"CA Repository",this.caRepository),e}}rg.NAME="Authority Info Access";function ki(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new ue("");n.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[ue.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(o)}),t[e]=r}}function xi(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Dt("url",o)),t.push(new Qr({accessMethod:n,accessLocation:V.parse(o.rawData,re)}))})}class dr extends en{constructor(...e){let n;if(M.isBufferSource(e[0]))n=M.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>M.toArrayBuffer(s)):[];n=V.serialize(new Bt({type:r,values:i}))}super(n,Bt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new ue("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[ue.NAME]===dr.NAME&&(e[ue.NAME]=Qt.toString(this.type)),e}}dr.NAME="Attribute";class ig extends dr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=new Cs({printableString:e[0]});super(Gh,[V.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=V.parse(this.values[0],Cs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[ue.VALUE]=this.password,e}}ig.NAME="Challenge Password";class Pl extends dr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new Gt;for(const s of r)i.push(V.parse(s.rawData,nt));super(jl,[V.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=V.parse(this.values[0],Gt);this.items=n.map(r=>st.create(V.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[ue.NAME]]=r;return e}}Pl.NAME="Extensions";class zo{static register(e,n){this.items.set(e,n)}static create(e){const n=new dr(e),r=this.items.get(n.type);return r?new r(e):n}}zo.items=new Map;const fi="crypto.signatureFormatter";class Q0{toAsnSignature(e,n){return M.toArrayBuffer(n)}toWebSignature(e,n){return M.toArrayBuffer(n)}}var ji;let Nc=ji=class{static createPssParams(e,n){const r=ji.getHashAlgorithm(e);return r?new Sn({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:ko,parameters:V.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Be.resolve(An);return typeof e=="string"?n.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?n.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let n;if(typeof e.hash=="string")n=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")n=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(n.toLowerCase()){case"sha-1":return new F({algorithm:ys,parameters:null});case"sha-256":return new F({algorithm:oc,parameters:null});case"sha-384":return new F({algorithm:vs,parameters:null});case"sha-512":return new F({algorithm:ws,parameters:null})}}else return new F({algorithm:kn,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const n=ji.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Ar,parameters:V.serialize(n)})}else return new F({algorithm:Ar,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case kn:return{name:"RSASSA-PKCS1-v1_5"};case ys:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case oc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case vs:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case ws:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Ar:if(e.parameters){const n=V.parse(e.parameters,Sn);return{name:"RSA-PSS",hash:Be.resolve(An).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Nc=ji=d([Eo()],Nc);Be.registerSingleton(di,Nc);let $c=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:bs});case"sha-256":return new F({algorithm:ks});case"sha-384":return new F({algorithm:xs});case"sha-512":return new F({algorithm:Ss})}return null}toWebAlgorithm(e){switch(e.algorithm){case bs:return{name:"SHA-1"};case ks:return{name:"SHA-256"};case xs:return{name:"SHA-384"};case Ss:return{name:"SHA-512"}}return null}};$c=d([Eo()],$c);Be.registerSingleton(di,$c);class tt{addPadding(e,n){const r=M.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=M.toUint8Array(e);for(let i=0;i<r.length;i++)if(r[i]){r=r.slice(i);break}if(n&&r[0]>127){const i=new Uint8Array(r.length+1);return i.set(r,1),i.buffer}return r.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const r=e.namedCurve,i=tt.namedCurveSize.get(r)||tt.defaultNamedCurveSize,s=new _s,o=M.toUint8Array(n);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),V.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=V.parse(n,_s),i=e.namedCurve,s=tt.namedCurveSize.get(i)||tt.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return p_(o,c)}return null}}tt.namedCurveSize=new Map;tt.defaultNamedCurveSize=32;const Qo="1.3.101.110",ep="1.3.101.111",ea="1.3.101.112",tp="1.3.101.113";let zc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=ea;break;case"x25519":n=Qo;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=ea;break;case"ed448":n=tp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=Qo;break;case"x448":n=ep;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case ea:return{name:"Ed25519"};case tp:return{name:"EdDSA",namedCurve:"Ed448"};case Qo:return{name:"X25519"};case ep:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};zc=d([Eo()],zc);Be.registerSingleton(di,zc);class ey extends Rt{constructor(e){Rt.isAsnEncoded(e)?super(e,Rr):super(e),this.tag=Je.CertificateRequestTag}onInit(e){this.tbs=V.serialize(e.certificationRequestInfo),this.publicKey=new dt(e.certificationRequestInfo.subjectPKInfo);const n=Be.resolve(An);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>zo.create(V.serialize(i)));const r=this.getAttribute(jl);this.extensions=[],r instanceof Pl&&(this.extensions=r.items),this.subjectName=new et(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const n of this.attributes)if(n.type===e)return n;return null}getAttributes(e){return this.attributes.filter(n=>n.type===e)}getExtension(e){for(const n of this.extensions)if(n.type===e)return n;return null}getExtensions(e){return this.extensions.filter(n=>n.type===e)}async verify(e=$e.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Be.resolveAll(fi).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(n,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,r,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,Rr),r=n.certificationRequestInfo,i=new ue("",{Version:`${vn[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new ue("");for(const o of this.attributes){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new ue("",{Algorithm:En.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}ey.NAME="PKCS#10 Certificate Request";class Rl extends Rt{constructor(e){Rt.isAsnEncoded(e)?super(e,wn):super(e),this.tag=Je.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=V.serialize(n),this.serialNumber=G.ToHex(n.serialNumber),this.subjectName=new et(n.subject),this.subject=new et(n.subject).toString(),this.issuerName=new et(n.issuer),this.issuer=this.issuerName.toString();const r=Be.resolve(An);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(o=>st.create(V.serialize(o)))),this.publicKey=new dt(n.subjectPublicKeyInfo)}getExtension(e){for(const n of this.extensions)if(typeof e=="string"){if(n.type===e)return n}else if(n instanceof e)return n;return null}getExtensions(e){return this.extensions.filter(n=>typeof e=="string"?n.type===e:n instanceof e)}async verify(e={},n=$e.get()){let r,i;const s=e.publicKey;try{if(!s)r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],n);else if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],n);else if(s instanceof dt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(M.isBufferSource(s)){const u=new dt(s);r={...u.algorithm,...this.signatureAlgorithm},i=await u.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=Be.resolveAll(fi).reverse();let c=null;for(const u of o)if(c=u.toWebSignature(r,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const l=await n.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return l;{const p=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let n,r="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(r=e[0]||r,n=e[1])),n??(n=$e.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=$e.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,wn),r=n.tbsCertificate,i=new ue("",{Version:`${vn[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":En.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new ue("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const s=new ue("");for(const o of this.extensions){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new ue("",{Algorithm:En.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}Rl.NAME="Certificate";class ty{static async createSelfSigned(e,n=$e.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},n)}static async create(e,n=$e.get()){var r;let i;e.publicKey instanceof dt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:M.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?M.toUint8Array(G.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const o=e.notBefore||new Date,c=e.notAfter||new Date(o.getTime()+31536e6),l=new wn({tbsCertificate:new Ye({version:vn.v3,serialNumber:s,validity:new ei({notBefore:o,notAfter:c}),extensions:new Gt(((r=e.extensions)===null||r===void 0?void 0:r.map(v=>V.parse(v.rawData,nt)))||[]),subjectPublicKeyInfo:V.parse(i,ut)})});if(e.subject){const v=e.subject instanceof et?e.subject:new et(e.subject);l.tbsCertificate.subject=V.parse(v.toArrayBuffer(),ke)}if(e.issuer){const v=e.issuer instanceof et?e.issuer:new et(e.issuer);l.tbsCertificate.issuer=V.parse(v.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=Be.resolve(An);l.tbsCertificate.signature=l.signatureAlgorithm=h.toAsnAlgorithm(p);const m=V.serialize(l.tbsCertificate),y="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,f=Be.resolveAll(fi).reverse();let _=null;for(const v of f)if(_=v.toAsnSignature(p,y),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=_,new Rl(V.serialize(l))}}var np;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(np||(np={}));st.register(yh,Ol);st.register(bh,Bl);st.register(kh,Tl);st.register(Eh,pi);st.register(Sa,Mr);st.register(Ah,eg);st.register(Na,ng);st.register(xa,rg);zo.register(Gh,ig);zo.register(jl,Pl);Be.registerSingleton(fi,Q0);Be.registerSingleton(fi,tt);tt.namedCurveSize.set("P-256",32);tt.namedCurveSize.set("K-256",32);tt.namedCurveSize.set("P-384",48);tt.namedCurveSize.set("P-521",66);const rp="0123456789abcdef";function jc(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=rp[i];const s=e[r]&15;n+=rp[s]}return n}class sg{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let o=0;o<i;o++){let c=0;const l=[];for(let p=0;p<8;p++){const h=e[o*8+p];if(h==="="){if(o+1!==i)throw new Error(`Invalid character: ${h}`);c+=1;continue}if(h===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const m=this.decodeMap.get(h)??null;if(m===null)throw new Error(`Invalid character: ${h}`);l.push(m)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const u=(l[0]<<3)+(l[1]>>2);if(s.push(u),c<6){const p=((l[1]&3)<<6)+(l[2]<<1)+(l[3]>>4);s.push(p)}if(c<4){const p=((l[3]&255)<<4)+(l[4]>>1);s.push(p)}if(c<3){const p=((l[4]&1)<<7)+(l[5]<<2)+(l[6]>>3);s.push(p)}if(c<1){const p=((l[6]&7)<<5)+l[7];s.push(p)}}return Uint8Array.from(s)}}new sg("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new sg("0123456789ABCDEFGHIJKLMNOPQRSTUV");class og{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let o=0;o<i;o++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[o*4+u];if(p==="="){if(o+1!==i)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const h=this.decodeMap.get(p)??null;if(h===null)throw new Error(`Invalid character: ${p}`);l+=h<<6*(3-u)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const ny=new og("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),pn=new og("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class ry{constructor(e){ee(this,"hash");this.hash=e}async verify(e,n,r){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,n,r)}async sign(e,n){const r=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",r,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function ag(t){return await crypto.subtle.digest("SHA-256",t)}async function Oc(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),r=qe(),i=jc(new TextEncoder().encode(r)),s=await ty.createSelfSigned({serialNumber:i,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new Ol(!0,2,!0),new Bl(["1.3.6.1.5.5.7.3.1"],!0),new Tl($s.keyCertSign|$s.cRLSign,!0),await pi.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await sy(s),u=jc(await s.getThumbprint()),p=iy("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function iy(t,e){const n=ny.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
|
|
122
122
|
`,i=0;for(;i<n.length;)i+64<=n.length?r+=n.substr(i,64)+`\r
|
|
123
123
|
`:r+=n.substr(i)+`\r
|
|
124
124
|
`,i+=64;return r+=`-----END ${t} KEY-----\r
|
|
125
|
-
`,r}async function iy(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),r=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(r);return jc(await og(s))}const sy=1e3*60*60*24,oy=new a.OpenAPIHono().openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(ha)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(r=>"cert"in r).map(r=>r);return t.json(n)}).openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ha}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),r=(await t.env.data.keys.list()).find(i=>i.kid===e);if(!r)throw new O(404,{message:"Key not found"});return t.json(r)}).openapi(a.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const r of e)await t.env.data.keys.update(r.kid,{revoked_at:new Date(Date.now()+sy).toISOString()});const n=await Oc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const{kid:e}=t.req.valid("param");if(!await t.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new O(404,{message:"Key not found"});const r=await Oc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),ay=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:a.z.object({email:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.array(qc)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await ff(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),cy=Yt.extend({clients:a.z.array(on)}),ly=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([cy,a.z.array(on)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:o}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:tr(s),q:o})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(a.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:on}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!i)throw new O(404);return t.json(i)}).openapi(a.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.applications.remove(e,n))throw new O(404,{message:"Application not found"});return t.text("OK")}).openapi(a.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Hi.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:on}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.applications.update(e,n,i);const s=await t.env.data.applications.get(e,n);if(!s)throw new O(404,{message:"Application not found"});return t.json(s)}).openapi(a.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Hi.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(on.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||qe(),client_secret:n.client_secret||qe()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});Ls.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any());const uy=Yt.extend({tenants:a.z.array(Rn)}),dy=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:hn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(Rn),uy])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),o=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:tr(i),q:s});return r?t.json(o):t.json(o.tenants)}).openapi(a.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Rn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new O(404);return t.json(n)}).openapi(a.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param");return await t.env.data.tenants.remove(e),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Wi.shape).partial()}}},params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param"),n=t.req.valid("json");return await t.env.data.tenants.update(e,n),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Wi.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Rn}},description:"An tenant"}}}),async t=>{const e=t.req.valid("json"),n=await t.env.data.tenants.create(e);return t.json(n,{status:201})}),py=Yt.extend({logs:a.z.array(Ji)}),fy=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Ji),py])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header"),c=await t.env.data.logs.list(o,{page:e,per_page:n,include_totals:r,sort:tr(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(a.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ji}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.logs.get(e,n);if(!r)throw new O(404);return t.json(r)}),hy=Yt.extend({hooks:a.z.array(Tn)}),gy=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Tn),hy])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:tr(s),q:o});return i?t.json(c):t.json(c.hooks)}).openapi(a.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Gi.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Tn}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.hooks.create(e,n);return t.json(r,{status:201})}).openapi(a.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Gi.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Tn.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=t.req.valid("json");await t.env.data.hooks.update(e,n,r);const i=await t.env.data.hooks.get(e,n);if(!i)throw new O(404,{message:"Hook not found"});return t.json(i)}).openapi(a.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Tn}},description:"A hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=await t.env.data.hooks.get(e,n);if(!r)throw new O(404,{message:"Hook not found"});return t.json(r)}).openapi(a.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param");if(!await t.env.data.hooks.remove(e,n))throw new O(404,{message:"Hook not found"});return t.text("OK")}),my=Yt.extend({connections:a.z.array(Mt)}),_y=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Mt),my])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i=!1,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:tr(s),q:o});return i?t.json(c):t.json(c.connections)}).openapi(a.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.connections.get(e,n);if(!r)throw new O(404);return t.json(r)}).openapi(a.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.connections.remove(e,n))throw new O(404,{message:"Connection not found"});return t.text("OK")}).openapi(a.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Ki.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mt}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.connections.update(e,n,r))throw new O(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new O(404,{message:"Connection not found"});return t.json(s)}).openapi(a.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Ki.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Mt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.connections.create(e,n);return t.json(r,{status:201})}),yy=new a.OpenAPIHono().openapi(a.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ii}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.promptSettings.get(e);return n?t.json(n):t.json(Ii.parse({}))}).openapi(a.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ii.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.promptSettings.get(e);return Object.assign(r,n),await t.env.data.promptSettings.set(e,r),t.json(r)});let ip=!1;function ag(t){t.use(async(e,n)=>(ip||(t.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),ip=!0),await n()))}a.z.object({alg:a.z.literal("RS256"),kty:a.z.literal("RSA"),use:a.z.literal("sig"),n:a.z.string(),e:a.z.string(),kid:a.z.string(),x5t:a.z.string(),x5c:a.z.array(a.z.string())});async function vy(t){try{const e=await t.JWKS_SERVICE.fetch(t.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new O(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function wy(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),o=(await vy(t.env)).find(l=>l.kid===e.header.kid);if(!o)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function by(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),o=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:o,raw:{header:e,payload:n,signature:r}}}function cg(t){return async(e,n)=>{var i,s,o;const r=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(r&&"route"in r){const c=(s=(i=r.route.security)==null?void 0:i[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[u,p]=l.split(" ");if((u==null?void 0:u.toLowerCase())!=="bearer"||!p)throw new O(401,{message:"Missing bearer token"});const h=by(p);if(!h||!await wy(e,h))throw new O(403,{message:"Invalid JWT signature"});e.set("user_id",h.payload.sub),e.set("user",h.payload);const m=h.payload.permissions||[],y=((o=h.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(f=>m.includes(f))||c.some(f=>y.includes(f))))throw new O(403,{message:"Unauthorized"})}return await n()}}const ky=new a.OpenAPIHono().openapi(a.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ci}},description:"Email provider"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.emailProviders.get(e);if(!n)throw new O(404,{message:"Email provider not found"});return t.json(n)}).openapi(a.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ci.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.create(e,n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ci.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.update(e,n),t.text("OK")}),xy=new a.OpenAPIHono().openapi(a.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vs}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.sessions.get(e,n);if(!r)throw new O(404);return t.json(r)}).openapi(a.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.remove(e,n))throw new O(404,{message:"Session not found"});return t.text("OK")}).openapi(a.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{202:{description:"Sesssion deletion status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.update(e,n,{revoked_at:new Date().toDateString()}))throw new O(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),Sy=new a.OpenAPIHono().openapi(a.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Hc}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.refreshTokens.get(e,n);if(!r)throw new O(404);return t.json(r)}).openapi(a.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.refreshTokens.remove(e,n))throw new O(404,{message:"Session not found"});return t.text("OK")});function Ay(){const t=new a.OpenAPIHono;t.use(cg(t));const e=t.route("/branding",Fm).route("/email/providers",ky).route("/users",o_).route("/keys",oy).route("/users-by-email",ay).route("/clients",ly).route("/tenants",dy).route("/logs",fy).route("/hooks",gy).route("/connections",_y).route("/prompts",yy).route("/sessions",xy).route("/refresh_tokens",Sy);return ag(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}function Ey(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}function pr(t){var e,n,r;return{auth0Client:(e=t.query("auth0Client"))==null?void 0:e.slice(0,255),ip:(n=t.header("x-real-ip"))==null?void 0:n.slice(0,45),useragent:(r=t.header("user-agent"))==null?void 0:r.slice(0,512)}}const Si=60*5,jo=30*24*60*60,qr=24*60*60,Iy="auth-token",Bc=30*60*1e3,Cy=5*60,Ny=5*60,$y=30*60*1e3;var sp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(sp||(sp={}));var op;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(op||(op={}));function zy(t){return ug(t,jy,Dr.Include)}function lg(t){return ug(t,Oy,Dr.None)}function ug(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===Dr.Include&&(r+="=")}return r}const jy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Oy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Dr;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Dr||(Dr={}));var ap;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(ap||(ap={}));class By{uint8(e,n){if(e.byteLength<n+1)throw new TypeError("Insufficient bytes");return e[n]}uint16(e,n){if(e.byteLength<n+2)throw new TypeError("Insufficient bytes");return e[n]<<8|e[n+1]}uint32(e,n){if(e.byteLength<n+4)throw new TypeError("Insufficient bytes");let r=0;for(let i=0;i<4;i++)r|=e[n+i]<<24-i*8;return r}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let r=0n;for(let i=0;i<8;i++)r|=BigInt(e[n+i])<<BigInt(56-i*8);return r}putUint8(e,n,r){if(e.length<r+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[r]=n}putUint16(e,n,r){if(e.length<r+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[r]=n>>8,e[r+1]=n&255}putUint32(e,n,r){if(e.length<r+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let i=0;i<4;i++)e[r+i]=n>>(3-i)*8&255}putUint64(e,n,r){if(e.length<r+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let i=0;i<8;i++)e[r+i]=Number(n>>BigInt((7-i)*8)&0xffn)}}const cp=new By;function yt(t,e){return(t<<32-e|t>>>e)>>>0}function Ty(t){const e=new Py;return e.update(t),e.digest()}class Py{constructor(){ee(this,"blockSize",64);ee(this,"size",32);ee(this,"blocks",new Uint8Array(64));ee(this,"currentBlockSize",0);ee(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));ee(this,"l",0n);ee(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),cp.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)cp.putUint32(e,this.H[n],n*4);return e}process(){for(let u=0;u<16;u++)this.w[u]=(this.blocks[u*4]<<24|this.blocks[u*4+1]<<16|this.blocks[u*4+2]<<8|this.blocks[u*4+3])>>>0;for(let u=16;u<64;u++){const p=(yt(this.w[u-2],17)^yt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,h=(yt(this.w[u-15],7)^yt(this.w[u-15],18)^this.w[u-15]>>>3)>>>0;this.w[u]=p+this.w[u-7]+h+this.w[u-16]|0}let e=this.H[0],n=this.H[1],r=this.H[2],i=this.H[3],s=this.H[4],o=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(yt(s,6)^yt(s,11)^yt(s,25))>>>0,h=(s&o^~s&c)>>>0,m=l+p+h+Ry[u]+this.w[u]|0,y=(yt(e,2)^yt(e,13)^yt(e,22))>>>0,f=(e&n^e&r^n&r)>>>0,_=y+f|0;l=c,c=o,o=s,s=i+m|0,i=r,r=n,n=e,e=m+_|0}this.H[0]=e+this.H[0]|0,this.H[1]=n+this.H[1]|0,this.H[2]=r+this.H[2]|0,this.H[3]=i+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=o+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const Ry=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class Ly{constructor(e){ee(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function Uy(t){const e=Ty(new TextEncoder().encode(t));return lg(e)}function Vy(){const t=new Uint8Array(32);return crypto.getRandomValues(t),lg(t)}function Ir(t,e){const n=new TextEncoder().encode(e.toString()),r=new Request(t,{method:"POST",body:n});return r.headers.set("Content-Type","application/x-www-form-urlencoded"),r.headers.set("Accept","application/json"),r.headers.set("User-Agent","arctic"),r.headers.set("Content-Length",n.byteLength.toString()),r}function ta(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return zy(n)}async function zs(t){let e;try{e=await fetch(t)}catch(n){throw new pg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Oi(e.status)}if(typeof n!="object"||n===null)throw new Vn(e.status,n);let r;try{r=dg(n)}catch{throw new Vn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Oi(e.status)}if(typeof n!="object"||n===null)throw new Vn(e.status,n);return new Ly(n)}throw e.body!==null&&await e.body.cancel(),new Oi(e.status)}async function My(t){let e;try{e=await fetch(t)}catch(n){throw new pg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Vn(e.status,null)}if(typeof n!="object"||n===null)throw new Vn(e.status,n);let r;try{r=dg(n)}catch{throw new Vn(e.status,n)}throw r}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new Oi(e.status)}function dg(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,r=null,i=null;if("error_description"in t){if(typeof t.error_description!="string")throw new Error("Invalid data");n=t.error_description}if("error_uri"in t){if(typeof t.error_uri!="string")throw new Error("Invalid data");r=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");i=t.state}return new qy(e,n,r,i)}class pg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class qy extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);ee(this,"code");ee(this,"description");ee(this,"uri");ee(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Oi extends Error{constructor(n){super("Unexpected error response");ee(this,"status");this.status=n}}class Vn extends Error{constructor(n,r){super("Unexpected error response body");ee(this,"status");ee(this,"data");this.status=n,this.data=r}}class Ll{constructor(e,n,r){ee(this,"clientId");ee(this,"clientPassword");ee(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const o=new URL(e);if(o.searchParams.set("response_type","code"),o.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&o.searchParams.set("redirect_uri",this.redirectURI),o.searchParams.set("state",n),r===Fr.S256){const c=Uy(i);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else r===Fr.Plain&&(o.searchParams.set("code_challenge_method","plain"),o.searchParams.set("code_challenge",i));return s.length>0&&o.searchParams.set("scope",s.join(" ")),o}async validateAuthorizationCode(e,n,r){const i=new URLSearchParams;i.set("grant_type","authorization_code"),i.set("code",n),this.redirectURI!==null&&i.set("redirect_uri",this.redirectURI),r!==null&&i.set("code_verifier",r),this.clientPassword===null&&i.set("client_id",this.clientId);const s=Ir(e,i);if(this.clientPassword!==null){const c=ta(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await zs(s)}async refreshAccessToken(e,n,r){const i=new URLSearchParams;i.set("grant_type","refresh_token"),i.set("refresh_token",n),this.clientPassword===null&&i.set("client_id",this.clientId),r.length>0&&i.set("scope",r.join(" "));const s=Ir(e,i);if(this.clientPassword!==null){const c=ta(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await zs(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Ir(e,r);if(this.clientPassword!==null){const s=ta(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await My(i)}}var Fr;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(Fr||(Fr={}));var lp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(lp||(lp={}));var up;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(up||(up={}));function Cr(t){return Dy(t,Fy,js.None)}function Dy(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===js.Include&&(r+="=")}return r}const Fy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var js;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(js||(js={}));var dp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(dp||(dp={}));function Hy(t,e,n){const r=Cr(new TextEncoder().encode(t)),i=Cr(new TextEncoder().encode(e)),s=Cr(n);return r+"."+i+"."+s}function Ky(t,e){const n=Cr(new TextEncoder().encode(t)),r=Cr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const Wy="https://appleid.apple.com/auth/authorize",Gy="https://appleid.apple.com/auth/token";class fg{constructor(e,n,r,i,s){ee(this,"clientId");ee(this,"teamId");ee(this,"keyId");ee(this,"pkcs8PrivateKey");ee(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(Wy);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId);const r=await this.createClientSecret();n.set("client_secret",r);const i=Ir(Gy,n);return await zs(i)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),r=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),i=JSON.stringify({iss:this.teamId,exp:n+5*60,aud:["https://appleid.apple.com"],sub:this.clientId,iat:n}),s=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,Ky(r,i)));return Hy(r,i,s)}}const Jy="https://www.facebook.com/v16.0/dialog/oauth",Zy="https://graph.facebook.com/v16.0/oauth/access_token";class hg{constructor(e,n,r){ee(this,"clientId");ee(this,"clientSecret");ee(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(Jy);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId),n.set("client_secret",this.clientSecret);const r=Ir(Zy,n);return await zs(r)}}const Yy="https://accounts.google.com/o/oauth2/v2/auth",pp="https://oauth2.googleapis.com/token",Xy="https://oauth2.googleapis.com/revoke";let gg=class{constructor(e,n,r){ee(this,"client");this.client=new Ll(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(Yy,e,Fr.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(pp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(pp,e,[])}async revokeToken(e){await this.client.revokeToken(Xy,e)}};class Ul{constructor(e,n){ee(this,"value");ee(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Ul(Math.round(this.milliseconds()*e),"ms")}}async function fp(t,e,n,r){const i={alg:t,typ:"JWT",...r==null?void 0:r.headers},s={...n};(r==null?void 0:r.audiences)!==void 0&&(s.aud=r.audiences),(r==null?void 0:r.subject)!==void 0&&(s.sub=r.subject),(r==null?void 0:r.issuer)!==void 0&&(s.iss=r.issuer),(r==null?void 0:r.jwtId)!==void 0&&(s.jti=r.jwtId),(r==null?void 0:r.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+r.expiresIn.seconds()),(r==null?void 0:r.notBefore)!==void 0&&(s.nbf=Math.floor(r.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const o=new TextEncoder,c=pn.encode(o.encode(JSON.stringify(i)),{includePadding:!1}),l=pn.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),u=o.encode([c,l].join(".")),p=await ev(t).sign(e,u),h=pn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,h].join(".")}function Qy(t){const e=t.split(".");return e.length!==3?null:e}function Vl(t){const e=Qy(t);if(!e)return null;const n=new TextDecoder,r=pn.decode(e[0],{strict:!1}),i=pn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!tv(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const o=JSON.parse(n.decode(i));if(typeof o!="object"||o===null)return null;const c={algorithm:s.alg,expiresAt:null,subject:null,issuedAt:null,issuer:null,jwtId:null,audiences:null,notBefore:null};if("exp"in o){if(typeof o.exp!="number")return null;c.expiresAt=new Date(o.exp*1e3)}if("iss"in o){if(typeof o.iss!="string")return null;c.issuer=o.iss}if("sub"in o){if(typeof o.sub!="string")return null;c.subject=o.sub}if("aud"in o)if(Array.isArray(o.aud)){for(const l of o.aud)if(typeof l!="string")return null;c.audiences=o.aud}else{if(typeof o.aud!="string")return null;c.audiences=[o.aud]}if("nbf"in o){if(typeof o.nbf!="number")return null;c.notBefore=new Date(o.nbf*1e3)}if("iat"in o){if(typeof o.iat!="number")return null;c.issuedAt=new Date(o.iat*1e3)}if("jti"in o){if(typeof o.jti!="string")return null;c.jwtId=o.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...o},parts:e,...c}}function ev(t){return new ny(nv[t])}function tv(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const nv={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"},Oo=a.z.object({iss:a.z.string().url(),sub:a.z.string(),aud:a.z.string(),exp:a.z.number(),email:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),name:a.z.string().optional(),iat:a.z.number(),auth_time:a.z.number().optional(),nonce:a.z.string().optional(),acr:a.z.string().optional(),amr:a.z.array(a.z.string()).optional(),azp:a.z.string().optional(),at_hash:a.z.string().optional(),c_hash:a.z.string().optional()}).passthrough();Oo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function rv(t){return t.ISSUER}function St(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function Ne(t){return t.OAUTH_API_URL||t.ISSUER}function mg(t){const{options:e}=t;if(!e||!e.client_id||!e.team_id||!e.kid||!e.app_secret)throw new Error("Missing required Apple authentication parameters");const n=Buffer.from(e.app_secret,"utf-8"),r=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),i=Uint8Array.from(Buffer.from(r,"base64"));return n.fill(0),{options:e,keyArray:i}}async function iv(t,e){var l,u;const{options:n,keyArray:r}=mg(e),i=new fg(n.client_id,n.team_id,n.kid,r,`${Ne(t.env)}callback`),s=qe(),o=await i.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((u=n.scope)==null?void 0:u.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function sv(t,e,n){const{options:r,keyArray:i}=mg(e),o=await new fg(r.client_id,r.team_id,r.kid,i,`${Ne(t.env)}callback`).validateAuthorizationCode(n),c=Vl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Oo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const ov=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:iv,validateAuthorizationCodeAndGetUser:sv},Symbol.toStringTag,{value:"Module"}));async function av(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new hg(n.client_id,n.client_secret,`${Ne(t.env)}callback`),i=qe();return{redirectUrl:r.createAuthorizationURL(i,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:i}}async function cv(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new hg(r.client_id,r.client_secret,`${Ne(t.env)}callback`).validateAuthorizationCode(n),o=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!o.ok)throw new Error("Failed to fetch user info");const c=await o.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const lv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:av,validateAuthorizationCodeAndGetUser:cv},Symbol.toStringTag,{value:"Module"}));async function uv(t,e){var c;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required Google authentication parameters");const r=new gg(n.client_id,n.client_secret,`${Ne(t.env)}callback`),i=qe(),s=Vy();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function dv(t,e,n,r){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret||!r)throw new Error("Missing required authentication parameters");const o=await new gg(i.client_id,i.client_secret,`${Ne(t.env)}callback`).validateAuthorizationCode(n,r);console.log("got here");const c=Vl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Oo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const pv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:uv,validateAuthorizationCodeAndGetUser:dv},Symbol.toStringTag,{value:"Module"}));async function fv(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Ll(n.client_id,n.client_secret,`${Ne(t.env)}callback`),i=qe(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((o=n.scope)==null?void 0:o.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:i}}async function hv(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new Ll(r.client_id,r.client_secret,`${Ne(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=Vl(s.idToken());if(!o)throw new Error("Invalid ID token");const c=Oo.parse(o.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const l=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!l.ok)throw new O(400,{message:"Failed to get user from vipps"});return await l.json()}const gv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:fv,validateAuthorizationCodeAndGetUser:hv},Symbol.toStringTag,{value:"Module"}));function _g(t,e){const n=t.env.STRATEGIES||{},i={apple:ov,facebook:lv,"google-oauth2":pv,vipps:gv,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Bo(t,e){const n=await t.data.clients.get(e);if(!n)throw new O(403,{message:"Client not found"});const r=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,i=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},o=i.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(h=>h.name===c.name);return l!=null&&l.options?Mt.parse({...l||{},...c,options:{...l.options||{},...c.options}}):c}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${St(t)}login`],allowed_logout_urls:[...(r==null?void 0:r.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(r==null?void 0:r.callbacks)||[],...n.callbacks||[],`${St(t)}info`],connections:o,domains:[...n.domains||[],...(r==null?void 0:r.domains)||[]],tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}function To(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return mv(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function mv(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const r=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${r}$`).test(t.pathname))return!1}else if(t.pathname!==e.pathname)return!1;if(e.hostname.startsWith("*.")&&e.hostname.split(".").length>2&&["http:","https:"].includes(e.protocol)){const r=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(r)}return t.hostname===e.hostname}function _v(t){try{const n=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(t);if(!n||!n[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(n[1].replace(/\s/g,"")),r=>r.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function yv(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await og(n);return pn.encode(new Uint8Array(r),{includePadding:!1})}function yg(t,e,n){const r=[];return r.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&r.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&r.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&r.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&r.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&r.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&r.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&r.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&r.push(["SameSite","Strict"]),n!=null&&n.secure&&r.push(["Secure"]),r.map(i=>i.join("=")).join("; ")}function vv(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],o=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(o))}return e}function Ml(t){return`${t}-${Iy}`}function vg(t,e){return e?(console.log("cookieHeaders",e),vv(e).get(Ml(t))):void 0}function wv(t){const e={path:"/",httpOnly:!0,secure:!0,maxAge:0};return yg(Ml(t),"",{...e,sameSite:"none"})}function wg(t,e){const n={path:"/",httpOnly:!0,secure:!0,maxAge:jo};return yg(Ml(t),e,{...n,sameSite:"none"})}var ql={},Po={};(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",r="["+e+"]["+n+"]*",i=new RegExp("^"+r+"$"),s=function(c,l){const u=[];let p=l.exec(c);for(;p;){const h=[];h.startIndex=l.lastIndex-p[0].length;const m=p.length;for(let y=0;y<m;y++)h.push(p[y]);u.push(h),p=l.exec(c)}return u},o=function(c){const l=i.exec(c);return!(l===null||typeof l>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,l,u){if(l){const p=Object.keys(l),h=p.length;for(let m=0;m<h;m++)u==="strict"?c[p[m]]=[l[p[m]]]:c[p[m]]=l[p[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=o,t.getAllMatches=s,t.nameRegexp=r})(Po);const Dl=Po,bv={allowBooleanAttributes:!1,unpairedTags:[]};ql.validate=function(t,e){e=Object.assign({},bv,e);const n=[];let r=!1,i=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=gp(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=mp(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let l="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
|
|
126
|
-
`&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--)
|
|
127
|
-
`||t==="\r"}function gp(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return we("InvalidXml","XML declaration allowed only at the start of the document.",Pe(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function mp(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
|
|
128
|
-
`);const e=new yr("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=ln(t,">",s,"Closing Tag is not closed.");let l=t.substring(s+2,c).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&&(r=this.saveTextToParentTag(r,n,i));const u=i.substring(i.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let p=0;u&&this.options.unpairedTags.indexOf(u)!==-1?(p=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=i.lastIndexOf("."),i=i.substring(0,p),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=Tc(t,s,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const l=new yr(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,l,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=ln(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=
|
|
129
|
-
`;function
|
|
125
|
+
`,r}async function sy(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),r=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(r);return jc(await ag(s))}const oy=1e3*60*60*24,ay=new a.OpenAPIHono().openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(ha)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(r=>"cert"in r).map(r=>r);return t.json(n)}).openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ha}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),r=(await t.env.data.keys.list()).find(i=>i.kid===e);if(!r)throw new O(404,{message:"Key not found"});return t.json(r)}).openapi(a.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const r of e)await t.env.data.keys.update(r.kid,{revoked_at:new Date(Date.now()+oy).toISOString()});const n=await Oc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const{kid:e}=t.req.valid("param");if(!await t.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new O(404,{message:"Key not found"});const r=await Oc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),cy=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:a.z.object({email:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.array(qc)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await hf(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),ly=Yt.extend({clients:a.z.array(on)}),uy=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([ly,a.z.array(on)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:o}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:tr(s),q:o})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(a.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:on}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!i)throw new O(404);return t.json(i)}).openapi(a.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.applications.remove(e,n))throw new O(404,{message:"Application not found"});return t.text("OK")}).openapi(a.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Hi.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:on}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.applications.update(e,n,i);const s=await t.env.data.applications.get(e,n);if(!s)throw new O(404,{message:"Application not found"});return t.json(s)}).openapi(a.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Hi.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(on.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||qe(),client_secret:n.client_secret||qe()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});Ls.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any());const dy=Yt.extend({tenants:a.z.array(Rn)}),py=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:hn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(Rn),dy])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),o=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:tr(i),q:s});return r?t.json(o):t.json(o.tenants)}).openapi(a.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Rn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new O(404);return t.json(n)}).openapi(a.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param");return await t.env.data.tenants.remove(e),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Wi.shape).partial()}}},params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param"),n=t.req.valid("json");return await t.env.data.tenants.update(e,n),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Wi.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Rn}},description:"An tenant"}}}),async t=>{const e=t.req.valid("json"),n=await t.env.data.tenants.create(e);return t.json(n,{status:201})}),fy=Yt.extend({logs:a.z.array(Ji)}),hy=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Ji),fy])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header"),c=await t.env.data.logs.list(o,{page:e,per_page:n,include_totals:r,sort:tr(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(a.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ji}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.logs.get(e,n);if(!r)throw new O(404);return t.json(r)}),gy=Yt.extend({hooks:a.z.array(Tn)}),my=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Tn),gy])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:tr(s),q:o});return i?t.json(c):t.json(c.hooks)}).openapi(a.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Gi.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Tn}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.hooks.create(e,n);return t.json(r,{status:201})}).openapi(a.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Gi.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Tn.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=t.req.valid("json");await t.env.data.hooks.update(e,n,r);const i=await t.env.data.hooks.get(e,n);if(!i)throw new O(404,{message:"Hook not found"});return t.json(i)}).openapi(a.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Tn}},description:"A hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=await t.env.data.hooks.get(e,n);if(!r)throw new O(404,{message:"Hook not found"});return t.json(r)}).openapi(a.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param");if(!await t.env.data.hooks.remove(e,n))throw new O(404,{message:"Hook not found"});return t.text("OK")}),_y=Yt.extend({connections:a.z.array(Mt)}),yy=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Mt),_y])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i=!1,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:tr(s),q:o});return i?t.json(c):t.json(c.connections)}).openapi(a.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.connections.get(e,n);if(!r)throw new O(404);return t.json(r)}).openapi(a.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.connections.remove(e,n))throw new O(404,{message:"Connection not found"});return t.text("OK")}).openapi(a.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Ki.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mt}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.connections.update(e,n,r))throw new O(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new O(404,{message:"Connection not found"});return t.json(s)}).openapi(a.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Ki.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Mt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.connections.create(e,n);return t.json(r,{status:201})}),vy=new a.OpenAPIHono().openapi(a.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ii}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.promptSettings.get(e);return n?t.json(n):t.json(Ii.parse({}))}).openapi(a.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ii.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.promptSettings.get(e);return Object.assign(r,n),await t.env.data.promptSettings.set(e,r),t.json(r)});let ip=!1;function cg(t){t.use(async(e,n)=>(ip||(t.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),ip=!0),await n()))}a.z.object({alg:a.z.literal("RS256"),kty:a.z.literal("RSA"),use:a.z.literal("sig"),n:a.z.string(),e:a.z.string(),kid:a.z.string(),x5t:a.z.string(),x5c:a.z.array(a.z.string())});async function wy(t){try{const e=await t.JWKS_SERVICE.fetch(t.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new O(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function by(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),o=(await wy(t.env)).find(l=>l.kid===e.header.kid);if(!o)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function ky(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),o=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:o,raw:{header:e,payload:n,signature:r}}}function lg(t){return async(e,n)=>{var i,s,o;const r=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(r&&"route"in r){const c=(s=(i=r.route.security)==null?void 0:i[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[u,p]=l.split(" ");if((u==null?void 0:u.toLowerCase())!=="bearer"||!p)throw new O(401,{message:"Missing bearer token"});const h=ky(p);if(!h||!await by(e,h))throw new O(403,{message:"Invalid JWT signature"});e.set("user_id",h.payload.sub),e.set("user",h.payload);const m=h.payload.permissions||[],y=((o=h.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(f=>m.includes(f))||c.some(f=>y.includes(f))))throw new O(403,{message:"Unauthorized"})}return await n()}}const xy=new a.OpenAPIHono().openapi(a.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ci}},description:"Email provider"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.emailProviders.get(e);if(!n)throw new O(404,{message:"Email provider not found"});return t.json(n)}).openapi(a.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ci.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.create(e,n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ci.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.update(e,n),t.text("OK")}),Sy=new a.OpenAPIHono().openapi(a.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vs}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.sessions.get(e,n);if(!r)throw new O(404);return t.json(r)}).openapi(a.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.remove(e,n))throw new O(404,{message:"Session not found"});return t.text("OK")}).openapi(a.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{202:{description:"Sesssion deletion status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.update(e,n,{revoked_at:new Date().toDateString()}))throw new O(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),Ay=new a.OpenAPIHono().openapi(a.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Hc}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.refreshTokens.get(e,n);if(!r)throw new O(404);return t.json(r)}).openapi(a.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.refreshTokens.remove(e,n))throw new O(404,{message:"Session not found"});return t.text("OK")});function Ey(){const t=new a.OpenAPIHono;t.use(lg(t));const e=t.route("/branding",Hm).route("/email/providers",xy).route("/users",a_).route("/keys",ay).route("/users-by-email",cy).route("/clients",uy).route("/tenants",py).route("/logs",hy).route("/hooks",my).route("/connections",yy).route("/prompts",vy).route("/sessions",Sy).route("/refresh_tokens",Ay);return cg(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}function Iy(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}function pr(t){var e,n,r;return{auth0Client:(e=t.query("auth0Client"))==null?void 0:e.slice(0,255),ip:(n=t.header("x-real-ip"))==null?void 0:n.slice(0,45),useragent:(r=t.header("user-agent"))==null?void 0:r.slice(0,512)}}const Si=60*5,jo=30*24*60*60,qr=24*60*60,Cy="auth-token",Bc=30*60*1e3,Ny=5*60,$y=5*60,zy=30*60*1e3;var sp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(sp||(sp={}));var op;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(op||(op={}));function jy(t){return dg(t,Oy,Dr.Include)}function ug(t){return dg(t,By,Dr.None)}function dg(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===Dr.Include&&(r+="=")}return r}const Oy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",By="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Dr;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Dr||(Dr={}));var ap;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(ap||(ap={}));class Ty{uint8(e,n){if(e.byteLength<n+1)throw new TypeError("Insufficient bytes");return e[n]}uint16(e,n){if(e.byteLength<n+2)throw new TypeError("Insufficient bytes");return e[n]<<8|e[n+1]}uint32(e,n){if(e.byteLength<n+4)throw new TypeError("Insufficient bytes");let r=0;for(let i=0;i<4;i++)r|=e[n+i]<<24-i*8;return r}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let r=0n;for(let i=0;i<8;i++)r|=BigInt(e[n+i])<<BigInt(56-i*8);return r}putUint8(e,n,r){if(e.length<r+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[r]=n}putUint16(e,n,r){if(e.length<r+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[r]=n>>8,e[r+1]=n&255}putUint32(e,n,r){if(e.length<r+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let i=0;i<4;i++)e[r+i]=n>>(3-i)*8&255}putUint64(e,n,r){if(e.length<r+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let i=0;i<8;i++)e[r+i]=Number(n>>BigInt((7-i)*8)&0xffn)}}const cp=new Ty;function yt(t,e){return(t<<32-e|t>>>e)>>>0}function Py(t){const e=new Ry;return e.update(t),e.digest()}class Ry{constructor(){ee(this,"blockSize",64);ee(this,"size",32);ee(this,"blocks",new Uint8Array(64));ee(this,"currentBlockSize",0);ee(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));ee(this,"l",0n);ee(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),cp.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)cp.putUint32(e,this.H[n],n*4);return e}process(){for(let u=0;u<16;u++)this.w[u]=(this.blocks[u*4]<<24|this.blocks[u*4+1]<<16|this.blocks[u*4+2]<<8|this.blocks[u*4+3])>>>0;for(let u=16;u<64;u++){const p=(yt(this.w[u-2],17)^yt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,h=(yt(this.w[u-15],7)^yt(this.w[u-15],18)^this.w[u-15]>>>3)>>>0;this.w[u]=p+this.w[u-7]+h+this.w[u-16]|0}let e=this.H[0],n=this.H[1],r=this.H[2],i=this.H[3],s=this.H[4],o=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(yt(s,6)^yt(s,11)^yt(s,25))>>>0,h=(s&o^~s&c)>>>0,m=l+p+h+Ly[u]+this.w[u]|0,y=(yt(e,2)^yt(e,13)^yt(e,22))>>>0,f=(e&n^e&r^n&r)>>>0,_=y+f|0;l=c,c=o,o=s,s=i+m|0,i=r,r=n,n=e,e=m+_|0}this.H[0]=e+this.H[0]|0,this.H[1]=n+this.H[1]|0,this.H[2]=r+this.H[2]|0,this.H[3]=i+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=o+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const Ly=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class Uy{constructor(e){ee(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function Vy(t){const e=Py(new TextEncoder().encode(t));return ug(e)}function My(){const t=new Uint8Array(32);return crypto.getRandomValues(t),ug(t)}function Ir(t,e){const n=new TextEncoder().encode(e.toString()),r=new Request(t,{method:"POST",body:n});return r.headers.set("Content-Type","application/x-www-form-urlencoded"),r.headers.set("Accept","application/json"),r.headers.set("User-Agent","arctic"),r.headers.set("Content-Length",n.byteLength.toString()),r}function ta(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return jy(n)}async function zs(t){let e;try{e=await fetch(t)}catch(n){throw new fg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Oi(e.status)}if(typeof n!="object"||n===null)throw new Vn(e.status,n);let r;try{r=pg(n)}catch{throw new Vn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Oi(e.status)}if(typeof n!="object"||n===null)throw new Vn(e.status,n);return new Uy(n)}throw e.body!==null&&await e.body.cancel(),new Oi(e.status)}async function qy(t){let e;try{e=await fetch(t)}catch(n){throw new fg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Vn(e.status,null)}if(typeof n!="object"||n===null)throw new Vn(e.status,n);let r;try{r=pg(n)}catch{throw new Vn(e.status,n)}throw r}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new Oi(e.status)}function pg(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,r=null,i=null;if("error_description"in t){if(typeof t.error_description!="string")throw new Error("Invalid data");n=t.error_description}if("error_uri"in t){if(typeof t.error_uri!="string")throw new Error("Invalid data");r=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");i=t.state}return new Dy(e,n,r,i)}class fg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class Dy extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);ee(this,"code");ee(this,"description");ee(this,"uri");ee(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Oi extends Error{constructor(n){super("Unexpected error response");ee(this,"status");this.status=n}}class Vn extends Error{constructor(n,r){super("Unexpected error response body");ee(this,"status");ee(this,"data");this.status=n,this.data=r}}class Ll{constructor(e,n,r){ee(this,"clientId");ee(this,"clientPassword");ee(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const o=new URL(e);if(o.searchParams.set("response_type","code"),o.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&o.searchParams.set("redirect_uri",this.redirectURI),o.searchParams.set("state",n),r===Fr.S256){const c=Vy(i);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else r===Fr.Plain&&(o.searchParams.set("code_challenge_method","plain"),o.searchParams.set("code_challenge",i));return s.length>0&&o.searchParams.set("scope",s.join(" ")),o}async validateAuthorizationCode(e,n,r){const i=new URLSearchParams;i.set("grant_type","authorization_code"),i.set("code",n),this.redirectURI!==null&&i.set("redirect_uri",this.redirectURI),r!==null&&i.set("code_verifier",r),this.clientPassword===null&&i.set("client_id",this.clientId);const s=Ir(e,i);if(this.clientPassword!==null){const c=ta(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await zs(s)}async refreshAccessToken(e,n,r){const i=new URLSearchParams;i.set("grant_type","refresh_token"),i.set("refresh_token",n),this.clientPassword===null&&i.set("client_id",this.clientId),r.length>0&&i.set("scope",r.join(" "));const s=Ir(e,i);if(this.clientPassword!==null){const c=ta(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await zs(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Ir(e,r);if(this.clientPassword!==null){const s=ta(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await qy(i)}}var Fr;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(Fr||(Fr={}));var lp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(lp||(lp={}));var up;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(up||(up={}));function Cr(t){return Fy(t,Hy,js.None)}function Fy(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===js.Include&&(r+="=")}return r}const Hy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var js;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(js||(js={}));var dp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(dp||(dp={}));function Ky(t,e,n){const r=Cr(new TextEncoder().encode(t)),i=Cr(new TextEncoder().encode(e)),s=Cr(n);return r+"."+i+"."+s}function Wy(t,e){const n=Cr(new TextEncoder().encode(t)),r=Cr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const Gy="https://appleid.apple.com/auth/authorize",Jy="https://appleid.apple.com/auth/token";class hg{constructor(e,n,r,i,s){ee(this,"clientId");ee(this,"teamId");ee(this,"keyId");ee(this,"pkcs8PrivateKey");ee(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(Gy);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId);const r=await this.createClientSecret();n.set("client_secret",r);const i=Ir(Jy,n);return await zs(i)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),r=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),i=JSON.stringify({iss:this.teamId,exp:n+5*60,aud:["https://appleid.apple.com"],sub:this.clientId,iat:n}),s=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,Wy(r,i)));return Ky(r,i,s)}}const Zy="https://www.facebook.com/v16.0/dialog/oauth",Yy="https://graph.facebook.com/v16.0/oauth/access_token";class gg{constructor(e,n,r){ee(this,"clientId");ee(this,"clientSecret");ee(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(Zy);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId),n.set("client_secret",this.clientSecret);const r=Ir(Yy,n);return await zs(r)}}const Xy="https://accounts.google.com/o/oauth2/v2/auth",pp="https://oauth2.googleapis.com/token",Qy="https://oauth2.googleapis.com/revoke";let mg=class{constructor(e,n,r){ee(this,"client");this.client=new Ll(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(Xy,e,Fr.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(pp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(pp,e,[])}async revokeToken(e){await this.client.revokeToken(Qy,e)}};class Ul{constructor(e,n){ee(this,"value");ee(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Ul(Math.round(this.milliseconds()*e),"ms")}}async function fp(t,e,n,r){const i={alg:t,typ:"JWT",...r==null?void 0:r.headers},s={...n};(r==null?void 0:r.audiences)!==void 0&&(s.aud=r.audiences),(r==null?void 0:r.subject)!==void 0&&(s.sub=r.subject),(r==null?void 0:r.issuer)!==void 0&&(s.iss=r.issuer),(r==null?void 0:r.jwtId)!==void 0&&(s.jti=r.jwtId),(r==null?void 0:r.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+r.expiresIn.seconds()),(r==null?void 0:r.notBefore)!==void 0&&(s.nbf=Math.floor(r.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const o=new TextEncoder,c=pn.encode(o.encode(JSON.stringify(i)),{includePadding:!1}),l=pn.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),u=o.encode([c,l].join(".")),p=await tv(t).sign(e,u),h=pn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,h].join(".")}function ev(t){const e=t.split(".");return e.length!==3?null:e}function Vl(t){const e=ev(t);if(!e)return null;const n=new TextDecoder,r=pn.decode(e[0],{strict:!1}),i=pn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!nv(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const o=JSON.parse(n.decode(i));if(typeof o!="object"||o===null)return null;const c={algorithm:s.alg,expiresAt:null,subject:null,issuedAt:null,issuer:null,jwtId:null,audiences:null,notBefore:null};if("exp"in o){if(typeof o.exp!="number")return null;c.expiresAt=new Date(o.exp*1e3)}if("iss"in o){if(typeof o.iss!="string")return null;c.issuer=o.iss}if("sub"in o){if(typeof o.sub!="string")return null;c.subject=o.sub}if("aud"in o)if(Array.isArray(o.aud)){for(const l of o.aud)if(typeof l!="string")return null;c.audiences=o.aud}else{if(typeof o.aud!="string")return null;c.audiences=[o.aud]}if("nbf"in o){if(typeof o.nbf!="number")return null;c.notBefore=new Date(o.nbf*1e3)}if("iat"in o){if(typeof o.iat!="number")return null;c.issuedAt=new Date(o.iat*1e3)}if("jti"in o){if(typeof o.jti!="string")return null;c.jwtId=o.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...o},parts:e,...c}}function tv(t){return new ry(rv[t])}function nv(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const rv={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"},Oo=a.z.object({iss:a.z.string().url(),sub:a.z.string(),aud:a.z.string(),exp:a.z.number(),email:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),name:a.z.string().optional(),iat:a.z.number(),auth_time:a.z.number().optional(),nonce:a.z.string().optional(),acr:a.z.string().optional(),amr:a.z.array(a.z.string()).optional(),azp:a.z.string().optional(),at_hash:a.z.string().optional(),c_hash:a.z.string().optional()}).passthrough();Oo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function iv(t){return t.ISSUER}function St(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function Ne(t){return t.OAUTH_API_URL||t.ISSUER}function _g(t){const{options:e}=t;if(!e||!e.client_id||!e.team_id||!e.kid||!e.app_secret)throw new Error("Missing required Apple authentication parameters");const n=Buffer.from(e.app_secret,"utf-8"),r=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),i=Uint8Array.from(Buffer.from(r,"base64"));return n.fill(0),{options:e,keyArray:i}}async function sv(t,e){var l,u;const{options:n,keyArray:r}=_g(e),i=new hg(n.client_id,n.team_id,n.kid,r,`${Ne(t.env)}callback`),s=qe(),o=await i.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((u=n.scope)==null?void 0:u.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function ov(t,e,n){const{options:r,keyArray:i}=_g(e),o=await new hg(r.client_id,r.team_id,r.kid,i,`${Ne(t.env)}callback`).validateAuthorizationCode(n),c=Vl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Oo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const av=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:sv,validateAuthorizationCodeAndGetUser:ov},Symbol.toStringTag,{value:"Module"}));async function cv(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new gg(n.client_id,n.client_secret,`${Ne(t.env)}callback`),i=qe();return{redirectUrl:r.createAuthorizationURL(i,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:i}}async function lv(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new gg(r.client_id,r.client_secret,`${Ne(t.env)}callback`).validateAuthorizationCode(n),o=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!o.ok)throw new Error("Failed to fetch user info");const c=await o.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const uv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:cv,validateAuthorizationCodeAndGetUser:lv},Symbol.toStringTag,{value:"Module"}));async function dv(t,e){var c;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required Google authentication parameters");const r=new mg(n.client_id,n.client_secret,`${Ne(t.env)}callback`),i=qe(),s=My();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function pv(t,e,n,r){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret||!r)throw new Error("Missing required authentication parameters");const o=await new mg(i.client_id,i.client_secret,`${Ne(t.env)}callback`).validateAuthorizationCode(n,r);console.log("got here");const c=Vl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Oo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const fv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:dv,validateAuthorizationCodeAndGetUser:pv},Symbol.toStringTag,{value:"Module"}));async function hv(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Ll(n.client_id,n.client_secret,`${Ne(t.env)}callback`),i=qe(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((o=n.scope)==null?void 0:o.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:i}}async function gv(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new Ll(r.client_id,r.client_secret,`${Ne(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=Vl(s.idToken());if(!o)throw new Error("Invalid ID token");const c=Oo.parse(o.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const l=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!l.ok)throw new O(400,{message:"Failed to get user from vipps"});return await l.json()}const mv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:hv,validateAuthorizationCodeAndGetUser:gv},Symbol.toStringTag,{value:"Module"}));function yg(t,e){const n=t.env.STRATEGIES||{},i={apple:av,facebook:uv,"google-oauth2":fv,vipps:mv,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Bo(t,e){const n=await t.data.clients.get(e);if(!n)throw new O(403,{message:"Client not found"});const r=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,i=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},o=i.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(h=>h.name===c.name);return l!=null&&l.options?Mt.parse({...l||{},...c,options:{...l.options||{},...c.options}}):c}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${St(t)}login`],allowed_logout_urls:[...(r==null?void 0:r.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(r==null?void 0:r.callbacks)||[],...n.callbacks||[],`${St(t)}info`],connections:o,domains:[...n.domains||[],...(r==null?void 0:r.domains)||[]],tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}function To(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return _v(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function _v(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const r=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${r}$`).test(t.pathname))return!1}else if(t.pathname!==e.pathname)return!1;if(e.hostname.startsWith("*.")&&e.hostname.split(".").length>2&&["http:","https:"].includes(e.protocol)){const r=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(r)}return t.hostname===e.hostname}function yv(t){try{const n=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(t);if(!n||!n[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(n[1].replace(/\s/g,"")),r=>r.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function vv(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await ag(n);return pn.encode(new Uint8Array(r),{includePadding:!1})}function vg(t,e,n){const r=[];return r.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&r.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&r.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&r.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&r.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&r.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&r.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&r.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&r.push(["SameSite","Strict"]),n!=null&&n.secure&&r.push(["Secure"]),r.map(i=>i.join("=")).join("; ")}function wv(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],o=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(o))}return e}function Ml(t){return`${t}-${Cy}`}function wg(t,e){return e?(console.log("cookieHeaders",e),wv(e).get(Ml(t))):void 0}function bv(t){const e={path:"/",httpOnly:!0,secure:!0,maxAge:0};return vg(Ml(t),"",{...e,sameSite:"none"})}function bg(t,e){const n={path:"/",httpOnly:!0,secure:!0,maxAge:jo};return vg(Ml(t),e,{...n,sameSite:"none"})}var ql={},Po={};(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",r="["+e+"]["+n+"]*",i=new RegExp("^"+r+"$"),s=function(c,l){const u=[];let p=l.exec(c);for(;p;){const h=[];h.startIndex=l.lastIndex-p[0].length;const m=p.length;for(let y=0;y<m;y++)h.push(p[y]);u.push(h),p=l.exec(c)}return u},o=function(c){const l=i.exec(c);return!(l===null||typeof l>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,l,u){if(l){const p=Object.keys(l),h=p.length;for(let m=0;m<h;m++)u==="strict"?c[p[m]]=[l[p[m]]]:c[p[m]]=l[p[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=o,t.getAllMatches=s,t.nameRegexp=r})(Po);const Dl=Po,kv={allowBooleanAttributes:!1,unpairedTags:[]};ql.validate=function(t,e){e=Object.assign({},kv,e);const n=[];let r=!1,i=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=gp(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=mp(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let l="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
|
|
126
|
+
`&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!$v(l)){let h;return l.trim().length===0?h="Invalid space after '<'.":h="Tag '"+l+"' is an invalid name.",we("InvalidTag",h,Pe(t,s))}const u=Av(t,s);if(u===!1)return we("InvalidAttr","Attributes for '"+l+"' have open quote.",Pe(t,s));let p=u.value;if(s=u.index,p[p.length-1]==="/"){const h=s-p.length;p=p.substring(0,p.length-1);const m=_p(p,e);if(m===!0)r=!0;else return we(m.err.code,m.err.msg,Pe(t,h+m.err.line))}else if(c)if(u.tagClosed){if(p.trim().length>0)return we("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Pe(t,o));if(n.length===0)return we("InvalidTag","Closing tag '"+l+"' has not been opened.",Pe(t,o));{const h=n.pop();if(l!==h.tagName){let m=Pe(t,h.tagStartPos);return we("InvalidTag","Expected closing tag '"+h.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",Pe(t,o))}n.length==0&&(i=!0)}}else return we("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Pe(t,s));else{const h=_p(p,e);if(h!==!0)return we(h.err.code,h.err.msg,Pe(t,s-p.length+h.err.line));if(i===!0)return we("InvalidXml","Multiple possible root nodes found.",Pe(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:o}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=mp(t,s);continue}else if(t[s+1]==="?"){if(s=gp(t,++s),s.err)return s}else break;else if(t[s]==="&"){const h=Cv(t,s);if(h==-1)return we("InvalidChar","char '&' is not expected.",Pe(t,s));s=h}else if(i===!0&&!hp(t[s]))return we("InvalidXml","Extra text at the end",Pe(t,s));t[s]==="<"&&s--}}else{if(hp(t[s]))continue;return we("InvalidChar","char '"+t[s]+"' is not expected.",Pe(t,s))}if(r){if(n.length==1)return we("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Pe(t,n[0].tagStartPos));if(n.length>0)return we("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return we("InvalidXml","Start tag expected.",1);return!0};function hp(t){return t===" "||t===" "||t===`
|
|
127
|
+
`||t==="\r"}function gp(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return we("InvalidXml","XML declaration allowed only at the start of the document.",Pe(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function mp(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 xv='"',Sv="'";function Av(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===xv||t[e]===Sv)r===""?r=t[e]:r!==t[e]||(r="");else if(t[e]===">"&&r===""){i=!0;break}n+=t[e]}return r!==""?!1:{value:n,index:e,tagClosed:i}}const Ev=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function _p(t,e){const n=Dl.getAllMatches(t,Ev),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return we("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",_r(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return we("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",_r(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return we("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",_r(n[i]));const s=n[i][2];if(!Nv(s))return we("InvalidAttr","Attribute '"+s+"' is an invalid name.",_r(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return we("InvalidAttr","Attribute '"+s+"' is repeated.",_r(n[i]))}return!0}function Iv(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 Cv(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Iv(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 we(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function Nv(t){return Dl.isName(t)}function $v(t){return Dl.isName(t)}function Pe(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function _r(t){return t.startIndex+t[1].length}var Fl={};const kg={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}},zv=function(t){return Object.assign({},kg,t)};Fl.buildOptions=zv;Fl.defaultOptions=kg;class jv{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 Ov=jv;const Bv=Po;function Tv(t,e){const n={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let r=1,i=!1,s=!1,o="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&Lv(t,e)){e+=7;let c,l;[c,l,e]=Pv(t,e+1),l.indexOf("&")===-1&&(n[qv(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(i&&Uv(t,e))e+=8;else if(i&&Vv(t,e))e+=8;else if(i&&Mv(t,e))e+=9;else if(Rv)s=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?i=!0:o+=t[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:e}}function Pv(t,e){let n="";for(;e<t.length&&t[e]!=="'"&&t[e]!=='"';e++)n+=t[e];if(n=n.trim(),n.indexOf(" ")!==-1)throw new Error("External entites are not supported");const r=t[e++];let i="";for(;e<t.length&&t[e]!==r;e++)i+=t[e];return[n,i,e]}function Rv(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function Lv(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="N"&&t[e+4]==="T"&&t[e+5]==="I"&&t[e+6]==="T"&&t[e+7]==="Y"}function Uv(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="L"&&t[e+4]==="E"&&t[e+5]==="M"&&t[e+6]==="E"&&t[e+7]==="N"&&t[e+8]==="T"}function Vv(t,e){return t[e+1]==="!"&&t[e+2]==="A"&&t[e+3]==="T"&&t[e+4]==="T"&&t[e+5]==="L"&&t[e+6]==="I"&&t[e+7]==="S"&&t[e+8]==="T"}function Mv(t,e){return t[e+1]==="!"&&t[e+2]==="N"&&t[e+3]==="O"&&t[e+4]==="T"&&t[e+5]==="A"&&t[e+6]==="T"&&t[e+7]==="I"&&t[e+8]==="O"&&t[e+9]==="N"}function qv(t){if(Bv.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var Dv=Tv;const Fv=/^[-+]?0x[a-fA-F0-9]+$/,Hv=/^([\-\+])?(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 Kv={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Wv(t,e={}){if(e=Object.assign({},Kv,e),!t||typeof t!="string")return t;let n=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(n))return t;if(e.hex&&Fv.test(n))return Number.parseInt(n,16);{const r=Hv.exec(n);if(r){const i=r[1],s=r[2];let o=Gv(r[3]);const c=r[4]||r[6];if(!e.leadingZeros&&s.length>0&&i&&n[2]!==".")return t;if(!e.leadingZeros&&s.length>0&&!i&&n[1]!==".")return t;{const l=Number(n),u=""+l;return u.search(/[eE]/)!==-1||c?e.eNotation?l:t:n.indexOf(".")!==-1?u==="0"&&o===""||u===o||i&&u==="-"+o?l:t:s?o===u||i+o===u?l:t:n===u||n===i+u?l:t}}else return t}}function Gv(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}var Jv=Wv;function Zv(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 xg=Zv;const Sg=Po,yr=Ov,Yv=Dv,Xv=Jv,Qv=xg;let ew=class{constructor(e){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,r)=>String.fromCharCode(Number.parseInt(r,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,16))}},this.addExternalEntities=tw,this.parseXml=ow,this.parseTextData=nw,this.resolveNameSpace=rw,this.buildAttributesMap=sw,this.isItStopNode=uw,this.replaceEntitiesValue=cw,this.readStopNodeData=pw,this.saveTextToParentTag=lw,this.addChild=aw,this.ignoreAttributesFn=Qv(this.options.ignoreAttributes)}};function tw(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function nw(t,e,n,r,i,s,o){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){o||(t=this.replaceEntitiesValue(t));const c=this.options.tagValueProcessor(e,t,n,i,s);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?Pc(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Pc(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function rw(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 iw=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function sw(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=Sg.getAllMatches(t,iw),i=r.length,s={};for(let o=0;o<i;o++){const c=this.resolveNameSpace(r[o][1]);if(this.ignoreAttributesFn(c,e))continue;let l=r[o][4],u=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(u=this.options.transformAttributeName(u)),u==="__proto__"&&(u="#__proto__"),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);const p=this.options.attributeValueProcessor(c,l,e);p==null?s[u]=l:typeof p!=typeof l||p!==l?s[u]=p:s[u]=Pc(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[u]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const o={};return o[this.options.attributesGroupName]=s,o}return s}}const ow=function(t){t=t.replace(/\r\n?/g,`
|
|
128
|
+
`);const e=new yr("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=ln(t,">",s,"Closing Tag is not closed.");let l=t.substring(s+2,c).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&&(r=this.saveTextToParentTag(r,n,i));const u=i.substring(i.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let p=0;u&&this.options.unpairedTags.indexOf(u)!==-1?(p=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=i.lastIndexOf("."),i=i.substring(0,p),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=Tc(t,s,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const l=new yr(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,l,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=ln(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=Yv(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=ln(t,"]]>",s,"CDATA is not closed.")-2,l=t.substring(s+9,c);r=this.saveTextToParentTag(r,n,i);let u=this.parseTextData(l,n.tagname,i,!0,!1,!0,!0);u==null&&(u=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,u),s=c+2}else{let c=Tc(t,s,this.options.removeNSPrefix),l=c.tagName;const u=c.rawTagName;let p=c.tagExp,h=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,i,!1));const y=n;if(y&&this.options.unpairedTags.indexOf(y.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),l!==e.tagname&&(i+=i?"."+l:l),this.isItStopNode(this.options.stopNodes,i,l)){let f="";if(p.length>0&&p.lastIndexOf("/")===p.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),s=c.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)s=c.closeIndex;else{const v=this.readStopNodeData(t,u,m+1);if(!v)throw new Error(`Unexpected end of ${u}`);s=v.i,f=v.tagContent}const _=new yr(l);l!==p&&h&&(_[":@"]=this.buildAttributesMap(p,i,l)),f&&(f=this.parseTextData(f,l,i,!0,h,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,f),this.addChild(n,_,i)}else{if(p.length>0&&p.lastIndexOf("/")===p.length-1){l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),this.options.transformTagName&&(l=this.options.transformTagName(l));const f=new yr(l);l!==p&&h&&(f[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,f,i),i=i.substr(0,i.lastIndexOf("."))}else{const f=new yr(l);this.tagsNodeStack.push(n),l!==p&&h&&(f[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,f,i),n=f}r="",s=m}}else r+=t[s];return e.child};function aw(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const cw=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const n=this.docTypeEntities[e];t=t.replace(n.regx,n.val)}for(let e in this.lastEntities){const n=this.lastEntities[e];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const n=this.htmlEntities[e];t=t.replace(n.regex,n.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function lw(t,e,n,r){return t&&(r===void 0&&(r=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function uw(t,e,n){const r="*."+n;for(const i in t){const s=t[i];if(r===s||e===s)return!0}return!1}function dw(t,e,n=">"){let r,i="";for(let s=e;s<t.length;s++){let o=t[s];if(r)o===r&&(r="");else if(o==='"'||o==="'")r=o;else if(o===n[0])if(n[1]){if(t[s+1]===n[1])return{data:i,index:s}}else return{data:i,index:s};else o===" "&&(o=" ");i+=o}}function ln(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function Tc(t,e,n,r=">"){const i=dw(t,e+1,r);if(!i)return;let s=i.data;const o=i.index,c=s.search(/\s/);let l=s,u=!0;c!==-1&&(l=s.substring(0,c),s=s.substring(c+1).trimStart());const p=l;if(n){const h=l.indexOf(":");h!==-1&&(l=l.substr(h+1),u=l!==i.data.substr(h+1))}return{tagName:l,tagExp:s,closeIndex:o,attrExpPresent:u,rawTagName:p}}function pw(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=ln(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(i--,i===0))return{tagContent:t.substring(r,n),i:s};n=s}else if(t[n+1]==="?")n=ln(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=ln(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=ln(t,"]]>",n,"StopNode is not closed.")-2;else{const s=Tc(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function Pc(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:Xv(t,n)}else return Sg.isExist(t)?t:""}var fw=ew,Ag={};function hw(t,e){return Eg(t,e)}function Eg(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const o=t[s],c=gw(o);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)r===void 0?r=o[c]:r+=""+o[c];else{if(c===void 0)continue;if(o[c]){let u=Eg(o[c],e,l);const p=_w(u,e);o[":@"]?mw(u,o[":@"],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=""),i[c]!==void 0&&i.hasOwnProperty(c)?(Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(u)):e.isArray(c,l,p)?i[c]=[u]:i[c]=u}}}return typeof r=="string"?r.length>0&&(i[e.textNodeName]=r):r!==void 0&&(i[e.textNodeName]=r),i}function gw(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function mw(t,e,n,r){if(e){const i=Object.keys(e),s=i.length;for(let o=0;o<s;o++){const c=i[o];r.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function _w(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return!!(r===0||r===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}Ag.prettify=hw;const{buildOptions:yw}=Fl,vw=fw,{prettify:ww}=Ag,bw=ql;let kw=class{constructor(e){this.externalEntities={},this.options=yw(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 s=bw.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new vw(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:ww(i,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 xw=kw;const Sw=`
|
|
129
|
+
`;function Aw(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=Sw),Ig(t,e,"",n)}function Ig(t,e,n,r){let i="",s=!1;for(let o=0;o<t.length;o++){const c=t[o],l=Ew(c);if(l===void 0)continue;let u="";if(n.length===0?u=l:u=`${n}.${l}`,l===e.textNodeName){let f=c[l];Iw(u,e)||(f=e.tagValueProcessor(l,f),f=Cg(f,e)),s&&(i+=r),i+=f,s=!1;continue}else if(l===e.cdataPropName){s&&(i+=r),i+=`<![CDATA[${c[l][0][e.textNodeName]}]]>`,s=!1;continue}else if(l===e.commentPropName){i+=r+`<!--${c[l][0][e.textNodeName]}-->`,s=!0;continue}else if(l[0]==="?"){const f=yp(c[":@"],e),_=l==="?xml"?"":r;let v=c[l][0][e.textNodeName];v=v.length!==0?" "+v:"",i+=_+`<${l}${v}${f}?>`,s=!0;continue}let p=r;p!==""&&(p+=e.indentBy);const h=yp(c[":@"],e),m=r+`<${l}${h}`,y=Ig(c[l],e,u,p);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?i+=m+">":i+=m+"/>":(!y||y.length===0)&&e.suppressEmptyNode?i+=m+"/>":y&&y.endsWith(">")?i+=m+`>${y}${r}</${l}>`:(i+=m+">",y&&r!==""&&(y.includes("/>")||y.includes("</"))?i+=r+e.indentBy+y+r:i+=y,i+=`</${l}>`),s=!0}return i}function Ew(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(t.hasOwnProperty(r)&&r!==":@")return r}}function yp(t,e){let n="";if(t&&!e.ignoreAttributes)for(let r in t){if(!t.hasOwnProperty(r))continue;let i=e.attributeValueProcessor(r,t[r]);i=Cg(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function Iw(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===t||e.stopNodes[r]==="*."+n)return!0;return!1}function Cg(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const r=e.entities[n];t=t.replace(r.regex,r.val)}return t}var Cw=Aw;const Nw=Cw,$w=xg,zw={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 tn(t){this.options=Object.assign({},zw,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=$w(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Bw),this.processTextOrObjNode=jw,this.options.format?(this.indentate=Ow,this.tagEndChar=`>
|
|
130
130
|
`,this.newLine=`
|
|
131
|
-
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}tn.prototype.build=function(t){return this.options.preserveOrder?
|
|
131
|
+
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}tn.prototype.build=function(t){return this.options.preserveOrder?Nw(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};tn.prototype.j2x=function(t,e,n){let r="",i="";const s=n.join(".");for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(typeof t[o]>"u")this.isAttribute(o)&&(i+="");else if(t[o]===null)this.isAttribute(o)?i+="":o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)i+=this.buildTextValNode(t[o],o,"",e);else if(typeof t[o]!="object"){const c=this.isAttribute(o);if(c&&!this.ignoreAttributesFn(c,s))r+=this.buildAttrPairStr(c,""+t[o]);else if(!c)if(o===this.options.textNodeName){let l=this.options.tagValueProcessor(o,""+t[o]);i+=this.replaceEntitiesValue(l)}else i+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){const c=t[o].length;let l="",u="";for(let p=0;p<c;p++){const h=t[o][p];if(!(typeof h>"u"))if(h===null)o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof h=="object")if(this.options.oneListGroup){const m=this.j2x(h,e+1,n.concat(o));l+=m.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(u+=m.attrStr)}else l+=this.processTextOrObjNode(h,o,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(o,h);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(h,o,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,o,u,e)),i+=l}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const c=Object.keys(t[o]),l=c.length;for(let u=0;u<l;u++)r+=this.buildAttrPairStr(c[u],""+t[o][c[u]])}else i+=this.processTextOrObjNode(t[o],o,e,n);return{attrStr:r,val:i}};tn.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 jw(t,e,n,r){const i=this.j2x(t,n+1,r.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,i.attrStr,n):this.buildObjectNode(i.val,e,i.attrStr,n)}tn.prototype.buildObjectNode=function(t,e,n,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+n+"?"+this.tagEndChar:this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let i="</"+e+this.tagEndChar,s="";return e[0]==="?"&&(s="?",i=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+n+s+">"+t+i:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+n+s+this.tagEndChar+t+this.indentate(r)+i}};tn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};tn.prototype.buildTextValNode=function(t,e,n,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+n+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),i===""?this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+n+">"+i+"</"+e+this.tagEndChar}};tn.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 Ow(t){return this.options.indentBy.repeat(t)}function Bw(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var Tw=tn;const Pw=ql,Rw=xw,Lw=Tw;var Uw={XMLParser:Rw,XMLValidator:Pw,XMLBuilder:Lw};function Vw(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
|
|
132
132
|
<!DOCTYPE html>
|
|
133
133
|
<html>
|
|
134
134
|
<body onload="document.forms[0].submit()">
|
|
@@ -146,7 +146,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
146
146
|
}};
|
|
147
147
|
<\/script>
|
|
148
148
|
</body>
|
|
149
|
-
</html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function Vw(t,e,n,r,i){var m,y,f;if(!n.redirect_uri)throw new O(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new O(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new O(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:o,audience:c}=e.addons.samlp,l=n.state||"";if(!o||!l||!r||!n.state)throw new O(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),h=await Mw(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:u.requestId,userId:((f=(y=r.app_metadata)==null?void 0:y.vimeo)==null?void 0:f.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Uw(p.toString(),h,u.relayState)}async function Mw(t,e){const n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),i=e.issueInstant||n,s=e.sessionNotOnOrAfter||r,o=e.responseId||`_${qe()}`,c=e.assertionId||`_${qe()}`,l=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":s}},{"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":c,"@_IssueInstant":i,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new Lw.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(l);if(e.signature){const m=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:p,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!m.ok)throw new Error(`Failed to sign SAML response: ${m.status}`);p=await m.text()}return e.encode===!1?p:btoa(p)}function qw(){const t=new Uint8Array(32);return crypto.getRandomValues(t),pn.encode(t,{includePadding:!1})}const vp=["sub","iss","aud","exp","nbf","iat","jti"];async function Hl(t,e){var _,v;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(x=>!x.revoked_at||new Date(x.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new O(500,{message:"No signing key available"});const u=_v(l.pkcs7),p={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:t.env.ISSUER,tenant_id:t.var.tenant_id,sid:s},h=r&&((_=n.scope)!=null&&_.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:t.env.ISSUER,sid:s,nonce:n.nonce,given_name:r.given_name,family_name:r.family_name,nickname:r.nickname,picture:r.picture,locale:r.locale,name:r.name,email:r.email,email_verified:r.email_verified}:void 0;(v=t.env.hooks)!=null&&v.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(x,N)=>{if(vp.includes(x))throw new Error(`Cannot overwrite reserved claim '${x}'`);p[x]=N}},idToken:{setCustomClaim:(x,N)=>{if(vp.includes(x))throw new Error(`Cannot overwrite reserved claim '${x}'`);h&&(h[x]=N)}},access:{deny:x=>{throw new O(400,{message:`Access denied: ${x}`})}}});const m={includeIssuedTimestamp:!0,expiresIn:new Ul(1,"d"),headers:{kid:l.kid}},y=await fp("RS256",u,p,m),f=h?await fp("RS256",u,h,m):void 0;return{access_token:y,refresh_token:e.refresh_token,id_token:f,token_type:"Bearer",expires_in:86400}}async function Dw(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e;return await t.env.data.refreshTokens.create(n.tenant.id,{id:qe(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+jo*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function Cg(t,e){const{user:n,client:r,scope:i,audience:s}=e,o=await t.env.data.sessions.create(r.tenant.id,{id:qe(),user_id:n.user_id,idle_expires_at:new Date(Date.now()+jo*1e3).toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[r.id]}),c=i!=null&&i.split(" ").includes("offline_access")?await Dw(t,{...e,session_id:o.id,scope:i,audience:s}):void 0;return{...o,refresh_token:c}}async function $n(t,e){var h;const{authParams:n,user:r,client:i}=e,s=be(t,{type:me.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(Xe(t,t.env.data.logs.create(i.tenant.id,s)),Xe(t,t.env.data.users.update(i.tenant.id,r.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:r.login_count+1})),e!=null&&e.ticketAuth){if(!e.loginSession)throw new O(500,{message:"Login session not found"});const m=qw(),y=qe(12),f=await t.env.data.codes.create(i.tenant.id,{code_id:qe(),code_type:"ticket",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+$y).toISOString(),code_verifier:[y,m].join("|")});return t.json({login_ticket:f.code_id,co_verifier:m,co_id:y})}let o=e.refreshToken,c=e.sessionId;if(!c){const m=await Cg(t,{user:r,client:i,scope:n.scope,audience:n.audience});c=m.id,o=(h=m.refresh_token)==null?void 0:h.id}if(e.authParams.response_mode===Wt.SAML_POST)return Vw(t,e.client,e.authParams,r,c);const l=await Hl(t,{authParams:n,user:r,client:i,session_id:c,refresh_token:o}),u=new Headers({"set-cookie":wg(i.tenant.id,c)});if(n.response_mode===Wt.WEB_MESSAGE)return t.json(l,{headers:u});if((n.response_type||fn.CODE)===fn.CODE){if(!e.loginSession)throw new O(500,{message:"Login session not found"});const m=await t.env.data.codes.create(i.tenant.id,{code_id:qe(),user_id:r.user_id,code_type:"authorization_code",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+Cy*1e3).toISOString()});u.set("location",`${n.redirect_uri}?state=${e.authParams.state}&code=${m.code_id}`)}return new Response("Redirecting",{status:302,headers:u})}function Fw(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await Ms({userAdapter:t.users,tenant_id:e,email:n.email});return r?(await t.users.create(e,{...n,linked_to:r.user_id}),r):t.users.create(e,n)}}async function Ng(t,e,n){for await(const r of e)if(!(await fetch(r.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const s=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await n.logs.create(t.var.tenant_id,s)}}function Hw(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n);return await Ng(t,i,{tenant_id:n,user:r,trigger_id:"post-user-registration"}),r}}function Kw(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await Ng(t,i,{tenant_id:n,email:r,trigger_id:"pre-user-signup"})}}function Ww(t,e){return async(n,r)=>{let i=await Fw(e)(n,r);return await Hw(t,e)(n,i),i}}async function $g(t,e,n,r){if(e.disable_sign_ups&&!await Ms({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:r})){const s=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});throw await t.env.data.logs.create(e.tenant.id,s),new O(400,{message:"Signups are disabled for this client"})}await Kw(t,n)(t.var.tenant_id||"",r)}function Gw(t,e){return{...e,users:{...e.users,create:Ww(t,e)}}}async function Jw(t,e,n,r){if(!r.state)throw new O(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new O(403,{message:"Connection Not Found"})}let s=await t.env.data.logins.get(e.tenant.id,r.state);s||(s=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:r,...pr(t.req)}));const c=await _g(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.login_id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+Ny*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function wp(t,{code:e,state:n}){var f;const{env:r}=t,i=await r.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!i||!i.connection_id)throw new O(403,{message:"State not found"});const s=await r.data.logins.get(t.var.tenant_id||"",i.login_id);if(!s)throw new O(403,{message:"Session not found"});const o=await Bo(r,s.authParams.client_id);t.set("client_id",o.id),t.set("tenant_id",o.tenant.id);const c=o.connections.find(_=>_.id===i.connection_id);if(!c){const _=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(o.tenant.id,_),new O(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=be(t,{type:me.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(o.tenant.id,_),new O(403,{message:"Redirect URI not defined"})}if(!To(s.authParams.redirect_uri,o.callbacks||[],{allowPathWildcards:!0})){const _=`Invalid redirect URI - ${s.authParams.redirect_uri}`,v=be(t,{type:me.FAILED_LOGIN,description:_});throw await r.data.logs.create(o.tenant.id,v),new O(403,{message:_})}const u=await _g(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:p,...h}=u;t.set("user_id",p);const m=((f=u.email)==null?void 0:f.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);let y=await Jr({userAdapter:r.data.users,tenant_id:o.tenant.id,email:m,provider:c.name});if(!y){try{await $g(t,o,t.env.data,m)}catch(_){const v=_;throw new O(500,{message:`Failed to run preUserSignupHook: ${v.message}`})}y=await r.data.users.create(o.tenant.id,{user_id:`${c.name}|${p}`,email:m,name:m,provider:c.name,connection:c.name,email_verified:!0,last_ip:"",is_social:!0,last_login:new Date().toISOString(),profileData:JSON.stringify(h)}),t.set("user_id",y.user_id)}return $n(t,{client:o,authParams:s.authParams,loginSession:s,user:y})}async function bp(t,e,n,r,i,s){const o=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!o)throw new O(400,{message:"State not found"});const c=await t.env.data.logins.get(t.var.tenant_id,o.login_id);if(!c)throw new O(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new O(400,{message:"Redirect uri not found"});const u=be(t,{type:me.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});Xe(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return Ey(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${St(t.env)}enter-email?state=${c.login_id}&error=${n}`)}const Zw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:o}=t.req.valid("query");if(r)return bp(t,e,r,i,s,o);if(!n)throw new O(400,{message:"Code is required"});return wp(t,{code:n,state:e})}).openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:o}=t.req.valid("form");if(r)return bp(t,e,r,i,s,o);if(!n)throw new O(400,{message:"Code is required"});return wp(t,{code:n,state:e})}),Yw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),returnTo:a.z.string().optional()}),header:a.z.object({cookie:a.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),r=await t.env.data.clients.get(e);if(!r)return t.text("OK");const i=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",r.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!To(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new O(400,{message:"Invalid redirect uri"});const o=t.req.header("cookie");if(o){const l=vg(r.tenant.id,o);if(l){const u=await t.env.data.sessions.get(r.tenant.id,l);if(u){const p=await t.env.data.users.get(r.tenant.id,u.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection))}await t.env.data.sessions.remove(r.tenant.id,l)}}const c=be(t,{type:me.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(r.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":wv(r.tenant.id),location:s}})}),kp=a.z.object({sub:a.z.string(),email:a.z.string().optional(),family_name:a.z.string().optional(),given_name:a.z.string().optional(),email_verified:a.z.boolean()}),Xw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:kp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new O(404,{message:"User not found"});const e=await t.env.data.users.get(t.var.user.tenant_id,t.var.user.sub);if(!e)throw new O(404,{message:"User not found"});return t.json(kp.parse({...e,sub:e.user_id}))}),Qw=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Yp}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async r=>{const s=await new Rl(r.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return Fc.parse({...o,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Si}, stale-while-revalidate=${Si*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:fa}},description:"List of tenants"}}}),async t=>{const e=fa.parse({issuer:rv(t.env),authorization_endpoint:`${Ne(t.env)}authorize`,token_endpoint:`${Ne(t.env)}oauth/token`,device_authorization_endpoint:`${Ne(t.env)}oauth/device/code`,userinfo_endpoint:`${Ne(t.env)}userinfo`,mfa_challenge_endpoint:`${Ne(t.env)}mfa/challenge`,jwks_uri:`${Ne(t.env)}.well-known/jwks.json`,registration_endpoint:`${Ne(t.env)}oidc/register`,revocation_endpoint:`${Ne(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Si}, stale-while-revalidate=${Si*2}, stale-if-error=86400`}})});function Bi(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t.charCodeAt(r)^e.charCodeAt(r);return n===0}const zg=a.z.object({grant_type:a.z.literal("client_credentials"),scope:a.z.string().optional(),client_secret:a.z.string(),client_id:a.z.string(),audience:a.z.string().optional()});async function eb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Invalid client credentials"});if(n.client_secret&&!Bi(n.client_secret,e.client_secret))throw new O(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await Hl(t,{authParams:r,client:n});return t.json(i)}const tb=a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string().optional(),client_secret:a.z.string().optional(),code_verifier:a.z.string().optional()}).refine(t=>"client_secret"in t&&!("code_verifier"in t)||!("client_secret"in t)&&"code_verifier"in t,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function nb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Client not found"});const r=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!r||!r.user_id)throw new O(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new O(403,{message:"Code expired"});if(r.used_at)throw new O(403,{message:"Code already used"});const i=await t.env.data.logins.get(n.tenant.id,r.login_id);if(!i)throw new O(403,{message:"Invalid login"});if("client_secret"in e){const o=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Bi(n.client_secret,e.client_secret)&&!Bi(o==null?void 0:o.client_secret,e.client_secret))throw new O(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const o=await yv(e.code_verifier,i.authParams.code_challenge_method);if(!Bi(o,i.authParams.code_challenge||""))throw new O(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new O(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new O(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),$n(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Wt.WEB_MESSAGE}})}const rb=a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),redirect_uri:a.z.string().optional(),refresh_token:a.z.string()});async function ib(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Client not found"});const r=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(r){if(r.expires_at&&new Date(r.expires_at)<new Date||r.idle_expires_at&&new Date(r.idle_expires_at)<new Date)throw new O(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new O(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const i=await t.env.data.users.get(n.tenant.id,r.user_id);if(!i)throw new O(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const o=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:o.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...r.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return $n(t,{user:i,client:n,refreshToken:r.id,sessionId:r.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Wt.WEB_MESSAGE}})}const xp=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),sb=a.z.union([zg.extend(xp.shape),a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string(),code_verifier:a.z.string().min(43).max(128)}),a.z.object({grant_type:a.z.literal("authorization_code"),code:a.z.string(),redirect_uri:a.z.string().optional(),...xp.shape}),a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),refresh_token:a.z.string(),redirect_uri:a.z.string().optional()})]);function ob(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[r,i]=atob(n).split(":");return{client_id:r,client_secret:i}}return{}}const ab=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:sb}}}},responses:{200:{content:{"application/json":{schema:rf}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=ob(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new O(400,{message:"client_id is required"});switch(e.grant_type){case kr.AuthorizationCode:return nb(t,tb.parse(r));case kr.ClientCredential:return eb(t,zg.parse(r));case kr.RefreshToken:return ib(t,rb.parse(r));default:throw new O(400,{message:"Not implemented"})}});var Kl={exports:{}};const Wl=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],jg=(t,e=Wl,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=t||"";e[0].minDiversity=0,e[0].minLength=0;const i=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&i.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),s.length=r.length;let o=e.filter(c=>s.contains.length>=c.minDiversity).filter(c=>s.length>=c.minLength).sort((c,l)=>l.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,o[0]),s};Kl.exports={passwordStrength:jg,defaultOptions:Wl};var cb=Kl.exports.passwordStrength=jg;Kl.exports.defaultOptions=Wl;function lb(t){return cb(t).id<2?!1:t.length>=8&&/[a-z]/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)}async function Ro(t,e){var i;const n=await t.env.data.emailProviders.get(t.var.tenant_id)||(t.env.DEFAULT_TENANT_ID?await t.env.data.emailProviders.get(t.env.DEFAULT_TENANT_ID):null);if(!n)throw new O(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new O(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function ub(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new O(500,{message:"Tenant not found"});const s=`${St(t.env)}reset-password?state=${r}&code=${n}`,o={vendorName:i.name,lng:i.language||"en"};await Ro(t,{to:e,subject:"Reset your password",html:`Click here to reset your password: ${St(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:s,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:fe("password_reset_title",o),resetPasswordEmailClickToReset:fe("reset_password_email_click_to_reset",o),resetPasswordEmailReset:fe("reset_password_email_reset",o),supportInfo:fe("support_info",o),contactUs:fe("contact_us",o),copyright:fe("copyright",o)}})}async function Og(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new O(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Ro(t,{to:e,subject:fe("code_email_subject",i),html:`Click here to validate your email: ${St(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",magicLink:`${Ne(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:r.primary_color||"",welcomeToYourAccount:fe("welcome_to_your_account",i),linkEmailClickToLogin:fe("link_email_click_to_login",i),linkEmailLogin:fe("link_email_login",i),linkEmailOrEnterCode:fe("link_email_or_enter_code",i),codeValid30Mins:fe("code_valid_30_minutes",i),supportInfo:fe("support_info",i),contactUs:fe("contact_us",i),copyright:fe("copyright",i)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Xe(t,t.env.data.logs.create(r.id,s))}async function Gl(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new O(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Ro(t,{to:e,subject:fe("code_email_subject",i),html:`Click here to validate your email: ${St(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",magicLink:`${Ne(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:r.primary_color||"",welcomeToYourAccount:fe("welcome_to_your_account",i),linkEmailClickToLogin:fe("link_email_click_to_login",i),linkEmailLogin:fe("link_email_login",i),linkEmailOrEnterCode:fe("link_email_or_enter_code",i),codeValid30Mins:fe("code_valid_30_minutes",i),supportInfo:fe("support_info",i),contactUs:fe("contact_us",i),copyright:fe("copyright",i)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Xe(t,t.env.data.logs.create(r.id,s))}async function Bg(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new O(500,{message:"Tenant not found"});const r={vendorName:n.name,lng:n.language||"en"};await Ro(t,{to:e.email,subject:"Validate your email address",html:`Click here to validate your email: ${St(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${St(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:fe("welcome_to_your_account",r),verifyEmailVerify:fe("verify_email_verify",r),supportInfo:fe("support_info",r),contactUs:fe("contact_us",r),copyright:fe("copyright",r)}})}const db=new a.OpenAPIHono().openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string()})}}}},responses:{200:{content:{"application/json":{schema:a.z.object({_id:a.z.string(),email:a.z.string(),email_verified:a.z.boolean(),app_metadata:a.z.object({}),user_metadata:a.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:r}=t.req.valid("json"),i=await t.env.data.clients.get(r);if(!i)throw new O(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!lb(n))throw new O(400,{message:"Password does not meet the requirements"});if(await Jr({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))throw new O(400,{message:"Invalid sign up"});const o=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${Wc()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",o.user_id),t.set("username",o.email),t.set("connection",o.connection);const c=await Kc.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await Bg(t,o);const l=be(t,{type:me.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:o.user_id,email:o.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase())})}}}},responses:{200:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{email:e,client_id:n}=t.req.valid("json"),r=await t.env.data.clients.get(n);if(!r)throw new O(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await Gc({userAdapter:t.env.data.users,tenant_id:r.tenant.id,email:e,provider:"auth2"}))return t.html("If an account with that email exists, we've sent instructions to reset your password.");const s={client_id:n,username:e},o=await t.env.data.logins.create(r.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:s,...pr(t.req)});return await ub(t,e,o.login_id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Os(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}async function Jl(t,e,n,r,i,s){const{env:o}=t,c=await o.data.codes.get(e.tenant.id,i,"otp");if(!c)throw new O(400,{message:"Code not found or expired"});if(c.expires_at<new Date().toISOString())throw new O(400,{message:"Code expired"});const l=await o.data.logins.get(e.tenant.id,c.login_id);if(!l||l.authParams.username!==r)throw new O(400,{message:"Code not found or expired"});const u=pr(t.req);if(l.ip!==u.ip)return t.redirect(`${St(t.env)}invalid-session?state=${l.login_id}`);if(n.redirect_uri&&!To(n.redirect_uri,e.callbacks,{allowPathWildcards:!0}))throw new O(400,{message:`Invalid redirect URI - ${n.redirect_uri}`});const p=await Jr({userAdapter:o.data.users,tenant_id:e.tenant.id,email:r,provider:"email"});if(!p)throw new O(400,{message:"User not found"});return $n(t,{user:p,client:e,loginSession:l,authParams:n,ticketAuth:s})}const pb=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:Dc.omit({client_id:!0})})}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,email:i,send:s,authParams:o}=e,c=await t.env.data.clients.get(r);if(!c)throw new O(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.logins.create(c.tenant.id,{authParams:{...o,client_id:r,username:i},expires_at:new Date(Date.now()+Bc).toISOString(),...pr(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:Os(),code_type:"otp",login_id:l.login_id,expires_at:new Date(Date.now()+Bc).toISOString()});return s==="link"?await Gl(t,i,u.code_id):await Og(t,i,u.code_id),t.html("OK")}).openapi(a.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:a.z.object({scope:a.z.string(),response_type:a.z.nativeEnum(fn),redirect_uri:a.z.string(),state:a.z.string(),nonce:a.z.string().optional(),verification_code:a.z.string(),connection:a.z.string(),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),audience:a.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:s,state:o,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),h=await Bo(e,n);return t.set("client_id",h.id),t.set("tenant_id",h.tenant.id),t.set("connection","email"),Jl(t,h,{client_id:n,redirect_uri:s,state:o,nonce:p,scope:c,audience:l,response_type:u},r,i)});class vr extends O{constructor(n,r){super(n,r);ee(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function Tg(t,e,n,r,i){const{env:s}=t,o=n.username;if(t.set("username",o),!o)throw new O(400,{message:"Username is required"});const c=await Gc({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:o,provider:"auth2"});if(!c){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw Xe(t,t.env.data.logs.create(e.tenant.id,f)),new vr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const l=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!l)throw new vr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",l.user_id);const{password:u}=await s.data.passwords.get(e.tenant.id,c.user_id);if(!await Kc.compare(n.password,u)){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw Xe(t,t.env.data.logs.create(e.tenant.id,f)),new vr(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await s.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${l.user_id}`})).logs.filter(f=>f.type===me.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(f.date)>new Date(Date.now()-1e3*60*5)).length>=3){const f=be(t,{type:me.FAILED_LOGIN,description:"Too many failed login attempts"});throw Xe(t,t.env.data.logs.create(e.tenant.id,f)),new vr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await Bg(t,c);const f=be(t,{type:me.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,f),new vr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const y=be(t,{type:me.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return Xe(t,t.env.data.logs.create(e.tenant.id,y)),$n(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}const fb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:a.z.string(),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),realm:a.z.enum(["email"]),scope:a.z.string().optional()}),a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string(),realm:a.z.enum(["Username-Password-Authentication"]),scope:a.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:r}=e;t.set("username",r);const i=await t.env.data.clients.get(n);if(!i)throw new O(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const s=r.toLocaleLowerCase();if("otp"in e)return Jl(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const o=await t.env.data.logins.create(i.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:{client_id:n,username:s},...pr(t.req)});return Tg(t,i,{username:s,password:e.password,client_id:n},o,!0)}else throw new O(400,{message:"Code or password required"})});function hb(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=na(t))==null?void 0:r.host)??null;if(!n)return!1;for(const o of e){let c;if(o.startsWith("http://")||o.startsWith("https://")?c=((i=na(o))==null?void 0:i.host)??null:c=((s=na("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function na(t){try{return new URL(t)}catch{return null}}async function gb({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const o=await t.env.data.logins.create(n.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:r,...pr(t.req)});if(e&&s){const c=await t.env.data.users.get(n.tenant.id,e.user_id);if((c==null?void 0:c.email)===s)return $n(t,{client:n,loginSession:o,authParams:r,user:c,sessionId:e.id})}if(i==="email"&&s){const c=Os();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:o.login_id,expires_at:new Date(Date.now()+qr*1e3).toISOString()}),await Gl(t,s,c),t.redirect(`/u/enter-code?state=${o.login_id}`)}return e?t.redirect(`/u/check-account?state=${o.login_id}`):t.redirect(`/u/enter-email?state=${o.login_id}`)}function mb(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new O(403,{message:"Invalid realm"})}async function _b(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const o=await s.data.codes.get(e,n,"ticket");if(!o||o.used_at)throw new O(403,{message:"Ticket not found"});const c=await s.data.logins.get(e,o.login_id);if(!c||!c.authParams.username)throw new O(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new O(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=mb(i);let p=await Jr({userAdapter:s.data.users,tenant_id:e,email:c.authParams.username,provider:u});p||(p=await s.data.users.create(e,{user_id:`email|${Wc()}`,email:c.authParams.username,name:c.authParams.username,provider:"email",connection:"email",email_verified:!0,is_social:!1,last_ip:"",last_login:new Date().toISOString()})),t.set("username",p.email),t.set("user_id",p.user_id);const h=await Cg(t,{user:p,client:l,scope:r.scope,audience:r.audience});return $n(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:h.id,user:p,client:l})}async function Sp(t,e){return`<!DOCTYPE html>
|
|
149
|
+
</html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function Mw(t,e,n,r,i){var m,y,f;if(!n.redirect_uri)throw new O(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new O(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new O(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:o,audience:c}=e.addons.samlp,l=n.state||"";if(!o||!l||!r||!n.state)throw new O(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),h=await qw(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:u.requestId,userId:((f=(y=r.app_metadata)==null?void 0:y.vimeo)==null?void 0:f.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Vw(p.toString(),h,u.relayState)}async function qw(t,e){const n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),i=e.issueInstant||n,s=e.sessionNotOnOrAfter||r,o=e.responseId||`_${qe()}`,c=e.assertionId||`_${qe()}`,l=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":s}},{"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":c,"@_IssueInstant":i,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new Uw.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(l);if(e.signature){const m=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:p,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!m.ok)throw new Error(`Failed to sign SAML response: ${m.status}`);p=await m.text()}return e.encode===!1?p:btoa(p)}function Dw(){const t=new Uint8Array(32);return crypto.getRandomValues(t),pn.encode(t,{includePadding:!1})}const vp=["sub","iss","aud","exp","nbf","iat","jti"];async function Hl(t,e){var _,v;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(x=>!x.revoked_at||new Date(x.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new O(500,{message:"No signing key available"});const u=yv(l.pkcs7),p={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:t.env.ISSUER,tenant_id:t.var.tenant_id,sid:s},h=r&&((_=n.scope)!=null&&_.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:t.env.ISSUER,sid:s,nonce:n.nonce,given_name:r.given_name,family_name:r.family_name,nickname:r.nickname,picture:r.picture,locale:r.locale,name:r.name,email:r.email,email_verified:r.email_verified}:void 0;(v=t.env.hooks)!=null&&v.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(x,N)=>{if(vp.includes(x))throw new Error(`Cannot overwrite reserved claim '${x}'`);p[x]=N}},idToken:{setCustomClaim:(x,N)=>{if(vp.includes(x))throw new Error(`Cannot overwrite reserved claim '${x}'`);h&&(h[x]=N)}},access:{deny:x=>{throw new O(400,{message:`Access denied: ${x}`})}}});const m={includeIssuedTimestamp:!0,expiresIn:new Ul(1,"d"),headers:{kid:l.kid}},y=await fp("RS256",u,p,m),f=h?await fp("RS256",u,h,m):void 0;return{access_token:y,refresh_token:e.refresh_token,id_token:f,token_type:"Bearer",expires_in:86400}}async function Fw(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e;return await t.env.data.refreshTokens.create(n.tenant.id,{id:qe(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+jo*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function Ng(t,e){const{user:n,client:r,scope:i,audience:s}=e,o=await t.env.data.sessions.create(r.tenant.id,{id:qe(),user_id:n.user_id,idle_expires_at:new Date(Date.now()+jo*1e3).toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[r.id]}),c=i!=null&&i.split(" ").includes("offline_access")?await Fw(t,{...e,session_id:o.id,scope:i,audience:s}):void 0;return{...o,refresh_token:c}}async function $n(t,e){var h;const{authParams:n,user:r,client:i}=e,s=be(t,{type:me.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(Xe(t,t.env.data.logs.create(i.tenant.id,s)),Xe(t,t.env.data.users.update(i.tenant.id,r.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:r.login_count+1})),e!=null&&e.ticketAuth){if(!e.loginSession)throw new O(500,{message:"Login session not found"});const m=Dw(),y=qe(12),f=await t.env.data.codes.create(i.tenant.id,{code_id:qe(),code_type:"ticket",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+zy).toISOString(),code_verifier:[y,m].join("|")});return t.json({login_ticket:f.code_id,co_verifier:m,co_id:y})}let o=e.refreshToken,c=e.sessionId;if(!c){const m=await Ng(t,{user:r,client:i,scope:n.scope,audience:n.audience});c=m.id,o=(h=m.refresh_token)==null?void 0:h.id}if(e.authParams.response_mode===Wt.SAML_POST)return Mw(t,e.client,e.authParams,r,c);const l=await Hl(t,{authParams:n,user:r,client:i,session_id:c,refresh_token:o}),u=new Headers({"set-cookie":bg(i.tenant.id,c)});if(n.response_mode===Wt.WEB_MESSAGE)return t.json(l,{headers:u});if((n.response_type||fn.CODE)===fn.CODE){if(!e.loginSession)throw new O(500,{message:"Login session not found"});const m=await t.env.data.codes.create(i.tenant.id,{code_id:qe(),user_id:r.user_id,code_type:"authorization_code",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+Ny*1e3).toISOString()});u.set("location",`${n.redirect_uri}?state=${e.authParams.state}&code=${m.code_id}`)}return new Response("Redirecting",{status:302,headers:u})}function Hw(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await Ms({userAdapter:t.users,tenant_id:e,email:n.email});return r?(await t.users.create(e,{...n,linked_to:r.user_id}),r):t.users.create(e,n)}}async function $g(t,e,n){for await(const r of e)if(!(await fetch(r.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const s=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await n.logs.create(t.var.tenant_id,s)}}function Kw(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n);return await $g(t,i,{tenant_id:n,user:r,trigger_id:"post-user-registration"}),r}}function Ww(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await $g(t,i,{tenant_id:n,email:r,trigger_id:"pre-user-signup"})}}function Gw(t,e){return async(n,r)=>{let i=await Hw(e)(n,r);return await Kw(t,e)(n,i),i}}async function zg(t,e,n,r){if(e.disable_sign_ups&&!await Ms({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:r})){const s=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});throw await t.env.data.logs.create(e.tenant.id,s),new O(400,{message:"Signups are disabled for this client"})}await Ww(t,n)(t.var.tenant_id||"",r)}function Jw(t,e){return{...e,users:{...e.users,create:Gw(t,e)}}}async function Zw(t,e,n,r){if(!r.state)throw new O(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new O(403,{message:"Connection Not Found"})}let s=await t.env.data.logins.get(e.tenant.id,r.state);s||(s=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:r,...pr(t.req)}));const c=await yg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.login_id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+$y*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function wp(t,{code:e,state:n}){var f;const{env:r}=t,i=await r.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!i||!i.connection_id)throw new O(403,{message:"State not found"});const s=await r.data.logins.get(t.var.tenant_id||"",i.login_id);if(!s)throw new O(403,{message:"Session not found"});const o=await Bo(r,s.authParams.client_id);t.set("client_id",o.id),t.set("tenant_id",o.tenant.id);const c=o.connections.find(_=>_.id===i.connection_id);if(!c){const _=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(o.tenant.id,_),new O(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=be(t,{type:me.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(o.tenant.id,_),new O(403,{message:"Redirect URI not defined"})}if(!To(s.authParams.redirect_uri,o.callbacks||[],{allowPathWildcards:!0})){const _=`Invalid redirect URI - ${s.authParams.redirect_uri}`,v=be(t,{type:me.FAILED_LOGIN,description:_});throw await r.data.logs.create(o.tenant.id,v),new O(403,{message:_})}const u=await yg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:p,...h}=u;t.set("user_id",p);const m=((f=u.email)==null?void 0:f.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);let y=await Jr({userAdapter:r.data.users,tenant_id:o.tenant.id,email:m,provider:c.name});if(!y){try{await zg(t,o,t.env.data,m)}catch(_){const v=_;throw new O(500,{message:`Failed to run preUserSignupHook: ${v.message}`})}y=await r.data.users.create(o.tenant.id,{user_id:`${c.name}|${p}`,email:m,name:m,provider:c.name,connection:c.name,email_verified:!0,last_ip:"",is_social:!0,last_login:new Date().toISOString(),profileData:JSON.stringify(h)}),t.set("user_id",y.user_id)}return $n(t,{client:o,authParams:s.authParams,loginSession:s,user:y})}async function bp(t,e,n,r,i,s){const o=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!o)throw new O(400,{message:"State not found"});const c=await t.env.data.logins.get(t.var.tenant_id,o.login_id);if(!c)throw new O(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new O(400,{message:"Redirect uri not found"});const u=be(t,{type:me.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});Xe(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return Iy(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${St(t.env)}enter-email?state=${c.login_id}&error=${n}`)}const Yw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:o}=t.req.valid("query");if(r)return bp(t,e,r,i,s,o);if(!n)throw new O(400,{message:"Code is required"});return wp(t,{code:n,state:e})}).openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:o}=t.req.valid("form");if(r)return bp(t,e,r,i,s,o);if(!n)throw new O(400,{message:"Code is required"});return wp(t,{code:n,state:e})}),Xw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),returnTo:a.z.string().optional()}),header:a.z.object({cookie:a.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),r=await t.env.data.clients.get(e);if(!r)return t.text("OK");const i=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",r.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!To(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new O(400,{message:"Invalid redirect uri"});const o=t.req.header("cookie");if(o){const l=wg(r.tenant.id,o);if(l){const u=await t.env.data.sessions.get(r.tenant.id,l);if(u){const p=await t.env.data.users.get(r.tenant.id,u.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection))}await t.env.data.sessions.remove(r.tenant.id,l)}}const c=be(t,{type:me.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(r.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":bv(r.tenant.id),location:s}})}),kp=a.z.object({sub:a.z.string(),email:a.z.string().optional(),family_name:a.z.string().optional(),given_name:a.z.string().optional(),email_verified:a.z.boolean()}),Qw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:kp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new O(404,{message:"User not found"});const e=await t.env.data.users.get(t.var.user.tenant_id,t.var.user.sub);if(!e)throw new O(404,{message:"User not found"});return t.json(kp.parse({...e,sub:e.user_id}))}),eb=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Xp}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async r=>{const s=await new Rl(r.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return Fc.parse({...o,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Si}, stale-while-revalidate=${Si*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:fa}},description:"List of tenants"}}}),async t=>{const e=fa.parse({issuer:iv(t.env),authorization_endpoint:`${Ne(t.env)}authorize`,token_endpoint:`${Ne(t.env)}oauth/token`,device_authorization_endpoint:`${Ne(t.env)}oauth/device/code`,userinfo_endpoint:`${Ne(t.env)}userinfo`,mfa_challenge_endpoint:`${Ne(t.env)}mfa/challenge`,jwks_uri:`${Ne(t.env)}.well-known/jwks.json`,registration_endpoint:`${Ne(t.env)}oidc/register`,revocation_endpoint:`${Ne(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Si}, stale-while-revalidate=${Si*2}, stale-if-error=86400`}})});function Bi(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t.charCodeAt(r)^e.charCodeAt(r);return n===0}const jg=a.z.object({grant_type:a.z.literal("client_credentials"),scope:a.z.string().optional(),client_secret:a.z.string(),client_id:a.z.string(),audience:a.z.string().optional()});async function tb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Invalid client credentials"});if(n.client_secret&&!Bi(n.client_secret,e.client_secret))throw new O(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await Hl(t,{authParams:r,client:n});return t.json(i)}const nb=a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string().optional(),client_secret:a.z.string().optional(),code_verifier:a.z.string().optional()}).refine(t=>"client_secret"in t&&!("code_verifier"in t)||!("client_secret"in t)&&"code_verifier"in t,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function rb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Client not found"});const r=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!r||!r.user_id)throw new O(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new O(403,{message:"Code expired"});if(r.used_at)throw new O(403,{message:"Code already used"});const i=await t.env.data.logins.get(n.tenant.id,r.login_id);if(!i)throw new O(403,{message:"Invalid login"});if("client_secret"in e){const o=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Bi(n.client_secret,e.client_secret)&&!Bi(o==null?void 0:o.client_secret,e.client_secret))throw new O(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const o=await vv(e.code_verifier,i.authParams.code_challenge_method);if(!Bi(o,i.authParams.code_challenge||""))throw new O(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new O(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new O(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),$n(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Wt.WEB_MESSAGE}})}const ib=a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),redirect_uri:a.z.string().optional(),refresh_token:a.z.string()});async function sb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Client not found"});const r=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(r){if(r.expires_at&&new Date(r.expires_at)<new Date||r.idle_expires_at&&new Date(r.idle_expires_at)<new Date)throw new O(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new O(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const i=await t.env.data.users.get(n.tenant.id,r.user_id);if(!i)throw new O(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const o=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:o.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...r.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return $n(t,{user:i,client:n,refreshToken:r.id,sessionId:r.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Wt.WEB_MESSAGE}})}const xp=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),ob=a.z.union([jg.extend(xp.shape),a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string(),code_verifier:a.z.string().min(43).max(128)}),a.z.object({grant_type:a.z.literal("authorization_code"),code:a.z.string(),redirect_uri:a.z.string().optional(),...xp.shape}),a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),refresh_token:a.z.string(),redirect_uri:a.z.string().optional()})]);function ab(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[r,i]=atob(n).split(":");return{client_id:r,client_secret:i}}return{}}const cb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:ob}}}},responses:{200:{content:{"application/json":{schema:sf}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=ab(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new O(400,{message:"client_id is required"});switch(e.grant_type){case kr.AuthorizationCode:return rb(t,nb.parse(r));case kr.ClientCredential:return tb(t,jg.parse(r));case kr.RefreshToken:return sb(t,ib.parse(r));default:throw new O(400,{message:"Not implemented"})}});var Kl={exports:{}};const Wl=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],Og=(t,e=Wl,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=t||"";e[0].minDiversity=0,e[0].minLength=0;const i=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&i.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),s.length=r.length;let o=e.filter(c=>s.contains.length>=c.minDiversity).filter(c=>s.length>=c.minLength).sort((c,l)=>l.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,o[0]),s};Kl.exports={passwordStrength:Og,defaultOptions:Wl};var lb=Kl.exports.passwordStrength=Og;Kl.exports.defaultOptions=Wl;function ub(t){return lb(t).id<2?!1:t.length>=8&&/[a-z]/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)}async function Ro(t,e){var i;const n=await t.env.data.emailProviders.get(t.var.tenant_id)||(t.env.DEFAULT_TENANT_ID?await t.env.data.emailProviders.get(t.env.DEFAULT_TENANT_ID):null);if(!n)throw new O(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new O(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function db(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new O(500,{message:"Tenant not found"});const s=`${St(t.env)}reset-password?state=${r}&code=${n}`,o={vendorName:i.name,lng:i.language||"en"};await Ro(t,{to:e,subject:"Reset your password",html:`Click here to reset your password: ${St(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:s,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:fe("password_reset_title",o),resetPasswordEmailClickToReset:fe("reset_password_email_click_to_reset",o),resetPasswordEmailReset:fe("reset_password_email_reset",o),supportInfo:fe("support_info",o),contactUs:fe("contact_us",o),copyright:fe("copyright",o)}})}async function Bg(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new O(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Ro(t,{to:e,subject:fe("code_email_subject",i),html:`Click here to validate your email: ${St(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",magicLink:`${Ne(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:r.primary_color||"",welcomeToYourAccount:fe("welcome_to_your_account",i),linkEmailClickToLogin:fe("link_email_click_to_login",i),linkEmailLogin:fe("link_email_login",i),linkEmailOrEnterCode:fe("link_email_or_enter_code",i),codeValid30Mins:fe("code_valid_30_minutes",i),supportInfo:fe("support_info",i),contactUs:fe("contact_us",i),copyright:fe("copyright",i)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Xe(t,t.env.data.logs.create(r.id,s))}async function Gl(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new O(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Ro(t,{to:e,subject:fe("code_email_subject",i),html:`Click here to validate your email: ${St(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",magicLink:`${Ne(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:r.primary_color||"",welcomeToYourAccount:fe("welcome_to_your_account",i),linkEmailClickToLogin:fe("link_email_click_to_login",i),linkEmailLogin:fe("link_email_login",i),linkEmailOrEnterCode:fe("link_email_or_enter_code",i),codeValid30Mins:fe("code_valid_30_minutes",i),supportInfo:fe("support_info",i),contactUs:fe("contact_us",i),copyright:fe("copyright",i)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Xe(t,t.env.data.logs.create(r.id,s))}async function Tg(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new O(500,{message:"Tenant not found"});const r={vendorName:n.name,lng:n.language||"en"};await Ro(t,{to:e.email,subject:"Validate your email address",html:`Click here to validate your email: ${St(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${St(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:fe("welcome_to_your_account",r),verifyEmailVerify:fe("verify_email_verify",r),supportInfo:fe("support_info",r),contactUs:fe("contact_us",r),copyright:fe("copyright",r)}})}const pb=new a.OpenAPIHono().openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string()})}}}},responses:{200:{content:{"application/json":{schema:a.z.object({_id:a.z.string(),email:a.z.string(),email_verified:a.z.boolean(),app_metadata:a.z.object({}),user_metadata:a.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:r}=t.req.valid("json"),i=await t.env.data.clients.get(r);if(!i)throw new O(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!ub(n))throw new O(400,{message:"Password does not meet the requirements"});if(await Jr({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))throw new O(400,{message:"Invalid sign up"});const o=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${Wc()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",o.user_id),t.set("username",o.email),t.set("connection",o.connection);const c=await Kc.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await Tg(t,o);const l=be(t,{type:me.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:o.user_id,email:o.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase())})}}}},responses:{200:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{email:e,client_id:n}=t.req.valid("json"),r=await t.env.data.clients.get(n);if(!r)throw new O(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await Gc({userAdapter:t.env.data.users,tenant_id:r.tenant.id,email:e,provider:"auth2"}))return t.html("If an account with that email exists, we've sent instructions to reset your password.");const s={client_id:n,username:e},o=await t.env.data.logins.create(r.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:s,...pr(t.req)});return await db(t,e,o.login_id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Os(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}async function Jl(t,e,n,r,i,s){const{env:o}=t,c=await o.data.codes.get(e.tenant.id,i,"otp");if(!c)throw new O(400,{message:"Code not found or expired"});if(c.expires_at<new Date().toISOString())throw new O(400,{message:"Code expired"});const l=await o.data.logins.get(e.tenant.id,c.login_id);if(!l||l.authParams.username!==r)throw new O(400,{message:"Code not found or expired"});const u=pr(t.req);if(l.ip!==u.ip)return t.redirect(`${St(t.env)}invalid-session?state=${l.login_id}`);if(n.redirect_uri&&!To(n.redirect_uri,e.callbacks,{allowPathWildcards:!0}))throw new O(400,{message:`Invalid redirect URI - ${n.redirect_uri}`});const p=await Jr({userAdapter:o.data.users,tenant_id:e.tenant.id,email:r,provider:"email"});if(!p)throw new O(400,{message:"User not found"});return $n(t,{user:p,client:e,loginSession:l,authParams:n,ticketAuth:s})}const fb=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:Dc.omit({client_id:!0})})}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,email:i,send:s,authParams:o}=e,c=await t.env.data.clients.get(r);if(!c)throw new O(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.logins.create(c.tenant.id,{authParams:{...o,client_id:r,username:i},expires_at:new Date(Date.now()+Bc).toISOString(),...pr(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:Os(),code_type:"otp",login_id:l.login_id,expires_at:new Date(Date.now()+Bc).toISOString()});return s==="link"?await Gl(t,i,u.code_id):await Bg(t,i,u.code_id),t.html("OK")}).openapi(a.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:a.z.object({scope:a.z.string(),response_type:a.z.nativeEnum(fn),redirect_uri:a.z.string(),state:a.z.string(),nonce:a.z.string().optional(),verification_code:a.z.string(),connection:a.z.string(),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),audience:a.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:s,state:o,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),h=await Bo(e,n);return t.set("client_id",h.id),t.set("tenant_id",h.tenant.id),t.set("connection","email"),Jl(t,h,{client_id:n,redirect_uri:s,state:o,nonce:p,scope:c,audience:l,response_type:u},r,i)});class vr extends O{constructor(n,r){super(n,r);ee(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function Pg(t,e,n,r,i){const{env:s}=t,o=n.username;if(t.set("username",o),!o)throw new O(400,{message:"Username is required"});const c=await Gc({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:o,provider:"auth2"});if(!c){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw Xe(t,t.env.data.logs.create(e.tenant.id,f)),new vr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const l=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!l)throw new vr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",l.user_id);const{password:u}=await s.data.passwords.get(e.tenant.id,c.user_id);if(!await Kc.compare(n.password,u)){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw Xe(t,t.env.data.logs.create(e.tenant.id,f)),new vr(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await s.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${l.user_id}`})).logs.filter(f=>f.type===me.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(f.date)>new Date(Date.now()-1e3*60*5)).length>=3){const f=be(t,{type:me.FAILED_LOGIN,description:"Too many failed login attempts"});throw Xe(t,t.env.data.logs.create(e.tenant.id,f)),new vr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await Tg(t,c);const f=be(t,{type:me.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,f),new vr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const y=be(t,{type:me.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return Xe(t,t.env.data.logs.create(e.tenant.id,y)),$n(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}const hb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:a.z.string(),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),realm:a.z.enum(["email"]),scope:a.z.string().optional()}),a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string(),realm:a.z.enum(["Username-Password-Authentication"]),scope:a.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:r}=e;t.set("username",r);const i=await t.env.data.clients.get(n);if(!i)throw new O(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const s=r.toLocaleLowerCase();if("otp"in e)return Jl(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const o=await t.env.data.logins.create(i.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:{client_id:n,username:s},...pr(t.req)});return Pg(t,i,{username:s,password:e.password,client_id:n},o,!0)}else throw new O(400,{message:"Code or password required"})});function gb(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=na(t))==null?void 0:r.host)??null;if(!n)return!1;for(const o of e){let c;if(o.startsWith("http://")||o.startsWith("https://")?c=((i=na(o))==null?void 0:i.host)??null:c=((s=na("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function na(t){try{return new URL(t)}catch{return null}}async function mb({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const o=await t.env.data.logins.create(n.tenant.id,{expires_at:new Date(Date.now()+qr*1e3).toISOString(),authParams:r,...pr(t.req)});if(e&&s){const c=await t.env.data.users.get(n.tenant.id,e.user_id);if((c==null?void 0:c.email)===s)return $n(t,{client:n,loginSession:o,authParams:r,user:c,sessionId:e.id})}if(i==="email"&&s){const c=Os();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:o.login_id,expires_at:new Date(Date.now()+qr*1e3).toISOString()}),await Gl(t,s,c),t.redirect(`/u/enter-code?state=${o.login_id}`)}return e?t.redirect(`/u/check-account?state=${o.login_id}`):t.redirect(`/u/enter-email?state=${o.login_id}`)}function _b(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new O(403,{message:"Invalid realm"})}async function yb(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const o=await s.data.codes.get(e,n,"ticket");if(!o||o.used_at)throw new O(403,{message:"Ticket not found"});const c=await s.data.logins.get(e,o.login_id);if(!c||!c.authParams.username)throw new O(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new O(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=_b(i);let p=await Jr({userAdapter:s.data.users,tenant_id:e,email:c.authParams.username,provider:u});p||(p=await s.data.users.create(e,{user_id:`email|${Wc()}`,email:c.authParams.username,name:c.authParams.username,provider:"email",connection:"email",email_verified:!0,is_social:!1,last_ip:"",last_login:new Date().toISOString()})),t.set("username",p.email),t.set("user_id",p.user_id);const h=await Ng(t,{user:p,client:l,scope:r.scope,audience:r.audience});return $n(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:h.id,user:p,client:l})}async function Sp(t,e){return`<!DOCTYPE html>
|
|
150
150
|
<html>
|
|
151
151
|
|
|
152
152
|
<head>
|
|
@@ -189,17 +189,17 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
189
189
|
<\/script>
|
|
190
190
|
</body>
|
|
191
191
|
|
|
192
|
-
</html>`}async function yb({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:h}=t,m=new URL(r);if(n!=null&&n.expires_at&&new Date(n.expires_at)>new Date){t.set("user_id",n.user_id);const f=new Headers,_=wg(e.tenant.id,n.id);f.set("set-cookie",_);const v=await h.data.users.get(e.tenant.id,n.user_id);if(v){t.set("username",v.email),t.set("connection",v.connection);const x=await Hl(t,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:i,nonce:s,response_type:p},user:v,session_id:n.id});await h.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),expires_at:new Date(Date.now()+jo*1e3).toISOString()});const N=be(t,{type:me.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await t.env.data.logs.create(e.tenant.id,N),t.html(Sp(`${m.protocol}//${m.host}`,JSON.stringify(x)),{headers:f})}}const y=be(t,{type:me.FAILED_SILENT_AUTH,description:"Login required"});return await t.env.data.logs.create(e.tenant.id,y),t.html(Sp(`${m.protocol}//${m.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:i})))}const vb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),redirect_uri:a.z.string(),scope:a.z.string().optional(),state:a.z.string(),prompt:a.z.string().optional(),response_mode:a.z.nativeEnum(Wt).optional(),response_type:a.z.nativeEnum(fn).optional(),audience:a.z.string().optional(),connection:a.z.string().optional(),nonce:a.z.string().optional(),max_age:a.z.string().optional(),login_ticket:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Us).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),login_hint:a.z.string().optional(),ui_locales:a.z.string().optional()})},responses:{200:{description:"Silent authentication page"},302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{env:e}=t,{client_id:n,vendor_id:r,redirect_uri:i,scope:s,state:o,audience:c,nonce:l,connection:u,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:y,prompt:f,login_ticket:_,realm:v,auth0Client:x,login_hint:N,ui_locales:B}=t.req.valid("query");t.set("log","authorize");const R=await Bo(e,n);t.set("client_id",R.id),t.set("tenant_id",R.tenant.id);const te={redirect_uri:i,scope:s,state:o,client_id:n,vendor_id:r,audience:c,nonce:l,prompt:f,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:y,username:N,ui_locales:B},pe=t.req.header("origin");if(pe&&!hb(pe,R.web_origins||[]))throw new O(403,{message:`Origin ${pe} not allowed`});if(te.redirect_uri&&!To(te.redirect_uri,R.callbacks||[],{allowPathWildcards:!0}))throw new O(400,{message:`Invalid redirect URI - ${te.redirect_uri}`});const le=vg(R.tenant.id,t.req.header("cookie")),Ue=le?await e.data.sessions.get(R.tenant.id,le):void 0;if(f=="none"){if(!p)throw new O(400,{message:"Missing response_type"});return yb({ctx:t,session:Ue||void 0,redirect_uri:i,state:o,response_type:p,client:R,nonce:l,code_challenge_method:y,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?Jw(t,R,u,te):_?_b(t,R.tenant.id,_,te,v):gb({ctx:t,client:R,auth0Client:x,authParams:te,session:Ue||void 0,connection:u,login_hint:N})});function wb(){const t=new a.OpenAPIHono;t.use(cg(t));const e=t.route("/v2/logout",Yw).route("/userinfo",Xw).route("/.well-known",Qw).route("/oauth/token",ab).route("/dbconnections",db).route("/passwordless",pb).route("/co/authenticate",fb).route("/authorize",vb).route("/callback",Zw);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"}}),ag(e),e}var bb={Stringify:1,BeforeStream:2,Stream:3},pt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},kb=/[&<>'"]/,Pg=async(t,e)=>{let n="";e||(e=[]);const r=await Promise.all(t);for(let i=r.length-1;n+=r[i],i--,!(i<0);i--){let s=r[i];typeof s=="object"&&e.push(...s.callbacks||[]);const o=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??o)n+=s;else{const c=[n];Kt(s,c),n=c[0]}}return pt(n,e)},Kt=(t,e)=>{const n=t.search(kb);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r=""";break;case 39:r="'";break;case 38:r="&";break;case 60:r="<";break;case 62:r=">";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},Rg=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:bb.Stringify,buffer:n,context:r})),n[0]},xb=(t,...e)=>{const n=[""];for(let r=0,i=t.length-1;r<i;r++){n[0]+=t[r];const s=Array.isArray(e[r])?e[r].flat(1/0):[e[r]];for(let o=0,c=s.length;o<c;o++){const l=s[o];if(typeof l=="string")Kt(l,n);else if(typeof l=="number")n[0]+=l;else{if(typeof l=="boolean"||l===null||l===void 0)continue;if(typeof l=="object"&&l.isEscaped)if(l.callbacks)n.unshift("",l);else{const u=l.toString();u instanceof Promise?n.unshift("",u):n[0]+=u}else l instanceof Promise?n.unshift("",l):Kt(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?pt(Rg(pt(n[0],n.callbacks))):pt(n[0]):Pg(n,n.callbacks)},Zl=Symbol("RENDERER"),Rc=Symbol("ERROR_HANDLER"),Se=Symbol("STASH"),Lg=Symbol("INTERNAL"),Sb=Symbol("MEMO"),Bs=Symbol("PERMALINK"),Ap=t=>(t[Lg]=!0,t),Ug=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Ap(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Ap(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Rc]=s=>{throw t.pop(),s},i},Vg=t=>{const e=[t],n=Ug(e);return n.values=e,n.Provider=n,Xn.push(n),n},Xn=[],Ab=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new Fg("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>pt(s,s.callbacks)):pt(i)};return n.values=e,n.Provider=n,n[Zl]=Ug(e),Xn.push(n),n},fr=t=>t.values.at(-1),Ti={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Lc={},Pi="data-precedence",hi=t=>Array.isArray(t)?t:[t],Ep=new WeakMap,Ip=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const o=Ep.get(s)||{};Ep.set(s,o);const c=o[t]||(o[t]=[]);let l=!1;const u=Ti[t];if(u.length>0){e:for(const[,p]of c)for(const h of u)if(((p==null?void 0:p[h])??null)===(n==null?void 0:n[h])){l=!0;break e}}if(l?i[0]=i[0].replaceAll(e,""):u.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let p;if(r===void 0)p=c.map(([h])=>h);else{const h=[];p=c.map(([m,,y])=>{let f=h.indexOf(y);return f===-1&&(h.push(y),f=h.length-1),[m,f]}).sort((m,y)=>m[1]-y[1]).map(([m])=>m)}p.forEach(h=>{i[0]=i[0].replaceAll(h,"")}),i[0]=i[0].replace(/(?=<\/head>)/,p.join(""))}},gi=(t,e,n)=>pt(new ft(t,n,hi(e??[])).toString()),mi=(t,e,n,r)=>{if("itemProp"in n)return gi(t,e,n);let{precedence:i,blocking:s,...o}=n;i=r?i??"":void 0,r&&(o[Pi]=i);const c=new ft(t,o,hi(e||[])).toString();return c instanceof Promise?c.then(l=>pt(c,[...l.callbacks||[],Ip(t,l,o,i)])):pt(c,[Ip(t,c,o,i)])},Eb=({children:t,...e})=>{const n=Yl();if(n){const r=fr(n);if(r==="svg"||r==="head")return new ft("title",e,hi(t??[]))}return mi("title",t,e,!1)},Ib=({children:t,...e})=>{const n=Yl();return["src","async"].some(r=>!e[r])||n&&fr(n)==="head"?gi("script",t,e):mi("script",t,e,!1)},Cb=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,mi("style",t,e,!0)):gi("style",t,e),Nb=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?gi("link",t,e):mi("link",t,e,"precedence"in e),$b=({children:t,...e})=>{const n=Yl();return n&&fr(n)==="head"?gi("meta",t,e):mi("meta",t,e,!1)},Mg=(t,{children:e,...n})=>new ft(t,n,hi(e??[])),zb=t=>(typeof t.action=="function"&&(t.action=Bs in t.action?t.action[Bs]:void 0),Mg("form",t)),qg=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Bs in e.formAction?e.formAction[Bs]:void 0),Mg(t,e)),jb=t=>qg("input",t),Ob=t=>qg("button",t);const ra=Object.freeze(Object.defineProperty({__proto__:null,button:Ob,form:zb,input:jb,link:Nb,meta:$b,script:Ib,style:Cb,title:Eb},Symbol.toStringTag,{value:"Module"}));var Bb=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Ts=t=>Bb.get(t)||t,Dg=(t,e)=>{for(const[n,r]of Object.entries(t)){const i=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(i,r==null?null:typeof r=="number"?i.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${r}`:`${r}px`:r)}},Hr=void 0,Yl=()=>Hr,Tb=t=>/[A-Z]/.test(t)&&t.match(/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/)?t.replace(/([A-Z])/g,"-$1").toLowerCase():t,Pb=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Rb=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","download","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],Xl=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")Kt(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof ft?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):Xl(i,e)}}},ft=class{constructor(t,e,n){ee(this,"tag");ee(this,"props");ee(this,"key");ee(this,"children");ee(this,"isEscaped",!0);ee(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?Rg(pt(t[0],t.callbacks)).toString():t[0]:Pg(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=Hr&&fr(Hr)==="svg"?s=>Tb(Ts(s)):s=>Ts(s);for(let[s,o]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";Dg(o,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',Kt(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,Kt(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&Rb.includes(s))o&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[pt(o.__html)]}else if(o instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',o);else if(typeof o=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,Kt(o.toString(),t),t[0]+='"'}if(Pb.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",Xl(r,t),t[0]+=`</${e}>`}},ia=class extends ft{toStringToBuffer(t){const{children:e}=this,n=this.tag.call(null,{...this.props,children:e.length<=1?e[0]:e});if(!(typeof n=="boolean"||n==null))if(n instanceof Promise)if(Xn.length===0)t.unshift("",n);else{const r=Xn.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof ft&&(i.localContexts=r),i)))}else n instanceof ft?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):Kt(n,t)}},Fg=class extends ft{toStringToBuffer(t){Xl(this.children,t)}},Lb=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Ri(t,e,n);return i.key=r,i},Cp=!1,Ri=(t,e,n)=>{if(!Cp){for(const r in Lc)ra[r][Zl]=Lc[r];Cp=!0}return typeof t=="function"?new ia(t,e,n):ra[t]?new ia(ra[t],e,n):t==="svg"||t==="head"?(Hr||(Hr=Ab("")),new ft(t,e,[new ia(Hr,{value:t},n)])):new ft(t,e,n)},Ql=({children:t})=>new Fg("",{children:t},Array.isArray(t)?t:t?[t]:[]),Ub=(t,e,...n)=>Lb(t.tag,{...t.props,...e},...n);function E(t,e,n){let r;if(!e||!("children"in e))r=Ri(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Ri(t,e,i):Ri(t,e,[i])}return r.key=n,r}const Vb=({vendorSettings:t})=>t!=null&&t.logoUrl?E("div",{className:"flex h-9 items-center",children:E("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):E(Ql,{}),Mb=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return E("div",{className:"mt-8",children:e&&E("div",{className:"text-xs text-gray-300",children:[Y.t("agree_to")," ",E("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:Y.t("terms")})]})})};var Hg={exports:{}};/*!
|
|
192
|
+
</html>`}async function vb({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:h}=t,m=new URL(r);if(n!=null&&n.expires_at&&new Date(n.expires_at)>new Date){t.set("user_id",n.user_id);const f=new Headers,_=bg(e.tenant.id,n.id);f.set("set-cookie",_);const v=await h.data.users.get(e.tenant.id,n.user_id);if(v){t.set("username",v.email),t.set("connection",v.connection);const x=await Hl(t,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:i,nonce:s,response_type:p},user:v,session_id:n.id});await h.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),expires_at:new Date(Date.now()+jo*1e3).toISOString()});const N=be(t,{type:me.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await t.env.data.logs.create(e.tenant.id,N),t.html(Sp(`${m.protocol}//${m.host}`,JSON.stringify(x)),{headers:f})}}const y=be(t,{type:me.FAILED_SILENT_AUTH,description:"Login required"});return await t.env.data.logs.create(e.tenant.id,y),t.html(Sp(`${m.protocol}//${m.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:i})))}const wb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),redirect_uri:a.z.string(),scope:a.z.string().optional(),state:a.z.string(),prompt:a.z.string().optional(),response_mode:a.z.nativeEnum(Wt).optional(),response_type:a.z.nativeEnum(fn).optional(),audience:a.z.string().optional(),connection:a.z.string().optional(),nonce:a.z.string().optional(),max_age:a.z.string().optional(),login_ticket:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Us).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),login_hint:a.z.string().optional(),ui_locales:a.z.string().optional()})},responses:{200:{description:"Silent authentication page"},302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{env:e}=t,{client_id:n,vendor_id:r,redirect_uri:i,scope:s,state:o,audience:c,nonce:l,connection:u,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:y,prompt:f,login_ticket:_,realm:v,auth0Client:x,login_hint:N,ui_locales:B}=t.req.valid("query");t.set("log","authorize");const R=await Bo(e,n);t.set("client_id",R.id),t.set("tenant_id",R.tenant.id);const te={redirect_uri:i,scope:s,state:o,client_id:n,vendor_id:r,audience:c,nonce:l,prompt:f,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:y,username:N,ui_locales:B},pe=t.req.header("origin");if(pe&&!gb(pe,R.web_origins||[]))throw new O(403,{message:`Origin ${pe} not allowed`});if(te.redirect_uri&&!To(te.redirect_uri,R.callbacks||[],{allowPathWildcards:!0}))throw new O(400,{message:`Invalid redirect URI - ${te.redirect_uri}`});const le=wg(R.tenant.id,t.req.header("cookie")),Ue=le?await e.data.sessions.get(R.tenant.id,le):void 0;if(f=="none"){if(!p)throw new O(400,{message:"Missing response_type"});return vb({ctx:t,session:Ue||void 0,redirect_uri:i,state:o,response_type:p,client:R,nonce:l,code_challenge_method:y,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?Zw(t,R,u,te):_?yb(t,R.tenant.id,_,te,v):mb({ctx:t,client:R,auth0Client:x,authParams:te,session:Ue||void 0,connection:u,login_hint:N})});function bb(){const t=new a.OpenAPIHono;t.use(lg(t));const e=t.route("/v2/logout",Xw).route("/userinfo",Qw).route("/.well-known",eb).route("/oauth/token",cb).route("/dbconnections",pb).route("/passwordless",fb).route("/co/authenticate",hb).route("/authorize",wb).route("/callback",Yw);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"}}),cg(e),e}var kb={Stringify:1,BeforeStream:2,Stream:3},pt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},xb=/[&<>'"]/,Rg=async(t,e)=>{let n="";e||(e=[]);const r=await Promise.all(t);for(let i=r.length-1;n+=r[i],i--,!(i<0);i--){let s=r[i];typeof s=="object"&&e.push(...s.callbacks||[]);const o=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??o)n+=s;else{const c=[n];Kt(s,c),n=c[0]}}return pt(n,e)},Kt=(t,e)=>{const n=t.search(xb);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r=""";break;case 39:r="'";break;case 38:r="&";break;case 60:r="<";break;case 62:r=">";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},Lg=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:kb.Stringify,buffer:n,context:r})),n[0]},Sb=(t,...e)=>{const n=[""];for(let r=0,i=t.length-1;r<i;r++){n[0]+=t[r];const s=Array.isArray(e[r])?e[r].flat(1/0):[e[r]];for(let o=0,c=s.length;o<c;o++){const l=s[o];if(typeof l=="string")Kt(l,n);else if(typeof l=="number")n[0]+=l;else{if(typeof l=="boolean"||l===null||l===void 0)continue;if(typeof l=="object"&&l.isEscaped)if(l.callbacks)n.unshift("",l);else{const u=l.toString();u instanceof Promise?n.unshift("",u):n[0]+=u}else l instanceof Promise?n.unshift("",l):Kt(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?pt(Lg(pt(n[0],n.callbacks))):pt(n[0]):Rg(n,n.callbacks)},Zl=Symbol("RENDERER"),Rc=Symbol("ERROR_HANDLER"),Se=Symbol("STASH"),Ug=Symbol("INTERNAL"),Ab=Symbol("MEMO"),Bs=Symbol("PERMALINK"),Ap=t=>(t[Ug]=!0,t),Vg=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Ap(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Ap(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Rc]=s=>{throw t.pop(),s},i},Mg=t=>{const e=[t],n=Vg(e);return n.values=e,n.Provider=n,Xn.push(n),n},Xn=[],Eb=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new Hg("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>pt(s,s.callbacks)):pt(i)};return n.values=e,n.Provider=n,n[Zl]=Vg(e),Xn.push(n),n},fr=t=>t.values.at(-1),Ti={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Lc={},Pi="data-precedence",hi=t=>Array.isArray(t)?t:[t],Ep=new WeakMap,Ip=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const o=Ep.get(s)||{};Ep.set(s,o);const c=o[t]||(o[t]=[]);let l=!1;const u=Ti[t];if(u.length>0){e:for(const[,p]of c)for(const h of u)if(((p==null?void 0:p[h])??null)===(n==null?void 0:n[h])){l=!0;break e}}if(l?i[0]=i[0].replaceAll(e,""):u.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let p;if(r===void 0)p=c.map(([h])=>h);else{const h=[];p=c.map(([m,,y])=>{let f=h.indexOf(y);return f===-1&&(h.push(y),f=h.length-1),[m,f]}).sort((m,y)=>m[1]-y[1]).map(([m])=>m)}p.forEach(h=>{i[0]=i[0].replaceAll(h,"")}),i[0]=i[0].replace(/(?=<\/head>)/,p.join(""))}},gi=(t,e,n)=>pt(new ft(t,n,hi(e??[])).toString()),mi=(t,e,n,r)=>{if("itemProp"in n)return gi(t,e,n);let{precedence:i,blocking:s,...o}=n;i=r?i??"":void 0,r&&(o[Pi]=i);const c=new ft(t,o,hi(e||[])).toString();return c instanceof Promise?c.then(l=>pt(c,[...l.callbacks||[],Ip(t,l,o,i)])):pt(c,[Ip(t,c,o,i)])},Ib=({children:t,...e})=>{const n=Yl();if(n){const r=fr(n);if(r==="svg"||r==="head")return new ft("title",e,hi(t??[]))}return mi("title",t,e,!1)},Cb=({children:t,...e})=>{const n=Yl();return["src","async"].some(r=>!e[r])||n&&fr(n)==="head"?gi("script",t,e):mi("script",t,e,!1)},Nb=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,mi("style",t,e,!0)):gi("style",t,e),$b=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?gi("link",t,e):mi("link",t,e,"precedence"in e),zb=({children:t,...e})=>{const n=Yl();return n&&fr(n)==="head"?gi("meta",t,e):mi("meta",t,e,!1)},qg=(t,{children:e,...n})=>new ft(t,n,hi(e??[])),jb=t=>(typeof t.action=="function"&&(t.action=Bs in t.action?t.action[Bs]:void 0),qg("form",t)),Dg=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Bs in e.formAction?e.formAction[Bs]:void 0),qg(t,e)),Ob=t=>Dg("input",t),Bb=t=>Dg("button",t);const ra=Object.freeze(Object.defineProperty({__proto__:null,button:Bb,form:jb,input:Ob,link:$b,meta:zb,script:Cb,style:Nb,title:Ib},Symbol.toStringTag,{value:"Module"}));var Tb=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Ts=t=>Tb.get(t)||t,Fg=(t,e)=>{for(const[n,r]of Object.entries(t)){const i=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(i,r==null?null:typeof r=="number"?i.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${r}`:`${r}px`:r)}},Hr=void 0,Yl=()=>Hr,Pb=t=>/[A-Z]/.test(t)&&t.match(/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/)?t.replace(/([A-Z])/g,"-$1").toLowerCase():t,Rb=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Lb=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","download","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],Xl=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")Kt(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof ft?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):Xl(i,e)}}},ft=class{constructor(t,e,n){ee(this,"tag");ee(this,"props");ee(this,"key");ee(this,"children");ee(this,"isEscaped",!0);ee(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?Lg(pt(t[0],t.callbacks)).toString():t[0]:Rg(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=Hr&&fr(Hr)==="svg"?s=>Pb(Ts(s)):s=>Ts(s);for(let[s,o]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";Fg(o,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',Kt(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,Kt(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&Lb.includes(s))o&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[pt(o.__html)]}else if(o instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',o);else if(typeof o=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,Kt(o.toString(),t),t[0]+='"'}if(Rb.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",Xl(r,t),t[0]+=`</${e}>`}},ia=class extends ft{toStringToBuffer(t){const{children:e}=this,n=this.tag.call(null,{...this.props,children:e.length<=1?e[0]:e});if(!(typeof n=="boolean"||n==null))if(n instanceof Promise)if(Xn.length===0)t.unshift("",n);else{const r=Xn.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof ft&&(i.localContexts=r),i)))}else n instanceof ft?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):Kt(n,t)}},Hg=class extends ft{toStringToBuffer(t){Xl(this.children,t)}},Ub=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Ri(t,e,n);return i.key=r,i},Cp=!1,Ri=(t,e,n)=>{if(!Cp){for(const r in Lc)ra[r][Zl]=Lc[r];Cp=!0}return typeof t=="function"?new ia(t,e,n):ra[t]?new ia(ra[t],e,n):t==="svg"||t==="head"?(Hr||(Hr=Eb("")),new ft(t,e,[new ia(Hr,{value:t},n)])):new ft(t,e,n)},Ql=({children:t})=>new Hg("",{children:t},Array.isArray(t)?t:t?[t]:[]),Vb=(t,e,...n)=>Ub(t.tag,{...t.props,...e},...n);function E(t,e,n){let r;if(!e||!("children"in e))r=Ri(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Ri(t,e,i):Ri(t,e,[i])}return r.key=n,r}const Mb=({vendorSettings:t})=>t!=null&&t.logoUrl?E("div",{className:"flex h-9 items-center",children:E("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):E(Ql,{}),qb=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return E("div",{className:"mt-8",children:e&&E("div",{className:"text-xs text-gray-300",children:[Y.t("agree_to")," ",E("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:Y.t("terms")})]})})};var Kg={exports:{}};/*!
|
|
193
193
|
Copyright (c) 2018 Jed Watson.
|
|
194
194
|
Licensed under the MIT License (MIT), see
|
|
195
195
|
http://jedwatson.github.io/classnames
|
|
196
|
-
*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var c=arguments[o];c&&(s=i(s,r(c)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var c in s)e.call(s,c)&&s[c]&&(o=i(o,c));return o}function i(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(
|
|
196
|
+
*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var c=arguments[o];c&&(s=i(s,r(c)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var c in s)e.call(s,c)&&s[c]&&(o=i(o,c));return o}function i(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(Kg);var Db=Kg.exports;const At=pf(Db),Fb=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",kt=({name:t,size:e,className:n=""})=>{const r=Fb(e);return E("span",{className:At(`uicon-${t}`,n,r)})};var Np=Object.freeze,Hb=Object.defineProperty,Kb=(t,e)=>Np(Hb(t,"raw",{value:Np(t.slice())})),$p;const Wb=t=>{const{style:e}=t;return`
|
|
197
197
|
body {
|
|
198
198
|
--primary-color: ${e.primaryColor};
|
|
199
199
|
--primary-hover: ${e.primaryHoverColor};
|
|
200
200
|
--text-on-primary: ${e.buttonTextColor};
|
|
201
201
|
}
|
|
202
|
-
`},
|
|
202
|
+
`},Gb="https://assets.sesamy.com/images/login-bg.jpg",Lo=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||Gb})`};return E("html",{lang:"en",children:[E("head",{children:[E("title",{children:t}),E("meta",{charset:"UTF-8"}),E("meta",{name:"robots",content:"noindex, follow"}),E("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),E("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),E("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),E("link",{rel:"stylesheet",href:"/css/tailwind.css"}),E("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),E("style",{children:Wb(n)}),E("meta",{name:"theme-color",content:"#000000"})]}),E("body",{children:E("div",{className:"row min-h-full w-full overflow-hidden bg-cover bg-center text-sm sm:bg-fixed sm:bg-left-top sm:pt-16 py-2",style:r,children:E("div",{className:"row-up-left w-[calc(100%-theme(space.2)-theme(space.2))] max-w-[1295px] !flex-nowrap sm:w-[calc(100%-theme(space.16)-theme(space.16))]",children:E("div",{className:"column-left w-full sm:w-auto",children:[E("div",{className:"relative flex w-full flex-col rounded-2xl bg-white px-5 py-10 dark:bg-gray-800 dark:text-white sm:min-h-[700px] sm:max-w-md sm:px-14 sm:py-14 md:min-w-[448px] short:min-h-[558px] min-h-[calc(100vh-83px)]",children:[E("div",{className:"mb-16",children:E(Mb,{vendorSettings:n})}),E("div",{className:"flex flex-1 flex-col",children:[e,E(qb,{vendorSettings:n})]})]}),E("div",{className:"flex w-full items-center px-6 pb-8 pt-4 justify-between",children:[E("div",{className:"flex justify-center leading-[0]",children:E("a",{href:"https://sesamy.com",target:"_blank",rel:"noreferrer",children:E(kt,{name:"sesamy",className:"text-xl text-white"})})}),E("div",{className:"flex justify-center space-x-2 text-xs text-white sm:justify-normal md:text-xs",children:[n.supportUrl&&E("a",{className:"text-xs text-white hover:underline md:text-xs",href:n.supportUrl,target:"_blank",rel:"noopener noreferrer",children:Y.t("contact_support")}),E("span",{className:"text-gray-300",children:"|"})," ",E("span",{children:Y.t("copyright_sesamy")})]})]})]})})})}),Sb($p||($p=Kb([`
|
|
203
203
|
<script>
|
|
204
204
|
function swapButtons() {
|
|
205
205
|
document.getElementById("initial-btn").classList.add("hidden");
|
|
@@ -214,12 +214,12 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
<\/script>
|
|
217
|
-
`])))]})},Ps=t=>E("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:Y.t("go_back")}),zp={name:"sesamy",logoUrl:"https://assets.sesamy.com/static/images/email/sesamy-logo.png",style:{primaryColor:"#7D68F4",buttonTextColor:"#FFFFFF",primaryHoverColor:"#A091F2"},loginBackgroundImage:"",checkoutHideSocial:!1,supportEmail:"support@sesamy.com",supportUrl:"https://support.sesamy.com",siteUrl:"https://sesamy.com",termsAndConditionsUrl:"https://store.sesamy.com/pages/terms-of-service",manageSubscriptionsUrl:"https://account.sesamy.com/manage-subscriptions"};async function
|
|
217
|
+
`])))]})},Ps=t=>E("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:Y.t("go_back")}),zp={name:"sesamy",logoUrl:"https://assets.sesamy.com/static/images/email/sesamy-logo.png",style:{primaryColor:"#7D68F4",buttonTextColor:"#FFFFFF",primaryHoverColor:"#A091F2"},loginBackgroundImage:"",checkoutHideSocial:!1,supportEmail:"support@sesamy.com",supportUrl:"https://support.sesamy.com",siteUrl:"https://sesamy.com",termsAndConditionsUrl:"https://store.sesamy.com/pages/terms-of-service",manageSubscriptionsUrl:"https://account.sesamy.com/manage-subscriptions"};async function Jb(t,e,n){if(!n&&!e)return zp;const r=n||e;try{const i=await fetch(`${t.API_URL}/profile/vendors/${r}/style`);if(!i.ok)throw new Error("Failed to fetch vendor settings");const s=await i.json();return Gp.parse(s)}catch(i){return console.error(i),zp}}async function Qn(t,e){var l;const{env:n}=t,r=await n.data.logins.get(t.var.tenant_id||"",e);if(!r)throw new O(400,{message:"Session not found"});t.set("login",r);const i=await Bo(n,r.authParams.client_id);t.set("client_id",i.id),t.set("tenant_id",i.tenant.id);const s=await n.data.tenants.get(i.tenant.id);if(!s)throw new O(400,{message:"Tenant not found"});const o=await Jb(n,i.id,r.authParams.vendor_id),c=(l=r.authParams.ui_locales)==null?void 0:l.split(" ").map(u=>u.split("-")[0]).find(u=>{if(Array.isArray(Y.options.supportedLngs))return Y.options.supportedLngs.includes(u)});return await Y.changeLanguage(c||s.language||"sv"),{vendorSettings:{...o,termsAndConditionsUrl:i.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":o.termsAndConditionsUrl},client:i,tenant:s,session:r}}async function Zb(t,e,n,r){if(r!==void 0)return r==="password";const i=await Ms({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(i){const o=await t.env.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,sort:{sort_by:"date",sort_order:"desc"},q:`type:${me.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=o.logs.filter(l=>l.strategy&&["Username-Password-Authentication","passwordless","email"].includes(l.strategy));if(c)return c.strategy==="Username-Password-Authentication"}return(await t.env.data.promptSettings.get(e.tenant.id)).password_first}const eu=({children:t})=>E("div",{className:"mb-2 text-sm text-red",children:t}),Yb=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Xb=({size:t})=>{const e=Yb(t);return E("div",{className:"relative inline-block leading-[0]",children:[E(kt,{className:At("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),E(kt,{className:At("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},Kr=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:o,id:c})=>{const l=n==="a"?{href:i}:{};return E(n,{class:At("relative w-full rounded-lg text-center",e,{"px-4 py-5":r!=="custom","bg-primary text-textOnPrimary hover:bg-primaryHover":r==="primary","border border-gray-300 bg-white text-black":r==="secondary","pointer-events-none cursor-not-allowed opacity-40":s},"focus:outline-none focus:ring"),type:"submit",disabled:s,id:c,...l,children:[E("span",{className:`
|
|
218
218
|
flex items-center justify-center space-x-2
|
|
219
219
|
${o?"invisible h-0":"visible h-auto"}
|
|
220
|
-
`,children:t}),o&&E("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:E(
|
|
220
|
+
`,children:t}),o&&E("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:E(Xb,{size:"medium"})})]})},Ai=({connection:t,text:e,icon:n=null,canResize:r=!1,session:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.login_id);const o=`/authorize?${s.toString()}`;return E(Kr,{className:At("border border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-400 dark:bg-black dark:hover:bg-black/90",{"px-0 py-3 sm:px-10 sm:py-4 short:px-0 short:py-3":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:o,children:[n||"",E("div",{className:At("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},Qb=({...t})=>E("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[E("path",{d:"M44.1035 23.0123C44.1054 21.4791 43.9758 19.9486 43.716 18.4375H22.498V27.1028H34.6507C34.4021 28.4868 33.8757 29.8061 33.1034 30.9812C32.3311 32.1562 31.3289 33.1628 30.1571 33.9401V39.5649H37.41C41.6567 35.6494 44.1035 29.859 44.1035 23.0123Z",fill:"#4285F4"}),E("path",{d:"M22.4982 44.9997C28.5698 44.9997 33.6821 43.0061 37.4101 39.5687L30.1573 33.9439C28.1386 35.3126 25.5387 36.0938 22.4982 36.0938C16.6296 36.0938 11.6485 32.1377 9.86736 26.8066H2.39575V32.6033C4.26839 36.3297 7.13989 39.4622 10.6896 41.6512C14.2394 43.8402 18.3277 44.9995 22.4982 44.9997Z",fill:"#34A853"}),E("path",{d:"M9.86737 26.8073C8.92572 24.0138 8.92572 20.9886 9.86737 18.1951V12.3984H2.39576C0.820432 15.5332 0 18.9929 0 22.5012C0 26.0095 0.820432 29.4692 2.39576 32.604L9.86737 26.8073Z",fill:"#FBBC04"}),E("path",{d:"M22.4982 8.90741C25.7068 8.85499 28.8071 10.0673 31.1291 12.2823L37.5507 5.86064C33.4788 2.03602 28.0843 -0.0637686 22.4982 0.00147616C18.3277 0.00166623 14.2394 1.16098 10.6896 3.34999C7.13989 5.539 4.26839 8.67155 2.39575 12.3979L9.86736 18.1946C11.6485 12.8635 16.6296 8.90741 22.4982 8.90741Z",fill:"#EA4335"})]}),tu=({children:t,className:e})=>E(Ql,{children:[E(Kr,{className:e,id:"initial-btn",children:t}),E(Kr,{className:At(e,"hidden"),isLoading:!0,id:"loading-btn",disabled:!0,children:" "})]}),nu=({children:t,className:e})=>E("form",{id:"form",method:"post",className:e,children:t}),e1=({...t})=>E("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 48 48",enableBackground:"new 0 0 48 48",width:"45",height:"45",...t,children:[E("path",{fill:"#FF5B24",d:"M3.5,8h41c1.9,0,3.5,1.6,3.5,3.5v25c0,1.9-1.6,3.5-3.5,3.5h-41C1.6,40,0,38.4,0,36.5v-25C0,9.6,1.6,8,3.5,8z"}),E("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FFFFFF",d:`M27.9,20.3c1.4,0,2.6-1,2.6-2.5h0c0-1.5-1.2-2.5-2.6-2.5c-1.4,0-2.6,1-2.6,2.5C25.3,19.2,26.5,20.3,27.9,20.3z
|
|
221
221
|
M31.2,24.4c-1.7,2.2-3.5,3.8-6.7,3.8h0c-3.2,0-5.8-2-7.7-4.8c-0.8-1.2-2-1.4-2.9-0.8c-0.8,0.6-1,1.8-0.3,2.9
|
|
222
|
-
c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),jp=({error:t,vendorSettings:e,session:n,email:r,client:i,impersonation:s})=>{const o=i.connections.map(({name:m})=>m),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),h=c||l||u||p;return E(Lo,{title:Y.t("welcome"),vendorSettings:e,children:[E("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:Y.t("welcome")}),E("div",{className:"mb-8 text-gray-300",children:Y.t("login_description")}),E("div",{className:"flex flex-1 flex-col justify-center",children:[E(nu,{className:"mb-7",children:[E("input",{type:"email",name:"username",placeholder:Y.t("email_placeholder"),className:At("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:r||""}),s&&E("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:At("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&E(eu,{children:t}),E(tu,{className:"text-base sm:mt-4 md:text-base",children:E("div",{className:"flex items-center space-x-2",children:[E("span",{children:Y.t("continue")}),E(kt,{className:"text-xs",name:"arrow-right"})]})})]}),h&&E("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[E("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),E("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:Y.t("continue_social_login")})]}),E("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&E(Ai,{connection:"facebook",text:Y.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:E(kt,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),session:n}),l&&E(Ai,{connection:"google-oauth2",text:Y.t("continue_with",{provider:"Google"}),canResize:!0,icon:E(Xb,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n}),u&&E(Ai,{connection:"apple",text:Y.t("continue_with",{provider:"Apple"}),canResize:!0,icon:E(kt,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),session:n}),p&&E(Ai,{connection:"vipps",text:Y.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:E(Qb,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n})]})]})]})},e1=["Auth0.swift"];function t1(t){if(!t)return"link";const e=atob(t),n=JSON.parse(e);return e1.includes(n.name)?"code":"link"}const n1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,session:i,client:s}=await Qn(t,e);return t.html(E(jp,{vendorSettings:r,session:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,session:s,vendorSettings:o}=await Qn(t,n);t.set("client_id",i.id);const c=r.username,l=await Ms({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await $g(t,i,t.env.data,r.username)}catch{const y=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,y),t.html(E(jp,{vendorSettings:o,session:s,error:Y.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,s.authParams.act_as=r.act_as,await e.data.logins.update(i.tenant.id,s.login_id,s),await Jb(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Os(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=Os(),p=await e.data.codes.get(i.tenant.id,u,"otp");const h=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.login_id,expires_at:new Date(Date.now()+Bc).toISOString()});return t1(s.auth0Client)==="link"&&!r.username.includes("online.no")?Xe(t,Gl(t,r.username,h.code_id)):Xe(t,Og(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)});var Wr="_hp",r1={Change:"Input",DoubleClick:"DblClick"},i1={svg:"2000/svg",math:"1998/Math/MathML"},Gr=[],Uc=new WeakMap,er=void 0,s1=()=>er,Nt=t=>"t"in t,sa={onClick:["click",!1]},Op=t=>{if(!t.startsWith("on"))return;if(sa[t])return sa[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return sa[t]=[(r1[n]||n).toLowerCase(),!!r]}},Bp=(t,e)=>er&&t instanceof SVGElement&&/[A-Z]/.test(e)&&(e in t.style||e.match(/^(?:o|pai|str|u|ve)/))?e.replace(/([A-Z])/g,"-$1").toLowerCase():e,o1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Ts(i);const o=Op(i);if(o){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(o[0],n[i],o[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(o[0],s,o[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),Uc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&Dg(s,c.setProperty.bind(c)))}else{if(i==="value"){const l=t.nodeName;if(l==="INPUT"||l==="TEXTAREA"||l==="SELECT"){if(t.value=s==null||s===!1?null:s,l==="TEXTAREA"){t.textContent=s;continue}else if(l==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Bp(t,i);s==null||s===!1?t.removeAttribute(c):s===!0?t.setAttribute(c,""):typeof s=="string"||typeof s=="number"?t.setAttribute(c,s):t.setAttribute(c,s.toString())}}}if(n)for(let i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Ts(i);const o=Op(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=Uc.get(t))==null||r():t.removeAttribute(Bp(t,i))}}},a1=(t,e)=>{e[Se][0]=0,Gr.push([t,e]);const n=e.tag[Zl]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{Gr.pop()}},Kg=(t,e,n,r,i)=>{var s,o;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((o=t[Se][1][Zg])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(Nt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(Kg(c,e,n,r,i),c.s){for(let p=u;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},c1=t=>{for(;;t=t.tag===Wr||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==Wr&&t.e)return t.e}},Wg=t=>{var e,n,r,i,s,o;Nt(t)||((n=(e=t[Se])==null?void 0:e[1][Zg])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Uc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(Wg)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(wr.delete(t),Li.delete(t),delete t[Se][3],t.a=!0)},Gg=(t,e,n)=>{t.c=e,Jg(t,e,n)},Tp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Pp=Symbol(),Jg=(t,e,n)=>{var u;const r=[],i=[],s=[];Kg(t,e,r,i,s),i.forEach(Wg);const o=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!o.length)c=0;else{const p=Tp(o,c1(t.nN));p!==void 0?(l=o[p],c=p):c=Tp(o,(u=r.find(h=>h.tag!==Wr&&h.e))==null?void 0:u.e)??-1,c===-1&&(n=!0)}for(let p=0,h=r.length;p<h;p++,c++){const m=r[p];let y;if(m.s&&m.e)y=m.e,m.s=!1;else{const f=n||!m.e;Nt(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,y=m.e||(m.e=document.createTextNode(m.t))):(y=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),o1(y,m.props,m.pP),Jg(m,y,f))}m.tag===Wr?c--:n?y.parentNode||e.appendChild(y):o[c]!==y&&o[c-1]!==y&&(o[c+1]===y?e.appendChild(o[c]):e.insertBefore(y,l||o[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],h=[];s.forEach(([,m,,y,f])=>{m&&p.push(m),y&&h.push(y),f==null||f()}),p.forEach(m=>m()),h.length&&requestAnimationFrame(()=>{h.forEach(m=>m())})}},Li=new WeakMap,Vc=(t,e,n)=>{var s,o,c,l,u,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?a1(t,e):hi(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Rc]&&(i=n[0][Rc],t[5].push([t,i,e]));const h=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let y;for(let f=0;f<n.length;f++){Array.isArray(n[f])&&n.splice(f,1,...n[f].flat());let _=l1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Lg]&&(Xn.length>0&&(_[Se][2]=Xn.map(x=>[x,x.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Se][3]=t[5].at(-1)));let v;if(h&&h.length){const x=h.findIndex(Nt(_)?N=>Nt(N):_.key!==void 0?N=>N.key===_.key&&N.tag===_.tag:N=>N.tag===_.tag);x!==-1&&(v=h[x],h.splice(x,1))}if(v)if(Nt(_))v.t!==_.t&&(v.t=_.t,v.d=!0),_=v;else{const x=v.pP=v.props;v.props=_.props,v.f||(v.f=_.f||e.f),typeof _.tag=="function"&&(v[Se][2]=_[Se][2]||[],v[Se][3]=_[Se][3],!v.f&&((v.o||v)===_.o||(l=(c=v.tag)[Sb])!=null&&l.call(c,x,v.props))&&(v.s=!0)),_=v}else if(!Nt(_)&&er){const x=fr(er);x&&(_.n=x)}if(!Nt(_)&&!_.s&&(Vc(t,_),delete _.f),m.push(_),y&&!y.s&&!_.s)for(let x=y;x&&!Nt(x);x=(u=x.vC)==null?void 0:u.at(-1))x.nN=_;y=_}}e.vR=r?[...e.vC,...h||[]]:h||[],e.vC=m,r&&delete e.pC}catch(h){if(e.f=!0,h===Pp){if(i)return;throw h}const[m,y,f]=((p=e[Se])==null?void 0:p[3])||[];if(y){const _=()=>Ui([0,!1,t[2]],f),v=Li.get(f)||[];v.push(_),Li.set(f,v);const x=y(h,()=>{const N=Li.get(f);if(N){const B=N.indexOf(_);if(B!==-1)return N.splice(B,1),_()}});if(x){if(t[0]===1)t[1]=!0;else if(Vc(t,f,[x]),(y.length===1||t!==m)&&f.c){Gg(f,f.c,!1);return}throw Pp}}throw h}finally{i&&t[5].pop()}},l1=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Se]=[0,[]];else{const e=i1[t.tag];e&&(er||(er=Vg("")),t.props.children=[{tag:er,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Rp=(t,e)=>{var n,r;(n=e[Se][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Vc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Se][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&Gg(e,e.c,!1)},wr=new WeakMap,Lp=[],Ui=async(t,e)=>{t[5]||(t[5]=[]);const n=wr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(wr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Rp(s,e)}).then(()=>r(e)):(Rp(t,e),r(e))}]),Lp.length)Lp.at(-1).add(e);else{await Promise.resolve();const s=wr.get(e);s&&(wr.delete(e),s[1]())}return i},u1=(t,e,n)=>({tag:Wr,props:{children:t},key:n,e,p:1}),oa=0,Zg=1,aa=2,ca=3,la=new WeakMap,Yg=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),d1=void 0,Up=[],p1=t=>{var o;const e=()=>typeof t=="function"?t():t,n=Gr.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Se][1])[oa]||(o[oa]=[]),s=r[Se][0]++;return i[s]||(i[s]=[e(),c=>{const l=d1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Up.length){const[p,h]=Up.at(-1);Promise.all([p===3?r:Ui([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const y=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{y===m.vC&&Ui([p===3?1:0,!1,l],m)})})})}else Ui([0,!1,l],r)}])},ru=(t,e)=>{var c;const n=Gr.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Se][1])[aa]||(c[aa]=[]),s=r[Se][0]++,o=i[s];return Yg(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},f1=t=>{const e=la.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>la.set(t,[n]),n=>la.set(t,[void 0,n])),t},h1=(t,e)=>{var c;const n=Gr.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Se][1])[ca]||(c[ca]=[]),s=r[Se][0]++,o=i[s];return Yg(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},g1=Vg({pending:!1,data:null,method:null,action:null}),Vp=new Set,m1=t=>{Vp.add(t),t.finally(()=>Vp.delete(t))},iu=(t,e)=>h1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),Bn=Object.create(null),Ei=Object.create(null),_i=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:o,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const y=Ti[t];let f;if(y.length>0){const N=s.querySelectorAll(t);e:for(const B of N)for(const R of Ti[t])if(B.getAttribute(R)===e[R]){h=B;break e}if(!h){const B=y.reduce((R,te)=>e[te]===void 0?R:`${R}-${te}-${e[te]}`,t);m=!Ei[B],h=Ei[B]||(Ei[B]=(()=>{const R=document.createElement(t);for(const te of y)e[te]!==void 0&&R.setAttribute(te,e[te]),e.rel&&R.setAttribute("rel",e.rel);return R})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Pi]=l);const _=ru(N=>{if(y.length>0){let B=!1;for(const R of s.querySelectorAll(t)){if(B&&R.getAttribute(Pi)!==l){s.insertBefore(N,R);return}R.getAttribute(Pi)===l&&(B=!0)}s.appendChild(N)}else if(f){let B=!1;for(const R of f)if(R===N){B=!0;break}B||s.insertBefore(N,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),v=iu(e.ref,N=>{var te;const B=y[0];if(n===2&&(N.innerHTML=""),(m||f)&&_(N),!c&&!o)return;let R=Bn[te=N.getAttribute(B)]||(Bn[te]=new Promise((pe,le)=>{N.addEventListener("load",pe),N.addEventListener("error",le)}));o&&(R=R.then(o)),c&&(R=R.catch(c)),R.catch(()=>{})});if(i&&u==="render"){const N=Ti[t][0];if(e[N]){const B=e[N],R=Bn[B]||(Bn[B]=new Promise((te,pe)=>{_(h),h.addEventListener("load",te),h.addEventListener("error",pe)}));f1(R)}}const x={tag:t,type:t,props:{...p,ref:v},ref:v};return x.p=n,h&&(x.e=h),u1(x,s)},_1=t=>{const e=s1(),n=e&&fr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:_i("title",t,void 0,!1,!1)},y1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:_i("script",t,1,!1,!0),v1=t=>!t||!["href","precedence"].every(e=>e in t)?{tag:"style",props:t,type:"style",ref:t.ref}:(t["data-href"]=t.href,delete t.href,_i("style",t,2,!0,!0)),w1=t=>!t||["onLoad","onError"].some(e=>e in t)||t.rel==="stylesheet"&&(!("precedence"in t)||"disabled"in t)?{tag:"link",props:t,type:"link",ref:t.ref}:_i("link",t,1,"precedence"in t,!0),b1=t=>_i("meta",t,void 0,!1,!1),Xg=Symbol(),k1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=p1([null,!1]),s=ru(async u=>{const p=u.isTrusted?e:u.detail[Xg];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(m1(m),await m),i([null,!0])},[]),o=iu(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:g1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:o},type:"form",ref:o}},f:l}},Qg=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=ru(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[Xg]:e}}))},[]);n.ref=iu(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},x1=t=>Qg("input",t),S1=t=>Qg("button",t);Object.assign(Lc,{title:_1,script:y1,style:v1,link:w1,meta:b1,form:k1,input:x1,button:S1});new TextEncoder;const A1=t=>{const{i18nKey:e,values:n,components:r}=t,i=Y.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&o.push(h);const m=parseInt(u,10);o.push(Ub(r[m],{},p)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),E(Ql,{children:o})},Mp=6,E1=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return E(Lo,{title:Y.t("verify_your_email"),vendorSettings:e,children:[E("div",{className:"mb-4 text-2xl font-medium",children:Y.t("verify_your_email")}),E("div",{className:"mb-8 text-gray-300",children:E(A1,{i18nKey:"we_sent_a_code_to",components:[E("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),E("div",{className:"flex flex-1 flex-col justify-center",children:[E(nu,{className:"pt-2",children:[E("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:Mp,inputMode:"numeric",name:"code",placeholder:"******",className:At("mb-2 w-full rounded-lg border bg-gray-100 px-4 pb-2 pt-2.5 text-center indent-[5px] font-mono text-3xl placeholder:text-gray-300 dark:bg-gray-600 md:text-3xl",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),minLength:Mp,required:!0,id:"code-input"}),t&&E(eu,{children:t}),E("div",{className:"text-center sm:mt-2",children:E(tu,{className:"text-base sm:mt-4 md:text-base",children:E("div",{className:"flex items-center space-x-2",children:[E("span",{children:Y.t("login")}),E(kt,{className:"text-xs",name:"arrow-right"})]})})}),E("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[E(kt,{className:"text-base",name:"info-bubble"}),E("div",{className:"text-sm text-gray-300 md:text-sm",children:Y.t("sent_code_spam")})]}),l&&E("div",{className:"text-center mb-12",children:[E("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[E("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),E("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:Y.t("or")})]}),E(Kr,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:Y.t("enter_your_password_btn")})]})]}),E(Ps,{state:r})]})]})},I1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,session:r,client:i}=await Qn(t,e);if(!r.authParams.username)throw new O(400,{message:"Username not found in state"});const s=await Jr({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(E(E1,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({code:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{session:r,client:i}=await Qn(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new O(400,{message:"Username not found in state"});return Jl(t,i,r.authParams,r.authParams.username,n)}),C1=t=>{const{vendorSettings:e,state:n}=t;return E(Lo,{title:Y.t("unverified_email"),vendorSettings:e,children:[E("div",{className:"flex flex-1 flex-col justify-center",children:[E("p",{className:"mb-8 text-gray-300 text-lg",children:Y.t("unverified_email")}),E("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[E(kt,{className:"text-base",name:"info-bubble"}),E("div",{className:"text-sm text-gray-300 md:text-sm",children:Y.t("sent_code_spam")})]}),E(Ps,{state:n})]}),E(Ps,{state:n})]})},ua=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return E(Lo,{title:Y.t("enter_password"),vendorSettings:n,children:[E("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:Y.t("enter_password")}),E("div",{className:"mb-6 text-gray-300",children:Y.t("enter_password_description")}),E("div",{className:"flex flex-1 flex-col justify-center",children:[E(nu,{className:"mb-7",children:[E("input",{type:"text",name:"username",placeholder:Y.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),E("input",{type:"password",name:"password",placeholder:Y.t("password")||"",className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),e&&E(eu,{children:e}),E(tu,{className:"text-base sm:mt-4 md:text-base",children:E("div",{className:"flex items-center space-x-2",children:[E("span",{children:Y.t("login")}),E(kt,{className:"text-xs",name:"arrow-right"})]})})]}),E("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:Y.t("forgot_password_link")}),E("div",{className:"text-center mb-12",children:[E("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[E("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),E("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:Y.t("or")})]}),E("form",{method:"post",action:`/u/enter-email?${s.toString()}`,children:[E("input",{type:"hidden",name:"login_selection",value:"code"}),E("input",{type:"hidden",name:"username",value:r}),E(Kr,{variant:"secondary",className:"block",children:Y.t("enter_a_code_btn")})]})]}),E(Ps,{state:i})]})]})},N1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/enter-password",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,session:i}=await Qn(t,e);if(!i.authParams.username)throw new O(400,{message:"Username required"});return t.html(E(ua,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/enter-password",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,session:o}=await Qn(t,e),{username:c}=o.authParams;if(!c)throw new O(400,{message:"Username required"});try{return Tg(t,s,{...o.authParams,password:r})}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(E(ua,{vendorSettings:i,email:c,error:Y.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(E(C1,{vendorSettings:i,state:e}),400):t.html(E(ua,{vendorSettings:i,email:c,error:u.message,state:e,client:s}),400)}});function $1(){const e=new a.OpenAPIHono().route("/enter-email",n1).route("/enter-code",I1).route("/enter-password",N1);return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const z1="Account detected",j1="We have detected that you have already created an account through",O1="By signing in, you agree to our",B1="and",T1="Callback URL mismatch",P1="The provided redirect_uri is not in the list of allowed callback URLs.",R1="continue with user",L1="Please click the button to create a new password account.",U1="Enter the code at {{vendorName}} to complete the login",V1="Welcome to {{vendorName}}! {{code}} is the login code",M1="Welcome to {{vendorName}}! {{code}} is the login code",q1="The code is valid for 30 minutes",D1="Confirm password",F1="Need Help?",H1="Contact us",K1="or continue with social account",W1="Continue with {{provider}}",G1="Would you like to continue with your existing account?",J1="Copyright © 2023 SESAMY. All rights reserved.",Z1="©2023 Sesamy",Y1="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",X1="Please enter a valid email address.",Q1="The passwords didn't match. Try again.",ek="Choose password",tk="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",nk="Create new account",rk="Sign up with password",ik="You are currently logged in as <0>{{email}}</0>",sk="Email",ok="Email address",ak="Your email address has been validated",ck="Now enter your password to login again",lk="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",uk="Email verification sent",dk="Enter a code",pk="We'll send you a verification link to ensure you own this email address.",fk="Enter new password",hk="Enter password",gk="Enter your email address and password to login.",mk="Enter your password",_k="The magic link has expired. Please click on the button below to receive a new link in your inbox.",yk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",vk="Send password reset email",wk="Click the button below and we’ll send instructions on how to reset your password.",bk="Password reset email sent",kk="Forgot password?",xk="Forgot password?",Sk="Go back",Ak="Invalid password",Ek=`The link is no longer valid.
|
|
222
|
+
c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),jp=({error:t,vendorSettings:e,session:n,email:r,client:i,impersonation:s})=>{const o=i.connections.map(({name:m})=>m),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),h=c||l||u||p;return E(Lo,{title:Y.t("welcome"),vendorSettings:e,children:[E("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:Y.t("welcome")}),E("div",{className:"mb-8 text-gray-300",children:Y.t("login_description")}),E("div",{className:"flex flex-1 flex-col justify-center",children:[E(nu,{className:"mb-7",children:[E("input",{type:"email",name:"username",placeholder:Y.t("email_placeholder"),className:At("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:r||""}),s&&E("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:At("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&E(eu,{children:t}),E(tu,{className:"text-base sm:mt-4 md:text-base",children:E("div",{className:"flex items-center space-x-2",children:[E("span",{children:Y.t("continue")}),E(kt,{className:"text-xs",name:"arrow-right"})]})})]}),h&&E("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[E("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),E("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:Y.t("continue_social_login")})]}),E("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&E(Ai,{connection:"facebook",text:Y.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:E(kt,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),session:n}),l&&E(Ai,{connection:"google-oauth2",text:Y.t("continue_with",{provider:"Google"}),canResize:!0,icon:E(Qb,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n}),u&&E(Ai,{connection:"apple",text:Y.t("continue_with",{provider:"Apple"}),canResize:!0,icon:E(kt,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),session:n}),p&&E(Ai,{connection:"vipps",text:Y.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:E(e1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n})]})]})]})},t1=["Auth0.swift"];function n1(t){if(!t)return"link";const e=atob(t),n=JSON.parse(e);return t1.includes(n.name)?"code":"link"}const r1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,session:i,client:s}=await Qn(t,e);return t.html(E(jp,{vendorSettings:r,session:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,session:s,vendorSettings:o}=await Qn(t,n);t.set("client_id",i.id);const c=r.username,l=await Ms({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await zg(t,i,t.env.data,r.username)}catch{const y=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,y),t.html(E(jp,{vendorSettings:o,session:s,error:Y.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,s.authParams.act_as=r.act_as,await e.data.logins.update(i.tenant.id,s.login_id,s),await Zb(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Os(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=Os(),p=await e.data.codes.get(i.tenant.id,u,"otp");const h=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.login_id,expires_at:new Date(Date.now()+Bc).toISOString()});return n1(s.auth0Client)==="link"&&!r.username.includes("online.no")?Xe(t,Gl(t,r.username,h.code_id)):Xe(t,Bg(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)});var Wr="_hp",i1={Change:"Input",DoubleClick:"DblClick"},s1={svg:"2000/svg",math:"1998/Math/MathML"},Gr=[],Uc=new WeakMap,er=void 0,o1=()=>er,Nt=t=>"t"in t,sa={onClick:["click",!1]},Op=t=>{if(!t.startsWith("on"))return;if(sa[t])return sa[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return sa[t]=[(i1[n]||n).toLowerCase(),!!r]}},Bp=(t,e)=>er&&t instanceof SVGElement&&/[A-Z]/.test(e)&&(e in t.style||e.match(/^(?:o|pai|str|u|ve)/))?e.replace(/([A-Z])/g,"-$1").toLowerCase():e,a1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Ts(i);const o=Op(i);if(o){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(o[0],n[i],o[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(o[0],s,o[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),Uc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&Fg(s,c.setProperty.bind(c)))}else{if(i==="value"){const l=t.nodeName;if(l==="INPUT"||l==="TEXTAREA"||l==="SELECT"){if(t.value=s==null||s===!1?null:s,l==="TEXTAREA"){t.textContent=s;continue}else if(l==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Bp(t,i);s==null||s===!1?t.removeAttribute(c):s===!0?t.setAttribute(c,""):typeof s=="string"||typeof s=="number"?t.setAttribute(c,s):t.setAttribute(c,s.toString())}}}if(n)for(let i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Ts(i);const o=Op(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=Uc.get(t))==null||r():t.removeAttribute(Bp(t,i))}}},c1=(t,e)=>{e[Se][0]=0,Gr.push([t,e]);const n=e.tag[Zl]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{Gr.pop()}},Wg=(t,e,n,r,i)=>{var s,o;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((o=t[Se][1][Yg])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(Nt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(Wg(c,e,n,r,i),c.s){for(let p=u;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},l1=t=>{for(;;t=t.tag===Wr||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==Wr&&t.e)return t.e}},Gg=t=>{var e,n,r,i,s,o;Nt(t)||((n=(e=t[Se])==null?void 0:e[1][Yg])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Uc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(Gg)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(wr.delete(t),Li.delete(t),delete t[Se][3],t.a=!0)},Jg=(t,e,n)=>{t.c=e,Zg(t,e,n)},Tp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Pp=Symbol(),Zg=(t,e,n)=>{var u;const r=[],i=[],s=[];Wg(t,e,r,i,s),i.forEach(Gg);const o=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!o.length)c=0;else{const p=Tp(o,l1(t.nN));p!==void 0?(l=o[p],c=p):c=Tp(o,(u=r.find(h=>h.tag!==Wr&&h.e))==null?void 0:u.e)??-1,c===-1&&(n=!0)}for(let p=0,h=r.length;p<h;p++,c++){const m=r[p];let y;if(m.s&&m.e)y=m.e,m.s=!1;else{const f=n||!m.e;Nt(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,y=m.e||(m.e=document.createTextNode(m.t))):(y=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),a1(y,m.props,m.pP),Zg(m,y,f))}m.tag===Wr?c--:n?y.parentNode||e.appendChild(y):o[c]!==y&&o[c-1]!==y&&(o[c+1]===y?e.appendChild(o[c]):e.insertBefore(y,l||o[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],h=[];s.forEach(([,m,,y,f])=>{m&&p.push(m),y&&h.push(y),f==null||f()}),p.forEach(m=>m()),h.length&&requestAnimationFrame(()=>{h.forEach(m=>m())})}},Li=new WeakMap,Vc=(t,e,n)=>{var s,o,c,l,u,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?c1(t,e):hi(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Rc]&&(i=n[0][Rc],t[5].push([t,i,e]));const h=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let y;for(let f=0;f<n.length;f++){Array.isArray(n[f])&&n.splice(f,1,...n[f].flat());let _=u1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Ug]&&(Xn.length>0&&(_[Se][2]=Xn.map(x=>[x,x.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Se][3]=t[5].at(-1)));let v;if(h&&h.length){const x=h.findIndex(Nt(_)?N=>Nt(N):_.key!==void 0?N=>N.key===_.key&&N.tag===_.tag:N=>N.tag===_.tag);x!==-1&&(v=h[x],h.splice(x,1))}if(v)if(Nt(_))v.t!==_.t&&(v.t=_.t,v.d=!0),_=v;else{const x=v.pP=v.props;v.props=_.props,v.f||(v.f=_.f||e.f),typeof _.tag=="function"&&(v[Se][2]=_[Se][2]||[],v[Se][3]=_[Se][3],!v.f&&((v.o||v)===_.o||(l=(c=v.tag)[Ab])!=null&&l.call(c,x,v.props))&&(v.s=!0)),_=v}else if(!Nt(_)&&er){const x=fr(er);x&&(_.n=x)}if(!Nt(_)&&!_.s&&(Vc(t,_),delete _.f),m.push(_),y&&!y.s&&!_.s)for(let x=y;x&&!Nt(x);x=(u=x.vC)==null?void 0:u.at(-1))x.nN=_;y=_}}e.vR=r?[...e.vC,...h||[]]:h||[],e.vC=m,r&&delete e.pC}catch(h){if(e.f=!0,h===Pp){if(i)return;throw h}const[m,y,f]=((p=e[Se])==null?void 0:p[3])||[];if(y){const _=()=>Ui([0,!1,t[2]],f),v=Li.get(f)||[];v.push(_),Li.set(f,v);const x=y(h,()=>{const N=Li.get(f);if(N){const B=N.indexOf(_);if(B!==-1)return N.splice(B,1),_()}});if(x){if(t[0]===1)t[1]=!0;else if(Vc(t,f,[x]),(y.length===1||t!==m)&&f.c){Jg(f,f.c,!1);return}throw Pp}}throw h}finally{i&&t[5].pop()}},u1=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Se]=[0,[]];else{const e=s1[t.tag];e&&(er||(er=Mg("")),t.props.children=[{tag:er,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Rp=(t,e)=>{var n,r;(n=e[Se][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Vc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Se][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&Jg(e,e.c,!1)},wr=new WeakMap,Lp=[],Ui=async(t,e)=>{t[5]||(t[5]=[]);const n=wr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(wr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Rp(s,e)}).then(()=>r(e)):(Rp(t,e),r(e))}]),Lp.length)Lp.at(-1).add(e);else{await Promise.resolve();const s=wr.get(e);s&&(wr.delete(e),s[1]())}return i},d1=(t,e,n)=>({tag:Wr,props:{children:t},key:n,e,p:1}),oa=0,Yg=1,aa=2,ca=3,la=new WeakMap,Xg=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),p1=void 0,Up=[],f1=t=>{var o;const e=()=>typeof t=="function"?t():t,n=Gr.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Se][1])[oa]||(o[oa]=[]),s=r[Se][0]++;return i[s]||(i[s]=[e(),c=>{const l=p1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Up.length){const[p,h]=Up.at(-1);Promise.all([p===3?r:Ui([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const y=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{y===m.vC&&Ui([p===3?1:0,!1,l],m)})})})}else Ui([0,!1,l],r)}])},ru=(t,e)=>{var c;const n=Gr.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Se][1])[aa]||(c[aa]=[]),s=r[Se][0]++,o=i[s];return Xg(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},h1=t=>{const e=la.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>la.set(t,[n]),n=>la.set(t,[void 0,n])),t},g1=(t,e)=>{var c;const n=Gr.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Se][1])[ca]||(c[ca]=[]),s=r[Se][0]++,o=i[s];return Xg(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},m1=Mg({pending:!1,data:null,method:null,action:null}),Vp=new Set,_1=t=>{Vp.add(t),t.finally(()=>Vp.delete(t))},iu=(t,e)=>g1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),Bn=Object.create(null),Ei=Object.create(null),_i=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:o,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const y=Ti[t];let f;if(y.length>0){const N=s.querySelectorAll(t);e:for(const B of N)for(const R of Ti[t])if(B.getAttribute(R)===e[R]){h=B;break e}if(!h){const B=y.reduce((R,te)=>e[te]===void 0?R:`${R}-${te}-${e[te]}`,t);m=!Ei[B],h=Ei[B]||(Ei[B]=(()=>{const R=document.createElement(t);for(const te of y)e[te]!==void 0&&R.setAttribute(te,e[te]),e.rel&&R.setAttribute("rel",e.rel);return R})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Pi]=l);const _=ru(N=>{if(y.length>0){let B=!1;for(const R of s.querySelectorAll(t)){if(B&&R.getAttribute(Pi)!==l){s.insertBefore(N,R);return}R.getAttribute(Pi)===l&&(B=!0)}s.appendChild(N)}else if(f){let B=!1;for(const R of f)if(R===N){B=!0;break}B||s.insertBefore(N,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),v=iu(e.ref,N=>{var te;const B=y[0];if(n===2&&(N.innerHTML=""),(m||f)&&_(N),!c&&!o)return;let R=Bn[te=N.getAttribute(B)]||(Bn[te]=new Promise((pe,le)=>{N.addEventListener("load",pe),N.addEventListener("error",le)}));o&&(R=R.then(o)),c&&(R=R.catch(c)),R.catch(()=>{})});if(i&&u==="render"){const N=Ti[t][0];if(e[N]){const B=e[N],R=Bn[B]||(Bn[B]=new Promise((te,pe)=>{_(h),h.addEventListener("load",te),h.addEventListener("error",pe)}));h1(R)}}const x={tag:t,type:t,props:{...p,ref:v},ref:v};return x.p=n,h&&(x.e=h),d1(x,s)},y1=t=>{const e=o1(),n=e&&fr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:_i("title",t,void 0,!1,!1)},v1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:_i("script",t,1,!1,!0),w1=t=>!t||!["href","precedence"].every(e=>e in t)?{tag:"style",props:t,type:"style",ref:t.ref}:(t["data-href"]=t.href,delete t.href,_i("style",t,2,!0,!0)),b1=t=>!t||["onLoad","onError"].some(e=>e in t)||t.rel==="stylesheet"&&(!("precedence"in t)||"disabled"in t)?{tag:"link",props:t,type:"link",ref:t.ref}:_i("link",t,1,"precedence"in t,!0),k1=t=>_i("meta",t,void 0,!1,!1),Qg=Symbol(),x1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=f1([null,!1]),s=ru(async u=>{const p=u.isTrusted?e:u.detail[Qg];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(_1(m),await m),i([null,!0])},[]),o=iu(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:m1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:o},type:"form",ref:o}},f:l}},em=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=ru(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[Qg]:e}}))},[]);n.ref=iu(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},S1=t=>em("input",t),A1=t=>em("button",t);Object.assign(Lc,{title:y1,script:v1,style:w1,link:b1,meta:k1,form:x1,input:S1,button:A1});new TextEncoder;const E1=t=>{const{i18nKey:e,values:n,components:r}=t,i=Y.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&o.push(h);const m=parseInt(u,10);o.push(Vb(r[m],{},p)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),E(Ql,{children:o})},Mp=6,I1=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return E(Lo,{title:Y.t("verify_your_email"),vendorSettings:e,children:[E("div",{className:"mb-4 text-2xl font-medium",children:Y.t("verify_your_email")}),E("div",{className:"mb-8 text-gray-300",children:E(E1,{i18nKey:"we_sent_a_code_to",components:[E("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),E("div",{className:"flex flex-1 flex-col justify-center",children:[E(nu,{className:"pt-2",children:[E("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:Mp,inputMode:"numeric",name:"code",placeholder:"******",className:At("mb-2 w-full rounded-lg border bg-gray-100 px-4 pb-2 pt-2.5 text-center indent-[5px] font-mono text-3xl placeholder:text-gray-300 dark:bg-gray-600 md:text-3xl",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),minLength:Mp,required:!0,id:"code-input"}),t&&E(eu,{children:t}),E("div",{className:"text-center sm:mt-2",children:E(tu,{className:"text-base sm:mt-4 md:text-base",children:E("div",{className:"flex items-center space-x-2",children:[E("span",{children:Y.t("login")}),E(kt,{className:"text-xs",name:"arrow-right"})]})})}),E("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[E(kt,{className:"text-base",name:"info-bubble"}),E("div",{className:"text-sm text-gray-300 md:text-sm",children:Y.t("sent_code_spam")})]}),l&&E("div",{className:"text-center mb-12",children:[E("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[E("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),E("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:Y.t("or")})]}),E(Kr,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:Y.t("enter_your_password_btn")})]})]}),E(Ps,{state:r})]})]})},C1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,session:r,client:i}=await Qn(t,e);if(!r.authParams.username)throw new O(400,{message:"Username not found in state"});const s=await Jr({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(E(I1,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({code:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{session:r,client:i}=await Qn(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new O(400,{message:"Username not found in state"});return Jl(t,i,r.authParams,r.authParams.username,n)}),N1=t=>{const{vendorSettings:e,state:n}=t;return E(Lo,{title:Y.t("unverified_email"),vendorSettings:e,children:[E("div",{className:"flex flex-1 flex-col justify-center",children:[E("p",{className:"mb-8 text-gray-300 text-lg",children:Y.t("unverified_email")}),E("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[E(kt,{className:"text-base",name:"info-bubble"}),E("div",{className:"text-sm text-gray-300 md:text-sm",children:Y.t("sent_code_spam")})]}),E(Ps,{state:n})]}),E(Ps,{state:n})]})},ua=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return E(Lo,{title:Y.t("enter_password"),vendorSettings:n,children:[E("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:Y.t("enter_password")}),E("div",{className:"mb-6 text-gray-300",children:Y.t("enter_password_description")}),E("div",{className:"flex flex-1 flex-col justify-center",children:[E(nu,{className:"mb-7",children:[E("input",{type:"text",name:"username",placeholder:Y.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),E("input",{type:"password",name:"password",placeholder:Y.t("password")||"",className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),e&&E(eu,{children:e}),E(tu,{className:"text-base sm:mt-4 md:text-base",children:E("div",{className:"flex items-center space-x-2",children:[E("span",{children:Y.t("login")}),E(kt,{className:"text-xs",name:"arrow-right"})]})})]}),E("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:Y.t("forgot_password_link")}),E("div",{className:"text-center mb-12",children:[E("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[E("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),E("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:Y.t("or")})]}),E("form",{method:"post",action:`/u/enter-email?${s.toString()}`,children:[E("input",{type:"hidden",name:"login_selection",value:"code"}),E("input",{type:"hidden",name:"username",value:r}),E(Kr,{variant:"secondary",className:"block",children:Y.t("enter_a_code_btn")})]})]}),E(Ps,{state:i})]})]})},qp=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,session:i}=await Qn(t,e);if(!i.authParams.username)throw new O(400,{message:"Username required"});return t.html(E(ua,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,session:o}=await Qn(t,e),{username:c}=o.authParams;if(!c)throw new O(400,{message:"Username required"});try{return Pg(t,s,{...o.authParams,password:r})}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(E(ua,{vendorSettings:i,email:c,error:Y.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(E(N1,{vendorSettings:i,state:e}),400):t.html(E(ua,{vendorSettings:i,email:c,error:u.message,state:e,client:s}),400)}});function $1(){const e=new a.OpenAPIHono().route("/enter-email",r1).route("/enter-code",C1).route("/enter-password",qp).route("/reset-password",qp);return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const z1="Account detected",j1="We have detected that you have already created an account through",O1="By signing in, you agree to our",B1="and",T1="Callback URL mismatch",P1="The provided redirect_uri is not in the list of allowed callback URLs.",R1="continue with user",L1="Please click the button to create a new password account.",U1="Enter the code at {{vendorName}} to complete the login",V1="Welcome to {{vendorName}}! {{code}} is the login code",M1="Welcome to {{vendorName}}! {{code}} is the login code",q1="The code is valid for 30 minutes",D1="Confirm password",F1="Need Help?",H1="Contact us",K1="or continue with social account",W1="Continue with {{provider}}",G1="Would you like to continue with your existing account?",J1="Copyright © 2023 SESAMY. All rights reserved.",Z1="©2023 Sesamy",Y1="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",X1="Please enter a valid email address.",Q1="The passwords didn't match. Try again.",ek="Choose password",tk="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",nk="Create new account",rk="Sign up with password",ik="You are currently logged in as <0>{{email}}</0>",sk="Email",ok="Email address",ak="Your email address has been validated",ck="Now enter your password to login again",lk="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",uk="Email verification sent",dk="Enter a code",pk="We'll send you a verification link to ensure you own this email address.",fk="Enter new password",hk="Enter password",gk="Enter your email address and password to login.",mk="Enter your password",_k="The magic link has expired. Please click on the button below to receive a new link in your inbox.",yk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",vk="Send password reset email",wk="Click the button below and we’ll send instructions on how to reset your password.",bk="Password reset email sent",kk="Forgot password?",xk="Forgot password?",Sk="Go back",Ak="Invalid password",Ek=`The link is no longer valid.
|
|
223
223
|
|
|
224
224
|
Please make sure to open the login link in the same browser you started the login with.
|
|
225
225
|
|
|
@@ -247,4 +247,4 @@ Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,yN="Neplatn
|
|
|
247
247
|
|
|
248
248
|
Varmista, että avaat kirjautumislinkin samalla selaimella, jolla aloitit kirjautumisen.
|
|
249
249
|
|
|
250
|
-
Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,Iz="Virheellinen linkki",Cz="Kirjaudu sisään napsauttamalla painiketta",Nz="Kirjaudu sisään",$z="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",zz="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",jz="Yhdistä tilisi {{service}}",Oz="Olet kirjautunut sisään nimellä",Bz="Kirjaudu sisään",Tz="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",Pz="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",Rz="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",Lz="Kirjaudu ulos",Uz="Ei, haluan käyttää toista tiliä",Vz="tai",Mz="Salasana",qz="Salasana on nollattu",Dz="Menestys",Fz="Vaihda salasana tilillesi {{vendorName}} ",Hz="Vaihda salasana tilillesi {{vendorName}} ",Kz="Tietosuojakäytäntö",Wz="Uudelleenohjaus",Gz="Vahvista salasana",Jz="Rekisteröi uusi salasana",Zz="Lähetä koodi uudelleen",Yz="Vaihda salasana",Xz="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",Qz="Napsauta painiketta salasanasi palauttamiseksi",ej="Napsauta painiketta salasanasi palauttamiseksi",tj="Nollaa salasanasi",nj="Vaihda salasana tilillesi {{vendorName}} ",rj="Nollaa salasana",ij="Lähetä",sj="Lähetä minulle uusi maaginen linkki",oj="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",aj="Aseta salasana",cj="Kirjaudu sisään",lj="Rekisteröityminen",uj="Rekisteröidy onnistuneesti",dj="Näyttää siltä, että Spotify-tilisi on tällä hetkellä yhdistetty toiseen Sesamy-tiliin. Mutta älä pelkää, me opastamme sinua prosessin läpi, jotta saat tämän korjattua.",pj="Siirry Spotifyn Content Access -sivulle",fj='Aloitetaan poistamalla Spotify-tilisi linkitys. Klikkaa alla olevaa painiketta siirtyäksesi Spotifyn Content Access -sivulle. Kun olet kirjautunut sisään Spotify-tilillesi, etsi Sesamy yhdistettyjen alustojen luettelosta. Napsauta "Unlink" Sesamyn logon vieressä.',hj="Vaihe 1: Poista Spotify-tilisi linkitys",gj="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",mj="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",_j="Hups! Spotify-tilisi on jo linkitetty",yj="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",vj="Ehdot ja edellytykset",wj="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",bj="Käyttäjätiliä ei ole olemassa",kj="Käyttäjätiliä ei ole olemassa",xj="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",Sj="Yritä uudelleen.",Aj="Validoi koodi",Ej="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",Ij="Rekisteröitynyt",Cj="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",Nj="Vahvista sähköpostiosoitteesi",$j="Vahvista sähköpostiosoitteesi",zj="Vahvista tili",jj="Vahvista sähköpostiosoitteesi",Oj="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",Bj="Tervetuloa",Tj="Tervetuloa tilillesi {{vendorName}}!",Pj="Jatka tällä tilillä",Rj="Kyllä, jatka {{text}}",Lj="Kyllä, jatka olemassa olevalla tilillä",Uj={"Server error: Invalid code":"Virheellinen koodi","Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},account_detected:z$,account_with_sso_provider:j$,agree_to:O$,and:B$,callback_url_mismatch:T$,callback_url_not_allowed:P$,check_email_title:R$,click_to_sign_up_description:L$,code_email_enter_code:U$,code_email_subject:V$,code_email_title:M$,code_valid_30_minutes:q$,confirm_password:D$,contact_support:F$,contact_us:H$,continue:"Jatka",continue_social_login:K$,continue_with:W$,continue_with_sso_provider_headline:G$,copyright:J$,copyright_sesamy:Z$,create_account_description:Y$,create_account_email_invalid:X$,create_account_passwords_didnt_match:Q$,create_account_title:ez,create_account_weak_password:tz,create_new_account_link:nz,create_password_account_title:rz,currently_logged_in_as:iz,email:sz,email_placeholder:oz,email_validated:az,email_validated_cta:cz,email_verification_for_signup_sent_description:lz,email_verification_for_signup_sent_title:uz,enter_a_code_btn:dz,enter_email_for_verification_description:pz,enter_new_password_placeholder:fz,enter_password:hz,enter_password_description:gz,enter_your_password_btn:mz,expired_code:_z,fokus_info_message:yz,forgot_password_cta:vz,forgot_password_description:wz,forgot_password_email_sent:bz,forgot_password_link:kz,forgot_password_title:xz,go_back:Sz,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:Az,invalid_session_body:Ez,invalid_session_title:Iz,link_email_click_to_login:Cz,link_email_login:Nz,link_email_or_enter_code:$z,link_page_body:zz,link_page_headline:jz,logged_in_as:Oz,login:Bz,login_description:Tz,login_description_code:Pz,login_description_link:Rz,logout:Lz,no_use_another:Uz,or:Vz,password:Mz,password_has_been_reset:qz,password_has_been_reset_title:Dz,password_reset_subject:Fz,password_reset_title:Hz,privacy_policy:Kz,redirecting:Wz,reenter_new_password_placeholder:Gz,register_password_account:Jz,resend_code:Zz,reset_password_cta:Yz,reset_password_description:Xz,reset_password_email_click_to_reset:Qz,reset_password_email_cta:ej,reset_password_email_reset:tj,reset_password_subject:nj,reset_password_title:rj,send:ij,send_me_a_new_magic_link:sj,sent_code_spam:oj,set_password:aj,sign_in:cj,signup:lj,signup_success:uj,spotify_already_linked_body:dj,spotify_already_linked_cta:pj,spotify_already_linked_step1_body:fj,spotify_already_linked_step1_title:hj,spotify_already_linked_step2_body:gj,spotify_already_linked_step2_title:mj,spotify_already_linked_title:_j,support_info:yj,terms:vj,unverified_email:wj,user_account_does_not_exist:bj,user_not_found:kj,user_not_found_body:xj,user_not_found_cta:Sj,validate_code:Aj,validate_email_body:Ej,validate_email_title:Ij,verify_email_click_to_verify:Cj,verify_email_subject:Nj,verify_email_title:$j,verify_email_verify:zj,verify_your_email:jj,we_sent_a_code_to:Oj,welcome:Bj,welcome_to_your_account:Tj,yes_continue:Pj,yes_continue_with:Rj,yes_continue_with_existing_account:Lj};Y.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:Ux},it:{translation:G2},nb:{translation:rE},sv:{translation:p3},pl:{translation:bC},cs:{translation:$$},fi:{translation:Uj}}});function Vj(t){const e=new a.OpenAPIHono;e.use(async(s,o)=>(s.env.data=
|
|
250
|
+
Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,Iz="Virheellinen linkki",Cz="Kirjaudu sisään napsauttamalla painiketta",Nz="Kirjaudu sisään",$z="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",zz="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",jz="Yhdistä tilisi {{service}}",Oz="Olet kirjautunut sisään nimellä",Bz="Kirjaudu sisään",Tz="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",Pz="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",Rz="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",Lz="Kirjaudu ulos",Uz="Ei, haluan käyttää toista tiliä",Vz="tai",Mz="Salasana",qz="Salasana on nollattu",Dz="Menestys",Fz="Vaihda salasana tilillesi {{vendorName}} ",Hz="Vaihda salasana tilillesi {{vendorName}} ",Kz="Tietosuojakäytäntö",Wz="Uudelleenohjaus",Gz="Vahvista salasana",Jz="Rekisteröi uusi salasana",Zz="Lähetä koodi uudelleen",Yz="Vaihda salasana",Xz="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",Qz="Napsauta painiketta salasanasi palauttamiseksi",ej="Napsauta painiketta salasanasi palauttamiseksi",tj="Nollaa salasanasi",nj="Vaihda salasana tilillesi {{vendorName}} ",rj="Nollaa salasana",ij="Lähetä",sj="Lähetä minulle uusi maaginen linkki",oj="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",aj="Aseta salasana",cj="Kirjaudu sisään",lj="Rekisteröityminen",uj="Rekisteröidy onnistuneesti",dj="Näyttää siltä, että Spotify-tilisi on tällä hetkellä yhdistetty toiseen Sesamy-tiliin. Mutta älä pelkää, me opastamme sinua prosessin läpi, jotta saat tämän korjattua.",pj="Siirry Spotifyn Content Access -sivulle",fj='Aloitetaan poistamalla Spotify-tilisi linkitys. Klikkaa alla olevaa painiketta siirtyäksesi Spotifyn Content Access -sivulle. Kun olet kirjautunut sisään Spotify-tilillesi, etsi Sesamy yhdistettyjen alustojen luettelosta. Napsauta "Unlink" Sesamyn logon vieressä.',hj="Vaihe 1: Poista Spotify-tilisi linkitys",gj="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",mj="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",_j="Hups! Spotify-tilisi on jo linkitetty",yj="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",vj="Ehdot ja edellytykset",wj="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",bj="Käyttäjätiliä ei ole olemassa",kj="Käyttäjätiliä ei ole olemassa",xj="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",Sj="Yritä uudelleen.",Aj="Validoi koodi",Ej="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",Ij="Rekisteröitynyt",Cj="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",Nj="Vahvista sähköpostiosoitteesi",$j="Vahvista sähköpostiosoitteesi",zj="Vahvista tili",jj="Vahvista sähköpostiosoitteesi",Oj="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",Bj="Tervetuloa",Tj="Tervetuloa tilillesi {{vendorName}}!",Pj="Jatka tällä tilillä",Rj="Kyllä, jatka {{text}}",Lj="Kyllä, jatka olemassa olevalla tilillä",Uj={"Server error: Invalid code":"Virheellinen koodi","Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},account_detected:z$,account_with_sso_provider:j$,agree_to:O$,and:B$,callback_url_mismatch:T$,callback_url_not_allowed:P$,check_email_title:R$,click_to_sign_up_description:L$,code_email_enter_code:U$,code_email_subject:V$,code_email_title:M$,code_valid_30_minutes:q$,confirm_password:D$,contact_support:F$,contact_us:H$,continue:"Jatka",continue_social_login:K$,continue_with:W$,continue_with_sso_provider_headline:G$,copyright:J$,copyright_sesamy:Z$,create_account_description:Y$,create_account_email_invalid:X$,create_account_passwords_didnt_match:Q$,create_account_title:ez,create_account_weak_password:tz,create_new_account_link:nz,create_password_account_title:rz,currently_logged_in_as:iz,email:sz,email_placeholder:oz,email_validated:az,email_validated_cta:cz,email_verification_for_signup_sent_description:lz,email_verification_for_signup_sent_title:uz,enter_a_code_btn:dz,enter_email_for_verification_description:pz,enter_new_password_placeholder:fz,enter_password:hz,enter_password_description:gz,enter_your_password_btn:mz,expired_code:_z,fokus_info_message:yz,forgot_password_cta:vz,forgot_password_description:wz,forgot_password_email_sent:bz,forgot_password_link:kz,forgot_password_title:xz,go_back:Sz,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:Az,invalid_session_body:Ez,invalid_session_title:Iz,link_email_click_to_login:Cz,link_email_login:Nz,link_email_or_enter_code:$z,link_page_body:zz,link_page_headline:jz,logged_in_as:Oz,login:Bz,login_description:Tz,login_description_code:Pz,login_description_link:Rz,logout:Lz,no_use_another:Uz,or:Vz,password:Mz,password_has_been_reset:qz,password_has_been_reset_title:Dz,password_reset_subject:Fz,password_reset_title:Hz,privacy_policy:Kz,redirecting:Wz,reenter_new_password_placeholder:Gz,register_password_account:Jz,resend_code:Zz,reset_password_cta:Yz,reset_password_description:Xz,reset_password_email_click_to_reset:Qz,reset_password_email_cta:ej,reset_password_email_reset:tj,reset_password_subject:nj,reset_password_title:rj,send:ij,send_me_a_new_magic_link:sj,sent_code_spam:oj,set_password:aj,sign_in:cj,signup:lj,signup_success:uj,spotify_already_linked_body:dj,spotify_already_linked_cta:pj,spotify_already_linked_step1_body:fj,spotify_already_linked_step1_title:hj,spotify_already_linked_step2_body:gj,spotify_already_linked_step2_title:mj,spotify_already_linked_title:_j,support_info:yj,terms:vj,unverified_email:wj,user_account_does_not_exist:bj,user_not_found:kj,user_not_found_body:xj,user_not_found_cta:Sj,validate_code:Aj,validate_email_body:Ej,validate_email_title:Ij,verify_email_click_to_verify:Cj,verify_email_subject:Nj,verify_email_title:$j,verify_email_verify:zj,verify_your_email:jj,we_sent_a_code_to:Oj,welcome:Bj,welcome_to_your_account:Tj,yes_continue:Pj,yes_continue_with:Rj,yes_continue_with_existing_account:Lj};Y.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:Ux},it:{translation:G2},nb:{translation:rE},sv:{translation:p3},pl:{translation:bC},cs:{translation:$$},fi:{translation:Uj}}});function Vj(t){const e=new a.OpenAPIHono;e.use(async(s,o)=>(s.env.data=Jw(s,t.dataAdapter),o())),e.get("/",s=>s.json({name:"authhero"}));const n=Ey();e.route("/api/v2",n);const r=bb();e.route("/",r);const i=$1();return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:Oc}}exports.Auth0Client=ef;exports.AuthorizationResponseMode=Wt;exports.AuthorizationResponseType=fn;exports.CodeChallengeMethod=Us;exports.GrantType=kr;exports.LogTypes=me;exports.applicationInsertSchema=Hi;exports.applicationSchema=on;exports.auth0UserResponseSchema=vt;exports.authParamsSchema=Dc;exports.baseUserSchema=Ls;exports.bordersSchema=of;exports.brandingSchema=pa;exports.codeInsertSchema=Zp;exports.codeSchema=Rm;exports.codeTypeSchema=Jp;exports.colorsSchema=af;exports.connectionInsertSchema=Ki;exports.connectionSchema=Mt;exports.domainInsertSchema=Yp;exports.domainSchema=Lm;exports.emailProviderSchema=Ci;exports.fontDetailsSchema=rn;exports.fontsSchema=cf;exports.hookInsertSchema=Gi;exports.hookSchema=Tn;exports.identitySchema=Kp;exports.init=Vj;exports.jwksKeySchema=Xp;exports.jwksSchema=Fc;exports.logSchema=Ji;exports.loginInsertSchema=Qp;exports.loginSchema=Um;exports.openIDConfigurationSchema=fa;exports.pageBackgroundSchema=lf;exports.parseUserId=Fm;exports.passwordInsertSchema=tf;exports.passwordSchema=Mm;exports.profileDataSchema=Hp;exports.promptSettingSchema=Ii;exports.refreshTokenInsertSchema=Hc;exports.refreshTokenSchema=Dm;exports.samlpAddon=Wp;exports.sessionInsertSchema=rf;exports.sessionSchema=Vs;exports.signingKeySchema=ha;exports.tenantInsertSchema=Wi;exports.tenantSchema=Rn;exports.themeInsertSchema=df;exports.themeSchema=qm;exports.tokenResponseSchema=sf;exports.totalsSchema=Yt;exports.userInsertSchema=Fi;exports.userResponseSchema=Om;exports.userSchema=qc;exports.vendorSettingsSchema=Gp;exports.widgetSchema=uf;
|