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