New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@descope/web-component

Package Overview
Dependencies
Maintainers
4
Versions
362
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@descope/web-component - npm Package Compare versions

Comparing version 3.32.10 to 3.32.11

2

dist/cjs/descope-wc/BaseDescopeWc.js

@@ -1,1 +0,1 @@

"use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),r=require("@descope/sdk-mixins/theme-mixin"),s=require("@descope/web-js-sdk"),o=require("../constants/index.js"),n=require("../helpers/helpers.js"),a=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var l,u,d,c,h,g,f,v,p,_,b,m,w,C,F,A,P,x,k,E,I,y=require("../helpers/flowInputs.js"),G=require("../mixins/formMountMixin.js"),j=require("./initTemplate.js"),L=require("../constants/content.js"),S=require("../constants/general.js");function U(t){return Object.freeze({__proto__:null,default:t})}const M=e.compose(r.themeMixin,i.staticResourcesMixin,G.formMountMixin)(HTMLElement);class O extends M{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),l.add(this),d.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,l,"m",E).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},c.set(this,new a),h.set(this,new a),g.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,g,"f"),this.nextRequestStatus=new a({isLoading:!1}),f.set(this,void 0),v.set(this,{popstate:t.__classPrivateFieldGet(this,l,"m",m).bind(this),componentsContext:t.__classPrivateFieldGet(this,l,"m",P).bind(this)}),p.set(this,void 0),this.getConfig=n.withMemCache((()=>t.__awaiter(this,void 0,void 0,(function*(){try{const{body:t,headers:e}=yield this.fetchStaticResource(L.CONFIG_FILENAME,"json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),t.__classPrivateFieldSet(this,p,e,"f"),t.__classPrivateFieldGet(this,l,"m",_).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return y.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return y.extractNestedAttribute(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,h,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",k).bind(this)),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,l,"m",b).call(this),yield t.__classPrivateFieldGet(this,l,"m",F).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t.__classPrivateFieldGet(this,l,"m",I).call(this);const{executionId:r,stepId:s,token:o,code:a,exchangeError:u,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:p,redirectAuthInitiator:_,ssoQueryParams:m}=n.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext),t.__classPrivateFieldGet(this,c,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",C).bind(this)),t.__classPrivateFieldGet(this,c,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:o,code:a,exchangeError:u,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:p,redirectAuthInitiator:_},m)),t.__classPrivateFieldSet(this,d,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,c,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,h,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,l,"m",x).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,d,"f")&&i!==r&&u.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,l,"m",b).call(this);const s=null===i;t.__classPrivateFieldGet(this,c,"f").update((({stepId:t,executionId:i})=>{let o=t,a=i;return s||(a=null,o=null,n.clearRunIdsFromUrl()),{[n.camelCase(e)]:r,stepId:o,executionId:a}})),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug})}}}u=O,d=new WeakMap,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,v=new WeakMap,p=new WeakMap,l=new WeakSet,_=function(){this.shadowRoot.appendChild(j.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},b=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];u.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[n.camelCase(e)])throw Error(`${e} cannot be empty`)}))},m=function(){const{stepId:e,executionId:i}=n.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,c,"f").update({stepId:e,executionId:i})},w=function(e,i){this.sdk=s(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},u.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:S.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},C=function(e,i,r){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:s}=e;if(r("projectId")||r("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,l,"m",w).call(this,i,s)}t.__classPrivateFieldGet(this,p,"f").call(this,e)}))},F=function(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield t.__classPrivateFieldGet(this,l,"m",A).call(this))}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=n.getContentUrl({projectId:this.projectId,filename:L.CONFIG_FILENAME,assetsFolder:L.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield n.fetchContent(t,"json"),!0}catch(t){return!1}}))},P=function(e){t.__classPrivateFieldSet(this,g,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,g,"f")),e.detail),"f")},x=function(){var e;null===(e=t.__classPrivateFieldGet(this,f,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,f,null,"f")},k=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,f,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,f,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return U(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,f,"f"))):t.__classPrivateFieldGet(this,l,"m",x).call(this)}))},E=function(e,i){var r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,f,"f"))||void 0===r||r.updateData({title:e,description:i}))},I=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=o.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||n)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},O.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.32.10"}},module.exports=O;
"use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),s=require("@descope/sdk-mixins/theme-mixin"),r=require("@descope/web-js-sdk"),o=require("../constants/index.js"),n=require("../helpers/helpers.js"),a=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var l,u,d,c,h,g,f,v,p,_,b,m,w,C,F,A,P,x,k,E,I,y=require("../helpers/flowInputs.js"),G=require("../mixins/formMountMixin.js"),j=require("./initTemplate.js"),L=require("../constants/content.js"),S=require("../constants/general.js");function U(t){return Object.freeze({__proto__:null,default:t})}const M=e.compose(s.themeMixin,i.staticResourcesMixin,G.formMountMixin)(HTMLElement);class q extends M{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),l.add(this),d.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,l,"m",E).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},c.set(this,new a),h.set(this,new a),g.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,g,"f"),this.nextRequestStatus=new a({isLoading:!1}),f.set(this,void 0),v.set(this,{popstate:t.__classPrivateFieldGet(this,l,"m",m).bind(this),componentsContext:t.__classPrivateFieldGet(this,l,"m",P).bind(this)}),p.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,p,e,"f"),t.__classPrivateFieldGet(this,l,"m",_).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return y.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return y.extractNestedAttribute(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,h,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",k).bind(this)),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,l,"m",b).call(this),yield t.__classPrivateFieldGet(this,l,"m",F).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t.__classPrivateFieldGet(this,l,"m",I).call(this);const{executionId:r,stepId:o,token:a,code:u,exchangeError:g,redirectAuthCallbackUrl:f,redirectAuthBackupCallbackUri:p,redirectAuthCodeChallenge:_,redirectAuthInitiator:m,ssoQueryParams:w}=n.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext),t.__classPrivateFieldGet(this,c,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",C).bind(this)),t.__classPrivateFieldGet(this,c,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:r,token:a,code:u,exchangeError:g,redirectAuthCallbackUrl:f,redirectAuthBackupCallbackUri:p,redirectAuthCodeChallenge:_,redirectAuthInitiator:m},w)),t.__classPrivateFieldSet(this,d,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,c,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,h,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,l,"m",x).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext)}attributeChangedCallback(e,i,s){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,d,"f")&&i!==s&&u.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,l,"m",b).call(this);const r=null===i;t.__classPrivateFieldGet(this,c,"f").update((({stepId:t,executionId:i})=>{let o=t,a=i;return r||(a=null,o=null,n.clearRunIdsFromUrl()),{[n.camelCase(e)]:s,stepId:o,executionId:a}})),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug})}}}u=q,d=new WeakMap,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,v=new WeakMap,p=new WeakMap,l=new WeakSet,_=function(){this.shadowRoot.appendChild(j.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},b=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];u.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[n.camelCase(e)])throw Error(`${e} cannot be empty`)}))},m=function(){const{stepId:e,executionId:i}=n.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,c,"f").update({stepId:e,executionId:i})},w=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},u.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:S.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},C=function(e,i,s){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:r}=e;if(s("projectId")||s("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,l,"m",w).call(this,i,r)}t.__classPrivateFieldGet(this,p,"f").call(this,e)}))},F=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,l,"m",A).call(this))}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=n.getContentUrl({projectId:this.projectId,filename:L.CONFIG_FILENAME,assetsFolder:L.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield n.fetchContent(t,"json"),!0}catch(t){return!1}}))},P=function(e){t.__classPrivateFieldSet(this,g,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,g,"f")),e.detail),"f")},x=function(){var e;null===(e=t.__classPrivateFieldGet(this,f,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,f,null,"f")},k=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,f,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,f,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return U(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,f,"f"))):t.__classPrivateFieldGet(this,l,"m",x).call(this)}))},E=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,f,"f"))||void 0===s||s.updateData({title:e,description:i}))},I=function(){this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=o.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||n)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},q.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.32.11"}},module.exports=q;

@@ -1,1 +0,1 @@

