@descope/web-component 0.0.26-alpha.0 → 0.0.26-alpha.10
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/README.md +4 -4
- package/dist/descope-wc.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -33,12 +33,12 @@ render(){
|
|
|
33
33
|
|
|
34
34
|
- Now you can add the custom element to your HTML
|
|
35
35
|
```html
|
|
36
|
-
<descope-wc project="
|
|
36
|
+
<descope-wc project-id="<project-id>" flow-id="<flow-id>"></descope-wc>
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
### Run the demo app
|
|
40
|
-
|
|
41
|
-
Edit the `index.html`
|
|
42
|
-
|
|
40
|
+
- Install dependencies - `npm i`
|
|
41
|
+
- Edit the `src/app/index.html` - replace `<project-id>` and `<project-id>` with your project and a flow
|
|
42
|
+
- Run application - `npm run start`
|
|
43
43
|
|
|
44
44
|
*TODO: we shoud host this file so it can be included without installing the package, once we will publish it to a public registry, we can also use unpkg.com/ to serve it*
|
package/dist/descope-wc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function t(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(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 e(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 n(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n}function r(t){this.message=t}r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(n=o%4?64*n+i:i,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function o(t){this.message=t}function s(t,e){if("string"!=typeof t)throw new o("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(i(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 i(e)}}(t.split(".")[n]))}catch(t){throw new o("Invalid token specified: "+t.message)}}o.prototype=new Error,o.prototype.name="InvalidTokenError";var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},c="__lodash_hash_undefined__",u="[object Function]",d="[object GeneratorFunction]",l=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,h=/^\w*$/,p=/^\./,f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,g=/\\(\\)?/g,v=/^\[object .+?Constructor\]$/,b="object"==typeof a&&a&&a.Object===Object&&a,y="object"==typeof self&&self&&self.Object===Object&&self,w=b||y||Function("return this")();var m,I=Array.prototype,j=Function.prototype,O=Object.prototype,k=w["__core-js_shared__"],x=(m=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||""))?"Symbol(src)_1."+m:"",_=j.toString,E=O.hasOwnProperty,S=O.toString,U=RegExp("^"+_.call(E).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=w.Symbol,P=I.splice,R=H(w,"Map"),M=H(Object,"create"),A=T?T.prototype:void 0,C=A?A.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 L(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 q(t,e){for(var n,r,i=t.length;i--;)if((n=t[i][0])===(r=e)||n!=n&&r!=r)return i;return-1}function D(t,e){var n;e=function(t,e){if(B(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Z(t))return!0;return h.test(t)||!l.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:B(n=e)?n:z(n);for(var r=0,i=e.length;null!=t&&r<i;)t=t[K(e[r++])];return r&&r==i?t:void 0}function J(t){if(!G(t)||(e=t,x&&x in e))return!1;var e,n=function(t){var e=G(t)?S.call(t):"";return e==u||e==d}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?U:v;return n.test(function(t){if(null!=t){try{return _.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function W(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function H(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return J(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===c?void 0:n}return E.call(e,t)?e[t]:void 0},$.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:E.call(e,t)},$.prototype.set=function(t,e){return this.__data__[t]=M&&void 0===e?c:e,this},L.prototype.clear=function(){this.__data__=[]},L.prototype.delete=function(t){var e=this.__data__,n=q(e,t);return!(n<0)&&(n==e.length-1?e.pop():P.call(e,n,1),!0)},L.prototype.get=function(t){var e=this.__data__,n=q(e,t);return n<0?void 0:e[n][1]},L.prototype.has=function(t){return q(this.__data__,t)>-1},L.prototype.set=function(t,e){var n=this.__data__,r=q(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},N.prototype.clear=function(){this.__data__={hash:new $,map:new(R||L),string:new $}},N.prototype.delete=function(t){return W(this,t).delete(t)},N.prototype.get=function(t){return W(this,t).get(t)},N.prototype.has=function(t){return W(this,t).has(t)},N.prototype.set=function(t,e){return W(this,t).set(t,e),this};var z=F((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Z(t))return C?C.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return p.test(t)&&n.push(""),t.replace(f,(function(t,e,r,i){n.push(r?i.replace(g,"$1"):e||t)})),n}));function K(t){if("string"==typeof t||Z(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function F(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=t.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(F.Cache||N),n}F.Cache=N;var B=Array.isArray;function G(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Z(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==S.call(t)}var Q,V=function(t,e,n){var r=null==t?void 0:D(t,e);return void 0===r?n:r},X="/v1/auth/code/verify",Y="/v1/auth/signin/otp",tt="/v1/auth/signup/otp",et={email:"/v1/user/update/email/otp",phone:"/v1/user/update/phone/otp"},nt="/v1/auth/sign-up-or-in/otp",rt="/v1/auth/magiclink/verify",it="/v1/auth/signin/magiclink",ot="/v1/auth/signup/magiclink",st="/v1/auth/magiclink/session",at={email:"/v1/user/update/email/magiclink",phone:"/v1/user/update/phone/magiclink"},ct="/v1/auth/sign-up-or-in/magiclink",ut="/v1/oauth/authorize",dt="/v1/auth/saml/authorize",lt="/v1/auth/verify/totp",ht="/v1/auth/signup/totp",pt="/v1/user/update/totp",ft={start:"/v1/webauthn/signup/start",finish:"/v1/webauthn/signup/finish"},gt={start:"/v1/webauthn/signin/start",finish:"/v1/webauthn/signin/finish"},vt={start:"/v1/webauthn/device/add/start",finish:"/v1/webauthn/device/add/finish"},bt="/v1/flow/start",yt="/v1/flow/next";!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Q||(Q={}));const wt=()=>{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")}},mt=(...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}),{})),It=t=>void 0===t?void 0:JSON.stringify(t),jt=(t,e="")=>{let n=t;return""!==e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Ot=({baseUrl:t,projectId:e,baseConfig:n,logger:r,hooks:i})=>{const o=((t,e)=>{const n=e||fetch;if(!n)throw new Error("fetch is not defined");return t?async(...e)=>{t.log((t=>wt().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)),wt().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(r)),r}:n})(r),s=r=>{const s=(null==i?void 0:i.beforeRequest)?i.beforeRequest(r):r,{path:a,body:c,headers:u,queryParams:d,method:l,token:h}=s;return o((({path:t,baseUrl:e,queryParams:n})=>{const r=new URL(t,e);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:a,baseUrl:t,queryParams:d}),{headers:mt(jt(e,h),(null==n?void 0:n.baseHeaders)||{},u),method:l,body:It(c)})};return{get:(t,{headers:e,queryParams:n,token:r}={})=>s({path:t,headers:e,queryParams:n,body:void 0,method:Q.get,token:r}),post:(t,e,{headers:n,queryParams:r,token:i}={})=>s({path:t,headers:n,queryParams:r,body:e,method:Q.post,token:i}),put:(t,e,{headers:n,queryParams:r,token:i}={})=>s({path:t,headers:n,queryParams:r,body:e,method:Q.put,token:i}),delete:(t,e,{headers:n,queryParams:r,token:i}={})=>s({path:t,headers:n,queryParams:r,body:e,method:Q.delete,token:i})}},kt=t=>{if("string"!=typeof t||!t)throw new Error("Invalid token provided");const{exp:e}=s(t);return(new Date).getTime()/1e3>e},xt=(...t)=>t.join("/").replace(/\/{2,}/g,"/"),_t=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 Et,St,Ut;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Et||(Et={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(St||(St={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(Ut||(Ut={}));const Tt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Pt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Rt=t=>e=>t.test(e),Mt=Rt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),At=Rt(/^\+[1-9]{1}[0-9]{3,14}$/),Ct=Tt(Mt,'"{val}" is not a valid email'),$t=Tt(At,'"{val}" is not a valid phone number'),Lt=Tt((1,t=>t.length>=1),"Minimum length is 1");const Nt=Tt((t=>"string"==typeof t),"Input is not a string"),qt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Pt(...t).validate(n[e]))),e(...n)),Dt=t=>[Nt(`"${t}" must be a string`),Lt(`"${t}" must not be empty`)],Jt=t=>[Nt(`"${t}" must be a string`),Ct()],Wt=t=>[Nt(`"${t}" must be a string`),$t()];var Ht;!function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(Ht||(Ht={}));const zt=Dt("identifier"),Kt=qt(zt,Dt("code")),Ft=qt(zt),Bt=qt(zt,Wt("phone")),Gt=qt(zt,Jt("email")),Zt=t=>({verify:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Kt(((e,r)=>_t(t.post(xt(X,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ft((e=>_t(t.post(xt(Y,n),{externalId:e}))))})),{}),signUp:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ft(((e,r)=>_t(t.post(xt(tt,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ft((e=>_t(t.post(xt(nt,n),{externalId:e}))))})),{}),update:{email:Gt(((e,n,r)=>_t(t.post(et.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(Et).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Bt(((e,r,i)=>_t(t.post(xt(et.phone,n),{externalId:e,phone:r},{token:i}))))})),{})}}),Qt=Dt("identifier"),Vt=Dt("uri"),Xt=qt(Dt("token")),Yt=qt(Qt,Vt),te=qt(Dt("pendingRef")),ee=qt(Qt,Wt("phone"),Vt),ne=qt(Qt,Jt("email"),Vt),re=t=>({verify:Xt((e=>_t(t.post(rt,{token:e})))),signIn:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Yt(((e,r)=>_t(t.post(xt(it,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Yt(((e,r)=>_t(t.post(xt(ct,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Yt(((e,r,i)=>_t(t.post(xt(ot,n),{externalId:e,URI:r,user:i,crossDevice:!0}))))})),{}),waitForSession:te(((e,n)=>new Promise((r=>{const{pollingIntervalMs:i,timeoutMs:o}=(({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(st,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(_t(Promise.resolve(n))))}),i);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${o}ms`,code:"0"},ok:!1}),clearInterval(a)}),o)})))),update:{email:ne(((e,n,r,i)=>_t(t.post(at.email,{externalId:e,email:n,URI:r,crossDevice:!0},{token:i})))),phone:Object.keys(Et).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ee(((e,r,i,o)=>_t(t.post(xt(at.phone,n),{externalId:e,phone:r,URI:i,crossDevice:!0},{token:o}))))})),{})}}),ie=t=>({verify:Xt((e=>_t(t.post(rt,{token:e})))),signIn:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Yt(((e,r)=>_t(t.post(xt(it,n),{externalId:e,URI:r}))))})),{}),signUp:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Yt(((e,r,i)=>_t(t.post(xt(ot,n),{externalId:e,URI:r,user:i}))))})),{}),signUpOrIn:Object.keys(St).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Yt(((e,r)=>_t(t.post(xt(ct,n),{externalId:e,URI:r}))))})),{}),update:{email:ne(((e,n,r,i)=>_t(t.post(at.email,{externalId:e,email:n,URI:r},{token:i})))),phone:Object.keys(Et).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ee(((e,r,i,o)=>_t(t.post(xt(at.phone,n),{externalId:e,phone:r,URI:i},{token:o}))))})),{})},crossDevice:re(t)}),oe=qt(Dt("code")),se=t=>({exchange:oe((e=>_t(t.get("/v1/auth/exchange",{queryParams:{code:e}}))))});var ae;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(ae||(ae={}));const ce=t=>Object.assign({start:Object.keys(ae).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={})=>{const i=await t.get(ut,{queryParams:Object.assign({provider:n},e&&{redirectURL:e})});if(!r||!i.ok)return _t(Promise.resolve(i));const{url:o}=await i.json();window.location.href=o}})),{})},se(t)),ue=qt(Dt("flowId")),de=qt(Dt("executionId"),Dt("stepId"),Dt("actionId")),le=t=>({start:ue((e=>_t(t.post(bt,{flowId:e})))),next:de(((e,n,r,i)=>_t(t.post(yt,{executionId:e,stepId:n,actionId:r,input:i}))))}),he=qt(Dt("tenant")),pe=t=>Object.assign({start:he((async(e,n,{redirect:r=!1}={})=>{const i=await t.get(dt,{queryParams:{tenant:e,redirectURL:n}});if(!r||!i.ok)return _t(Promise.resolve(i));const{url:o}=await i.json();window.location.href=o}))},se(t)),fe=Dt("identifier"),ge=qt(fe,Dt("code")),ve=qt(fe),be=qt(fe),ye=t=>({signUp:ve(((e,n)=>_t(t.post(ht,{externalId:e,user:n})))),verify:ge(((e,n)=>_t(t.post(lt,{externalId:e,code:n})))),update:be(((e,n)=>_t(t.post(pt,{externalId:e},{token:n}))))}),we=Dt("identifier"),me=Dt("origin"),Ie=qt(we,me,Dt("name")),je=qt(we,me),Oe=qt(we,me,Dt("token")),ke=qt(Dt("transactionId"),Dt("response")),xe=t=>({signUp:{start:Ie(((e,n,r)=>_t(t.post(ft.start,{user:{externalId:e,name:r},origin:n})))),finish:ke(((e,n)=>_t(t.post(ft.finish,{transactionId:e,response:n}))))},signIn:{start:je(((e,n)=>_t(t.post(gt.start,{externalId:e,origin:n})))),finish:ke(((e,n)=>_t(t.post(gt.finish,{transactionId:e,response:n}))))},add:{start:Oe(((e,n,r)=>_t(t.post(vt.start,{externalId:e,origin:n},{token:r})))),finish:ke(((e,n)=>_t(t.post(vt.finish,{transactionId:e,response:n}))))}}),_e=qt(Dt("token"));var Ee;const Se=qt([("projectId",Ee=Dt("projectId"),Tt(((t,e)=>t=>Pt(...e).validate(V(t,"projectId")))(0,Ee))())])((({projectId:t,logger:e,baseUrl:n,hooks:r})=>{return i=Ot({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r}),{otp:Zt(i),magicLink:ie(i),oauth:ce(i),saml:pe(i),totp:ye(i),webauthn:xe(i),flow:le(i),refresh:t=>_t(i.get("/v1/auth/refresh",{token:t})),logout:t=>_t(i.get("/v1/auth/logoutall",{token:t})),isJwtExpired:_e(kt),httpClient:i};var i}));Se.DeliveryMethods=St;const Ue="descope-login-flow",Te="code",Pe="redirect",Re="poll",Me="webauthnCreate",Ae="webauthnGet";function Ce(t){return new URLSearchParams(window.location.search).get(t)}function $e(){return Ce(Ue)}function Le(t){if(window.history.replaceState&&Ce(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 Ne;function qe(t){const e=`/${t}.html`,n=new URL("https://s3.eu-central-1.amazonaws.com/static.sandbox.descope.com/pages");return n.pathname+=e,n.toString()}function De(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?Ne.forward:t<e?Ne.backward:void 0}!function(t){t.backward="backward",t.forward="forward"}(Ne||(Ne={}));const Je=()=>{const[t="",e=""]=($e()||"").split("_");return{executionId:t,stepId:e}},We=(t,e)=>{!function(t){if(window.history.pushState&&t!==$e()){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.set(Ue,t),e.search=n.toString(),window.history.pushState({},"",e.toString())}}([t,e].join("_"))};const He=(t,e,n="")=>{const r=t.getElementById(e);r&&(r.innerText=n,r.classList[n?"remove":"add"]("hide"))},ze=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Ke,Fe,Be,Ge,Ze,Qe,Ve,Xe,Ye,tn,en,nn,rn,on,sn,an,cn,un,dn,ln,hn,pn,fn,gn;class vn{constructor(t={}){Ke.set(this,void 0),Fe.set(this,{}),Be.set(this,0),n(this,Ke,t,"f")}get current(){return Object.assign({},e(this,Ke,"f"))}update(t){const r="function"==typeof t?t(e(this,Ke,"f")):t,i=Object.assign(Object.assign({},e(this,Ke,"f")),r);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 i=n[r];if(t[i]!==e[i])return!1}return!0}(e(this,Ke,"f"),i)){const t=e(this,Ke,"f");n(this,Ke,i,"f"),Object.freeze(e(this,Ke,"f")),setTimeout((()=>{Object.values(e(this,Fe,"f")).forEach((e=>e(i,t,((t,e)=>n=>t[n]!==e[n])(i,t))))}),0)}}subscribe(t){return n(this,Be,e(this,Be,"f")+1,"f"),e(this,Fe,"f")[e(this,Be,"f")]=t,e(this,Be,"f").toString()}unsubscribe(t){const n=!!e(this,Fe,"f")[t];return n&&delete e(this,Fe,"f")[t],n}unsubscribeAll(){return n(this,Fe,{},"f"),!0}}function bn(e){return t(this,void 0,void 0,(function*(){const t=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=wn(n.publicKey.challenge),n.publicKey.user.id=wn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=wn(t.id)})),n}(e),n=yield navigator.credentials.create(t);return r=n,JSON.stringify({id:r.id,rawId:mn(r.rawId),type:r.type,response:{attestationObject:mn(r.response.attestationObject),clientDataJSON:mn(r.response.clientDataJSON)}});var r}))}function yn(e){return t(this,void 0,void 0,(function*(){const t=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=wn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=wn(t.id)})),n}(e),n=yield navigator.credentials.get(t);return r=n,JSON.stringify({id:r.id,rawId:mn(r.rawId),type:r.type,response:{authenticatorData:mn(r.response.authenticatorData),clientDataJSON:mn(r.response.clientDataJSON),signature:mn(r.response.signature),userHandle:mn(r.response.userHandle)}});var r}))}function wn(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function mn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}Ke=new WeakMap,Fe=new WeakMap,Be=new WeakMap,function(t){t.waiting="waiting",t.completed="completed",t.failed="failed",t.running="running"}(Ge||(Ge={}));const In=document.createElement("template");In.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 jn extends HTMLElement{constructor(){super(),Ze.add(this),Qe.set(this,!1),Ve.set(this,new vn),Xe.set(this,new vn),Ye.set(this,void 0),tn.set(this,void 0),en.set(this,void 0),nn.set(this,{popstate:e(this,Ze,"m",an).bind(this)}),rn.set(this,void 0),ln.set(this,(t=>{var n,r;if(e(this,Ze,"m",un).call(this,t))return;const{executionId:i,stepId:o,status:s,action:a,screen:c,redirect:u,authInfo:d,error:l,webauthn:h}=t.data;e(this,Ze,"m",cn).call(this,s,l,d)||e(this,Ve,"f").update({stepId:o,executionId:i,action:a,redirectUrl:null==u?void 0:u.url,screenId:null==c?void 0:c.id,screenErrorText:null===(n=null==c?void 0:c.state)||void 0===n?void 0:n.errorText,screenMessageText:null===(r=null==c?void 0:c.state)||void 0===r?void 0:r.messageText,webauthnTransactionId:null==h?void 0:h.transactionId,webauthnOptions:null==h?void 0:h.options})})),e(this,Ze,"m",on).call(this),e(this,Ve,"f").subscribe(e(this,Ze,"m",dn).bind(this)),e(this,Xe,"f").subscribe(e(this,Ze,"m",pn).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){n(this,Qe,!0,"f"),e(this,Ze,"m",sn).call(this);const{executionId:t,stepId:r}=Je(),i=Ce("t")||void 0;i&&Le("t");const o=Ce(Te)||void 0;o&&Le(Te),e(this,Ve,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],stepId:r,executionId:t,token:i,code:o}),window.addEventListener("popstate",e(this,nn,"f").popstate)}}disconnectedCallback(){e(this,Ve,"f").unsubscribeAll(),e(this,Xe,"f").unsubscribeAll(),window.removeEventListener("popstate",e(this,nn,"f").popstate)}attributeChangedCallback(t,n,r){if(this.shadowRoot.isConnected&&e(this,Qe,"f")&&n!==r&&jn.observedAttributes.includes(t)){e(this,Ze,"m",sn).call(this);const i=null===n;e(this,Ve,"f").update((({stepId:e,executionId:n})=>{let o=e,s=n;return i||(s=null,o=null,Le(Ue)),{[ze(t)]:r,stepId:o,executionId:s}}))}}}Qe=new WeakMap,Ve=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,tn=new WeakMap,en=new WeakMap,nn=new WeakMap,rn=new WeakMap,ln=new WeakMap,Ze=new WeakSet,on=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(In.content.cloneNode(!0)),n(this,Ye,this.shadowRoot.querySelector("form"),"f"),n(this,tn,this.shadowRoot.querySelector("style"),"f")},sn=function(){const t=["base-url"];jn.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)}))},an=function(){const{stepId:t,executionId:n}=Je();e(this,Ve,"f").update({stepId:t,executionId:n})},cn=function(t,n,r){switch(t){case Ge.failed:return e(this,Ze,"m",gn).call(this,"error",n),!0;case Ge.completed:return e(this,Ze,"m",gn).call(this,"success",r),!0;default:return!1}},un=function({ok:t,error:n}){return t||e(this,Ze,"m",gn).call(this,"error",n),!t},dn=function(r,i,o){return t(this,void 0,void 0,(function*(){const{projectId:s,flowId:a,baseUrl:c,stepId:u,executionId:d,action:l,screenId:h,screenErrorText:p,screenMessageText:f,redirectUrl:g,token:v,code:b,webauthnTransactionId:y,webauthnOptions:w}=r,m=o("projectId")||o("baseUrl");if(e(this,en,"f")&&(clearInterval(e(this,en,"f")),n(this,en,null,"f")),m){if(!s)return;n(this,rn,Se({projectId:s,baseUrl:c}),"f")}if(!d){if(!a)return;const t=yield e(this,rn,"f").flow.start(a);return void e(this,ln,"f").call(this,t)}if(o("token")&&v||o("code")&&b){const t=yield e(this,rn,"f").flow.next(d,u,"submit",{token:v,code:b});return e(this,ln,"f").call(this,t),We(t.data.executionId,t.data.stepId),void e(this,Ve,"f").update({token:void 0,code:void 0})}if(l===Pe)return g?void window.location.assign(g):void console.error("Did not get redirect url");if(l===Me||l===Ae){if(!y||!w)return void console.error("Did not get webauthn transaction id or options");const t=l===Me?yield bn(w):yield yn(w),n=yield e(this,rn,"f").flow.next(d,u,"submit",{transactionId:y,response:t});return void e(this,ln,"f").call(this,n)}if(l===Re&&n(this,en,setInterval((()=>t(this,void 0,void 0,(function*(){const t=yield e(this,rn,"f").flow.next(d,u,"submit",{});e(this,ln,"f").call(this,t)}))),2e3),"f"),!h)return void console.error("Refreshing the page during a flow is not supported yet");const I={direction:De(+u,+i.stepId),screenErrorText:p,screenMessageText:f,htmlUrl:qe(h)};(m||o("executionId")||o("stepId"))&&(I.next=(...t)=>e(this,rn,"f").flow.next(d,u,...t)),e(this,Xe,"f").update(I)}))},hn=function(n){this.shadowRoot.querySelectorAll('button[type="button"]').forEach((r=>{const i=(t=>Array.from(t.attributes).reduce(((t,e)=>{var n;const r=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return r?Object.assign(t,{[r]:e.value}):t}),{}))(r),{action:o}=i,s=function(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 i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(i,["action"]);r.onclick=()=>t(this,void 0,void 0,(function*(){const t=yield n(o,s);e(this,ln,"f").call(this,t),We(t.data.executionId,t.data.stepId)}))})),e(this,Ye,"f").onsubmit=r=>t(this,void 0,void 0,(function*(){r.preventDefault();const t=Object.fromEntries(new FormData(r.target).entries()),i=yield n("submit",Object.assign(Object.assign({},t),{origin:window.location.origin}));e(this,ln,"f").call(this,i),We(i.data.executionId,i.data.stepId)}))},pn=function(n,r,i){return t(this,void 0,void 0,(function*(){const r="error",o="info",{htmlUrl:s,validations:a={},direction:c,next:u,screenErrorText:d,screenMessageText:l}=n;if(!i("htmlUrl"))return i("next")&&e(this,Ze,"m",hn).call(this,u),i("screenErrorText")&&He(this.shadowRoot,r,d),void(i("screenMessageText")&&He(this.shadowRoot,o,l));const h=document.createElement("template");h.innerHTML=yield function(e){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw new Error(e);return t.text()}))}(s);const p=h.content.cloneNode(!0),f=(t=>{var e;const n=Array.from(t.querySelectorAll("script[data-id]")).map((e=>{var n;const r=e.getAttribute("data-id"),i=null===(n=t.getElementById(r))||void 0===n?void 0:n.innerHTML,o=Function(i).bind(e.previousSibling);return e.remove(),o}));return null===(e=t.querySelector("scripts"))||void 0===e||e.remove(),n})(p),g=()=>{!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})}))}))}(p,a),He(p,r,d),He(p,o,l);try{f.forEach((t=>t()))}catch(t){console.error(t)}e(this,Ye,"f").replaceChildren(p),e(this,Ze,"m",hn).call(this,u),e(this,Ze,"m",gn).call(this,"page-updated",{})};c?e(this,Ze,"m",fn).call(this,g,c):g()}))},fn=function(t,n){e(this,Ye,"f").addEventListener("transitionend",(()=>{e(this,Ye,"f").classList.remove("fade-out"),t()}),{once:!0});const r=n===Ne.forward?"slide-forward":"slide-backward";Array.from(e(this,Ye,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(r)})),e(this,Ye,"f").classList.add("fade-out")},gn=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",jn)}();
|
|
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)\]/,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=H(k,"Map"),M=H(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:z(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 H(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 z=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/accesskey/exchange",nt="/v1/auth/otp/verify",rt="/v1/auth/otp/signin",ot="/v1/auth/otp/signup",it={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},st="/v1/auth/otp/signup-in",at="/v1/auth/magiclink/verify",ct="/v1/auth/magiclink/signin",ut="/v1/auth/magiclink/signup",lt="/v1/auth/magiclink/pending-session",dt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},ht="/v1/auth/magiclink/signup-in",pt="/v1/auth/oauth/authorize",ft="/v1/auth/saml/authorize",vt="/v1/auth/totp/verify",gt="/v1/auth/totp/signup",bt="/v1/user/totp/update",mt={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"},wt={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},It="/v1/flow/start",kt="/v1/flow/next";!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Y||(Y={}));const jt=()=>{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")}},Ot=(...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}),{})),xt=t=>void 0===t?void 0:JSON.stringify(t),St=(t,e="")=>{let n=t;return""!==e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},_t=({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=>jt().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)),jt().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:Ot(St(e,p),(null==n?void 0:n.baseHeaders)||{},l),method:h,body:xt(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})}},Et=t=>{if("string"!=typeof t||!t)throw new Error("Invalid token provided");const{exp:e}=c(t);return(new Date).getTime()/1e3>e},Ut=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Pt(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}const Rt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Ct=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Tt=t=>e=>t.test(e),Dt=Tt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),At=Tt(/^\+[1-9]{1}[0-9]{3,14}$/),Mt=Rt(Dt,'"{val}" is not a valid email'),qt=Rt(At,'"{val}" is not a valid phone number'),Lt=Rt((1,t=>t.length>=1),"Minimum length is 1");const $t=Rt((t=>"string"==typeof t),"Input is not a string"),Nt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Ct(...t).validate(n[e]))),e(...n)),Jt=t=>[$t(`"${t}" must be a string`),Lt(`"${t}" must not be empty`)],Kt=t=>[$t(`"${t}" must be a string`),Mt()],Bt=t=>[$t(`"${t}" must be a string`),qt()],Wt=Nt(Jt("accessKey")),Ft=t=>({exchange:Wt((e=>Pt(t.get(et,{token:e}))))});var Ht,zt,Gt,Zt;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Ht||(Ht={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(zt||(zt={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(Gt||(Gt={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(Zt||(Zt={}));const Vt=Jt("identifier"),Qt=Nt(Vt,Jt("code")),Xt=Nt(Vt),Yt=Nt(Vt,Bt("phone")),te=Nt(Vt,Kt("email")),ee=t=>({verify:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Qt(((e,r)=>Pt(t.post(Ut(nt,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Xt((e=>Pt(t.post(Ut(rt,n),{externalId:e}))))})),{}),signUp:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Xt(((e,r)=>Pt(t.post(Ut(ot,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Xt((e=>Pt(t.post(Ut(st,n),{externalId:e}))))})),{}),update:{email:te(((e,n,r)=>Pt(t.post(it.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(Ht).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Yt(((e,r,o)=>Pt(t.post(Ut(it.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),ne=Jt("identifier"),re=Jt("uri"),oe=Nt(Jt("token")),ie=Nt(ne,re),se=Nt(Jt("pendingRef")),ae=Nt(ne,Bt("phone"),re),ce=Nt(ne,Kt("email"),re),ue=t=>({verify:oe((e=>Pt(t.post(at,{token:e})))),signIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r)=>Pt(t.post(Ut(ct,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r)=>Pt(t.post(Ut(ht,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r,o)=>Pt(t.post(Ut(ut,n),{externalId:e,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:se(((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(lt,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Pt(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ce(((e,n,r,o)=>Pt(t.post(dt.email,{externalId:e,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Ht).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ae(((e,r,o,i)=>Pt(t.post(Ut(dt.phone,n),{externalId:e,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),le=t=>({verify:oe((e=>Pt(t.post(at,{token:e})))),signIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r)=>Pt(t.post(Ut(ct,n),{externalId:e,URI:r}))))})),{}),signUp:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r,o)=>Pt(t.post(Ut(ut,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r)=>Pt(t.post(Ut(ht,n),{externalId:e,URI:r}))))})),{}),update:{email:ce(((e,n,r,o)=>Pt(t.post(dt.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(Ht).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ae(((e,r,o,i)=>Pt(t.post(Ut(dt.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})},crossDevice:ue(t)}),de=Nt(Jt("code")),he=t=>({exchange:de((e=>Pt(t.get("/v1/auth/exchange",{queryParams:{code:e}}))))});var pe;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(pe||(pe={}));const fe=t=>Object.assign({start:Object.keys(pe).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={})=>{const o=await t.get(pt,{queryParams:Object.assign({provider:n},e&&{redirectURL:e})});if(!r||!o.ok)return Pt(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},he(t)),ve=Nt(Jt("flowId")),ge=Nt(Jt("executionId"),Jt("stepId"),Jt("interactionId")),be=t=>({start:ve((e=>Pt(t.post(It,{flowId:e})))),next:ge(((e,n,r,o)=>Pt(t.post(kt,{executionId:e,stepId:n,interactionId:r,input:o}))))}),me=Nt(Jt("tenant")),ye=t=>Object.assign({start:me((async(e,n,{redirect:r=!1}={})=>{const o=await t.get(ft,{queryParams:{tenant:e,redirectURL:n}});if(!r||!o.ok)return Pt(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},he(t)),we=Jt("identifier"),Ie=Nt(we,Jt("code")),ke=Nt(we),je=Nt(we),Oe=t=>({signUp:ke(((e,n)=>Pt(t.post(gt,{externalId:e,user:n})))),verify:Ie(((e,n)=>Pt(t.post(vt,{externalId:e,code:n})))),update:je(((e,n)=>Pt(t.post(bt,{externalId:e},{token:n}))))}),xe=Jt("identifier"),Se=Jt("origin"),_e=Nt(xe,Se,Jt("name")),Ee=Nt(xe,Se),Ue=Nt(xe,Se,Jt("token")),Pe=Nt(Jt("transactionId"),Jt("response")),Re=t=>({signUp:{start:_e(((e,n,r)=>Pt(t.post(mt.start,{user:{externalId:e,name:r},origin:n})))),finish:Pe(((e,n)=>Pt(t.post(mt.finish,{transactionId:e,response:n}))))},signIn:{start:Ee(((e,n)=>Pt(t.post(yt.start,{externalId:e,origin:n})))),finish:Pe(((e,n)=>Pt(t.post(yt.finish,{transactionId:e,response:n}))))},update:{start:Ue(((e,n,r)=>Pt(t.post(wt.start,{externalId:e,origin:n},{token:r})))),finish:Pe(((e,n)=>Pt(t.post(wt.finish,{transactionId:e,response:n}))))}}),Ce=Nt(Jt("token"));var Te;const De=Nt([("projectId",Te=Jt("projectId"),Rt(((t,e)=>t=>Ct(...e).validate(tt(t,"projectId")))(0,Te))())])((({projectId:t,logger:e,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=_t({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r,cookiePolicy:o}),{accessKey:Ft(i),otp:ee(i),magicLink:le(i),oauth:fe(i),saml:ye(i),totp:Oe(i),webauthn:Re(i),flow:be(i),refresh:t=>Pt(i.get("/v1/auth/refresh",{token:t})),logout:t=>Pt(i.get("/v1/auth/logoutall",{token:t})),me:t=>Pt(i.get("/v1/auth/me",{token:t})),isJwtExpired:Ce(Et),httpClient:i};var i}));function Ae(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 Ae(t,e,n+1)}))}))}De.DeliveryMethods=zt;var Me="Failed to load the JS script of the agent";function qe(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 Ae({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(Me))},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(Me);return r.load(t(t({},c),{ldi:{attempts:l}}))}))}var Le={exports:{}},$e={exports:{}};$e.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=$e.exports}(Le);var Ne=l(Le.exports);const Je=t=>{const e=qe({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 Ke=[];function Be(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=Ke.pop();)clearTimeout(e);const r=n.getTime()-2e4-(new Date).getTime(),o=setTimeout((()=>{const e=We();e&&t(e)}),r);Ke.push(o)}}function We(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}var Fe=t=>{var{persistTokens:n=!0}=t,r=e(t,["persistTokens"]);Je(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=We()),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&&Ne.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&&Be(t,n)}}catch(t){console.error("Could not set tokens from body",t)}}(i.refresh,0,e)}),i=De(r),n){const t=i.logout;i.logout=(...e)=>(localStorage&&localStorage.removeItem("DSR"),Ne.remove("DS"),t(...e))}return i};const He=(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("base.content.url"))||"https://static.app.descope.com",ze="descope-login-flow",Ge="code",Ze="redirect",Ve="poll",Qe="webauthnCreate",Xe="webauthnGet";function Ye(t){return new URLSearchParams(window.location.search).get(t)}function tn(){return Ye(ze)}function en(t){if(window.history.replaceState&&Ye(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 nn;function rn(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 on(t,e,n){const r=new URL(He);return r.pathname+=`${t}/${e}.${n}`,r.toString()}function sn(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?nn.forward:t<e?nn.backward:void 0}!function(t){t.backward="backward",t.forward="forward"}(nn||(nn={}));const an=()=>{const[t="",e=""]=(tn()||"").split("_");return{executionId:t,stepId:e}},cn=(t,e)=>{!function(t){if(window.history.pushState&&t!==tn()){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.set(ze,t),e.search=n.toString(),window.history.pushState({},"",e.toString())}}([t,e].join("_"))};function un(){en(ze)}const ln=(t,e,n="")=>{t.querySelectorAll(`[data-type="${e}"]`).forEach((t=>{t.innerText=n,t.classList[n?"remove":"add"]("hide")}))},dn=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var hn,pn,fn,vn,gn,bn,mn,yn,wn,In,kn,jn,On,xn,Sn,_n,En,Un,Pn,Rn,Cn,Tn,Dn,An,Mn;class qn{constructor(t={}){hn.set(this,void 0),pn.set(this,{}),fn.set(this,0),o(this,hn,t,"f")}get current(){return Object.assign({},r(this,hn,"f"))}update(t){const e="function"==typeof t?t(r(this,hn,"f")):t,n=Object.assign(Object.assign({},r(this,hn,"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,hn,"f"),n)){const t=r(this,hn,"f");o(this,hn,n,"f"),Object.freeze(r(this,hn,"f")),setTimeout((()=>{Object.values(r(this,pn,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}}subscribe(t){return o(this,fn,r(this,fn,"f")+1,"f"),r(this,pn,"f")[r(this,fn,"f")]=t,r(this,fn,"f").toString()}unsubscribe(t){const e=!!r(this,pn,"f")[t];return e&&delete r(this,pn,"f")[t],e}unsubscribeAll(){return o(this,pn,{},"f"),!0}}function Ln(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Nn(n.publicKey.challenge),n.publicKey.user.id=Nn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Nn(t.id)})),n}(t),n=yield navigator.credentials.create(e);return r=n,JSON.stringify({id:r.id,rawId:Jn(r.rawId),type:r.type,response:{attestationObject:Jn(r.response.attestationObject),clientDataJSON:Jn(r.response.clientDataJSON)}});var r}))}function $n(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Nn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Nn(t.id)})),n}(t),n=yield navigator.credentials.get(e);return r=n,JSON.stringify({id:r.id,rawId:Jn(r.rawId),type:r.type,response:{authenticatorData:Jn(r.response.authenticatorData),clientDataJSON:Jn(r.response.clientDataJSON),signature:Jn(r.response.signature),userHandle:Jn(r.response.userHandle)}});var r}))}function Nn(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Jn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}hn=new WeakMap,pn=new WeakMap,fn=new WeakMap,function(t){t.waiting="waiting",t.completed="completed",t.failed="failed",t.running="running"}(vn||(vn={}));const Kn=document.createElement("template");Kn.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 Bn extends HTMLElement{constructor(){super(),gn.add(this),bn.set(this,!1),mn.set(this,new qn),yn.set(this,new qn),wn.set(this,void 0),In.set(this,void 0),kn.set(this,void 0),jn.set(this,{popstate:r(this,gn,"m",_n).bind(this)}),On.set(this,void 0),Rn.set(this,(t=>{var e;if(r(this,gn,"m",Un).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,gn,"m",En).call(this,i,l,u)||r(this,mn,"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,gn,"m",xn).call(this),r(this,mn,"f").subscribe(r(this,gn,"m",Pn).bind(this)),r(this,yn,"f").subscribe(r(this,gn,"m",Tn).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,bn,!0,"f"),r(this,gn,"m",Sn).call(this),r(this,gn,"m",Mn).call(this);const{executionId:t,stepId:e}=an(),n=Ye("t")||void 0;n&&en("t");const i=Ye(Ge)||void 0;i&&en(Ge),r(this,mn,"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,jn,"f").popstate),r(this,wn,"f").onkeydown=t=>{"Enter"===t.key&&t.preventDefault()}}}disconnectedCallback(){r(this,mn,"f").unsubscribeAll(),r(this,yn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,jn,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,bn,"f")&&e!==n&&Bn.observedAttributes.includes(t)){r(this,gn,"m",Sn).call(this);const o=null===e;r(this,mn,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,un()),{[dn(t)]:n,stepId:i,executionId:s}}))}}}bn=new WeakMap,mn=new WeakMap,yn=new WeakMap,wn=new WeakMap,In=new WeakMap,kn=new WeakMap,jn=new WeakMap,On=new WeakMap,Rn=new WeakMap,gn=new WeakSet,xn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Kn.content.cloneNode(!0)),o(this,wn,this.shadowRoot.querySelector("form"),"f"),o(this,In,this.shadowRoot.querySelector("style"),"f")},Sn=function(){const t=["base-url"];Bn.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)}))},_n=function(){const{stepId:t,executionId:e}=an();r(this,mn,"f").update({stepId:t,executionId:e})},En=function(t,e,n){switch(t){case vn.failed:return un(),r(this,gn,"m",An).call(this,"error",e),!0;case vn.completed:return un(),r(this,gn,"m",An).call(this,"success",n),!0;default:return!1}},Un=function({ok:t,error:e}){return t||r(this,gn,"m",An).call(this,"error",e),!t},Pn=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,kn,"f")&&(clearInterval(r(this,kn,"f")),o(this,kn,null,"f")),y){if(!s)return;o(this,On,Fe({projectId:s,baseUrl:c}),"f")}if(!l){if(!a)return;const t=yield r(this,On,"f").flow.start(a);return void r(this,Rn,"f").call(this,t)}if(i("token")&&v||i("code")&&g){const t=yield r(this,On,"f").flow.next(l,u,"submit",{token:v,code:g});return cn(t.data.executionId,t.data.stepId),r(this,Rn,"f").call(this,t),void r(this,mn,"f").update({token:void 0,code:void 0})}if(d===Ze)return f?void window.location.assign(f):void console.error("Did not get redirect url");if(d===Qe||d===Xe){if(!b||!m)return void console.error("Did not get webauthn transaction id or options");const t=d===Qe?yield Ln(m):yield $n(m),e=yield r(this,On,"f").flow.next(l,u,"submit",{transactionId:b,response:t});return void r(this,Rn,"f").call(this,e)}if(d===Ve&&o(this,kn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,On,"f").flow.next(l,u,"submit",{});r(this,Rn,"f").call(this,t)}))),2e3),"f"),!h)return void console.error("Refreshing the page during a flow is not supported yet");const w={direction:sn(+u,+e.stepId),screenErrorText:p,htmlUrl:on(s,h,"html")};(y||i("executionId")||i("stepId"))&&(w.next=(...t)=>r(this,On,"f").flow.next(l,u,...t)),r(this,yn,"f").update(w)}))},Cn=function(t){r(this,wn,"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=(a=e.submitter,Array.from((null==a?void 0:a.attributes)||[]).reduce(((t,e)=>{var n;const r=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return r?Object.assign(t,{[r]:e.value}):t}),{}));var a;const c=yield t(o,Object.assign(Object.assign(Object.assign({},s),i),{origin:window.location.origin}));cn(c.data.executionId,c.data.stepId),r(this,Rn,"f").call(this,c)}))},Tn=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,gn,"m",Cn).call(this,a),void(o("screenErrorText")&&ln(this.shadowRoot,e,c));const u=document.createElement("template");u.innerHTML=yield rn(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),ln(l,e,c);try{d.forEach((t=>t()))}catch(t){console.error(t)}r(this,wn,"f").replaceChildren(l),r(this,gn,"m",Cn).call(this,a),r(this,gn,"m",An).call(this,"page-updated",{})};s?r(this,gn,"m",Dn).call(this,h,s):h()}))},Dn=function(t,e){r(this,wn,"f").addEventListener("transitionend",(()=>{r(this,wn,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===nn.forward?"slide-forward":"slide-backward";Array.from(r(this,wn,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,wn,"f").classList.add("fade-out")},An=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},Mn=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=on(this["project-id"],"theme","css");t.innerText=yield rn(e),this.shadowRoot.appendChild(t)}))},customElements.define("descope-wc",Bn)}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/web-component",
|
|
3
|
-
"version": "0.0.26-alpha.
|
|
3
|
+
"version": "0.0.26-alpha.10",
|
|
4
4
|
"main": "dist/descope-wc",
|
|
5
5
|
"types": "dist/descope-wc.d.ts",
|
|
6
6
|
"description": "Descope WC",
|
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
"typescript": "^4.5.3"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@descope/core-js-sdk": "0.0.41-alpha.
|
|
63
|
+
"@descope/core-js-sdk": "0.0.41-alpha.17",
|
|
64
|
+
"@descope/web-js-sdk": "0.0.1-alpha.7"
|
|
64
65
|
},
|
|
65
66
|
"overrides": {
|
|
66
67
|
"terser": "5.14.2"
|