@descope/web-component
Advanced tools
Comparing version 0.0.26-alpha.5 to 0.0.26-alpha.6
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function n(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}function r(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}function o(t,e,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(t,n):o?o.value=n:e.set(t,n),n}function i(t){this.message=t}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var s="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new i("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,s=0,a="";r=e.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function a(t){this.message=t}function c(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(s(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return s(e)}}(t.split(".")[n]))}catch(t){throw new a("Invalid token specified: "+t.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d="__lodash_hash_undefined__",h="[object Function]",p="[object GeneratorFunction]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/,v=/^\./,b=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y=/\\(\\)?/g,m=/^\[object .+?Constructor\]$/,w="object"==typeof u&&u&&u.Object===Object&&u,I="object"==typeof self&&self&&self.Object===Object&&self,k=w||I||Function("return this")();var j,O=Array.prototype,x=Function.prototype,S=Object.prototype,_=k["__core-js_shared__"],E=(j=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+j:"",U=x.toString,P=S.hasOwnProperty,R=S.toString,C=RegExp("^"+U.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=k.Symbol,D=O.splice,A=z(k,"Map"),M=z(Object,"create"),q=T?T.prototype:void 0,L=q?q.toString:void 0;function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function $(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function J(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function K(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function B(t,e){var n;e=function(t,e){if(V(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||X(t))return!0;return g.test(t)||!f.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:V(n=e)?n:H(n);for(var r=0,o=e.length;null!=t&&r<o;)t=t[G(e[r++])];return r&&r==o?t:void 0}function W(t){if(!Q(t)||(e=t,E&&E in e))return!1;var e,n=function(t){var e=Q(t)?R.call(t):"";return e==h||e==p}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?C:m;return n.test(function(t){if(null!=t){try{return U.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function F(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function z(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return W(n)?n:void 0}N.prototype.clear=function(){this.__data__=M?M(null):{}},N.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},N.prototype.get=function(t){var e=this.__data__;if(M){var n=e[t];return n===d?void 0:n}return P.call(e,t)?e[t]:void 0},N.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:P.call(e,t)},N.prototype.set=function(t,e){return this.__data__[t]=M&&void 0===e?d:e,this},$.prototype.clear=function(){this.__data__=[]},$.prototype.delete=function(t){var e=this.__data__,n=K(e,t);return!(n<0)&&(n==e.length-1?e.pop():D.call(e,n,1),!0)},$.prototype.get=function(t){var e=this.__data__,n=K(e,t);return n<0?void 0:e[n][1]},$.prototype.has=function(t){return K(this.__data__,t)>-1},$.prototype.set=function(t,e){var n=this.__data__,r=K(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},J.prototype.clear=function(){this.__data__={hash:new N,map:new(A||$),string:new N}},J.prototype.delete=function(t){return F(this,t).delete(t)},J.prototype.get=function(t){return F(this,t).get(t)},J.prototype.has=function(t){return F(this,t).has(t)},J.prototype.set=function(t,e){return F(this,t).set(t,e),this};var H=Z((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(X(t))return L?L.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return v.test(t)&&n.push(""),t.replace(b,(function(t,e,r,o){n.push(r?o.replace(y,"$1"):e||t)})),n}));function G(t){if("string"==typeof t||X(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Z(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(Z.Cache||J),n}Z.Cache=J;var V=Array.isArray;function Q(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function X(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==R.call(t)}var Y,tt=function(t,e,n){var r=null==t?void 0:B(t,e);return void 0===r?n:r},et="/v1/auth/otp/verify",nt="/v1/auth/otp/signin",rt="/v1/auth/otp/signup",ot={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},it="/v1/auth/otp/signup-in",st="/v1/auth/magiclink/verify",at="/v1/auth/magiclink/signin",ct="/v1/auth/magiclink/signup",ut="/v1/auth/magiclink/pending-session",lt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},dt="/v1/auth/magiclink/signup-in",ht="/v1/auth/oauth/authorize",pt="/v1/auth/saml/authorize",ft="/v1/auth/totp/verify",gt="/v1/auth/totp/signup",vt="/v1/user/totp/update",bt={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},yt={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},mt={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},wt="/v1/flow/start",It="/v1/flow/next";!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Y||(Y={}));const kt=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}},jt=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,r])=>(t[n]=r,t)),t),t}),{})),Ot=t=>void 0===t?void 0:JSON.stringify(t),xt=(t,e="")=>{let n=t;return""!==e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},St=({baseUrl:t,projectId:e,baseConfig:n,logger:r,hooks:o,cookiePolicy:i})=>{const s=((t,e)=>{const n=e||fetch;if(!n)throw new Error("fetch is not defined");return t?async(...e)=>{t.log((t=>kt().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const r=await n(...e);return t[r.ok?"log":"error"](await(async t=>{const e=await t.text();return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),kt().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(r)),r}:n})(r),a=async r=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:l,queryParams:d,method:h,token:p}=a,f=await s((({path:t,baseUrl:e,queryParams:n})=>{const r=new URL(t,e);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:t,queryParams:d}),{headers:jt(xt(e,p),(null==n?void 0:n.baseHeaders)||{},l),method:h,body:Ot(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:r}={})=>a({path:t,headers:e,queryParams:n,body:void 0,method:Y.get,token:r}),post:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.post,token:o}),put:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.put,token:o}),delete:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.delete,token:o})}},_t=t=>{if("string"!=typeof t||!t)throw new Error("Invalid token provided");const{exp:e}=c(t);return(new Date).getTime()/1e3>e},Et=(...t)=>t.join("/").replace(/\/{2,}/g,"/"),Ut=async t=>{const e=await t,n={code:e.status,ok:e.ok,response:e},r=await e.json();return e.ok?n.data=r:n.error=r,n};var Pt,Rt,Ct;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Pt||(Pt={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(Rt||(Rt={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(Ct||(Ct={}));const Tt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Dt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),At=t=>e=>t.test(e),Mt=At(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),qt=At(/^\+[1-9]{1}[0-9]{3,14}$/),Lt=Tt(Mt,'"{val}" is not a valid email'),Nt=Tt(qt,'"{val}" is not a valid phone number'),$t=Tt((1,t=>t.length>=1),"Minimum length is 1");const Jt=Tt((t=>"string"==typeof t),"Input is not a string"),Kt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Dt(...t).validate(n[e]))),e(...n)),Bt=t=>[Jt(`"${t}" must be a string`),$t(`"${t}" must not be empty`)],Wt=t=>[Jt(`"${t}" must be a string`),Lt()],Ft=t=>[Jt(`"${t}" must be a string`),Nt()];var zt;!function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(zt||(zt={}));const Ht=Bt("identifier"),Gt=Kt(Ht,Bt("code")),Zt=Kt(Ht),Vt=Kt(Ht,Ft("phone")),Qt=Kt(Ht,Wt("email")),Xt=t=>({verify:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Gt(((e,r)=>Ut(t.post(Et(et,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Zt((e=>Ut(t.post(Et(nt,n),{externalId:e}))))})),{}),signUp:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Zt(((e,r)=>Ut(t.post(Et(rt,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Zt((e=>Ut(t.post(Et(it,n),{externalId:e}))))})),{}),update:{email:Qt(((e,n,r)=>Ut(t.post(ot.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(Pt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Vt(((e,r,o)=>Ut(t.post(Et(ot.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),Yt=Bt("identifier"),te=Bt("uri"),ee=Kt(Bt("token")),ne=Kt(Yt,te),re=Kt(Bt("pendingRef")),oe=Kt(Yt,Ft("phone"),te),ie=Kt(Yt,Wt("email"),te),se=t=>({verify:ee((e=>Ut(t.post(st,{token:e})))),signIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(at,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(dt,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r,o)=>Ut(t.post(Et(ct,n),{externalId:e,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:re(((e,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||6e5,6e5)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(ut,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Ut(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ie(((e,n,r,o)=>Ut(t.post(lt.email,{externalId:e,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Pt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:oe(((e,r,o,i)=>Ut(t.post(Et(lt.phone,n),{externalId:e,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),ae=t=>({verify:ee((e=>Ut(t.post(st,{token:e})))),signIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(at,n),{externalId:e,URI:r}))))})),{}),signUp:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r,o)=>Ut(t.post(Et(ct,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(dt,n),{externalId:e,URI:r}))))})),{}),update:{email:ie(((e,n,r,o)=>Ut(t.post(lt.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(Pt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:oe(((e,r,o,i)=>Ut(t.post(Et(lt.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})},crossDevice:se(t)}),ce=Kt(Bt("code")),ue=t=>({exchange:ce((e=>Ut(t.get("/v1/auth/exchange",{queryParams:{code:e}}))))});var le;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(le||(le={}));const de=t=>Object.assign({start:Object.keys(le).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={})=>{const o=await t.get(ht,{queryParams:Object.assign({provider:n},e&&{redirectURL:e})});if(!r||!o.ok)return Ut(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},ue(t)),he=Kt(Bt("flowId")),pe=Kt(Bt("executionId"),Bt("stepId"),Bt("interactionId")),fe=t=>({start:he((e=>Ut(t.post(wt,{flowId:e})))),next:pe(((e,n,r,o)=>Ut(t.post(It,{executionId:e,stepId:n,interactionId:r,input:o}))))}),ge=Kt(Bt("tenant")),ve=t=>Object.assign({start:ge((async(e,n,{redirect:r=!1}={})=>{const o=await t.get(pt,{queryParams:{tenant:e,redirectURL:n}});if(!r||!o.ok)return Ut(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},ue(t)),be=Bt("identifier"),ye=Kt(be,Bt("code")),me=Kt(be),we=Kt(be),Ie=t=>({signUp:me(((e,n)=>Ut(t.post(gt,{externalId:e,user:n})))),verify:ye(((e,n)=>Ut(t.post(ft,{externalId:e,code:n})))),update:we(((e,n)=>Ut(t.post(vt,{externalId:e},{token:n}))))}),ke=Bt("identifier"),je=Bt("origin"),Oe=Kt(ke,je,Bt("name")),xe=Kt(ke,je),Se=Kt(ke,je,Bt("token")),_e=Kt(Bt("transactionId"),Bt("response")),Ee=t=>({signUp:{start:Oe(((e,n,r)=>Ut(t.post(bt.start,{user:{externalId:e,name:r},origin:n})))),finish:_e(((e,n)=>Ut(t.post(bt.finish,{transactionId:e,response:n}))))},signIn:{start:xe(((e,n)=>Ut(t.post(yt.start,{externalId:e,origin:n})))),finish:_e(((e,n)=>Ut(t.post(yt.finish,{transactionId:e,response:n}))))},update:{start:Se(((e,n,r)=>Ut(t.post(mt.start,{externalId:e,origin:n},{token:r})))),finish:_e(((e,n)=>Ut(t.post(mt.finish,{transactionId:e,response:n}))))}}),Ue=Kt(Bt("token"));var Pe;const Re=Kt([("projectId",Pe=Bt("projectId"),Tt(((t,e)=>t=>Dt(...e).validate(tt(t,"projectId")))(0,Pe))())])((({projectId:t,logger:e,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=St({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r,cookiePolicy:o}),{otp:Xt(i),magicLink:ae(i),oauth:de(i),saml:ve(i),totp:Ie(i),webauthn:Ee(i),flow:fe(i),refresh:t=>Ut(i.get("/v1/auth/refresh",{token:t})),logout:t=>Ut(i.get("/v1/auth/logoutall",{token:t})),isJwtExpired:Ue(_t),httpClient:i};var i}));function Ce(t,e,n){return void 0===n&&(n=0),e(n).catch((function(r){if(n>=t.maxRetries||!t.shouldRetry(r))throw r;var o,i,s,a,c=(o=t.baseDelay,i=t.maxDelay,s=t.baseDelay*Math.pow(2,n),Math.max(o,Math.min(i,s)));return(a=c,new Promise((function(t){return setTimeout(t,a)}))).then((function(){return Ce(t,e,n+1)}))}))}Re.DeliveryMethods=Rt;var Te="Failed to load the JS script of the agent";function De(n){var r,o=n.scriptUrlPattern,i=n.token,s=n.apiKey,a=void 0===s?i:s,c=e(n,["scriptUrlPattern","token","apiKey"]),u=(r=n,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(r,"scriptUrlPattern")?o:void 0),l=[];return Promise.resolve().then((function(){if(!a||"string"!=typeof a)throw new Error("API key required");return Ce({maxRetries:5,baseDelay:100,maxDelay:3e3,shouldRetry:function(t){return!(t instanceof Error&&"Blocked by CSP"===t.message)}},(function(){var t,e=new Date,n=function(){return l.push({startedAt:e,finishedAt:new Date})},r=function(t,e,n,r){var o,i=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),r=e.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=e,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return c(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(c(),o)return function(){throw new Error("Blocked by CSP")}();throw t}))}))}(t=function(t,e){void 0===e&&(e="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js");var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.7.1"):e}))}(a,u),(function(){return function(t){return new Promise((function(e,n){var r=document.createElement("script"),o=function(){var t;return null===(t=r.parentNode)||void 0===t?void 0:t.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),e()},r.onerror=function(){o(),n(new Error(Te))},r.async=!0,r.src=t,i.appendChild(r)}))}(t)}));return r.then(n,n),r}))})).then((function(){var e=window,n="__fpjs_p_l_b",r=e[n];if(function(t,e){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==r?void 0:r.configurable)?delete t[e]:r&&!r.writable||(t[e]=void 0)}(e,n),"function"!=typeof(null==r?void 0:r.load))throw new Error(Te);return r.load(t(t({},c),{ldi:{attempts:l}}))}))}var Ae={exports:{}},Me={exports:{}};Me.exports=function(){function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function e(n,r){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=t({},r,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=e+"="+n.write(o,e)+s}}function i(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],r={},o=0;o<e.length;o++){var i=e[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=n.read(s,a),t===a)break}catch(t){}}return t?r[t]:r}}return Object.create({set:o,get:i,remove:function(e,n){o(e,"",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}return e({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}(),function(t){t.exports=Me.exports}(Ae);var qe=l(Ae.exports);const Le=t=>{const e=De({apiKey:t||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let t=sessionStorage.getItem("vsid");t||(t=(t=>new Proxy(new URLSearchParams(window.location.search),{get:(t,e)=>t.get(e.toString())})[t])("vsid")),t||(t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",t);const n=await e,r=await n.get({linkedId:t});sessionStorage.setItem("vrid",r.requestId)}catch(t){global.FB_DEBUG&&console.error(t)}}}};let Ne=[];function $e(t,e){const n=function(t){const e=t.split(".");try{if(3===e.length){const e=JSON.parse(window.atob(t.split(".")[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(t){}return null}(e);if(n){let e;for(;e=Ne.pop();)clearTimeout(e);const r=n.getTime()-2e4-(new Date).getTime(),o=setTimeout((()=>{const e=Je();e&&t(e)}),r);Ne.push(o)}}function Je(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}var Ke=t=>{var{persistTokens:n=!0}=t,r=e(t,["persistTokens"]);Le(r.fpKey).get().catch((()=>null));const o=r;let i;if(o.hooks={beforeRequest:t=>{var e;return t.queryParams=(e=t.queryParams,Object.assign(Object.assign({},e),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),n&&!t.token&&(t.token=Je()),t}},n&&(o.hooks.afterRequest=async(t,e)=>{!async function(t,e,n){try{const e=await(null==n?void 0:n.json());if(e){const n=function(t){const{sessionJwt:e,refreshJwt:n}=t||{};return function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:r}){t&&qe.set("DS",t,{path:e,domain:n,expires:r,sameSite:"None",secure:!0})}(e,t||{}),function(t){localStorage&&t&&localStorage.setItem("DSR",t)}(n),e}((null==e?void 0:e.authInfo)||e);n&&$e(t,n)}}catch(t){console.error("Could not set tokens from body",t)}}(i.refresh,0,e)}),i=Re(r),n){const t=i.logout;i.logout=(...e)=>(localStorage&&localStorage.removeItem("DSR"),qe.remove("DS"),t(...e))}return i};const Be="descope-login-flow",We="code",Fe="redirect",ze="poll",He="webauthnCreate",Ge="webauthnGet";function Ze(t){return new URLSearchParams(window.location.search).get(t)}function Ve(){return Ze(Be)}function Qe(t){if(window.history.replaceState&&Ze(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}var Xe;function Ye(t){const e=`/${t}.html`,n=new URL("http://static.sandbox.descope.com.s3-website.eu-central-1.amazonaws.com/pages");return n.pathname+=e,n.toString()}function tn(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?Xe.forward:t<e?Xe.backward:void 0}!function(t){t.backward="backward",t.forward="forward"}(Xe||(Xe={}));const en=()=>{const[t="",e=""]=(Ve()||"").split("_");return{executionId:t,stepId:e}},nn=(t,e)=>{!function(t){if(window.history.pushState&&t!==Ve()){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.set(Be,t),e.search=n.toString(),window.history.pushState({},"",e.toString())}}([t,e].join("_"))};function rn(){Qe(Be)}const on=(t,e,n="")=>{t.querySelectorAll(`[data-type="${e}"]`).forEach((t=>{t.innerText=n,t.classList[n?"remove":"add"]("hide")}))},sn=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var an,cn,un,ln,dn,hn,pn,fn,gn,vn,bn,yn,mn,wn,In,kn,jn,On,xn,Sn,_n,En,Un,Pn;class Rn{constructor(t={}){an.set(this,void 0),cn.set(this,{}),un.set(this,0),o(this,an,t,"f")}get current(){return Object.assign({},r(this,an,"f"))}update(t){const e="function"==typeof t?t(r(this,an,"f")):t,n=Object.assign(Object.assign({},r(this,an,"f")),e);if(!function(t,e){const n=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r];if(t[o]!==e[o])return!1}return!0}(r(this,an,"f"),n)){const t=r(this,an,"f");o(this,an,n,"f"),Object.freeze(r(this,an,"f")),setTimeout((()=>{Object.values(r(this,cn,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return o(this,un,r(this,un,"f")+1,"f"),r(this,cn,"f")[r(this,un,"f")]=t,r(this,un,"f").toString()}unsubscribe(t){const e=!!r(this,cn,"f")[t];return e&&delete r(this,cn,"f")[t],e}unsubscribeAll(){return o(this,cn,{},"f"),!0}}function Cn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Dn(n.publicKey.challenge),n.publicKey.user.id=Dn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Dn(t.id)})),n}(t),n=yield navigator.credentials.create(e);return r=n,JSON.stringify({id:r.id,rawId:An(r.rawId),type:r.type,response:{attestationObject:An(r.response.attestationObject),clientDataJSON:An(r.response.clientDataJSON)}});var r}))}function Tn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Dn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Dn(t.id)})),n}(t),n=yield navigator.credentials.get(e);return r=n,JSON.stringify({id:r.id,rawId:An(r.rawId),type:r.type,response:{authenticatorData:An(r.response.authenticatorData),clientDataJSON:An(r.response.clientDataJSON),signature:An(r.response.signature),userHandle:An(r.response.userHandle)}});var r}))}function Dn(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function An(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}an=new WeakMap,cn=new WeakMap,un=new WeakMap,function(t){t.waiting="waiting",t.completed="completed",t.failed="failed",t.running="running"}(ln||(ln={}));const Mn=document.createElement("template");Mn.innerHTML="\n\t<style>\n\t\t:host {\n\t\t\tdisplay: inline-block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\tform {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<form></form>\n\t";class qn extends HTMLElement{constructor(){super(),dn.add(this),hn.set(this,!1),pn.set(this,new Rn),fn.set(this,new Rn),gn.set(this,void 0),vn.set(this,void 0),bn.set(this,void 0),yn.set(this,{popstate:r(this,dn,"m",kn).bind(this)}),mn.set(this,void 0),Sn.set(this,(t=>{var e;if(r(this,dn,"m",On).call(this,t))return;const{executionId:n,stepId:o,status:i,action:s,screen:a,redirect:c,authInfo:u,error:l,webauthn:d}=t.data;r(this,dn,"m",jn).call(this,i,l,u)||r(this,pn,"f").update({stepId:o,executionId:n,action:s,redirectUrl:null==c?void 0:c.url,screenId:null==a?void 0:a.id,screenErrorText:null===(e=null==a?void 0:a.state)||void 0===e?void 0:e.errorText,webauthnTransactionId:null==d?void 0:d.transactionId,webauthnOptions:null==d?void 0:d.options})})),r(this,dn,"m",wn).call(this),r(this,pn,"f").subscribe(r(this,dn,"m",xn).bind(this)),r(this,fn,"f").subscribe(r(this,dn,"m",En).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url"]}get"project-id"(){return this.getAttribute("project-id")}get"flow-id"(){return this.getAttribute("flow-id")}get"base-url"(){return this.getAttribute("base-url")||void 0}connectedCallback(){if(this.shadowRoot.isConnected){o(this,hn,!0,"f"),r(this,dn,"m",In).call(this);const{executionId:t,stepId:e}=en(),n=Ze("t")||void 0;n&&Qe("t");const i=Ze(We)||void 0;i&&Qe(We),r(this,pn,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],stepId:e,executionId:t,token:n,code:i}),window.addEventListener("popstate",r(this,yn,"f").popstate),r(this,gn,"f").onkeydown=t=>{"Enter"===t.key&&t.preventDefault()}}}disconnectedCallback(){r(this,pn,"f").unsubscribeAll(),r(this,fn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,yn,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,hn,"f")&&e!==n&&qn.observedAttributes.includes(t)){r(this,dn,"m",In).call(this);const o=null===e;r(this,pn,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,rn()),{[sn(t)]:n,stepId:i,executionId:s}}))}}}hn=new WeakMap,pn=new WeakMap,fn=new WeakMap,gn=new WeakMap,vn=new WeakMap,bn=new WeakMap,yn=new WeakMap,mn=new WeakMap,Sn=new WeakMap,dn=new WeakSet,wn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Mn.content.cloneNode(!0)),o(this,gn,this.shadowRoot.querySelector("form"),"f"),o(this,vn,this.shadowRoot.querySelector("style"),"f")},In=function(){const t=["base-url"];qn.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)}))},kn=function(){const{stepId:t,executionId:e}=en();r(this,pn,"f").update({stepId:t,executionId:e})},jn=function(t,e,n){switch(t){case ln.failed:return rn(),r(this,dn,"m",Pn).call(this,"error",e),!0;case ln.completed:return rn(),r(this,dn,"m",Pn).call(this,"success",n),!0;default:return!1}},On=function({ok:t,error:e}){return t||r(this,dn,"m",Pn).call(this,"error",e),!t},xn=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:s,flowId:a,baseUrl:c,stepId:u,executionId:l,action:d,screenId:h,screenErrorText:p,redirectUrl:f,token:g,code:v,webauthnTransactionId:b,webauthnOptions:y}=t,m=i("projectId")||i("baseUrl");if(r(this,bn,"f")&&(clearInterval(r(this,bn,"f")),o(this,bn,null,"f")),m){if(!s)return;o(this,mn,Ke({projectId:s,baseUrl:c}),"f")}if(!l){if(!a)return;const t=yield r(this,mn,"f").flow.start(a);return void r(this,Sn,"f").call(this,t)}if(i("token")&&g||i("code")&&v){const t=yield r(this,mn,"f").flow.next(l,u,"submit",{token:g,code:v});return r(this,Sn,"f").call(this,t),nn(t.data.executionId,t.data.stepId),void r(this,pn,"f").update({token:void 0,code:void 0})}if(d===Fe)return f?void window.location.assign(f):void console.error("Did not get redirect url");if(d===He||d===Ge){if(!b||!y)return void console.error("Did not get webauthn transaction id or options");const t=d===He?yield Cn(y):yield Tn(y),e=yield r(this,mn,"f").flow.next(l,u,"submit",{transactionId:b,response:t});return void r(this,Sn,"f").call(this,e)}if(d===ze&&o(this,bn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,mn,"f").flow.next(l,u,"submit",{});r(this,Sn,"f").call(this,t)}))),2e3),"f"),!h)return void console.error("Refreshing the page during a flow is not supported yet");const w={direction:tn(+u,+e.stepId),screenErrorText:p,htmlUrl:Ye(h)};(m||i("executionId")||i("stepId"))&&(w.next=(...t)=>r(this,mn,"f").flow.next(l,u,...t)),r(this,fn,"f").update(w)}))},_n=function(t){r(this,gn,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n;const o=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id");e.preventDefault();const i=Object.fromEntries(new FormData(e.target).entries()),s=yield t(o,Object.assign(Object.assign({},i),{origin:window.location.origin}));nn(s.data.executionId,s.data.stepId),r(this,Sn,"f").call(this,s)}))},En=function(t,e,o){return n(this,void 0,void 0,(function*(){const e="error-message",{htmlUrl:i,validations:s={},direction:a,next:c,screenErrorText:u}=t;if(!o("htmlUrl"))return o("next")&&r(this,dn,"m",_n).call(this,c),void(o("screenErrorText")&&on(this.shadowRoot,e,u));const l=document.createElement("template");l.innerHTML=yield function(t){return n(this,void 0,void 0,(function*(){const e=yield fetch(t,{cache:"default"});if(!e.ok)throw new Error(t);return e.text()}))}(i);const d=l.content.cloneNode(!0),h=(t=>{var e;const n=Array.from(t.querySelectorAll("script[data-id]")).map((e=>{var n;const r=e.getAttribute("data-id"),o=null===(n=t.getElementById(r))||void 0===n?void 0:n.innerHTML,i=Function(o).bind(e.previousSibling);return e.remove(),i}));return null===(e=t.querySelector("scripts"))||void 0===e||e.remove(),n})(d),p=()=>{!function(t,e){Object.entries(e).forEach((([e,n])=>{const r=t.getElementById(e);if(!r)throw new Error(`Cannot find element with id: ${e}`);Object.entries(n).forEach((([t,e])=>{r.setAttribute(t,e.toString()),r.addEventListener("blur",(()=>r.classList.add("touched")),{once:!0})}))}))}(d,s),on(d,e,u);try{h.forEach((t=>t()))}catch(t){console.error(t)}r(this,gn,"f").replaceChildren(d),r(this,dn,"m",_n).call(this,c),r(this,dn,"m",Pn).call(this,"page-updated",{})};a?r(this,dn,"m",Un).call(this,p,a):p()}))},Un=function(t,e){r(this,gn,"f").addEventListener("transitionend",(()=>{r(this,gn,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===Xe.forward?"slide-forward":"slide-backward";Array.from(r(this,gn,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,gn,"f").classList.add("fade-out")},Pn=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",qn)}(); | ||
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function n(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}function r(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}function o(t,e,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(t,n):o?o.value=n:e.set(t,n),n}function i(t){this.message=t}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var s="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new i("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,s=0,a="";r=e.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function a(t){this.message=t}function c(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(s(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return s(e)}}(t.split(".")[n]))}catch(t){throw new a("Invalid token specified: "+t.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d="__lodash_hash_undefined__",h="[object Function]",p="[object GeneratorFunction]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,v=/^\w*$/,g=/^\./,b=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,m=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,w="object"==typeof u&&u&&u.Object===Object&&u,I="object"==typeof self&&self&&self.Object===Object&&self,k=w||I||Function("return this")();var j,O=Array.prototype,x=Function.prototype,S=Object.prototype,_=k["__core-js_shared__"],E=(j=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+j:"",U=x.toString,P=S.hasOwnProperty,R=S.toString,C=RegExp("^"+U.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=k.Symbol,D=O.splice,A=z(k,"Map"),M=z(Object,"create"),q=T?T.prototype:void 0,L=q?q.toString:void 0;function $(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function J(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function K(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function B(t,e){var n;e=function(t,e){if(V(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||X(t))return!0;return v.test(t)||!f.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:V(n=e)?n:H(n);for(var r=0,o=e.length;null!=t&&r<o;)t=t[G(e[r++])];return r&&r==o?t:void 0}function W(t){if(!Q(t)||(e=t,E&&E in e))return!1;var e,n=function(t){var e=Q(t)?R.call(t):"";return e==h||e==p}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?C:y;return n.test(function(t){if(null!=t){try{return U.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function F(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function z(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return W(n)?n:void 0}$.prototype.clear=function(){this.__data__=M?M(null):{}},$.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},$.prototype.get=function(t){var e=this.__data__;if(M){var n=e[t];return n===d?void 0:n}return P.call(e,t)?e[t]:void 0},$.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:P.call(e,t)},$.prototype.set=function(t,e){return this.__data__[t]=M&&void 0===e?d:e,this},N.prototype.clear=function(){this.__data__=[]},N.prototype.delete=function(t){var e=this.__data__,n=K(e,t);return!(n<0)&&(n==e.length-1?e.pop():D.call(e,n,1),!0)},N.prototype.get=function(t){var e=this.__data__,n=K(e,t);return n<0?void 0:e[n][1]},N.prototype.has=function(t){return K(this.__data__,t)>-1},N.prototype.set=function(t,e){var n=this.__data__,r=K(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},J.prototype.clear=function(){this.__data__={hash:new $,map:new(A||N),string:new $}},J.prototype.delete=function(t){return F(this,t).delete(t)},J.prototype.get=function(t){return F(this,t).get(t)},J.prototype.has=function(t){return F(this,t).has(t)},J.prototype.set=function(t,e){return F(this,t).set(t,e),this};var H=Z((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(X(t))return L?L.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return g.test(t)&&n.push(""),t.replace(b,(function(t,e,r,o){n.push(r?o.replace(m,"$1"):e||t)})),n}));function G(t){if("string"==typeof t||X(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Z(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(Z.Cache||J),n}Z.Cache=J;var V=Array.isArray;function Q(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function X(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==R.call(t)}var Y,tt=function(t,e,n){var r=null==t?void 0:B(t,e);return void 0===r?n:r},et="/v1/auth/otp/verify",nt="/v1/auth/otp/signin",rt="/v1/auth/otp/signup",ot={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},it="/v1/auth/otp/signup-in",st="/v1/auth/magiclink/verify",at="/v1/auth/magiclink/signin",ct="/v1/auth/magiclink/signup",ut="/v1/auth/magiclink/pending-session",lt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},dt="/v1/auth/magiclink/signup-in",ht="/v1/auth/oauth/authorize",pt="/v1/auth/saml/authorize",ft="/v1/auth/totp/verify",vt="/v1/auth/totp/signup",gt="/v1/user/totp/update",bt={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},mt={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},yt={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},wt="/v1/flow/start",It="/v1/flow/next";!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Y||(Y={}));const kt=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}},jt=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,r])=>(t[n]=r,t)),t),t}),{})),Ot=t=>void 0===t?void 0:JSON.stringify(t),xt=(t,e="")=>{let n=t;return""!==e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},St=({baseUrl:t,projectId:e,baseConfig:n,logger:r,hooks:o,cookiePolicy:i})=>{const s=((t,e)=>{const n=e||fetch;if(!n)throw new Error("fetch is not defined");return t?async(...e)=>{t.log((t=>kt().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const r=await n(...e);return t[r.ok?"log":"error"](await(async t=>{const e=await t.text();return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),kt().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(r)),r}:n})(r),a=async r=>{const a=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:u,headers:l,queryParams:d,method:h,token:p}=a,f=await s((({path:t,baseUrl:e,queryParams:n})=>{const r=new URL(t,e);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:c,baseUrl:t,queryParams:d}),{headers:jt(xt(e,p),(null==n?void 0:n.baseHeaders)||{},l),method:h,body:Ot(u),credentials:i||"include"});return(null==o?void 0:o.afterRequest)&&o.afterRequest(r,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:r}={})=>a({path:t,headers:e,queryParams:n,body:void 0,method:Y.get,token:r}),post:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.post,token:o}),put:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.put,token:o}),delete:(t,e,{headers:n,queryParams:r,token:o}={})=>a({path:t,headers:n,queryParams:r,body:e,method:Y.delete,token:o})}},_t=t=>{if("string"!=typeof t||!t)throw new Error("Invalid token provided");const{exp:e}=c(t);return(new Date).getTime()/1e3>e},Et=(...t)=>t.join("/").replace(/\/{2,}/g,"/"),Ut=async t=>{const e=await t,n={code:e.status,ok:e.ok,response:e},r=await e.json();return e.ok?n.data=r:n.error=r,n};var Pt,Rt,Ct;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Pt||(Pt={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(Rt||(Rt={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(Ct||(Ct={}));const Tt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Dt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),At=t=>e=>t.test(e),Mt=At(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),qt=At(/^\+[1-9]{1}[0-9]{3,14}$/),Lt=Tt(Mt,'"{val}" is not a valid email'),$t=Tt(qt,'"{val}" is not a valid phone number'),Nt=Tt((1,t=>t.length>=1),"Minimum length is 1");const Jt=Tt((t=>"string"==typeof t),"Input is not a string"),Kt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Dt(...t).validate(n[e]))),e(...n)),Bt=t=>[Jt(`"${t}" must be a string`),Nt(`"${t}" must not be empty`)],Wt=t=>[Jt(`"${t}" must be a string`),Lt()],Ft=t=>[Jt(`"${t}" must be a string`),$t()];var zt;!function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(zt||(zt={}));const Ht=Bt("identifier"),Gt=Kt(Ht,Bt("code")),Zt=Kt(Ht),Vt=Kt(Ht,Ft("phone")),Qt=Kt(Ht,Wt("email")),Xt=t=>({verify:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Gt(((e,r)=>Ut(t.post(Et(et,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Zt((e=>Ut(t.post(Et(nt,n),{externalId:e}))))})),{}),signUp:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Zt(((e,r)=>Ut(t.post(Et(rt,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Zt((e=>Ut(t.post(Et(it,n),{externalId:e}))))})),{}),update:{email:Qt(((e,n,r)=>Ut(t.post(ot.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(Pt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Vt(((e,r,o)=>Ut(t.post(Et(ot.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),Yt=Bt("identifier"),te=Bt("uri"),ee=Kt(Bt("token")),ne=Kt(Yt,te),re=Kt(Bt("pendingRef")),oe=Kt(Yt,Ft("phone"),te),ie=Kt(Yt,Wt("email"),te),se=t=>({verify:ee((e=>Ut(t.post(st,{token:e})))),signIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(at,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(dt,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r,o)=>Ut(t.post(Et(ct,n),{externalId:e,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:re(((e,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||6e5,6e5)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(ut,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Ut(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ie(((e,n,r,o)=>Ut(t.post(lt.email,{externalId:e,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Pt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:oe(((e,r,o,i)=>Ut(t.post(Et(lt.phone,n),{externalId:e,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),ae=t=>({verify:ee((e=>Ut(t.post(st,{token:e})))),signIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(at,n),{externalId:e,URI:r}))))})),{}),signUp:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r,o)=>Ut(t.post(Et(ct,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Rt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ut(t.post(Et(dt,n),{externalId:e,URI:r}))))})),{}),update:{email:ie(((e,n,r,o)=>Ut(t.post(lt.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(Pt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:oe(((e,r,o,i)=>Ut(t.post(Et(lt.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})},crossDevice:se(t)}),ce=Kt(Bt("code")),ue=t=>({exchange:ce((e=>Ut(t.get("/v1/auth/exchange",{queryParams:{code:e}}))))});var le;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(le||(le={}));const de=t=>Object.assign({start:Object.keys(le).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={})=>{const o=await t.get(ht,{queryParams:Object.assign({provider:n},e&&{redirectURL:e})});if(!r||!o.ok)return Ut(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},ue(t)),he=Kt(Bt("flowId")),pe=Kt(Bt("executionId"),Bt("stepId"),Bt("interactionId")),fe=t=>({start:he((e=>Ut(t.post(wt,{flowId:e})))),next:pe(((e,n,r,o)=>Ut(t.post(It,{executionId:e,stepId:n,interactionId:r,input:o}))))}),ve=Kt(Bt("tenant")),ge=t=>Object.assign({start:ve((async(e,n,{redirect:r=!1}={})=>{const o=await t.get(pt,{queryParams:{tenant:e,redirectURL:n}});if(!r||!o.ok)return Ut(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},ue(t)),be=Bt("identifier"),me=Kt(be,Bt("code")),ye=Kt(be),we=Kt(be),Ie=t=>({signUp:ye(((e,n)=>Ut(t.post(vt,{externalId:e,user:n})))),verify:me(((e,n)=>Ut(t.post(ft,{externalId:e,code:n})))),update:we(((e,n)=>Ut(t.post(gt,{externalId:e},{token:n}))))}),ke=Bt("identifier"),je=Bt("origin"),Oe=Kt(ke,je,Bt("name")),xe=Kt(ke,je),Se=Kt(ke,je,Bt("token")),_e=Kt(Bt("transactionId"),Bt("response")),Ee=t=>({signUp:{start:Oe(((e,n,r)=>Ut(t.post(bt.start,{user:{externalId:e,name:r},origin:n})))),finish:_e(((e,n)=>Ut(t.post(bt.finish,{transactionId:e,response:n}))))},signIn:{start:xe(((e,n)=>Ut(t.post(mt.start,{externalId:e,origin:n})))),finish:_e(((e,n)=>Ut(t.post(mt.finish,{transactionId:e,response:n}))))},update:{start:Se(((e,n,r)=>Ut(t.post(yt.start,{externalId:e,origin:n},{token:r})))),finish:_e(((e,n)=>Ut(t.post(yt.finish,{transactionId:e,response:n}))))}}),Ue=Kt(Bt("token"));var Pe;const Re=Kt([("projectId",Pe=Bt("projectId"),Tt(((t,e)=>t=>Dt(...e).validate(tt(t,"projectId")))(0,Pe))())])((({projectId:t,logger:e,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=St({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r,cookiePolicy:o}),{otp:Xt(i),magicLink:ae(i),oauth:de(i),saml:ge(i),totp:Ie(i),webauthn:Ee(i),flow:fe(i),refresh:t=>Ut(i.get("/v1/auth/refresh",{token:t})),logout:t=>Ut(i.get("/v1/auth/logoutall",{token:t})),isJwtExpired:Ue(_t),httpClient:i};var i}));function Ce(t,e,n){return void 0===n&&(n=0),e(n).catch((function(r){if(n>=t.maxRetries||!t.shouldRetry(r))throw r;var o,i,s,a,c=(o=t.baseDelay,i=t.maxDelay,s=t.baseDelay*Math.pow(2,n),Math.max(o,Math.min(i,s)));return(a=c,new Promise((function(t){return setTimeout(t,a)}))).then((function(){return Ce(t,e,n+1)}))}))}Re.DeliveryMethods=Rt;var Te="Failed to load the JS script of the agent";function De(n){var r,o=n.scriptUrlPattern,i=n.token,s=n.apiKey,a=void 0===s?i:s,c=e(n,["scriptUrlPattern","token","apiKey"]),u=(r=n,"scriptUrlPattern",Object.prototype.hasOwnProperty.call(r,"scriptUrlPattern")?o:void 0),l=[];return Promise.resolve().then((function(){if(!a||"string"!=typeof a)throw new Error("API key required");return Ce({maxRetries:5,baseDelay:100,maxDelay:3e3,shouldRetry:function(t){return!(t instanceof Error&&"Blocked by CSP"===t.message)}},(function(){var t,e=new Date,n=function(){return l.push({startedAt:e,finishedAt:new Date})},r=function(t,e,n,r){var o,i=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),r=e.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=e,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return c(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(c(),o)return function(){throw new Error("Blocked by CSP")}();throw t}))}))}(t=function(t,e){void 0===e&&(e="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js");var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.7.1"):e}))}(a,u),(function(){return function(t){return new Promise((function(e,n){var r=document.createElement("script"),o=function(){var t;return null===(t=r.parentNode)||void 0===t?void 0:t.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),e()},r.onerror=function(){o(),n(new Error(Te))},r.async=!0,r.src=t,i.appendChild(r)}))}(t)}));return r.then(n,n),r}))})).then((function(){var e=window,n="__fpjs_p_l_b",r=e[n];if(function(t,e){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==r?void 0:r.configurable)?delete t[e]:r&&!r.writable||(t[e]=void 0)}(e,n),"function"!=typeof(null==r?void 0:r.load))throw new Error(Te);return r.load(t(t({},c),{ldi:{attempts:l}}))}))}var Ae={exports:{}},Me={exports:{}};Me.exports=function(){function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function e(n,r){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=t({},r,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=e+"="+n.write(o,e)+s}}function i(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],r={},o=0;o<e.length;o++){var i=e[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=n.read(s,a),t===a)break}catch(t){}}return t?r[t]:r}}return Object.create({set:o,get:i,remove:function(e,n){o(e,"",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}return e({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}(),function(t){t.exports=Me.exports}(Ae);var qe=l(Ae.exports);const Le=t=>{const e=De({apiKey:t||"A9aCLRHzKCv3uL69oqDr"});return{get:async()=>{try{let t=sessionStorage.getItem("vsid");t||(t=(t=>new Proxy(new URLSearchParams(window.location.search),{get:(t,e)=>t.get(e.toString())})[t])("vsid")),t||(t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27)),sessionStorage.setItem("vsid",t);const n=await e,r=await n.get({linkedId:t});sessionStorage.setItem("vrid",r.requestId)}catch(t){global.FB_DEBUG&&console.error(t)}}}};let $e=[];function Ne(t,e){const n=function(t){const e=t.split(".");try{if(3===e.length){const e=JSON.parse(window.atob(t.split(".")[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(t){}return null}(e);if(n){let e;for(;e=$e.pop();)clearTimeout(e);const r=n.getTime()-2e4-(new Date).getTime(),o=setTimeout((()=>{const e=Je();e&&t(e)}),r);$e.push(o)}}function Je(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}var Ke=t=>{var{persistTokens:n=!0}=t,r=e(t,["persistTokens"]);Le(r.fpKey).get().catch((()=>null));const o=r;let i;if(o.hooks={beforeRequest:t=>{var e;return t.queryParams=(e=t.queryParams,Object.assign(Object.assign({},e),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),n&&!t.token&&(t.token=Je()),t}},n&&(o.hooks.afterRequest=async(t,e)=>{!async function(t,e,n){try{const e=await(null==n?void 0:n.json());if(e){const n=function(t){const{sessionJwt:e,refreshJwt:n}=t||{};return function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:r}){t&&qe.set("DS",t,{path:e,domain:n,expires:r,sameSite:"None",secure:!0})}(e,t||{}),function(t){localStorage&&t&&localStorage.setItem("DSR",t)}(n),e}((null==e?void 0:e.authInfo)||e);n&&Ne(t,n)}}catch(t){console.error("Could not set tokens from body",t)}}(i.refresh,0,e)}),i=Re(r),n){const t=i.logout;i.logout=(...e)=>(localStorage&&localStorage.removeItem("DSR"),qe.remove("DS"),t(...e))}return i};const Be="descope-login-flow",We="code",Fe="redirect",ze="poll",He="webauthnCreate",Ge="webauthnGet";function Ze(t){return new URLSearchParams(window.location.search).get(t)}function Ve(){return Ze(Be)}function Qe(t){if(window.history.replaceState&&Ze(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}var Xe;function Ye(t){return n(this,void 0,void 0,(function*(){const e=yield fetch(t,{cache:"default"});if(!e.ok)throw new Error(t);return e.text()}))}function tn(t,e,n){const r=new URL("http://static.sandbox.descope.com.s3-website.eu-central-1.amazonaws.com/pages");return r.pathname+=`/${t}/${e}.${n}`,r.toString()}function en(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?Xe.forward:t<e?Xe.backward:void 0}!function(t){t.backward="backward",t.forward="forward"}(Xe||(Xe={}));const nn=()=>{const[t="",e=""]=(Ve()||"").split("_");return{executionId:t,stepId:e}},rn=(t,e)=>{!function(t){if(window.history.pushState&&t!==Ve()){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.set(Be,t),e.search=n.toString(),window.history.pushState({},"",e.toString())}}([t,e].join("_"))};function on(){Qe(Be)}const sn=(t,e,n="")=>{t.querySelectorAll(`[data-type="${e}"]`).forEach((t=>{t.innerText=n,t.classList[n?"remove":"add"]("hide")}))},an=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var cn,un,ln,dn,hn,pn,fn,vn,gn,bn,mn,yn,wn,In,kn,jn,On,xn,Sn,_n,En,Un,Pn,Rn,Cn;class Tn{constructor(t={}){cn.set(this,void 0),un.set(this,{}),ln.set(this,0),o(this,cn,t,"f")}get current(){return Object.assign({},r(this,cn,"f"))}update(t){const e="function"==typeof t?t(r(this,cn,"f")):t,n=Object.assign(Object.assign({},r(this,cn,"f")),e);if(!function(t,e){const n=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r];if(t[o]!==e[o])return!1}return!0}(r(this,cn,"f"),n)){const t=r(this,cn,"f");o(this,cn,n,"f"),Object.freeze(r(this,cn,"f")),setTimeout((()=>{Object.values(r(this,un,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return o(this,ln,r(this,ln,"f")+1,"f"),r(this,un,"f")[r(this,ln,"f")]=t,r(this,ln,"f").toString()}unsubscribe(t){const e=!!r(this,un,"f")[t];return e&&delete r(this,un,"f")[t],e}unsubscribeAll(){return o(this,un,{},"f"),!0}}function Dn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Mn(n.publicKey.challenge),n.publicKey.user.id=Mn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Mn(t.id)})),n}(t),n=yield navigator.credentials.create(e);return r=n,JSON.stringify({id:r.id,rawId:qn(r.rawId),type:r.type,response:{attestationObject:qn(r.response.attestationObject),clientDataJSON:qn(r.response.clientDataJSON)}});var r}))}function An(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Mn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Mn(t.id)})),n}(t),n=yield navigator.credentials.get(e);return r=n,JSON.stringify({id:r.id,rawId:qn(r.rawId),type:r.type,response:{authenticatorData:qn(r.response.authenticatorData),clientDataJSON:qn(r.response.clientDataJSON),signature:qn(r.response.signature),userHandle:qn(r.response.userHandle)}});var r}))}function Mn(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function qn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}cn=new WeakMap,un=new WeakMap,ln=new WeakMap,function(t){t.waiting="waiting",t.completed="completed",t.failed="failed",t.running="running"}(dn||(dn={}));const Ln=document.createElement("template");Ln.innerHTML="\n\t<style>\n\t\t:host {\n\t\t\tdisplay: inline-block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\tform {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<form></form>\n\t";class $n extends HTMLElement{constructor(){super(),hn.add(this),pn.set(this,!1),fn.set(this,new Tn),vn.set(this,new Tn),gn.set(this,void 0),bn.set(this,void 0),mn.set(this,void 0),yn.set(this,{popstate:r(this,hn,"m",jn).bind(this)}),wn.set(this,void 0),_n.set(this,(t=>{var e;if(r(this,hn,"m",xn).call(this,t))return;const{executionId:n,stepId:o,status:i,action:s,screen:a,redirect:c,authInfo:u,error:l,webauthn:d}=t.data;r(this,hn,"m",On).call(this,i,l,u)||r(this,fn,"f").update({stepId:o,executionId:n,action:s,redirectUrl:null==c?void 0:c.url,screenId:null==a?void 0:a.id,screenErrorText:null===(e=null==a?void 0:a.state)||void 0===e?void 0:e.errorText,webauthnTransactionId:null==d?void 0:d.transactionId,webauthnOptions:null==d?void 0:d.options})})),r(this,hn,"m",In).call(this),r(this,fn,"f").subscribe(r(this,hn,"m",Sn).bind(this)),r(this,vn,"f").subscribe(r(this,hn,"m",Un).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url"]}get"project-id"(){return this.getAttribute("project-id")}get"flow-id"(){return this.getAttribute("flow-id")}get"base-url"(){return this.getAttribute("base-url")||void 0}connectedCallback(){if(this.shadowRoot.isConnected){o(this,pn,!0,"f"),r(this,hn,"m",kn).call(this),r(this,hn,"m",Cn).call(this);const{executionId:t,stepId:e}=nn(),n=Ze("t")||void 0;n&&Qe("t");const i=Ze(We)||void 0;i&&Qe(We),r(this,fn,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],stepId:e,executionId:t,token:n,code:i}),window.addEventListener("popstate",r(this,yn,"f").popstate),r(this,gn,"f").onkeydown=t=>{"Enter"===t.key&&t.preventDefault()}}}disconnectedCallback(){r(this,fn,"f").unsubscribeAll(),r(this,vn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,yn,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,pn,"f")&&e!==n&&$n.observedAttributes.includes(t)){r(this,hn,"m",kn).call(this);const o=null===e;r(this,fn,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,on()),{[an(t)]:n,stepId:i,executionId:s}}))}}}pn=new WeakMap,fn=new WeakMap,vn=new WeakMap,gn=new WeakMap,bn=new WeakMap,mn=new WeakMap,yn=new WeakMap,wn=new WeakMap,_n=new WeakMap,hn=new WeakSet,In=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ln.content.cloneNode(!0)),o(this,gn,this.shadowRoot.querySelector("form"),"f"),o(this,bn,this.shadowRoot.querySelector("style"),"f")},kn=function(){const t=["base-url"];$n.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)}))},jn=function(){const{stepId:t,executionId:e}=nn();r(this,fn,"f").update({stepId:t,executionId:e})},On=function(t,e,n){switch(t){case dn.failed:return on(),r(this,hn,"m",Rn).call(this,"error",e),!0;case dn.completed:return on(),r(this,hn,"m",Rn).call(this,"success",n),!0;default:return!1}},xn=function({ok:t,error:e}){return t||r(this,hn,"m",Rn).call(this,"error",e),!t},Sn=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:s,flowId:a,baseUrl:c,stepId:u,executionId:l,action:d,screenId:h,screenErrorText:p,redirectUrl:f,token:v,code:g,webauthnTransactionId:b,webauthnOptions:m}=t,y=i("projectId")||i("baseUrl");if(r(this,mn,"f")&&(clearInterval(r(this,mn,"f")),o(this,mn,null,"f")),y){if(!s)return;o(this,wn,Ke({projectId:s,baseUrl:c}),"f")}if(!l){if(!a)return;const t=yield r(this,wn,"f").flow.start(a);return void r(this,_n,"f").call(this,t)}if(i("token")&&v||i("code")&&g){const t=yield r(this,wn,"f").flow.next(l,u,"submit",{token:v,code:g});return r(this,_n,"f").call(this,t),rn(t.data.executionId,t.data.stepId),void r(this,fn,"f").update({token:void 0,code:void 0})}if(d===Fe)return f?void window.location.assign(f):void console.error("Did not get redirect url");if(d===He||d===Ge){if(!b||!m)return void console.error("Did not get webauthn transaction id or options");const t=d===He?yield Dn(m):yield An(m),e=yield r(this,wn,"f").flow.next(l,u,"submit",{transactionId:b,response:t});return void r(this,_n,"f").call(this,e)}if(d===ze&&o(this,mn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,wn,"f").flow.next(l,u,"submit",{});r(this,_n,"f").call(this,t)}))),2e3),"f"),!h)return void console.error("Refreshing the page during a flow is not supported yet");const w={direction:en(+u,+e.stepId),screenErrorText:p,htmlUrl:tn(s,h,"html")};(y||i("executionId")||i("stepId"))&&(w.next=(...t)=>r(this,wn,"f").flow.next(l,u,...t)),r(this,vn,"f").update(w)}))},En=function(t){r(this,gn,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n;const o=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id");e.preventDefault();const i=Object.fromEntries(new FormData(e.target).entries()),s=yield t(o,Object.assign(Object.assign({},i),{origin:window.location.origin}));rn(s.data.executionId,s.data.stepId),r(this,_n,"f").call(this,s)}))},Un=function(t,e,o){return n(this,void 0,void 0,(function*(){const e="error-message",{htmlUrl:n,validations:i={},direction:s,next:a,screenErrorText:c}=t;if(!o("htmlUrl"))return o("next")&&r(this,hn,"m",En).call(this,a),void(o("screenErrorText")&&sn(this.shadowRoot,e,c));const u=document.createElement("template");u.innerHTML=yield Ye(n);const l=u.content.cloneNode(!0),d=(t=>{var e;const n=Array.from(t.querySelectorAll("script[data-id]")).map((e=>{var n;const r=e.getAttribute("data-id"),o=null===(n=t.getElementById(r))||void 0===n?void 0:n.innerHTML,i=Function(o).bind(e.previousSibling);return e.remove(),i}));return null===(e=t.querySelector("scripts"))||void 0===e||e.remove(),n})(l),h=()=>{!function(t,e){Object.entries(e).forEach((([e,n])=>{const r=t.getElementById(e);if(!r)throw new Error(`Cannot find element with id: ${e}`);Object.entries(n).forEach((([t,e])=>{r.setAttribute(t,e.toString()),r.addEventListener("blur",(()=>r.classList.add("touched")),{once:!0})}))}))}(l,i),sn(l,e,c);try{d.forEach((t=>t()))}catch(t){console.error(t)}r(this,gn,"f").replaceChildren(l),r(this,hn,"m",En).call(this,a),r(this,hn,"m",Rn).call(this,"page-updated",{})};s?r(this,hn,"m",Pn).call(this,h,s):h()}))},Pn=function(t,e){r(this,gn,"f").addEventListener("transitionend",(()=>{r(this,gn,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===Xe.forward?"slide-forward":"slide-backward";Array.from(r(this,gn,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,gn,"f").classList.add("fade-out")},Rn=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},Cn=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=tn(this["project-id"],"theme","css");t.innerText=yield Ye(e),this.shadowRoot.appendChild(t)}))},customElements.define("descope-wc",$n)}(); |
{ | ||
"name": "@descope/web-component", | ||
"version": "0.0.26-alpha.5", | ||
"version": "0.0.26-alpha.6", | ||
"main": "dist/descope-wc", | ||
@@ -63,4 +63,4 @@ "types": "dist/descope-wc.d.ts", | ||
"dependencies": { | ||
"@descope/core-js-sdk": "^0.0.41-alpha.17", | ||
"@descope/web-js-sdk": "^0.0.1-alpha.6" | ||
"@descope/core-js-sdk": "0.0.41-alpha.17", | ||
"@descope/web-js-sdk": "0.0.1-alpha.6" | ||
}, | ||
@@ -67,0 +67,0 @@ "overrides": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
38024
143
+ Added@descope/core-js-sdk@0.0.41-alpha.17(transitive)
+ Added@descope/web-js-sdk@0.0.1-alpha.6(transitive)
- Removed@descope/core-js-sdk@0.0.41-alpha.56(transitive)
- Removed@descope/web-js-sdk@0.0.1-alpha.7(transitive)