"use strict";var e,t,i,s,o,r,n,a,l,d,c,h,u,p,g,v,m,f,_,b,w,S,I,E=require("tslib"),C=require("@descope/web-js-sdk"),y=require("../constants/index.js"),O=require("../helpers/helpers.js"),P=require("../helpers/state.js"),R=require("../helpers/templates.js"),T=require("../helpers/webauthn.js"),F=require("../helpers/abTestingKey.js"),A=require("../helpers/conditions.js"),k=require("../helpers/lastAuth.js"),N=require("../types.js"),U=require("./BaseDescopeWc.js"),j=require("./sdkScripts/index.js"),x=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,d=new WeakMap,_=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},r=function(){return E.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},c=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},h=function(t,s){return E.__awaiter(this,void 0,void 0,(function*(){var o;null===(o=E.__classPrivateFieldGet(this,i,"f"))||void 0===o||o.abort();const r=t.querySelector('*[autocomplete="webauthn"]');if(r&&(yield T.isConditionalLoginSupported())){const{options:t,transactionId:o}=(yield E.__classPrivateFieldGet(this,d,"f").call(this))||{};if(t&&o){E.__classPrivateFieldGet(this,e,"m",c).call(this,r),E.__classPrivateFieldSet(this,i,new AbortController,"f");const n=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,E.__classPrivateFieldGet(this,i,"f")).then((e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield s(r.id,n.version,a.componentsVersion,{transactionId:o,response:e});E.__classPrivateFieldGet(this,l,"f").call(this,t)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},u=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,s;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(s=t.checkValidity)||void 0===s?void 0:s.call(t)))})),e},p=function(){return E.__awaiter(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`));return(yield Promise.all(e.map((e=>E.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},g=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},v=function(e={}){var t,i;const s=O.getFirstNonEmptyValue(e,["externalId","email","phone"]),o=O.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},m=function(){O.clearPreviousExternalInputs();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>E.__classPrivateFieldGet(this,e,"m",f).call(this,t)))},f=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",s),this.appendChild(t)}))},b=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var i;(null===(i=t.checkValidity)||void 0===i?void 0:i.call(t))&&E.__classPrivateFieldGet(this,_,"f").call(this,t,e)}))}))},w=function(t){this.rootElement.querySelectorAll(`descope-button:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}])`).forEach((e=>{e.onclick=()=>{E.__classPrivateFieldGet(this,_,"f").call(this,e,t)}})),E.__classPrivateFieldGet(this,e,"m",b).call(this,t)},S=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===N.Direction.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},I=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},module.exports=class extends U{static set sdkConfigOverrides(e){U.sdkConfigOverrides=e}static get sdkConfigOverrides(){return U.sdkConfigOverrides}constructor(){const c=new P({deferredRedirect:!1});super(c.update.bind(c)),e.add(this),this.stepState=new P({},{updateOnlyOnChange:!1}),t.set(this,void 0),i.set(this,null),s.set(this,{visibilitychange:E.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var i;const s=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=s;if(!e){e=null===(i=new URL(s.url).searchParams)||void 0===i?void 0:i.get(y.URL_CODE_PARAM_NAME)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(s.url),t=e.searchParams.get(y.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(y.URL_RUN_IDS_PARAM_NAME).split("_").pop();E.__classPrivateFieldGet(this,a,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else this.nativeComplete(s)},n.set(this,((e,i,s,o,r=!1)=>{if(this.flowState.current.action===y.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=r?500:2e3;E.__classPrivateFieldSet(this,t,setTimeout((()=>E.__awaiter(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,y.CUSTOM_INTERACTIONS.polling,s,o,{}),h=document.hidden&&!r&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield O.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===x.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o)}))),d),"f")}})),a.set(this,(()=>{clearTimeout(E.__classPrivateFieldGet(this,t,"f")),E.__classPrivateFieldSet(this,t,null,"f")})),l.set(this,(t=>{var i,s,o,n,a,l,d,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const d=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,c=`${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;E.__classPrivateFieldGet(this,e,"m",I).call(this,"error",(null==t?void 0:t.error)||{errorCode:x.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:c,errorMessage:d}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||d,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||c);const h=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==h&&"E103205"!==h||!this.isRestartOnError||E.__classPrivateFieldGet(this,e,"m",r).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:_}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&k.setLastAuth(_),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"success",f);const{executionId:b,stepId:w,stepName:S,action:C,screen:O,redirect:P,openInNewTabUrl:R,webauthn:T,error:F,samlIdpResponse:A,nativeResponse:N}=t.data;C!==y.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${S||`#${w}`}" is ${m}`,"",{screen:O,status:m,stepId:w,stepName:S,action:C,error:F}),this.flowState.update({stepId:w,executionId:b,action:C,redirectTo:null==P?void 0:P.url,openInNewTabUrl:R,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload})):this.flowState.update({action:C})})),d.set(this,O.withMemCache((()=>E.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),_.set(this,O.leadingDebounce(((t,i)=>E.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||E.__classPrivateFieldGet(this,e,"m",u).call(this)){const o=null==t?void 0:t.getAttribute("id");E.__classPrivateFieldGet(this,e,"m",g).call(this,t);const r=yield E.__classPrivateFieldGet(this,e,"m",p).call(this),n=O.getElementDescopeAttributes(t),a=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},a),n),r),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin}),c=yield this.getFlowConfig(),h=yield this.getProjectConfig(),u=yield i(o,c.version,h.componentsVersion,d);E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,e,"m",v).call(this,r)}}))))),this.flowState=c}loadSdkScripts(){return E.__awaiter(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>E.__awaiter(this,void 0,void 0,(function*(){(yield j.default(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[j.getScriptResultPath(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return E.__awaiter(this,void 0,void 0,(function*(){var t,i,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=E.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),E.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return E.__awaiter(this,void 0,void 0,(function*(){let i;const s=O.getUserLocale(e),o=yield this.getTargetLocales();return o.includes(s.locale)?i=`${t}-${s.locale}.html`:o.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return E.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,s,o){return E.__awaiter(this,void 0,void 0,(function*(){var r,a;const{projectId:d,flowId:c,tenant:h,stepId:u,executionId:p,action:g,screenId:v,screenState:m,redirectTo:f,openInNewTabUrl:_,redirectUrl:b,token:w,code:S,exchangeError:P,webauthnTransactionId:R,webauthnOptions:T,redirectAuthCodeChallenge:N,redirectAuthCallbackUrl:U,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:x,locale:G,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:W,samlIdpResponseRelayState:q,nativeResponseType:D,nativePayload:M}=t,$=E.__rest(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let V,B;const K=F.getABTestingKey(),H=this.sdk.getLastUserLoginId(),X=yield this.getFlowConfig(),J=yield this.getProjectConfig(),Y=Object.entries(J.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),z=U&&N?{callbackUrl:U,codeChallenge:N,backupCallbackUri:j}:void 0,Q=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!p&&(this.loadSdkScripts(),X.fingerprintEnabled&&X.fingerprintKey?yield C.ensureFingerprintIds(X.fingerprintKey,this.baseUrl):C.clearFingerprintData(),X.conditions?({startScreenId:V,conditionInteractionId:B}=A.calculateConditions({loginId:H,code:S,token:w,abTestingKey:K},X.conditions)):X.condition?({startScreenId:V,conditionInteractionId:B}=A.calculateCondition(X.condition,{loginId:H,code:S,token:w,abTestingKey:K})):V=X.startScreenId,!O.showFirstScreenOnExecutionInit(V,$))){const e=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:k.getLastAuth(H),abTestingKey:K,locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,"",J.componentsVersion,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return E.__classPrivateFieldGet(this,l,"f").call(this,e),void("completed"!==(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(o("token")&&w||o("code")&&S||o("exchangeError")&&P)){const e=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{token:w,exchangeCode:S,exchangeError:P});return E.__classPrivateFieldGet(this,l,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===y.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!L||!W)return void this.loggerWrapper.error("Did not get saml idp params data to load");O.injectSamlIdpForm(L,W,q||"",O.submitForm)}if(g===y.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect")))return f?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(f):void this.loggerWrapper.error("Did not get redirect url");if(g===y.RESPONSE_ACTIONS.webauthnCreate||g===y.RESPONSE_ACTIONS.webauthnGet){if(!R||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=E.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),E.__classPrivateFieldSet(this,i,null,"f");try{e=g===y.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const s=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{transactionId:R,response:e,failure:t});E.__classPrivateFieldGet(this,l,"f").call(this,s)}if(g===y.RESPONSE_ACTIONS.nativeBridge)return this.nativeComplete=e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,e);E.__classPrivateFieldGet(this,l,"f").call(this,t)})),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"bridge",{type:D,payload:M});if(E.__classPrivateFieldGet(this,n,"f").call(this,p,u,X.version,J.componentsVersion),!v&&!V)return void this.loggerWrapper.warn("No screen was found to show");const Z=V||v,ee=yield this.getHtmlFilenameWithLocale(G,Z),{oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,samlIdpUsername:oe}=$,re={direction:O.getAnimationDirection(u,s.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:H,name:this.sdk.getLastUserDisplayName()||H}}),htmlFilename:`${Z}.html`,htmlLocaleFilename:ee,samlIdpUsername:oe,oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,openInNewTabUrl:_},ne=k.getLastAuth(H);O.showFirstScreenOnExecutionInit(V,$)?re.next=(e,t,i,s)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{lastAuth:ne,preview:this.preview,abTestingKey:K,client:this.client}),b&&{redirectUrl:b}),{locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,e,i,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),s),S&&{exchangeCode:S,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(re.next=(...e)=>this.sdk.flow.next(p,u,...e)),this.stepState.update(re)}))}onStepChange(t,i){return E.__awaiter(this,void 0,void 0,(function*(){var s,o;const{htmlFilename:r,htmlLocaleFilename:n,direction:a,next:d,screenState:c,openInNewTabUrl:u}=t,p=document.createElement("template");p.innerHTML=yield this.getPageContent(r,n);const g=p.content.cloneNode(!0),v=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield E.__classPrivateFieldGet(this,e,"m",h).call(this,g,d):R.disableWebauthnButtons(g),!t.samlIdpUsername||(null===(s=c.form)||void 0===s?void 0:s.loginId)||(null===(o=c.form)||void 0===o?void 0:o.email)||(c.form||(c.form={}),c.form.loginId=t.samlIdpUsername,c.form.email=t.samlIdpUsername),R.updateTemplateFromScreenState(g,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();R.setPhoneAutoDetectDefaultCode(g,f);const _=()=>E.__awaiter(this,void 0,void 0,(function*(){var t,s;yield v;const o=this.shadowRoot.querySelector("div");R.setTOTPVariable(o,null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image),R.setNOTPVariable(o,null===(s=null==c?void 0:c.notp)||void 0===s?void 0:s.image),R.setCssVars(o,g,c.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(g);const r=!i.htmlFilename;setTimeout((()=>{E.__classPrivateFieldGet(this,e,"m",m).call(this),O.handleAutoFocus(this.rootElement,this.autoFocus,r),this.validateOnBlur&&O.handleReportValidityOnBlur(this.rootElement),R.updateScreenFromScreenState(this.rootElement,c)})),E.__classPrivateFieldGet(this,e,"m",w).call(this,d),r&&E.__classPrivateFieldGet(this,e,"m",I).call(this,"ready",{}),E.__classPrivateFieldGet(this,e,"m",I).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${y.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),i=yield d(y.CUSTOM_INTERACTIONS.polling,e.version,t.componentsVersion,{});E.__classPrivateFieldGet(this,l,"f").call(this,i)}u&&!i.openInNewTabUrl&&window.open(u,"_blank")}));a?E.__classPrivateFieldGet(this,e,"m",S).call(this,_,a):_()}))}};
"use strict";var e,t,i,s,o,r,n,a,l,d,c,h,u,p,g,v,m,f,_,b,w,S,I,E=require("tslib"),C=require("@descope/web-js-sdk"),y=require("../constants/index.js"),O=require("../helpers/helpers.js"),P=require("../helpers/state.js"),R=require("../helpers/templates.js"),T=require("../helpers/webauthn.js"),F=require("../helpers/abTestingKey.js"),A=require("../helpers/conditions.js"),k=require("../helpers/lastAuth.js"),N=require("../types.js"),U=require("./BaseDescopeWc.js"),j=require("./sdkScripts/index.js"),x=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,d=new WeakMap,_=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},r=function(){return E.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},c=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},h=function(t,s){return E.__awaiter(this,void 0,void 0,(function*(){var o;null===(o=E.__classPrivateFieldGet(this,i,"f"))||void 0===o||o.abort();const r=t.querySelector('*[autocomplete="webauthn"]');if(r&&(yield T.isConditionalLoginSupported())){const{options:t,transactionId:o}=(yield E.__classPrivateFieldGet(this,d,"f").call(this))||{};if(t&&o){E.__classPrivateFieldGet(this,e,"m",c).call(this,r),E.__classPrivateFieldSet(this,i,new AbortController,"f");const n=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,E.__classPrivateFieldGet(this,i,"f")).then((e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield s(r.id,n.version,a.componentsVersion,{transactionId:o,response:e});E.__classPrivateFieldGet(this,l,"f").call(this,t)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},u=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,s;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(s=t.checkValidity)||void 0===s?void 0:s.call(t)))})),e},p=function(){return E.__awaiter(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`));return(yield Promise.all(e.map((e=>E.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},g=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},v=function(e={}){var t,i;const s=O.getFirstNonEmptyValue(e,["externalId","email","phone"]),o=O.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},m=function(){O.clearPreviousExternalInputs();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>E.__classPrivateFieldGet(this,e,"m",f).call(this,t)))},f=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",s),this.appendChild(t)}))},b=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var i;(null===(i=t.checkValidity)||void 0===i?void 0:i.call(t))&&E.__classPrivateFieldGet(this,_,"f").call(this,t,e)}))}))},w=function(t){this.rootElement.querySelectorAll(`descope-button:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}])`).forEach((e=>{e.onclick=()=>{E.__classPrivateFieldGet(this,_,"f").call(this,e,t)}})),E.__classPrivateFieldGet(this,e,"m",b).call(this,t)},S=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===N.Direction.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},I=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},module.exports=class extends U{static set sdkConfigOverrides(e){U.sdkConfigOverrides=e}static get sdkConfigOverrides(){return U.sdkConfigOverrides}constructor(){const c=new P({deferredRedirect:!1});super(c.update.bind(c)),e.add(this),this.stepState=new P({},{updateOnlyOnChange:!1}),t.set(this,void 0),i.set(this,null),s.set(this,{visibilitychange:E.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var i;const s=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=s;if(!e){e=null===(i=new URL(s.url).searchParams)||void 0===i?void 0:i.get(y.URL_CODE_PARAM_NAME)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(s.url),t=e.searchParams.get(y.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(y.URL_RUN_IDS_PARAM_NAME).split("_").pop();E.__classPrivateFieldGet(this,a,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else this.nativeComplete(s)},n.set(this,((e,i,s,o,r=!1)=>{if(this.flowState.current.action===y.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=r?500:2e3;E.__classPrivateFieldSet(this,t,setTimeout((()=>E.__awaiter(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,y.CUSTOM_INTERACTIONS.polling,s,o,{}),h=document.hidden&&!r&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield O.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===x.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o)}))),d),"f")}})),a.set(this,(()=>{clearTimeout(E.__classPrivateFieldGet(this,t,"f")),E.__classPrivateFieldSet(this,t,null,"f")})),l.set(this,(t=>{var i,s,o,n,a,l,d,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const d=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,c=`${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;E.__classPrivateFieldGet(this,e,"m",I).call(this,"error",(null==t?void 0:t.error)||{errorCode:x.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:c,errorMessage:d}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||d,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||c);const h=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==h&&"E103205"!==h||!this.isRestartOnError||E.__classPrivateFieldGet(this,e,"m",r).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:_}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&k.setLastAuth(_),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"success",f);const{executionId:b,stepId:w,stepName:S,action:C,screen:O,redirect:P,openInNewTabUrl:R,webauthn:T,error:F,samlIdpResponse:A,nativeResponse:N}=t.data;C!==y.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${S||`#${w}`}" is ${m}`,"",{screen:O,status:m,stepId:w,stepName:S,action:C,error:F}),this.flowState.update({stepId:w,executionId:b,action:C,redirectTo:null==P?void 0:P.url,openInNewTabUrl:R,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload})):this.flowState.update({action:C})})),d.set(this,O.withMemCache((()=>E.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),_.set(this,O.leadingDebounce(((t,i)=>E.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||E.__classPrivateFieldGet(this,e,"m",u).call(this)){const o=null==t?void 0:t.getAttribute("id");E.__classPrivateFieldGet(this,e,"m",g).call(this,t);const r=yield E.__classPrivateFieldGet(this,e,"m",p).call(this),n=O.getElementDescopeAttributes(t),a=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},a),n),r),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin}),c=yield this.getFlowConfig(),h=yield this.getProjectConfig(),u=yield i(o,c.version,h.componentsVersion,d);E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,e,"m",v).call(this,r)}}))))),this.flowState=c}loadSdkScripts(){return E.__awaiter(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>E.__awaiter(this,void 0,void 0,(function*(){(yield j.default(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[j.getScriptResultPath(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return E.__awaiter(this,void 0,void 0,(function*(){var t,i,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=E.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),E.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return E.__awaiter(this,void 0,void 0,(function*(){let i;const s=O.getUserLocale(e),o=yield this.getTargetLocales();return o.includes(s.locale)?i=`${t}-${s.locale}.html`:o.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return E.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,s,o){return E.__awaiter(this,void 0,void 0,(function*(){var r,a;const{projectId:d,flowId:c,tenant:h,stepId:u,executionId:p,action:g,screenId:v,screenState:m,redirectTo:f,openInNewTabUrl:_,redirectUrl:b,token:w,code:S,exchangeError:P,webauthnTransactionId:R,webauthnOptions:T,redirectAuthCodeChallenge:N,redirectAuthCallbackUrl:U,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:x,locale:G,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:W,samlIdpResponseRelayState:q,nativeResponseType:D,nativePayload:M}=t,$=E.__rest(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let V,B;const K=F.getABTestingKey(),H=this.sdk.getLastUserLoginId(),X=yield this.getFlowConfig(),J=yield this.getProjectConfig(),Y=Object.entries(J.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),z=U&&N?{callbackUrl:U,codeChallenge:N,backupCallbackUri:j}:void 0,Q=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!p&&(this.loadSdkScripts(),X.fingerprintEnabled&&X.fingerprintKey?yield C.ensureFingerprintIds(X.fingerprintKey,this.baseUrl):C.clearFingerprintData(),X.conditions?({startScreenId:V,conditionInteractionId:B}=A.calculateConditions({loginId:H,code:S,token:w,abTestingKey:K},X.conditions)):X.condition?({startScreenId:V,conditionInteractionId:B}=A.calculateCondition(X.condition,{loginId:H,code:S,token:w,abTestingKey:K})):V=X.startScreenId,!O.showFirstScreenOnExecutionInit(V,$))){const e=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:k.getLastAuth(H),abTestingKey:K,locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,"",J.componentsVersion,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return E.__classPrivateFieldGet(this,l,"f").call(this,e),void("completed"!==(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(o("token")&&w||o("code")&&S||o("exchangeError")&&P)){const e=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{token:w,exchangeCode:S,exchangeError:P});return E.__classPrivateFieldGet(this,l,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===y.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!L||!W)return void this.loggerWrapper.error("Did not get saml idp params data to load");O.injectSamlIdpForm(L,W,q||"",O.submitForm)}if(g===y.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect")))return f?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(f):void this.loggerWrapper.error("Did not get redirect url");if(g===y.RESPONSE_ACTIONS.webauthnCreate||g===y.RESPONSE_ACTIONS.webauthnGet){if(!R||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=E.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),E.__classPrivateFieldSet(this,i,null,"f");try{e=g===y.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const s=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{transactionId:R,response:e,failure:t});E.__classPrivateFieldGet(this,l,"f").call(this,s)}if(g===y.RESPONSE_ACTIONS.nativeBridge)return this.nativeComplete=e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,e);E.__classPrivateFieldGet(this,l,"f").call(this,t)})),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"bridge",{type:D,payload:M});if(E.__classPrivateFieldGet(this,n,"f").call(this,p,u,X.version,J.componentsVersion),!v&&!V)return void this.loggerWrapper.warn("No screen was found to show");const Z=V||v,ee=yield this.getHtmlFilenameWithLocale(G,Z),{oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,samlIdpUsername:oe}=$,re={direction:O.getAnimationDirection(u,s.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:H,name:this.sdk.getLastUserDisplayName()||H}}),htmlFilename:`${Z}.html`,htmlLocaleFilename:ee,samlIdpUsername:oe,oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,openInNewTabUrl:_},ne=k.getLastAuth(H);O.showFirstScreenOnExecutionInit(V,$)?re.next=(e,t,i,s)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{lastAuth:ne,preview:this.preview,abTestingKey:K,client:this.client}),b&&{redirectUrl:b}),{locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,e,i,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),s),S&&{exchangeCode:S,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(re.next=(...e)=>this.sdk.flow.next(p,u,...e)),this.stepState.update(re)}))}onStepChange(t,i){return E.__awaiter(this,void 0,void 0,(function*(){var s,o;const{htmlFilename:r,htmlLocaleFilename:n,direction:a,next:d,screenState:c,openInNewTabUrl:u}=t,p=document.createElement("template");p.innerHTML=yield this.getPageContent(r,n);const g=p.content.cloneNode(!0),v=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield E.__classPrivateFieldGet(this,e,"m",h).call(this,g,d):R.disableWebauthnButtons(g),!t.samlIdpUsername||(null===(s=c.form)||void 0===s?void 0:s.loginId)||(null===(o=c.form)||void 0===o?void 0:o.email)||(c.form||(c.form={}),c.form.loginId=t.samlIdpUsername,c.form.email=t.samlIdpUsername),R.updateTemplateFromScreenState(g,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();R.setPhoneAutoDetectDefaultCode(g,f);const _=()=>E.__awaiter(this,void 0,void 0,(function*(){var t,s;yield v;const o=this.shadowRoot.querySelector("div");R.setTOTPVariable(o,null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image),R.setNOTPVariable(o,null===(s=null==c?void 0:c.notp)||void 0===s?void 0:s.image),R.setCssVars(o,g,c.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(g);const r=!i.htmlFilename;setTimeout((()=>{E.__classPrivateFieldGet(this,e,"m",m).call(this),O.handleAutoFocus(this.rootElement,this.autoFocus,r),this.validateOnBlur&&O.handleReportValidityOnBlur(this.rootElement),R.updateScreenFromScreenState(this.rootElement,c)})),E.__classPrivateFieldGet(this,e,"m",w).call(this,d),r&&E.__classPrivateFieldGet(this,e,"m",I).call(this,"ready",{}),E.__classPrivateFieldGet(this,e,"m",I).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${y.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),i=yield d(y.CUSTOM_INTERACTIONS.polling,e.version,t.componentsVersion,{});E.__classPrivateFieldGet(this,l,"f").call(this,i)}u&&!i.openInNewTabUrl&&window.open(u,"_blank")}));a?E.__classPrivateFieldGet(this,e,"m",S).call(this,_,a):_()}))}};

