@descope/web-component 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +12 -3
- package/dist/descope-wc.d.ts +1 -0
- package/dist/descope-wc.js +1 -1
- package/package.json +81 -69
package/README.md
CHANGED
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
Create your login pages on our console-app, once done, you can use this library to inject those pages to your app</br>
|
|
4
4
|
it registers- a [web component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) and update the web-component content based on the relevant page,
|
|
5
5
|
See usage example below
|
|
6
|
+
|
|
6
7
|
## Usage
|
|
8
|
+
|
|
7
9
|
### Install the package
|
|
10
|
+
|
|
8
11
|
```bash
|
|
9
12
|
npm install @descope/web-component
|
|
10
13
|
```
|
|
14
|
+
|
|
11
15
|
### As a library
|
|
16
|
+
|
|
12
17
|
```js
|
|
13
18
|
import '@descope/web-component'
|
|
14
19
|
import { DescopeWc } // in case you need types definition or you want to use the class directly
|
|
@@ -20,25 +25,29 @@ render(){
|
|
|
20
25
|
)
|
|
21
26
|
}
|
|
22
27
|
```
|
|
28
|
+
|
|
23
29
|
### In HTML file
|
|
24
30
|
|
|
25
31
|
- Copy the file `@descope/web-js/sdk/dist/descope-wc.js` and place it where your HTML file is located
|
|
26
32
|
|
|
27
33
|
- Add the following script tag to your HTML file
|
|
34
|
+
|
|
28
35
|
```html
|
|
29
36
|
<head>
|
|
30
|
-
|
|
37
|
+
<script src="./my-lib.umd.production.min.js"></script>
|
|
31
38
|
</head>
|
|
32
39
|
```
|
|
33
40
|
|
|
34
41
|
- Now you can add the custom element to your HTML
|
|
42
|
+
|
|
35
43
|
```html
|
|
36
44
|
<descope-wc project-id="<project-id>" flow-id="<flow-id>"></descope-wc>
|
|
37
45
|
```
|
|
38
46
|
|
|
39
47
|
### Run the demo app
|
|
48
|
+
|
|
40
49
|
- Install dependencies - `npm i`
|
|
41
|
-
- Edit the `src/app/index.html` - replace `<project-id>` and `<project-id>` with your project and a flow
|
|
50
|
+
- Edit the `src/app/index.html` - replace `<project-id>` and `<project-id>` or set `DESCOPE_PROJECT_ID` env variable with your project and a flow
|
|
42
51
|
- Run application - `npm run start`
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
_TODO: we should 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.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare class DescopeWc extends HTMLElement {
|
|
|
5
5
|
get 'project-id'(): string;
|
|
6
6
|
get 'flow-id'(): string;
|
|
7
7
|
get 'base-url'(): string;
|
|
8
|
+
get tenant(): string;
|
|
8
9
|
connectedCallback(): void;
|
|
9
10
|
disconnectedCallback(): void;
|
|
10
11
|
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
package/dist/descope-wc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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]",f="[object GeneratorFunction]",p=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/,v=/^\./,b=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,w=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,m="object"==typeof u&&u&&u.Object===Object&&u,I="object"==typeof self&&self&&self.Object===Object&&self,O=m||I||Function("return this")();var j,k=Array.prototype,x=Function.prototype,S=Object.prototype,_=O["__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=O.Symbol,D=k.splice,A=F(O,"Map"),M=F(Object,"create"),L=T?T.prototype:void 0,N=L?L.toString:void 0;function q(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 $(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 W(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)||!p.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 B(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==f}(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 H(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 F(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return B(n)?n:void 0}q.prototype.clear=function(){this.__data__=M?M(null):{}},q.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},q.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},q.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:P.call(e,t)},q.prototype.set=function(t,e){return this.__data__[t]=M&&void 0===e?d:e,this},J.prototype.clear=function(){this.__data__=[]},J.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)},J.prototype.get=function(t){var e=this.__data__,n=K(e,t);return n<0?void 0:e[n][1]},J.prototype.has=function(t){return K(this.__data__,t)>-1},J.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},$.prototype.clear=function(){this.__data__={hash:new q,map:new(A||J),string:new q}},$.prototype.delete=function(t){return H(this,t).delete(t)},$.prototype.get=function(t){return H(this,t).get(t)},$.prototype.has=function(t){return H(this,t).has(t)},$.prototype.set=function(t,e){return H(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 N?N.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(w,"$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||$),n}Z.Cache=$;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:W(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",ft="/v1/auth/oauth/authorize",pt="/v1/auth/saml/authorize",gt="/v1/auth/totp/verify",vt="/v1/auth/totp/signup",bt="/v1/user/totp/update",wt={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"},It="/v1/flow/start",Ot="/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")}},kt=(...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:f}=a,p=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:kt(St(e,f),(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==p?void 0:p.clone()),p};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})}};function Et(t){const{exp:e}=Dt(t);return(new Date).getTime()/1e3>e}function Ut(t,e){return Tt(t,e,"permissions")}function Pt(t,e){return Tt(t,e,"roles")}const Rt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Ct(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}function Tt(t,e,n){var r;let o=Dt(t);e&&(o=null===(r=o.tenants)||void 0===r?void 0:r[e]);const i=o[n];return Array.isArray(i)?i:[]}function Dt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return c(t)}const At=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Mt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Lt=t=>e=>t.test(e),Nt=Lt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),qt=Lt(/^\+[1-9]{1}[0-9]{3,14}$/),Jt=At(Nt,'"{val}" is not a valid email'),$t=At(qt,'"{val}" is not a valid phone number'),Kt=At((1,t=>t.length>=1),"Minimum length is 1");const Wt=At((t=>"string"==typeof t),"Input is not a string"),Bt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Mt(...t).validate(n[e]))),e(...n)),Ht=t=>[Wt(`"${t}" must be a string`),Kt(`"${t}" must not be empty`)],Ft=t=>[Wt(`"${t}" must be a string`),Jt()],zt=t=>[Wt(`"${t}" must be a string`),$t()],Gt=Bt(Ht("accessKey")),Zt=t=>({exchange:Gt((e=>Ct(t.get(et,{token:e}))))});var Vt,Qt,Xt,Yt,te;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Vt||(Vt={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(Qt||(Qt={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Xt||(Xt={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(Yt||(Yt={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(te||(te={}));const ee=Ht("identifier"),ne=Bt(ee,Ht("code")),re=Bt(ee),oe=Bt(ee,zt("phone")),ie=Bt(ee,Ft("email")),se=t=>({verify:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ne(((e,r)=>Ct(t.post(Rt(nt,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:re((e=>Ct(t.post(Rt(rt,n),{externalId:e}))))})),{}),signUp:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:re(((e,r)=>Ct(t.post(Rt(ot,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:re((e=>Ct(t.post(Rt(st,n),{externalId:e}))))})),{}),update:{email:ie(((e,n,r)=>Ct(t.post(it.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(Vt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:oe(((e,r,o)=>Ct(t.post(Rt(it.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),ae=Ht("identifier"),ce=Ht("uri"),ue=Bt(Ht("token")),le=Bt(ae,ce),de=Bt(Ht("pendingRef")),he=Bt(ae,zt("phone"),ce),fe=Bt(ae,Ft("email"),ce),pe=t=>({verify:ue((e=>Ct(t.post(at,{token:e})))),signIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r)=>Ct(t.post(Rt(ct,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r)=>Ct(t.post(Rt(ht,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r,o)=>Ct(t.post(Rt(ut,n),{externalId:e,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:de(((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(Ct(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:fe(((e,n,r,o)=>Ct(t.post(dt.email,{externalId:e,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Vt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,r,o,i)=>Ct(t.post(Rt(dt.phone,n),{externalId:e,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),ge=t=>({verify:ue((e=>Ct(t.post(at,{token:e})))),signIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r)=>Ct(t.post(Rt(ct,n),{externalId:e,URI:r}))))})),{}),signUp:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r,o)=>Ct(t.post(Rt(ut,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:le(((e,r)=>Ct(t.post(Rt(ht,n),{externalId:e,URI:r}))))})),{}),update:{email:fe(((e,n,r,o)=>Ct(t.post(dt.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(Vt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,r,o,i)=>Ct(t.post(Rt(dt.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})},crossDevice:pe(t)}),ve=Bt(Ht("code")),be=t=>({exchange:ve((e=>Ct(t.get("/v1/auth/exchange",{queryParams:{code:e}}))))});var we;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(we||(we={}));const ye=t=>Object.assign({start:Object.keys(we).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={})=>{const o=await t.get(ft,{queryParams:Object.assign({provider:n},e&&{redirectURL:e})});if(!r||!o.ok)return Ct(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},be(t)),me=Bt(Ht("flowId")),Ie=Bt(Ht("executionId"),Ht("stepId"),Ht("interactionId")),Oe=t=>({start:me((e=>Ct(t.post(It,{flowId:e})))),next:Ie(((e,n,r,o)=>Ct(t.post(Ot,{executionId:e,stepId:n,interactionId:r,input:o}))))}),je=Bt(Ht("tenant")),ke=t=>Object.assign({start:je((async(e,n,{redirect:r=!1}={})=>{const o=await t.get(pt,{queryParams:{tenant:e,redirectURL:n}});if(!r||!o.ok)return Ct(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},be(t)),xe=Ht("identifier"),Se=Bt(xe,Ht("code")),_e=Bt(xe),Ee=Bt(xe),Ue=t=>({signUp:_e(((e,n)=>Ct(t.post(vt,{externalId:e,user:n})))),verify:Se(((e,n)=>Ct(t.post(gt,{externalId:e,code:n})))),update:Ee(((e,n)=>Ct(t.post(bt,{externalId:e},{token:n}))))}),Pe=Ht("identifier"),Re=Ht("origin"),Ce=Bt(Pe,Re,Ht("name")),Te=Bt(Pe,Re),De=Bt(Pe,Re,Ht("token")),Ae=Bt(Ht("transactionId"),Ht("response")),Me=t=>({signUp:{start:Ce(((e,n,r)=>Ct(t.post(wt.start,{user:{externalId:e,name:r},origin:n})))),finish:Ae(((e,n)=>Ct(t.post(wt.finish,{transactionId:e,response:n}))))},signIn:{start:Te(((e,n)=>Ct(t.post(yt.start,{externalId:e,origin:n})))),finish:Ae(((e,n)=>Ct(t.post(yt.finish,{transactionId:e,response:n}))))},update:{start:De(((e,n,r)=>Ct(t.post(mt.start,{externalId:e,origin:n},{token:r})))),finish:Ae(((e,n)=>Ct(t.post(mt.finish,{transactionId:e,response:n}))))}}),Le=Bt(Ht("token"));var Ne;const qe=Bt([("projectId",Ne=Ht("projectId"),At(((t,e)=>t=>Mt(...e).validate(tt(t,"projectId")))(0,Ne))())])((({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:Zt(i),otp:se(i),magicLink:ge(i),oauth:ye(i),saml:ke(i),totp:Ue(i),webauthn:Me(i),flow:Oe(i),refresh:t=>Ct(i.get("/v1/auth/refresh",{token:t})),logout:t=>Ct(i.get("/v1/auth/logoutall",{token:t})),me:t=>Ct(i.get("/v1/auth/me",{token:t})),isJwtExpired:Le(Et),getJwtPermissions:Le(Ut),getJwtRoles:Le(Pt),httpClient:i};var i}));function Je(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 Je(t,e,n+1)}))}))}qe.DeliveryMethods=Qt;var $e="Failed to load the JS script of the agent";function Ke(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 Je({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($e))},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($e);return r.load(t(t({},c),{ldi:{attempts:l}}))}))}var We={exports:{}},Be={exports:{}};Be.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=Be.exports}(We);var He=l(We.exports);const Fe=t=>{const e=Ke({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)}}}};var ze,Ge,Ze,Ve,Qe;const Xe=t=>"string"==typeof t?t:Object.assign({},t);class Ye{constructor(t){ze.add(this),Ge.set(this,void 0),Ze.set(this,{}),Ve.set(this,0),o(this,Ge,t,"f")}get current(){return Xe(r(this,Ge,"f"))}update(t){let e=t;if("object"==typeof t&&"object"==typeof r(this,Ge,"f")&&(e=Object.assign(Object.assign({},r(this,Ge,"f")),t)),!((t,e)=>{if("string"==typeof t)return t===e;const n=t&&Object.getOwnPropertyNames(t)||[],r=e&&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,Ge,"f"),e)){const t=r(this,Ge,"f");o(this,Ge,e,"f"),Object.freeze(r(this,Ge,"f")),setTimeout((()=>{Object.values(r(this,Ze,"f")).forEach((n=>n(Xe(e),t)))}),0)}}subscribe(t){var e;o(this,Ve,r(this,Ve,"f")+1,"f"),r(this,Ze,"f")[r(this,Ve,"f")]=t,((e=r(this,Ge,"f"))&&"string"!=typeof e?0===Object.entries(e).length:!e)||t(Xe(r(this,Ge,"f")));const n=r(this,Ve,"f");return()=>r(this,ze,"m",Qe).call(this,n.toString())}unsubscribeAll(){o(this,Ze,{},"f")}}Ge=new WeakMap,Ze=new WeakMap,Ve=new WeakMap,ze=new WeakSet,Qe=function(t){r(this,Ze,"f")[t]&&delete r(this,Ze,"f")[t]};let tn=[];function en(t,e,n){const r=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(r){let e;for(;e=tn.pop();)clearTimeout(e);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{t(n)}),o);tn.push(i)}}function nn(t,e,n){!function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:r}){t&&He.set("DS",t,{path:e,domain:n,expires:r,sameSite:"None",secure:!0})}(t,n),function(t){localStorage&&t&&localStorage.setItem("DSR",t)}(e)}function rn(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function on(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=an(n.publicKey.challenge),n.publicKey.user.id=an(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=an(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:cn(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:cn(n.response.attestationObject),clientDataJSON:cn(n.response.clientDataJSON)})}));var n}async function sn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=an(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=an(t.id)})),n}(t);return n=await navigator.credentials.get(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:cn(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:cn(n.response.authenticatorData),clientDataJSON:cn(n.response.clientDataJSON),signature:cn(n.response.signature),userHandle:n.response.userHandle?cn(n.response.userHandle):void 0})}));var n}function an(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function cn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var un=t=>{var{autoRefresh:n=!0,persistTokens:r=!0}=t,o=e(t,["autoRefresh","persistTokens"]);Fe(o.fpKey).get().catch((()=>null));const i=o;let s,a;const c=new Ye(""),u=new Ye({});i.hooks={beforeRequest:t=>null==s?void 0:s(t),afterRequest:(t,e)=>null==a?void 0:a(t,e)};const l=qe(i),d=Object.assign(Object.assign({},l),{webauthn:(h=l,{async signUp(t,e){const n=await h.webauthn.signUp.start(t,window.location.origin,e),r=await on(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,r)},async signIn(t){const e=await h.webauthn.signIn.start(t,window.location.origin),n=await sn(e.data.options);return await h.webauthn.signIn.finish(e.data.transactionId,n)},async update(t,e){const n=await h.webauthn.update.start(t,window.location.origin,e),r=await on(n.data.options);return await h.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:on,get:sn}}),onSessionTokenChange:c.subscribe,onUserChange:u.subscribe});var h;return n&&(d.logout=(...t)=>{const e=rn(),n=[(null==t?void 0:t.shift())||e,...t],r=l.logout(...n);return localStorage&&localStorage.removeItem("DSR"),He.remove("DS"),r}),s=t=>{var e;return t.queryParams=(e=t.queryParams,Object.assign(Object.assign({},e),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!t.token&&r&&(t.token=rn()),t},(n||r)&&(a=(t,o)=>{!async function(t,n,r,o){try{const i=await(null==n?void 0:n.json());if(i){const n=function(t){return(null==t?void 0:t.authInfo)||t||{}}(i),{sessionJwt:s,refreshJwt:a,user:c}=n,u=e(n,["sessionJwt","refreshJwt","user"]);o.persistTokens&&nn(s,a,u),r.sessionToken.update(s),r.user.update(c),s&&a&&o.autoRefresh&&en(t,s,a)}}catch(t){console.error("Could not set tokens from body",t)}}(d.refresh,o,{sessionToken:c,user:u},{autoRefresh:n,persistTokens:r})}),n&&d.refresh(),d};const ln=(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("base.content.url"))||"https://static.prod.descope.com/pages",dn="descope-login-flow",hn="code",fn="redirect",pn="poll",gn="webauthnCreate",vn="webauthnGet";function bn(t){return new URLSearchParams(window.location.search).get(t)}function wn(){return bn(dn)}function yn(t){if(window.history.replaceState&&bn(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 mn;function In(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(t){t.backward="backward",t.forward="forward"}(mn||(mn={}));function On(t,e,n){const r=new URL(ln);return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,`${e}.${n}`),r.toString()}function jn(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?mn.forward:t<e?mn.backward:void 0}const kn=()=>{const[t="",e=""]=(wn()||"").split("_");return{executionId:t,stepId:e}},xn=(t,e)=>{!function(t){if(window.history.pushState&&t!==wn()){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.set(dn,t),e.search=n.toString(),window.history.pushState({},"",e.toString())}}([t,e].join("_"))};function Sn(){yn(dn)}const _n=(t,e,n="")=>{t.querySelectorAll(`[data-type="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))},En=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Un,Pn,Rn,Cn,Tn,Dn,An,Mn,Ln,Nn,qn,Jn,$n,Kn,Wn,Bn,Hn,Fn,zn,Gn,Zn,Vn,Qn,Xn,Yn,tr,er;class nr{constructor(t={}){Un.set(this,void 0),Pn.set(this,{}),Rn.set(this,0),o(this,Un,t,"f")}get current(){return Object.assign({},r(this,Un,"f"))}update(t){const e="function"==typeof t?t(r(this,Un,"f")):t,n=Object.assign(Object.assign({},r(this,Un,"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,Un,"f"),n)){const t=r(this,Un,"f");o(this,Un,n,"f"),Object.freeze(r(this,Un,"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,Rn,r(this,Rn,"f")+1,"f"),r(this,Pn,"f")[r(this,Rn,"f")]=t,r(this,Rn,"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 rr(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ir(n.publicKey.challenge),n.publicKey.user.id=ir(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ir(t.id)})),n}(t),n=yield navigator.credentials.create(e);return r=n,JSON.stringify({id:r.id,rawId:sr(r.rawId),type:r.type,response:{attestationObject:sr(r.response.attestationObject),clientDataJSON:sr(r.response.clientDataJSON)}});var r}))}function or(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ir(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ir(t.id)})),n}(t),n=yield navigator.credentials.get(e);return r=n,JSON.stringify({id:r.id,rawId:sr(r.rawId),type:r.type,response:{authenticatorData:sr(r.response.authenticatorData),clientDataJSON:sr(r.response.clientDataJSON),signature:sr(r.response.signature),userHandle:sr(r.response.userHandle)}});var r}))}function ir(t){const e=t.replace(/-/g,"+").replace(/_/g,"/");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function sr(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}Un=new WeakMap,Pn=new WeakMap,Rn=new WeakMap,function(t){t.waiting="waiting",t.completed="completed",t.failed="failed",t.running="running"}(Cn||(Cn={}));const ar=document.createElement("template");ar.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 cr extends HTMLElement{constructor(){super(),Tn.add(this),Dn.set(this,!1),An.set(this,new nr),Mn.set(this,new nr),Ln.set(this,new nr({isLoading:!1})),Nn.set(this,void 0),qn.set(this,void 0),Jn.set(this,void 0),$n.set(this,{popstate:r(this,Tn,"m",Hn).bind(this)}),Kn.set(this,void 0),Vn.set(this,(t=>{var e;if(r(this,Tn,"m",zn).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,Tn,"m",Fn).call(this,i,l,u)||r(this,An,"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,Tn,"m",Wn).call(this),r(this,An,"f").subscribe(r(this,Tn,"m",Zn).bind(this)),r(this,Mn,"f").subscribe(r(this,Tn,"m",Xn).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,Dn,!0,"f"),r(this,Tn,"m",Bn).call(this),r(this,Tn,"m",er).call(this);const{executionId:t,stepId:e}=kn(),n=bn("t")||void 0;n&&yn("t");const i=bn(hn)||void 0;i&&yn(hn),r(this,An,"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,$n,"f").popstate),r(this,Nn,"f").onkeydown=t=>{if("Enter"===t.key){t.preventDefault();const e=r(this,Nn,"f").querySelectorAll("button");1===e.length&&e[0].click()}}}}disconnectedCallback(){r(this,An,"f").unsubscribeAll(),r(this,Mn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,$n,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,Dn,"f")&&e!==n&&cr.observedAttributes.includes(t)){r(this,Tn,"m",Bn).call(this);const o=null===e;r(this,An,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,Sn()),{[En(t)]:n,stepId:i,executionId:s}}))}}}Dn=new WeakMap,An=new WeakMap,Mn=new WeakMap,Ln=new WeakMap,Nn=new WeakMap,qn=new WeakMap,Jn=new WeakMap,$n=new WeakMap,Kn=new WeakMap,Vn=new WeakMap,Tn=new WeakSet,Wn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ar.content.cloneNode(!0)),o(this,Nn,this.shadowRoot.querySelector("form"),"f"),o(this,qn,this.shadowRoot.querySelector("style"),"f")},Bn=function(){const t=["base-url"];cr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)}))},Hn=function(){const{stepId:t,executionId:e}=kn();r(this,An,"f").update({stepId:t,executionId:e})},Fn=function(t,e,n){switch(t){case Cn.failed:return Sn(),r(this,Tn,"m",tr).call(this,"error",e),!0;case Cn.completed:return Sn(),r(this,Tn,"m",tr).call(this,"success",n),!0;default:return!1}},zn=function(t){return(null==t?void 0:t.ok)||r(this,Tn,"m",tr).call(this,"error",null==t?void 0:t.error),!(null==t?void 0:t.ok)},Gn=function(t,e){o(this,Kn,un({projectId:t,baseUrl:e}),"f");const i=r(this,Kn,"f").flow.next;r(this,Kn,"f").flow.next=(...t)=>n(this,void 0,void 0,(function*(){r(this,Ln,"f").update({isLoading:!0});try{return yield i(...t)}finally{r(this,Ln,"f").update({isLoading:!1})}}))},Zn=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:f,redirectUrl:p,token:g,code:v,webauthnTransactionId:b,webauthnOptions:w}=t,y=i("projectId")||i("baseUrl");if(r(this,Jn,"f")&&(clearInterval(r(this,Jn,"f")),o(this,Jn,null,"f")),y){if(!s)return;r(this,Tn,"m",Gn).call(this,s,c)}if(!l){if(!a)return;const t=yield r(this,Kn,"f").flow.start(a);return void r(this,Vn,"f").call(this,t)}if(i("token")&&g||i("code")&&v){const t=yield r(this,Kn,"f").flow.next(l,u,"submit",{token:g,code:v});return xn(t.data.executionId,t.data.stepId),r(this,Vn,"f").call(this,t),void r(this,An,"f").update({token:void 0,code:void 0})}if(d===fn)return p?void window.location.assign(p):void console.error("Did not get redirect url");if(d===gn||d===vn){if(!b||!w)return void console.error("Did not get webauthn transaction id or options");const t=d===gn?yield rr(w):yield or(w),e=yield r(this,Kn,"f").flow.next(l,u,"submit",{transactionId:b,response:t});return void r(this,Vn,"f").call(this,e)}if(d===pn&&o(this,Jn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,Kn,"f").flow.next(l,u,"submit",{});r(this,Vn,"f").call(this,t)}))),2e3),"f"),!h)return void console.error("Refreshing the page during a flow is not supported yet");const m={direction:jn(+u,+e.stepId),screenErrorText:f,htmlUrl:On(s,h,"html")};(y||i("executionId")||i("stepId"))&&(m.next=(...t)=>r(this,Kn,"f").flow.next(l,u,...t)),r(this,Mn,"f").update(m)}))},Qn=function(t){r(this,Nn,"f").onsubmit=e=>n(this,void 0,void 0,(function*(){var n,o,i;const s=null===(n=e.submitter)||void 0===n?void 0:n.getAttribute("id"),a=r(this,Ln,"f").subscribe((({isLoading:t})=>{var n,o,i,s;t?null===(o=null===(n=e.submitter)||void 0===n?void 0:n.classList)||void 0===o||o.add("loading"):(r(this,Ln,"f").unsubscribe(a),null===(s=null===(i=e.submitter)||void 0===i?void 0:i.classList)||void 0===s||s.remove("loading"))}));e.preventDefault();const c=Object.fromEntries(new FormData(e.target).entries()),u=(l=e.submitter,Array.from((null==l?void 0:l.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 l;const d=yield t(s,Object.assign(Object.assign(Object.assign({},u),c),{origin:window.location.origin}));xn(null===(o=d.data)||void 0===o?void 0:o.executionId,null===(i=d.data)||void 0===i?void 0:i.stepId),r(this,Vn,"f").call(this,d)}))},Xn=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,Tn,"m",Qn).call(this,a),void(o("screenErrorText")&&_n(this.shadowRoot,e,c));const u=document.createElement("template");u.innerHTML=yield In(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),_n(l,e,c);try{d.forEach((t=>t()))}catch(t){console.error(t)}r(this,Nn,"f").replaceChildren(l),r(this,Tn,"m",Qn).call(this,a),r(this,Tn,"m",tr).call(this,"page-updated",{})};s?r(this,Tn,"m",Yn).call(this,h,s):h()}))},Yn=function(t,e){r(this,Nn,"f").addEventListener("transitionend",(()=>{r(this,Nn,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===mn.forward?"slide-forward":"slide-backward";Array.from(r(this,Nn,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,Nn,"f").classList.add("fade-out")},tr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},er=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=On(this["project-id"],"theme","css");t.innerText=yield In(e),this.shadowRoot.appendChild(t)}))},customElements.define("descope-wc",cr)}();
|
|
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,w=/^\[object .+?Constructor\]$/,m="object"==typeof u&&u&&u.Object===Object&&u,k="object"==typeof self&&self&&self.Object===Object&&self,O=m||k||Function("return this")();var I,j=Array.prototype,x=Function.prototype,S=Object.prototype,_=O["__core-js_shared__"],E=(I=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",U=x.toString,P=S.hasOwnProperty,C=S.toString,R=RegExp("^"+U.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=O.Symbol,A=j.splice,D=H(O,"Map"),M=H(Object,"create"),N=T?T.prototype:void 0,L=N?N.toString:void 0;function q(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 W(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: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 B(t){if(!Q(t)||(e=t,E&&E in e))return!1;var e,n=function(t){var e=Q(t)?C.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)?R:w;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 B(n)?n:void 0}q.prototype.clear=function(){this.__data__=M?M(null):{}},q.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},q.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},q.prototype.has=function(t){var e=this.__data__;return M?void 0!==e[t]:P.call(e,t)},q.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():A.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 q,map:new(D||$),string:new q}},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 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]"==C.call(t)}var Y,tt=function(t,e,n){var r=null==t?void 0:W(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/phone"},ht="/v1/auth/magiclink/signup-in",pt="/v1/auth/oauth/authorize",ft="/v1/auth/oauth/exchange",gt="/v1/auth/saml/authorize",vt="/v1/auth/saml/exchange",bt="/v1/auth/totp/verify",yt="/v1/auth/totp/signup",wt="/v1/user/totp/update",mt={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},kt={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Ot={start:"/v1/auth/webauthn/signup-in/start"},It={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},jt="/v1/flow/start",xt="/v1/flow/next";!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Y||(Y={}));const St=()=>{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")}},_t=(...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}),{})),Et=t=>void 0===t?void 0:JSON.stringify(t),Ut=(t,e="")=>{let n=t;return""!==e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Pt=({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=>St().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)),St().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:_t(Ut(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"0.0.41-alpha.27"},(null==n?void 0:n.baseHeaders)||{},l),method:h,body:Et(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})}};function Ct(t,e,n){var r;let o=Rt(t);e&&(o=null===(r=o.tenants)||void 0===r?void 0:r[e]);const i=o[n];return Array.isArray(i)?i:[]}function Rt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return c(t)}function Tt(t){const{exp:e}=Rt(t);return(new Date).getTime()/1e3>e}function At(t,e){return Ct(t,e,"permissions")}function Dt(t,e){return Ct(t,e,"roles")}const Mt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Nt(t){const e=await t,n={code:e.status,ok:e.ok,response:e},r=await e.clone().json();return e.ok?n.data=r:n.error=r,n}const Lt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),qt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),$t=t=>e=>t.test(e),Jt=$t(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Kt=$t(/^\+[1-9]{1}[0-9]{3,14}$/),Wt=Lt(Jt,'"{val}" is not a valid email'),Bt=Lt(Kt,'"{val}" is not a valid phone number'),Ft=Lt((1,t=>t.length>=1),"Minimum length is 1");const Ht=Lt((t=>"string"==typeof t),"Input is not a string"),zt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>qt(...t).validate(n[e]))),e(...n)),Gt=t=>[Ht(`"${t}" must be a string`),Ft(`"${t}" must not be empty`)],Zt=t=>[Ht(`"${t}" must be a string`),Wt()],Vt=t=>[Ht(`"${t}" must be a string`),Bt()],Qt=zt(Gt("accessKey")),Xt=t=>({exchange:Qt((e=>Nt(t.post(et,{},{token:e}))))});var Yt,te,ee,ne,re;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Yt||(Yt={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(te||(te={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(ee||(ee={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(ne||(ne={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(re||(re={}));const oe=Gt("identifier"),ie=zt(oe,Gt("code")),se=zt(oe),ae=zt(oe,Vt("phone")),ce=zt(oe,Zt("email")),ue=t=>({verify:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ie(((e,r)=>Nt(t.post(Mt(nt,n),{code:r,externalId:e}))))})),{}),signIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,r,o)=>Nt(t.post(Mt(rt,n),{externalId:e,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,r)=>Nt(t.post(Mt(ot,n),{externalId:e,user:r}))))})),{}),signUpOrIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se((e=>Nt(t.post(Mt(st,n),{externalId:e}))))})),{}),update:{email:ce(((e,n,r)=>Nt(t.post(it.email,{externalId:e,email:n},{token:r})))),phone:Object.keys(Yt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ae(((e,r,o)=>Nt(t.post(Mt(it.phone,n),{externalId:e,phone:r},{token:o}))))})),{})}}),le=Gt("identifier"),de=Gt("uri"),he=zt(Gt("token")),pe=zt(le,de),fe=zt(Gt("pendingRef")),ge=zt(le,Vt("phone"),de),ve=zt(le,Zt("email"),de),be=t=>({verify:he((e=>Nt(t.post(at,{token:e})))),signIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o,i)=>Nt(t.post(Mt(ct,n),{externalId:e,URI:r,crossDevice:!0,loginOptions:o},{token:i}))))})),{}),signUpOrIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r)=>Nt(t.post(Mt(ht,n),{externalId:e,URI:r,crossDevice:!0}))))})),{}),signUp:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o)=>Nt(t.post(Mt(ut,n),{externalId:e,URI:r,user:o,crossDevice:!0}))))})),{}),waitForSession:fe(((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(Nt(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ve(((e,n,r,o)=>Nt(t.post(dt.email,{externalId:e,email:n,URI:r,crossDevice:!0},{token:o})))),phone:Object.keys(Yt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o,i)=>Nt(t.post(Mt(dt.phone,n),{externalId:e,phone:r,URI:o,crossDevice:!0},{token:i}))))})),{})}}),ye=t=>({verify:he((e=>Nt(t.post(at,{token:e})))),signIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o,i)=>Nt(t.post(Mt(ct,n),{externalId:e,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r,o)=>Nt(t.post(Mt(ut,n),{externalId:e,URI:r,user:o}))))})),{}),signUpOrIn:Object.keys(te).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pe(((e,r)=>Nt(t.post(Mt(ht,n),{externalId:e,URI:r}))))})),{}),update:{email:ve(((e,n,r,o)=>Nt(t.post(dt.email,{externalId:e,email:n,URI:r},{token:o})))),phone:Object.keys(Yt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,r,o,i)=>Nt(t.post(Mt(dt.phone,n),{externalId:e,phone:r,URI:o},{token:i}))))})),{})},crossDevice:be(t)});var we;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple"}(we||(we={}));const me=zt(Gt("code")),ke=t=>({start:Object.keys(we).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:r=!1}={},o,i)=>{const s=await t.post(pt,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i});if(!r||!s.ok)return Nt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:me((e=>Nt(t.post(ft,{code:e}))))}),Oe=zt(Gt("flowId")),Ie=zt(Gt("executionId"),Gt("stepId"),Gt("interactionId")),je=t=>({start:Oe(((e,n)=>Nt(t.post(jt,{flowId:e,options:n})))),next:Ie(((e,n,r,o)=>Nt(t.post(xt,{executionId:e,stepId:n,interactionId:r,input:o}))))}),xe=zt(Gt("tenant")),Se=zt(Gt("code")),_e=t=>({start:xe((async(e,n,{redirect:r=!1}={},o,i)=>{const s=await t.post(gt,o||{},{queryParams:{tenant:e,redirectURL:n},token:i});if(!r||!s.ok)return Nt(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Se((e=>Nt(t.post(vt,{code:e}))))}),Ee=Gt("identifier"),Ue=zt(Ee,Gt("code")),Pe=zt(Ee),Ce=zt(Ee),Re=t=>({signUp:Pe(((e,n)=>Nt(t.post(yt,{externalId:e,user:n})))),verify:Ue(((e,n,r,o)=>Nt(t.post(bt,{externalId:e,code:n,loginOptions:r},{token:o})))),update:Ce(((e,n)=>Nt(t.post(wt,{externalId:e},{token:n}))))}),Te=Gt("identifier"),Ae=Gt("origin"),De=zt(Te,Ae,Gt("name")),Me=zt(Te,Ae),Ne=zt(Te,Ae,Gt("token")),Le=zt(Gt("transactionId"),Gt("response")),qe=t=>({signUp:{start:De(((e,n,r)=>Nt(t.post(mt.start,{user:{externalId:e,name:r},origin:n})))),finish:Le(((e,n)=>Nt(t.post(mt.finish,{transactionId:e,response:n}))))},signIn:{start:Me(((e,n,r,o)=>Nt(t.post(kt.start,{externalId:e,origin:n,loginOptions:r},{token:o})))),finish:Le(((e,n)=>Nt(t.post(kt.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Me(((e,n)=>Nt(t.post(Ot.start,{externalId:e,origin:n}))))},update:{start:Ne(((e,n,r)=>Nt(t.post(It.start,{externalId:e,origin:n},{token:r})))),finish:Le(((e,n)=>Nt(t.post(It.finish,{transactionId:e,response:n}))))}}),$e=zt(Gt("token"));var Je;const Ke=zt([("projectId",Je=Gt("projectId"),Lt(((t,e)=>t=>qt(...e).validate(tt(t,"projectId")))(0,Je))())])((({projectId:t,logger:e,baseUrl:n,hooks:r,cookiePolicy:o})=>{return i=Pt({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:r,cookiePolicy:o}),{accessKey:Xt(i),otp:ue(i),magicLink:ye(i),oauth:ke(i),saml:_e(i),totp:Re(i),webauthn:qe(i),flow:je(i),refresh:t=>Nt(i.post("/v1/auth/refresh",{},{token:t})),logout:t=>Nt(i.post("/v1/auth/logout",{},{token:t})),logoutAll:t=>Nt(i.post("/v1/auth/logoutall",{},{token:t})),me:t=>Nt(i.get("/v1/auth/me",{token:t})),isJwtExpired:$e(Tt),getJwtPermissions:$e(At),getJwtRoles:$e(Dt),httpClient:i};var i}));function We(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 We(t,e,n+1)}))}))}Ke.DeliveryMethods=te;var Be="Failed to load the JS script of the agent";function Fe(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 We({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(Be))},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(Be);return r.load(t(t({},c),{ldi:{attempts:l}}))}))}var He={exports:{}},ze={exports:{}};ze.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=ze.exports}(He);var Ge=l(He.exports);const Ze=t=>{const e=Fe({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)}}}};var Ve,Qe,Xe,Ye,tn;const en=t=>Object.assign({},t);class nn{constructor(t){Ve.add(this),Qe.set(this,void 0),Xe.set(this,{}),Ye.set(this,0),o(this,Qe,t,"f")}get current(){return en(r(this,Qe,"f"))}update(t){const e=t;if(!((t,e)=>{const n=t&&Object.getOwnPropertyNames(t)||[],r=e&&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,Qe,"f"),e)){const t=r(this,Qe,"f");o(this,Qe,e,"f"),Object.freeze(r(this,Qe,"f")),setTimeout((()=>{Object.values(r(this,Xe,"f")).forEach((n=>n(en(e),t)))}),0)}}subscribe(t){o(this,Ye,r(this,Ye,"f")+1,"f"),r(this,Xe,"f")[r(this,Ye,"f")]=t;const e=r(this,Ye,"f");return()=>r(this,Ve,"m",tn).call(this,e.toString())}unsubscribeAll(){o(this,Xe,{},"f")}}Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Ve=new WeakSet,tn=function(t){r(this,Xe,"f")[t]&&delete r(this,Xe,"f")[t]};let rn=[];function on(t,e,n){const r=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(r){let e;for(;e=rn.pop();)clearTimeout(e);const o=r.getTime()-2e4-(new Date).getTime(),i=setTimeout((()=>{t(n)}),o);rn.push(i)}}function sn(t,e,n){!function(t,{cookiePath:e,cookieDomain:n,cookieExpiration:r}){t&&Ge.set("DS",t,{path:e,domain:n,expires:r,sameSite:"None",secure:!0})}(t,n),function(t){localStorage&&t&&localStorage.setItem("DSR",t)}(e)}function an(){return localStorage?null===localStorage||void 0===localStorage?void 0:localStorage.getItem("DSR"):""}async function cn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ln(n.publicKey.challenge),n.publicKey.user.id=ln(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ln(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:dn(n.rawId),response:Object.assign(Object.assign({},n.response),{attestationObject:dn(n.response.attestationObject),clientDataJSON:dn(n.response.clientDataJSON)})}));var n}async function un(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ln(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ln(t.id)})),n}(t);return n=await navigator.credentials.get(e),JSON.stringify(Object.assign(Object.assign({},n),{rawId:dn(n.rawId),response:Object.assign(Object.assign({},n.response),{authenticatorData:dn(n.response.authenticatorData),clientDataJSON:dn(n.response.clientDataJSON),signature:dn(n.response.signature),userHandle:n.response.userHandle?dn(n.response.userHandle):void 0})}));var n}function ln(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function dn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}const hn="undefined"!=typeof window;var pn=t=>{var{autoRefresh:n=!0,persistTokens:r=!0}=t,o=e(t,["autoRefresh","persistTokens"]);hn?Ze(o.fpKey).get().catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server");const i=o;let s,a;const c=new nn({sessionToken:""}),u=new nn({});i.hooks={beforeRequest:t=>null==s?void 0:s(t),afterRequest:(t,e)=>null==a?void 0:a(t,e)};const l=Ke(i),d=Object.assign(Object.assign({},l),{webauthn:(h=l,{async signUp(t,e){const n=await h.webauthn.signUp.start(t,window.location.origin,e),r=await cn(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,r)},async signIn(t){const e=await h.webauthn.signIn.start(t,window.location.origin),n=await un(e.data.options);return await h.webauthn.signIn.finish(e.data.transactionId,n)},async signUpOrIn(t){var e;const n=await h.webauthn.signUpOrIn.start(t,window.location.origin);if(null===(e=n.data)||void 0===e?void 0:e.create){const t=await cn(n.data.options);return await h.webauthn.signUp.finish(n.data.transactionId,t)}{const t=await un(n.data.options);return await h.webauthn.signIn.finish(n.data.transactionId,t)}},async update(t,e){const n=await h.webauthn.update.start(t,window.location.origin,e),r=await cn(n.data.options);return await h.webauthn.update.finish(n.data.transactionId,r)},helpers:{create:cn,get:un}}),onSessionTokenChange:t=>{var e;const n=null===(e=c.current)||void 0===e?void 0:e.sessionToken;return n&&t(n),c.subscribe((({sessionToken:e})=>{t(e)}))},onUserChange:t=>{const e=u.current;return e&&Object.entries(e).length>0&&t(e),u.subscribe((e=>{t(e)}))}});var h;return n&&["logout","logoutAll"].forEach((t=>{const e=l[t];d[t]=(...t)=>{const n=an(),r=[(null==t?void 0:t.shift())||n,...t],o=e(...r);return localStorage&&localStorage.removeItem("DSR"),Ge.remove("DS"),c.update({sessionToken:""}),o}})),s=t=>{var e;return t.queryParams=(e=t.queryParams,Object.assign(Object.assign({},e),{vsid:sessionStorage.getItem("vsid")||"",vrid:sessionStorage.getItem("vrid")||""})),!t.token&&r&&(t.token=an()),t.headers=Object.assign(Object.assign({},t.headers),{"x-descope-sdk-name":"web-js","x-descope-sdk-version":"0.1.0-alpha.8"}),t},d.me=async(...t)=>{var e;const n=await l.me(...t);if(n.ok){const t=await(null===(e=n.response)||void 0===e?void 0:e.clone().json());u.update(t)}return n},(n||r)&&(a=(t,o)=>{!async function(t,n,r,o){try{if(401===n.status)return r.sessionToken.update({sessionToken:""}),void r.user.update({});const i=await(null==n?void 0:n.json());if(i){const n=function(t){return(null==t?void 0:t.authInfo)||t||{}}(i),{sessionJwt:s,refreshJwt:a,user:c}=n,u=e(n,["sessionJwt","refreshJwt","user"]);o.persistTokens&&sn(s,a,u),s&&r.sessionToken.update({sessionToken:s}),c&&r.user.update(c),s&&a&&o.autoRefresh&&on(t,s,a)}}catch(t){console.error("Could not set tokens from body",t)}}(d.refresh,o,{sessionToken:c,user:u},{autoRefresh:n,persistTokens:r})}),n&&an()&&d.refresh(),d};const fn=(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("base.content.url"))||"https://static.prod.descope.com/pages",gn="descope-login-flow",vn="code",bn="redirect",yn="poll",wn="webauthnCreate",mn="webauthnGet";function kn(t){return new URLSearchParams(window.location.search).get(t)}function On(t){if(window.history.replaceState&&kn(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 In;function jn(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t}`);return n[e||"text"]()}))}!function(t){t.backward="backward",t.forward="forward"}(In||(In={}));function xn(t,e){const n=new URL(fn);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,e),n.toString()}function Sn(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?In.forward:t<e?In.backward:void 0}const _n=()=>{const[t="",e=""]=(kn(gn)||"").split("_");return{executionId:t,stepId:e}};function En(){On(gn)}const Un=t=>t.replace(/-./g,(t=>t[1].toUpperCase()));var Pn,Cn,Rn;function Tn(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],i=t[o],s=e[o];if("object"==typeof i&&"object"==typeof s){if(!Tn(i,s))return!1}else if(i!==s)return!1}return!0}class An{constructor(t={}){Pn.set(this,void 0),Cn.set(this,{}),Rn.set(this,0),o(this,Pn,t,"f")}get current(){return Object.assign({},r(this,Pn,"f"))}update(t){const e="function"==typeof t?t(r(this,Pn,"f")):t,n=Object.assign(Object.assign({},r(this,Pn,"f")),e);if(!Tn(r(this,Pn,"f"),n)){const t=r(this,Pn,"f");o(this,Pn,n,"f"),Object.freeze(r(this,Pn,"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,Rn,r(this,Rn,"f")+1,"f"),r(this,Cn,"f")[r(this,Rn,"f")]=t,r(this,Rn,"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}}Pn=new WeakMap,Cn=new WeakMap,Rn=new WeakMap;const Dn=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[data-type="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll('[data-type="totp-link"]').forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return r=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),r);var r})))(t.textContent,e)}))})(t,e)};function Mn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Ln(n.publicKey.challenge),n.publicKey.user.id=Ln(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Ln(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 Nn(t){return n(this,void 0,void 0,(function*(){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Ln(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Ln(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 Ln(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,"")}var $n,Jn,Kn,Wn,Bn,Fn,Hn,zn,Gn,Zn,Vn,Qn,Xn,Yn,tr,er,nr,rr,or,ir,sr,ar,cr,ur;const lr=document.createElement("template");lr.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 dr extends HTMLElement{constructor(){super(),$n.add(this),Jn.set(this,!1),Kn.set(this,new An),Wn.set(this,new An),Bn.set(this,new An({isLoading:!1})),Fn.set(this,void 0),Hn.set(this,void 0),zn.set(this,void 0),Gn.set(this,{popstate:r(this,$n,"m",Xn).bind(this)}),Zn.set(this,void 0),er.set(this,(t=>{if(!(null==t?void 0:t.ok))return void r(this,$n,"m",ir).call(this,"error",null==t?void 0:t.error);const{status:e,authInfo:n}=t.data;if("completed"===e)return void r(this,$n,"m",ir).call(this,"success",n);const{executionId:o,stepId:i,action:s,screen:a,redirect:c,webauthn:u}=t.data;r(this,Kn,"f").update({stepId:i,executionId:o,action:s,redirectUrl:null==c?void 0:c.url,screenId:null==a?void 0:a.id,screenState:null==a?void 0:a.state,webauthnTransactionId:null==u?void 0:u.transactionId,webauthnOptions:null==u?void 0:u.options})})),sr.set(this,(()=>{let t;return()=>n(this,void 0,void 0,(function*(){if(t)return t;const e=xn(this["project-id"],"config.json");try{t=yield jn(e,"json")}catch(t){console.error("Cannot get config file")}return t}))})()),r(this,$n,"m",Vn).call(this),r(this,Kn,"f").subscribe(r(this,$n,"m",tr).bind(this)),r(this,Wn,"f").subscribe(r(this,$n,"m",rr).bind(this))}static get observedAttributes(){return["project-id","flow-id","base-url","tenant"]}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}get tenant(){return this.getAttribute("tenant")||void 0}connectedCallback(){if(this.shadowRoot.isConnected){o(this,Jn,!0,"f"),r(this,$n,"m",Qn).call(this),r(this,$n,"m",ur).call(this),r(this,$n,"m",cr).call(this);const{executionId:t,stepId:e}=_n();(t||e)&&En();const n=kn("t")||void 0;n&&On("t");const i=kn(vn)||void 0;i&&On(vn),r(this,Kn,"f").update({projectId:this["project-id"],flowId:this["flow-id"],baseUrl:this["base-url"],tenant:this.tenant,stepId:e,executionId:t,token:n,code:i}),window.addEventListener("popstate",r(this,Gn,"f").popstate),r(this,Fn,"f").onkeydown=t=>{if("Enter"===t.key){t.preventDefault();const e=r(this,Fn,"f").querySelectorAll("button");1===e.length&&e[0].click()}}}}disconnectedCallback(){r(this,Kn,"f").unsubscribeAll(),r(this,Wn,"f").unsubscribeAll(),window.removeEventListener("popstate",r(this,Gn,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&r(this,Jn,"f")&&e!==n&&dr.observedAttributes.includes(t)){r(this,$n,"m",Qn).call(this);const o=null===e;r(this,Kn,"f").update((({stepId:e,executionId:r})=>{let i=e,s=r;return o||(s=null,i=null,En()),{[Un(t)]:n,stepId:i,executionId:s}}))}}}Jn=new WeakMap,Kn=new WeakMap,Wn=new WeakMap,Bn=new WeakMap,Fn=new WeakMap,Hn=new WeakMap,zn=new WeakMap,Gn=new WeakMap,Zn=new WeakMap,er=new WeakMap,sr=new WeakMap,$n=new WeakSet,Vn=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(lr.content.cloneNode(!0)),o(this,Fn,this.shadowRoot.querySelector("form"),"f"),o(this,Hn,this.shadowRoot.querySelector("style"),"f")},Qn=function(){const t=["base-url","tenant"];dr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[e])throw Error(`${e} cannot be empty`)}))},Xn=function(){const{stepId:t,executionId:e}=_n();r(this,Kn,"f").update({stepId:t,executionId:e})},Yn=function(t,e){o(this,Zn,pn({projectId:t,baseUrl:e,autoRefresh:!1}),"f");const i=r(this,Zn,"f").flow.next;r(this,Zn,"f").flow.next=(...t)=>n(this,void 0,void 0,(function*(){r(this,Bn,"f").update({isLoading:!0});try{return yield i(...t)}finally{r(this,Bn,"f").update({isLoading:!1})}}))},tr=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:s,flowId:a,baseUrl:c,tenant:u,stepId:l,executionId:d,action:h,screenId:p,screenState:f,redirectUrl:g,token:v,code:b,webauthnTransactionId:y,webauthnOptions:w}=t,m=i("projectId")||i("baseUrl");if(r(this,zn,"f")&&(clearInterval(r(this,zn,"f")),o(this,zn,null,"f")),m){if(!s)return;r(this,$n,"m",Yn).call(this,s,c)}if(!d){if(!a)return;const t=yield r(this,Zn,"f").flow.start(a,{tenant:u,redirectUrl:window.location.href});return void r(this,er,"f").call(this,t)}if(i("token")&&v||i("code")&&b){const t=yield r(this,Zn,"f").flow.next(d,l,"submit",{token:v,exchangeCode:b});return r(this,er,"f").call(this,t),void r(this,Kn,"f").update({token:void 0,code:void 0})}if(h===bn)return g?void window.location.assign(g):void console.error("Did not get redirect url");if(h===wn||h===mn){if(!y||!w)return void console.error("Did not get webauthn transaction id or options");const t=h===wn?yield Mn(w):yield Nn(w),e=yield r(this,Zn,"f").flow.next(d,l,"submit",{transactionId:y,response:t});return void r(this,er,"f").call(this,e)}if(h===yn&&o(this,zn,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield r(this,Zn,"f").flow.next(d,l,"submit",{});r(this,er,"f").call(this,t)}))),2e3),"f"),!p)return void console.error("Refreshing the page during a flow is not supported yet");const k={direction:Sn(+l,+e.stepId),screenState:f,htmlUrl:xn(s,`${p}.html`)};(m||i("executionId")||i("stepId"))&&(k.next=(...t)=>r(this,Zn,"f").flow.next(d,l,...t)),r(this,Wn,"f").update(k)}))},nr=function(t){r(this,Fn,"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"),i=r(this,Bn,"f").subscribe((({isLoading:t})=>{var n,o,s,a;t?null===(o=null===(n=e.submitter)||void 0===n?void 0:n.classList)||void 0===o||o.add("loading"):(r(this,Bn,"f").unsubscribe(i),null===(a=null===(s=e.submitter)||void 0===s?void 0:s.classList)||void 0===a||a.remove("loading"))}));e.preventDefault();const s=Object.fromEntries(new FormData(e.target).entries()),a=(c=e.submitter,Array.from((null==c?void 0:c.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 c;const u=yield t(o,Object.assign(Object.assign(Object.assign({},a),s),{origin:window.location.origin}));r(this,er,"f").call(this,u)}))},rr=function(t){return n(this,void 0,void 0,(function*(){const{htmlUrl:e,validations:n={},direction:o,next:i,screenState:s}=t,a=document.createElement("template");a.innerHTML=yield jn(e,"text");const c=a.content.cloneNode(!0),u=(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})(c),l=()=>{var t;!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})}))}))}(c,n),Dn(c,s);((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(c.querySelector("div"),null===(t=null==s?void 0:s.totp)||void 0===t?void 0:t.image);try{u.forEach((t=>t()))}catch(t){console.error(t)}r(this,Fn,"f").replaceChildren(c),r(this,$n,"m",nr).call(this,i),r(this,$n,"m",ir).call(this,"page-updated",{})};o?r(this,$n,"m",or).call(this,l,o):l()}))},or=function(t,e){r(this,Fn,"f").addEventListener("transitionend",(()=>{r(this,Fn,"f").classList.remove("fade-out"),t()}),{once:!0});const n=e===In.forward?"slide-forward":"slide-backward";Array.from(r(this,Fn,"f").getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),r(this,Fn,"f").classList.add("fade-out")},ir=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},ar=function(t){if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)},cr=function(){var t,e,o;return n(this,void 0,void 0,(function*(){const n=yield r(this,sr,"f").call(this);null===(o=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t.typography)||void 0===e?void 0:e.fontFamilies)||void 0===o||o.forEach((t=>r(this,$n,"m",ar).call(this,t.url)))}))},ur=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=xn(this["project-id"],"theme.css");t.innerText=yield jn(e,"text"),this.shadowRoot.appendChild(t)}))},customElements.define("descope-wc",dr)}();
|
package/package.json
CHANGED
|
@@ -1,71 +1,83 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
2
|
+
"name": "@descope/web-component",
|
|
3
|
+
"version": "0.1.0-alpha.11",
|
|
4
|
+
"main": "dist/descope-wc",
|
|
5
|
+
"types": "dist/descope-wc.d.ts",
|
|
6
|
+
"description": "Descope WC",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "rollup -c rollup.config.app.serve.js -w",
|
|
9
|
+
"build-app": "rollup -c rollup.config.app.js",
|
|
10
|
+
"build": "rollup -c",
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"prepare": "husky install",
|
|
13
|
+
"lint": "eslint '+(src|test)/**/*.ts' --fix",
|
|
14
|
+
"format": "prettier . -w --ignore-path .gitignore",
|
|
15
|
+
"format-check": "prettier . --check --ignore-path .gitignore",
|
|
16
|
+
"format-lint": "pretty-quick --staged --ignore-path .gitignore && lint-staged",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"lint-staged": {
|
|
20
|
+
"+(src|test)/**/*.{js,ts,jsx,tsx}": [
|
|
21
|
+
"npm run lint"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/descope/web-component.git"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@open-wc/rollup-plugin-html": "1.2.5",
|
|
34
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
35
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
36
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
37
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
38
|
+
"@testing-library/dom": "^8.19.0",
|
|
39
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
40
|
+
"@types/jest": "^29.0.0",
|
|
41
|
+
"@types/lodash": "^4.14.186",
|
|
42
|
+
"@types/lodash.get": "^4.4.7",
|
|
43
|
+
"@types/lodash.set": "^4.3.7",
|
|
44
|
+
"eslint": "8.26.0",
|
|
45
|
+
"eslint-config-airbnb": "19.0.4",
|
|
46
|
+
"eslint-config-airbnb-typescript": "17.0.0",
|
|
47
|
+
"eslint-config-prettier": "8.5.0",
|
|
48
|
+
"eslint-config-standard": "17.0.0",
|
|
49
|
+
"eslint-import-resolver-typescript": "3.4.0",
|
|
50
|
+
"eslint-plugin-import": "2.26.0",
|
|
51
|
+
"eslint-plugin-jest": "27.1.3",
|
|
52
|
+
"eslint-plugin-jest-dom": "4.0.2",
|
|
53
|
+
"eslint-plugin-jest-formatting": "3.1.0",
|
|
54
|
+
"eslint-plugin-n": "15.3.0",
|
|
55
|
+
"eslint-plugin-no-only-tests": "3.1.0",
|
|
56
|
+
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
57
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
58
|
+
"eslint-plugin-promise": "6.1.1",
|
|
59
|
+
"husky": "^8.0.1",
|
|
60
|
+
"jest": "^29.0.0",
|
|
61
|
+
"jest-environment-jsdom": "^29.0.0",
|
|
62
|
+
"lint-staged": "^13.0.3",
|
|
63
|
+
"prettier": "^2.6.2",
|
|
64
|
+
"pretty-quick": "^3.1.3",
|
|
65
|
+
"rollup": "^2.62.0",
|
|
66
|
+
"rollup-plugin-browsersync": "^1.3.3",
|
|
67
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
68
|
+
"rollup-plugin-dts": "^4.2.2",
|
|
69
|
+
"rollup-plugin-livereload": "^2.0.5",
|
|
70
|
+
"rollup-plugin-terser": "7.0.2",
|
|
71
|
+
"shadow-dom-testing-library": "^1.2.0",
|
|
72
|
+
"string-to-arraybuffer": "^1.0.2",
|
|
73
|
+
"ts-jest": "^29.0.0",
|
|
74
|
+
"ts-node": "10.9.1",
|
|
75
|
+
"typescript": "^4.5.3"
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@descope/web-js-sdk": "0.1.0-alpha.8"
|
|
79
|
+
},
|
|
80
|
+
"overrides": {
|
|
81
|
+
"terser": "5.15.1"
|
|
82
|
+
}
|
|
71
83
|
}
|