@@ -1,1 +0,1 @@

import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as s}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as o}from"@descope/sdk-mixins/theme-mixin";import n from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as u}from"../constants/index.js";import{withMemCache as a,handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as f,fetchContent as g}from"../helpers/helpers.js";import p from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{transformFlowInputFormData as v,extractNestedAttribute as m}from"../helpers/flowInputs.js";import{formMountMixin as b}from"../mixins/formMountMixin.js";import w from"./initTemplate.js";import{CONFIG_FILENAME as A,PREV_VER_ASSETS_FOLDER as C}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as k}from"../constants/general.js";var x,y,j,I,E,L,U,S,M,O,W,R,D,P,q,F,T,B,N,V,H;const K=r(o,s,b)(HTMLElement);class z extends K{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(r){super(),x.add(this),j.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,x,"m",V).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},I.set(this,new p),E.set(this,new p),L.set(this,{}),this.getComponentsContext=()=>t(this,L,"f"),this.nextRequestStatus=new p({isLoading:!1}),U.set(this,void 0),S.set(this,{popstate:t(this,x,"m",R).bind(this),componentsContext:t(this,x,"m",T).bind(this)}),M.set(this,void 0),this.getConfig=a((()=>e(this,void 0,void 0,(function*(){try{const{body:t,headers:e}=yield this.fetchStaticResource(A,"json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,M,r,"f"),t(this,x,"m",O).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return v(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return m(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,E,"f").subscribe(t(this,x,"m",N).bind(this)),t(this,E,"f").update({isDebug:this.debug}),t(this,x,"m",W).call(this),yield t(this,x,"m",q).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,x,"m",H).call(this);const{executionId:s,stepId:o,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f,ssoQueryParams:g}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,S,"f").popstate),window.addEventListener("components-context",t(this,S,"f").componentsContext),t(this,I,"f").subscribe(t(this,x,"m",P).bind(this)),t(this,I,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:s,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f},g)),i(this,j,!0,"f")}))}disconnectedCallback(){t(this,I,"f").unsubscribeAll(),t(this,E,"f").unsubscribeAll(),t(this,x,"m",B).call(this),window.removeEventListener("popstate",t(this,S,"f").popstate),window.removeEventListener("components-context",t(this,S,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,j,"f")&&i!==r&&y.observedAttributes.includes(e)){t(this,x,"m",W).call(this);const s=null===i;t(this,I,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,d()),{[c(e)]:r,stepId:o,executionId:n}})),t(this,E,"f").update({isDebug:this.debug})}}}y=z,j=new WeakMap,I=new WeakMap,E=new WeakMap,L=new WeakMap,U=new WeakMap,S=new WeakMap,M=new WeakMap,x=new WeakSet,O=function(){this.shadowRoot.appendChild(w.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},W=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];y.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},R=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,I,"f").update({stepId:e,executionId:i})},D=function(t,i){this.sdk=n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},y.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(t){return{error:{errorCode:k,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},P=function(i,r,s){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(s("projectId")||s("baseUrl")){if(!e)return;t(this,x,"m",D).call(this,e,r)}t(this,M,"f").call(this,i)}))},q=function(){return e(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield t(this,x,"m",F).call(this))}))},F=function(){return e(this,void 0,void 0,(function*(){const t=f({projectId:this.projectId,filename:A,assetsFolder:C,baseUrl:this.baseStaticUrl});try{return yield g(t,"json"),!0}catch(t){return!1}}))},T=function(e){i(this,L,Object.assign(Object.assign({},t(this,L,"f")),e.detail),"f")},B=function(){var e;null===(e=t(this,U,"f"))||void 0===e||e.remove(),i(this,U,null,"f")},N=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,U,document.createElement("descope-debugger"),"f"),Object.assign(t(this,U,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,U,"f"))):t(this,x,"m",B).call(this)}))},V=function(e,i){var r;e&&this.debug&&(null===(r=t(this,U,"f"))||void 0===r||r.updateData({title:e,description:i}))},H=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=u.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},z.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.32.10"}};export{z as default};
import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as s}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as o}from"@descope/sdk-mixins/theme-mixin";import n from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as u}from"../constants/index.js";import{handleUrlParams as a,clearRunIdsFromUrl as l,camelCase as d,getRunIdsFromUrl as c,getContentUrl as h,fetchContent as f}from"../helpers/helpers.js";import g from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{transformFlowInputFormData as p,extractNestedAttribute as v}from"../helpers/flowInputs.js";import{formMountMixin as m}from"../mixins/formMountMixin.js";import b from"./initTemplate.js";import{CONFIG_FILENAME as w,PREV_VER_ASSETS_FOLDER as C}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as A}from"../constants/general.js";var k,x,y,j,I,E,L,U,M,S,O,W,D,R,P,q,F,T,B,N,V;const H=r(o,s,m)(HTMLElement);class K extends H{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(r){super(),k.add(this),y.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,k,"m",N).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},j.set(this,new g),I.set(this,new g),E.set(this,{}),this.getComponentsContext=()=>t(this,E,"f"),this.nextRequestStatus=new g({isLoading:!1}),L.set(this,void 0),U.set(this,{popstate:t(this,k,"m",W).bind(this),componentsContext:t(this,k,"m",F).bind(this)}),M.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,M,r,"f"),t(this,k,"m",S).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return p(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return v(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,I,"f").subscribe(t(this,k,"m",B).bind(this)),t(this,I,"f").update({isDebug:this.debug}),t(this,k,"m",O).call(this),yield t(this,k,"m",P).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,k,"m",V).call(this);const{executionId:o,stepId:n,token:u,code:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:f,redirectAuthInitiator:g,ssoQueryParams:p}=a(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,U,"f").popstate),window.addEventListener("components-context",t(this,U,"f").componentsContext),t(this,j,"f").subscribe(t(this,k,"m",R).bind(this)),t(this,j,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:o,token:u,code:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:f,redirectAuthInitiator:g},p)),i(this,y,!0,"f")}))}disconnectedCallback(){t(this,j,"f").unsubscribeAll(),t(this,I,"f").unsubscribeAll(),t(this,k,"m",T).call(this),window.removeEventListener("popstate",t(this,U,"f").popstate),window.removeEventListener("components-context",t(this,U,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,y,"f")&&i!==r&&x.observedAttributes.includes(e)){t(this,k,"m",O).call(this);const s=null===i;t(this,j,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,l()),{[d(e)]:r,stepId:o,executionId:n}})),t(this,I,"f").update({isDebug:this.debug})}}}x=K,y=new WeakMap,j=new WeakMap,I=new WeakMap,E=new WeakMap,L=new WeakMap,U=new WeakMap,M=new WeakMap,k=new WeakSet,S=function(){this.shadowRoot.appendChild(b.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},O=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[d(e)])throw Error(`${e} cannot be empty`)}))},W=function(){const{stepId:e,executionId:i}=c(this.flowId);t(this,j,"f").update({stepId:e,executionId:i})},D=function(t,i){this.sdk=n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},x.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(t){return{error:{errorCode:A,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},R=function(i,r,s){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(s("projectId")||s("baseUrl")){if(!e)return;t(this,k,"m",D).call(this,e,r)}t(this,M,"f").call(this,i)}))},P=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,k,"m",q).call(this))}))},q=function(){return e(this,void 0,void 0,(function*(){const t=h({projectId:this.projectId,filename:w,assetsFolder:C,baseUrl:this.baseStaticUrl});try{return yield f(t,"json"),!0}catch(t){return!1}}))},F=function(e){i(this,E,Object.assign(Object.assign({},t(this,E,"f")),e.detail),"f")},T=function(){var e;null===(e=t(this,L,"f"))||void 0===e||e.remove(),i(this,L,null,"f")},B=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,L,document.createElement("descope-debugger"),"f"),Object.assign(t(this,L,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,L,"f"))):t(this,k,"m",T).call(this)}))},N=function(e,i){var r;e&&this.debug&&(null===(r=t(this,L,"f"))||void 0===r||r.updateData({title:e,description:i}))},V=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=u.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},K.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.32.11"}};export{K as default};

@@ -1,1 +0,1 @@

import{__classPrivateFieldGet as e,__classPrivateFieldSet as t,__awaiter as i,__rest as o}from"tslib";import{ensureFingerprintIds as s,clearFingerprintData as n}from"@descope/web-js-sdk";import{URL_CODE_PARAM_NAME as r,URL_TOKEN_PARAM_NAME as l,URL_RUN_IDS_PARAM_NAME as a,RESPONSE_ACTIONS as d,CUSTOM_INTERACTIONS as c,ELEMENT_TYPE_ATTRIBUTE as h,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as u,DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON as p}from"../constants/index.js";import{timeoutPromise as g,withMemCache as v,leadingDebounce as m,getUserLocale as f,showFirstScreenOnExecutionInit as b,injectSamlIdpForm as w,getAnimationDirection as y,getElementDescopeAttributes as I,submitForm as C,handleAutoFocus as k,handleReportValidityOnBlur as S,getFirstNonEmptyValue as O,clearPreviousExternalInputs as R}from"../helpers/helpers.js";import j from"../helpers/state.js";import{disableWebauthnButtons as E,updateTemplateFromScreenState as A,setPhoneAutoDetectDefaultCode as x,setTOTPVariable as W,setNOTPVariable as U,setCssVars as T,updateScreenFromScreenState as L}from"../helpers/templates.js";import{isConditionalLoginSupported as $}from"../helpers/webauthn.js";import{getABTestingKey as P}from"../helpers/abTestingKey.js";import{calculateConditions as F,calculateCondition as V}from"../helpers/conditions.js";import{setLastAuth as N,getLastAuth as q}from"../helpers/lastAuth.js";import{Direction as M}from"../types.js";import D from"./BaseDescopeWc.js";import K,{getScriptResultPath as H}from"./sdkScripts/index.js";import{FETCH_EXCEPTION_ERROR_CODE as B,FETCH_ERROR_RESPONSE_ERROR_CODE as G}from"../constants/general.js";var J,_,z,Q,X,Y,Z,ee,te,ie,oe,se,ne,re,le,ae,de,ce,he,ue,pe,ge,ve;class me extends D{static set sdkConfigOverrides(e){D.sdkConfigOverrides=e}static get sdkConfigOverrides(){return D.sdkConfigOverrides}constructor(){const o=new j({deferredRedirect:!1});super(o.update.bind(o)),J.add(this),this.stepState=new j({},{updateOnlyOnChange:!1}),_.set(this,void 0),z.set(this,null),Q.set(this,{visibilitychange:e(this,J,"m",X).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const s=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:e}=s;if(!e){e=null===(o=new URL(s.url).searchParams)||void 0===o?void 0:o.get(r)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(s.url),i=t.searchParams.get(l),o=t.searchParams.get(a).split("_").pop();e(this,ee,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(s)},Z.set(this,((o,s,n,r,l=!1)=>{if(this.flowState.current.action===d.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=l?500:2e3;t(this,_,setTimeout((()=>i(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,s,c.polling,n,r,{}),h=document.hidden&&!l&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield g(e,i)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,Z,"f").call(this,o,s,n,r,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===B)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Z,"f").call(this,o,s,n,r);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),e(this,te,"f").call(this,u),e(this,Z,"f").call(this,o,s,n,r)}))),d),"f")}})),ee.set(this,(()=>{clearTimeout(e(this,_,"f")),t(this,_,null,"f")})),te.set(this,(t=>{var i,o,s,n,r,l,a,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.statusText}`;e(this,J,"m",ve).call(this,"error",(null==t?void 0:t.error)||{errorCode:G,errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,J,"m",Y).call(this))}null===(c=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:b}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&N(b),void e(this,J,"m",ve).call(this,"success",f);const{executionId:w,stepId:y,stepName:I,action:C,screen:k,redirect:S,openInNewTabUrl:O,webauthn:R,error:j,samlIdpResponse:E,nativeResponse:A}=t.data;C!==d.poll?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${m}`,"",{screen:k,status:m,stepId:y,stepName:I,action:C,error:j}),this.flowState.update({stepId:y,executionId:w,action:C,redirectTo:null==S?void 0:S.url,openInNewTabUrl:O,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==R?void 0:R.transactionId,webauthnOptions:null==R?void 0:R.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:C})})),ie.set(this,v((()=>i(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),he.set(this,m(((t,o)=>i(this,void 0,void 0,(function*(){var i;if("true"===t.getAttribute("formnovalidate")||e(this,J,"m",ne).call(this)){const s=null==t?void 0:t.getAttribute("id");e(this,J,"m",le).call(this,t);const n=yield e(this,J,"m",re).call(this),r=I(t),l=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},l),r),n),{origin:(null===(i=this.nativeOptions)||void 0===i?void 0:i.origin)||window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),h=yield o(s,d.version,c.componentsVersion,a);e(this,te,"f").call(this,h),e(this,J,"m",ae).call(this,n)}}))))),this.flowState=o}loadSdkScripts(){return i(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>i(this,void 0,void 0,(function*(){(yield K(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[H(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i,o,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",e(this,Q,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var i;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(i=e(this,z,"f"))||void 0===i||i.abort(),t(this,z,null,"f"),window.removeEventListener("visibilitychange",e(this,Q,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return i(this,void 0,void 0,(function*(){let i;const o=f(e),s=yield this.getTargetLocales();return s.includes(o.locale)?i=`${t}-${o.locale}.html`:s.includes(o.fallback)&&(i=`${t}-${o.fallback}.html`),i}))}getPageContent(e,t){return i(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,l,a){return i(this,void 0,void 0,(function*(){var h,u;const{projectId:p,flowId:g,tenant:v,stepId:m,executionId:I,action:k,screenId:S,screenState:O,redirectTo:R,openInNewTabUrl:j,redirectUrl:E,token:A,code:x,exchangeError:W,webauthnTransactionId:U,webauthnOptions:T,redirectAuthCodeChallenge:L,redirectAuthCallbackUrl:$,redirectAuthBackupCallbackUri:N,redirectAuthInitiator:M,locale:D,samlIdpResponseUrl:K,samlIdpResponseSamlResponse:H,samlIdpResponseRelayState:B,nativeResponseType:G,nativePayload:_}=r,Q=o(r,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let X,Y;const ee=P(),ie=this.sdk.getLastUserLoginId(),oe=yield this.getFlowConfig(),se=yield this.getProjectConfig(),ne=Object.entries(se.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),re=$&&L?{callbackUrl:$,codeChallenge:L,backupCallbackUri:N}:void 0,le=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!I&&(this.loadSdkScripts(),oe.fingerprintEnabled&&oe.fingerprintKey?yield s(oe.fingerprintKey,this.baseUrl):n(),oe.conditions?({startScreenId:X,conditionInteractionId:Y}=F({loginId:ie,code:x,token:A,abTestingKey:ee},oe.conditions)):oe.condition?({startScreenId:X,conditionInteractionId:Y}=V(oe.condition,{loginId:ie,code:x,token:A,abTestingKey:ee})):X=oe.startScreenId,!b(X,Q))){const t=yield this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{client:this.client}),E&&{redirectUrl:E}),{lastAuth:q(ie),abTestingKey:ee,locale:f(D).locale,nativeOptions:le}),Y,"",se.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),x?{exchangeCode:x,idpInitiated:!0}:{}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A?{token:A}:{}),Q.oidcLoginHint?{externalId:Q.oidcLoginHint}:{}));return e(this,te,"f").call(this,t),void("completed"!==(null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.status)&&this.flowState.update({code:void 0,token:void 0}))}if(I&&(a("token")&&A||a("code")&&x||a("exchangeError")&&W)){const t=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{token:A,exchangeCode:x,exchangeError:W});return e(this,te,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(k===d.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>a(e)))){if(!K||!H)return void this.loggerWrapper.error("Did not get saml idp params data to load");w(K,H,B||"",C)}if(k===d.redirect&&(a("redirectTo")||a("deferredRedirect")))return R?"android"===M&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(R):void this.loggerWrapper.error("Did not get redirect url");if(k===d.webauthnCreate||k===d.webauthnGet){if(!U||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let i,o;null===(u=e(this,z,"f"))||void 0===u||u.abort(),t(this,z,null,"f");try{i=k===d.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const s=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{transactionId:U,response:i,failure:o});e(this,te,"f").call(this,s)}if(k===d.nativeBridge)return this.nativeComplete=t=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,t);e(this,te,"f").call(this,i)})),void e(this,J,"m",ve).call(this,"bridge",{type:G,payload:_});if(e(this,Z,"f").call(this,I,m,oe.version,se.componentsVersion),!S&&!X)return void this.loggerWrapper.warn("No screen was found to show");const ae=X||S,de=yield this.getHtmlFilenameWithLocale(D,ae),{oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,samlIdpUsername:pe}=Q,ge={direction:y(m,l.stepId),screenState:Object.assign(Object.assign({},O),{form:Object.assign(Object.assign({},this.formConfigValues),null==O?void 0:O.form),lastAuth:{loginId:ie,name:this.sdk.getLastUserDisplayName()||ie}}),htmlFilename:`${ae}.html`,htmlLocaleFilename:de,samlIdpUsername:pe,oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,openInNewTabUrl:j},me=q(ie);b(X,Q)?ge.next=(e,t,i,o)=>this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{lastAuth:me,preview:this.preview,abTestingKey:ee,client:this.client}),E&&{redirectUrl:E}),{locale:f(D).locale,nativeOptions:le}),Y,e,i,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),x&&{exchangeCode:x,idpInitiated:!0}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A&&{token:A})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(ge.next=(...e)=>this.sdk.flow.next(I,m,...e)),this.stepState.update(ge)}))}onStepChange(t,o){return i(this,void 0,void 0,(function*(){var s,n;const{htmlFilename:r,htmlLocaleFilename:l,direction:a,next:d,screenState:u,openInNewTabUrl:p}=t,g=document.createElement("template");g.innerHTML=yield this.getPageContent(r,l);const v=g.content.cloneNode(!0),m=this.loadDescopeUiComponents(g);this.sdk.webauthn.helpers.isSupported()?yield e(this,J,"m",se).call(this,v,d):E(v),!t.samlIdpUsername||(null===(s=u.form)||void 0===s?void 0:s.loginId)||(null===(n=u.form)||void 0===n?void 0:n.email)||(u.form||(u.form={}),u.form.loginId=t.samlIdpUsername,u.form.email=t.samlIdpUsername),A(v,u,u.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();x(v,f);const b=()=>i(this,void 0,void 0,(function*(){var t,i;yield m;const s=this.shadowRoot.querySelector("div");W(s,null===(t=null==u?void 0:u.totp)||void 0===t?void 0:t.image),U(s,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),T(s,v,u.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(v);const n=!o.htmlFilename;setTimeout((()=>{e(this,J,"m",de).call(this),k(this.rootElement,this.autoFocus,n),this.validateOnBlur&&S(this.rootElement),L(this.rootElement,u)})),e(this,J,"m",pe).call(this,d),n&&e(this,J,"m",ve).call(this,"ready",{}),e(this,J,"m",ve).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${h}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(c.polling,t.version,i.componentsVersion,{});e(this,te,"f").call(this,o)}p&&!o.openInNewTabUrl&&window.open(p,"_blank")}));a?e(this,J,"m",ge).call(this,b,a):b()}))}}_=new WeakMap,z=new WeakMap,Q=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,he=new WeakMap,J=new WeakSet,X=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Y=function(){return i(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},oe=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},se=function(o,s){return i(this,void 0,void 0,(function*(){var n;null===(n=e(this,z,"f"))||void 0===n||n.abort();const r=o.querySelector('*[autocomplete="webauthn"]');if(r&&(yield $())){const{options:o,transactionId:n}=(yield e(this,ie,"f").call(this))||{};if(o&&n){e(this,J,"m",oe).call(this,r),t(this,z,new AbortController,"f");const l=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,z,"f")).then((t=>i(this,void 0,void 0,(function*(){const i=yield s(r.id,l.version,a.componentsVersion,{transactionId:n,response:t});e(this,te,"f").call(this,i)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},ne=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},re=function(){return i(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`));return(yield Promise.all(e.map((e=>i(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},le=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ae=function(e={}){var t,i;const o=O(e,["externalId","email","phone"]),s=O(e,["newPassword","password"]);if(o&&s)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:s});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},de=function(){R();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,J,"m",ce).call(this,t)))},ce=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),o=`input-${e.id}-${i}`,s=document.createElement("slot");s.setAttribute("name",o),s.setAttribute("slot",i),e.appendChild(s),t.setAttribute("slot",o),this.appendChild(t)}))},ue=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,he,"f").call(this,i,t)}))}))},pe=function(t){this.rootElement.querySelectorAll(`descope-button:not([${p}])`).forEach((i=>{i.onclick=()=>{e(this,he,"f").call(this,i,t)}})),e(this,J,"m",ue).call(this,t)},ge=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===M.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},ve=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))};export{me as default};
import{__classPrivateFieldGet as e,__classPrivateFieldSet as t,__awaiter as i,__rest as o}from"tslib";import{ensureFingerprintIds as s,clearFingerprintData as n}from"@descope/web-js-sdk";import{URL_CODE_PARAM_NAME as r,URL_TOKEN_PARAM_NAME as l,URL_RUN_IDS_PARAM_NAME as a,RESPONSE_ACTIONS as d,CUSTOM_INTERACTIONS as c,ELEMENT_TYPE_ATTRIBUTE as h,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as u,DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON as p}from"../constants/index.js";import{timeoutPromise as g,withMemCache as v,leadingDebounce as m,getUserLocale as f,showFirstScreenOnExecutionInit as b,injectSamlIdpForm as w,getAnimationDirection as y,getElementDescopeAttributes as I,submitForm as C,handleAutoFocus as k,handleReportValidityOnBlur as S,getFirstNonEmptyValue as O,clearPreviousExternalInputs as R}from"../helpers/helpers.js";import j from"../helpers/state.js";import{disableWebauthnButtons as E,updateTemplateFromScreenState as A,setPhoneAutoDetectDefaultCode as x,setTOTPVariable as W,setNOTPVariable as U,setCssVars as T,updateScreenFromScreenState as L}from"../helpers/templates.js";import{isConditionalLoginSupported as $}from"../helpers/webauthn.js";import{getABTestingKey as P}from"../helpers/abTestingKey.js";import{calculateConditions as F,calculateCondition as V}from"../helpers/conditions.js";import{setLastAuth as N,getLastAuth as q}from"../helpers/lastAuth.js";import{Direction as M}from"../types.js";import D from"./BaseDescopeWc.js";import K,{getScriptResultPath as H}from"./sdkScripts/index.js";import{FETCH_EXCEPTION_ERROR_CODE as B,FETCH_ERROR_RESPONSE_ERROR_CODE as G}from"../constants/general.js";var J,_,z,Q,X,Y,Z,ee,te,ie,oe,se,ne,re,le,ae,de,ce,he,ue,pe,ge,ve;class me extends D{static set sdkConfigOverrides(e){D.sdkConfigOverrides=e}static get sdkConfigOverrides(){return D.sdkConfigOverrides}constructor(){const o=new j({deferredRedirect:!1});super(o.update.bind(o)),J.add(this),this.stepState=new j({},{updateOnlyOnChange:!1}),_.set(this,void 0),z.set(this,null),Q.set(this,{visibilitychange:e(this,J,"m",X).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const s=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:e}=s;if(!e){e=null===(o=new URL(s.url).searchParams)||void 0===o?void 0:o.get(r)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(s.url),i=t.searchParams.get(l),o=t.searchParams.get(a).split("_").pop();e(this,ee,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(s)},Z.set(this,((o,s,n,r,l=!1)=>{if(this.flowState.current.action===d.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=l?500:2e3;t(this,_,setTimeout((()=>i(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,s,c.polling,n,r,{}),h=document.hidden&&!l&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield g(e,i)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,Z,"f").call(this,o,s,n,r,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===B)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Z,"f").call(this,o,s,n,r);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),e(this,te,"f").call(this,u),e(this,Z,"f").call(this,o,s,n,r)}))),d),"f")}})),ee.set(this,(()=>{clearTimeout(e(this,_,"f")),t(this,_,null,"f")})),te.set(this,(t=>{var i,o,s,n,r,l,a,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.statusText}`;e(this,J,"m",ve).call(this,"error",(null==t?void 0:t.error)||{errorCode:G,errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,J,"m",Y).call(this))}null===(c=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:b}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&N(b),void e(this,J,"m",ve).call(this,"success",f);const{executionId:w,stepId:y,stepName:I,action:C,screen:k,redirect:S,openInNewTabUrl:O,webauthn:R,error:j,samlIdpResponse:E,nativeResponse:A}=t.data;C!==d.poll?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${m}`,"",{screen:k,status:m,stepId:y,stepName:I,action:C,error:j}),this.flowState.update({stepId:y,executionId:w,action:C,redirectTo:null==S?void 0:S.url,openInNewTabUrl:O,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==R?void 0:R.transactionId,webauthnOptions:null==R?void 0:R.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:C})})),ie.set(this,v((()=>i(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),he.set(this,m(((t,o)=>i(this,void 0,void 0,(function*(){var i;if("true"===t.getAttribute("formnovalidate")||e(this,J,"m",ne).call(this)){const s=null==t?void 0:t.getAttribute("id");e(this,J,"m",le).call(this,t);const n=yield e(this,J,"m",re).call(this),r=I(t),l=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},l),r),n),{origin:(null===(i=this.nativeOptions)||void 0===i?void 0:i.origin)||window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),h=yield o(s,d.version,c.componentsVersion,a);e(this,te,"f").call(this,h),e(this,J,"m",ae).call(this,n)}}))))),this.flowState=o}loadSdkScripts(){return i(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>i(this,void 0,void 0,(function*(){(yield K(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[H(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i,o,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",e(this,Q,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var i;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(i=e(this,z,"f"))||void 0===i||i.abort(),t(this,z,null,"f"),window.removeEventListener("visibilitychange",e(this,Q,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return i(this,void 0,void 0,(function*(){let i;const o=f(e),s=yield this.getTargetLocales();return s.includes(o.locale)?i=`${t}-${o.locale}.html`:s.includes(o.fallback)&&(i=`${t}-${o.fallback}.html`),i}))}getPageContent(e,t){return i(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,l,a){return i(this,void 0,void 0,(function*(){var h,u;const{projectId:p,flowId:g,tenant:v,stepId:m,executionId:I,action:k,screenId:S,screenState:O,redirectTo:R,openInNewTabUrl:j,redirectUrl:E,token:A,code:x,exchangeError:W,webauthnTransactionId:U,webauthnOptions:T,redirectAuthCodeChallenge:L,redirectAuthCallbackUrl:$,redirectAuthBackupCallbackUri:N,redirectAuthInitiator:M,locale:D,samlIdpResponseUrl:K,samlIdpResponseSamlResponse:H,samlIdpResponseRelayState:B,nativeResponseType:G,nativePayload:_}=r,Q=o(r,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let X,Y;const ee=P(),ie=this.sdk.getLastUserLoginId(),oe=yield this.getFlowConfig(),se=yield this.getProjectConfig(),ne=Object.entries(se.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),re=$&&L?{callbackUrl:$,codeChallenge:L,backupCallbackUri:N}:void 0,le=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!I&&(this.loadSdkScripts(),oe.fingerprintEnabled&&oe.fingerprintKey?yield s(oe.fingerprintKey,this.baseUrl):n(),oe.conditions?({startScreenId:X,conditionInteractionId:Y}=F({loginId:ie,code:x,token:A,abTestingKey:ee},oe.conditions)):oe.condition?({startScreenId:X,conditionInteractionId:Y}=V(oe.condition,{loginId:ie,code:x,token:A,abTestingKey:ee})):X=oe.startScreenId,!b(X,Q))){const t=yield this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{client:this.client}),E&&{redirectUrl:E}),{lastAuth:q(ie),abTestingKey:ee,locale:f(D).locale,nativeOptions:le}),Y,"",se.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),x?{exchangeCode:x,idpInitiated:!0}:{}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A?{token:A}:{}),Q.oidcLoginHint?{externalId:Q.oidcLoginHint}:{}));return e(this,te,"f").call(this,t),void("completed"!==(null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.status)&&this.flowState.update({code:void 0,token:void 0}))}if(I&&(a("token")&&A||a("code")&&x||a("exchangeError")&&W)){const t=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{token:A,exchangeCode:x,exchangeError:W});return e(this,te,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(k===d.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>a(e)))){if(!K||!H)return void this.loggerWrapper.error("Did not get saml idp params data to load");w(K,H,B||"",C)}if(k===d.redirect&&(a("redirectTo")||a("deferredRedirect")))return R?"android"===M&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(R):void this.loggerWrapper.error("Did not get redirect url");if(k===d.webauthnCreate||k===d.webauthnGet){if(!U||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let i,o;null===(u=e(this,z,"f"))||void 0===u||u.abort(),t(this,z,null,"f");try{i=k===d.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const s=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{transactionId:U,response:i,failure:o});e(this,te,"f").call(this,s)}if(k===d.nativeBridge)return this.nativeComplete=t=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,t);e(this,te,"f").call(this,i)})),void e(this,J,"m",ve).call(this,"bridge",{type:G,payload:_});if(e(this,Z,"f").call(this,I,m,oe.version,se.componentsVersion),!S&&!X)return void this.loggerWrapper.warn("No screen was found to show");const ae=X||S,de=yield this.getHtmlFilenameWithLocale(D,ae),{oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,samlIdpUsername:pe}=Q,ge={direction:y(m,l.stepId),screenState:Object.assign(Object.assign({},O),{form:Object.assign(Object.assign({},this.formConfigValues),null==O?void 0:O.form),lastAuth:{loginId:ie,name:this.sdk.getLastUserDisplayName()||ie}}),htmlFilename:`${ae}.html`,htmlLocaleFilename:de,samlIdpUsername:pe,oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,openInNewTabUrl:j},me=q(ie);b(X,Q)?ge.next=(e,t,i,o)=>this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{lastAuth:me,preview:this.preview,abTestingKey:ee,client:this.client}),E&&{redirectUrl:E}),{locale:f(D).locale,nativeOptions:le}),Y,e,i,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),x&&{exchangeCode:x,idpInitiated:!0}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A&&{token:A})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(ge.next=(...e)=>this.sdk.flow.next(I,m,...e)),this.stepState.update(ge)}))}onStepChange(t,o){return i(this,void 0,void 0,(function*(){var s,n;const{htmlFilename:r,htmlLocaleFilename:l,direction:a,next:d,screenState:u,openInNewTabUrl:p}=t,g=document.createElement("template");g.innerHTML=yield this.getPageContent(r,l);const v=g.content.cloneNode(!0),m=this.loadDescopeUiComponents(g);this.sdk.webauthn.helpers.isSupported()?yield e(this,J,"m",se).call(this,v,d):E(v),!t.samlIdpUsername||(null===(s=u.form)||void 0===s?void 0:s.loginId)||(null===(n=u.form)||void 0===n?void 0:n.email)||(u.form||(u.form={}),u.form.loginId=t.samlIdpUsername,u.form.email=t.samlIdpUsername),A(v,u,u.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();x(v,f);const b=()=>i(this,void 0,void 0,(function*(){var t,i;yield m;const s=this.shadowRoot.querySelector("div");W(s,null===(t=null==u?void 0:u.totp)||void 0===t?void 0:t.image),U(s,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),T(s,v,u.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(v);const n=!o.htmlFilename;setTimeout((()=>{e(this,J,"m",de).call(this),k(this.rootElement,this.autoFocus,n),this.validateOnBlur&&S(this.rootElement),L(this.rootElement,u)})),e(this,J,"m",pe).call(this,d),n&&e(this,J,"m",ve).call(this,"ready",{}),e(this,J,"m",ve).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${h}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(c.polling,t.version,i.componentsVersion,{});e(this,te,"f").call(this,o)}p&&!o.openInNewTabUrl&&window.open(p,"_blank")}));a?e(this,J,"m",ge).call(this,b,a):b()}))}}_=new WeakMap,z=new WeakMap,Q=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,he=new WeakMap,J=new WeakSet,X=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Y=function(){return i(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},oe=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},se=function(o,s){return i(this,void 0,void 0,(function*(){var n;null===(n=e(this,z,"f"))||void 0===n||n.abort();const r=o.querySelector('*[autocomplete="webauthn"]');if(r&&(yield $())){const{options:o,transactionId:n}=(yield e(this,ie,"f").call(this))||{};if(o&&n){e(this,J,"m",oe).call(this,r),t(this,z,new AbortController,"f");const l=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,z,"f")).then((t=>i(this,void 0,void 0,(function*(){const i=yield s(r.id,l.version,a.componentsVersion,{transactionId:n,response:t});e(this,te,"f").call(this,i)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},ne=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},re=function(){return i(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`));return(yield Promise.all(e.map((e=>i(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},le=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ae=function(e={}){var t,i;const o=O(e,["externalId","email","phone"]),s=O(e,["newPassword","password"]);if(o&&s)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:s});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},de=function(){R();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,J,"m",ce).call(this,t)))},ce=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),o=`input-${e.id}-${i}`,s=document.createElement("slot");s.setAttribute("name",o),s.setAttribute("slot",i),e.appendChild(s),t.setAttribute("slot",o),this.appendChild(t)}))},ue=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,he,"f").call(this,i,t)}))}))},pe=function(t){this.rootElement.querySelectorAll(`descope-button:not([${p}])`).forEach((i=>{i.onclick=()=>{e(this,he,"f").call(this,i,t)}})),e(this,J,"m",ue).call(this,t)},ge=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===M.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},ve=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))};export{me as default};
{
"name": "@descope/web-component",
"version": "3.32.10",
"version": "3.32.11",
"author": "Descope Team <info@descope.com>",

@@ -32,3 +32,3 @@ "homepage": "https://github.com/descope/descope-js",

"@types/jest": "^29.0.0",
"@types/node": "20.17.12",
"@types/node": "20.17.13",
"dotenv": "^16.0.3",

@@ -42,3 +42,3 @@ "eslint": "8.57.1",

"eslint-plugin-import": "2.31.0",
"eslint-plugin-jest": "28.6.0",
"eslint-plugin-jest": "28.10.0",
"eslint-plugin-jest-dom": "5.4.0",

@@ -50,3 +50,3 @@ "eslint-plugin-jest-formatting": "3.1.0",

"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-promise": "6.2.0",
"eslint-plugin-promise": "6.6.0",
"jest": "^29.0.0",

@@ -73,6 +73,6 @@ "jest-environment-jsdom": "^29.0.0",

"@fingerprintjs/fingerprintjs-pro": "3.11.6",
"@descope/sdk-helpers": "0.1.66",
"@descope/sdk-mixins": "0.6.7",
"@descope/escape-markdown": "0.1.4",
"@descope/web-js-sdk": "1.23.8"
"@descope/sdk-helpers": "0.1.67",
"@descope/sdk-mixins": "0.6.8",
"@descope/web-js-sdk": "1.23.9",
"@descope/escape-markdown": "0.1.5"
},

@@ -79,0 +79,0 @@ "overrides": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc