@descope/web-component 4.3.4 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{__awaiter as t}from"tslib";import{URL_RUN_IDS_PARAM_NAME as e,URL_TOKEN_PARAM_NAME as n,URL_CODE_PARAM_NAME as o,URL_REDIRECT_MODE_PARAM_NAME as r,URL_ERR_PARAM_NAME as i,OIDC_IDP_STATE_ID_PARAM_NAME as s,SAML_IDP_STATE_ID_PARAM_NAME as c,WSFED_IDP_STATE_ID_PARAM_NAME as a,SAML_IDP_USERNAME_PARAM_NAME as u,DESCOPE_IDP_INITIATED_PARAM_NAME as d,SSO_APP_ID_PARAM_NAME as l,CUSTOM_APP_ID_PARAM_NAME as p,THIRD_PARTY_APP_ID_PARAM_NAME as m,THIRD_PARTY_APP_STATE_ID_PARAM_NAME as f,APPLICATION_SCOPES_PARAM_NAME as v,OIDC_LOGIN_HINT_PARAM_NAME as h,OIDC_PROMPT_PARAM_NAME as y,OIDC_ERROR_REDIRECT_URI_PARAM_NAME as g,OIDC_RESOURCE_PARAM_NAME as w,DESCOPE_ATTRIBUTE_PREFIX as b,SDK_SCRIPT_RESULTS_KEY as A,URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME as S,URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME as C,URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME as k,URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME as I}from"../constants/index.js";import{EXCLUDED_STATE_KEYS as P}from"../constants/customScreens.js";import{Direction as E}from"../types.js";import{OVERRIDE_CONTENT_URL as T,BASE_CONTENT_URL as O,ASSETS_FOLDER as j}from"../constants/content.js";const x=["descope-enriched-text"];function U(e,n,o){return(...r)=>t(this,void 0,void 0,(function*(){let t;const i=o+1;for(let s=0;s<i;s++)try{return yield e(...r)}catch(e){t=e,s<o&&(yield new Promise((t=>{setTimeout(t,n*Math.pow(2,s+1))})))}throw t}))}function L(t){return new URLSearchParams(window.location.search).get(t)}function $(t){if(window.history.replaceState&&L(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function R(e,n){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e} [${t.status}]`);return{body:yield t[n](),headers:Object.fromEntries(t.headers.entries())}}))}function M({projectId:t,filename:e,assetsFolder:n=j,baseUrl:o}){const r=new URL(T||o||O);return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,n,e),r.toString()}function F(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?E.forward:n<o?E.backward:void 0}const N=t=>{let[n="",o=""]=(L(e)||"").split("_");const r=(t=>{var e;return(null===(e=/(.*)\|#\|.*/.exec(t))||void 0===e?void 0:e[1])||""})(n);return(!t||r&&r!==t)&&(n="",o=""),{executionId:n,stepId:o,executionFlowId:r}};function q(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function B(){$(e)}function H(){return L(n)||void 0}function D(){$(n)}function Q(){return L(o)||void 0}function W(){return"popup"===L(r)}function G(){return L(i)||void 0}function V(){$(o)}function _(){$(r)}function z(){$(i)}function J(){return{redirectAuthCodeChallenge:L(S),redirectAuthCallbackUrl:L(C),redirectAuthBackupCallbackUri:L(k),redirectAuthInitiator:L(I)}}function K(){return L(s)}function X(){$(s)}function Y(){return L(c)}function Z(){$(c)}function tt(){return L(a)}function et(){$(a)}function nt(){return L(u)}function ot(){$(u)}function rt(){return L(d)}function it(){$(d)}function st(){return L(l)}function ct(){return L(p)}function at(){return L(m)}function ut(){$(l)}function dt(){$(p)}function lt(){$(m)}function pt(){return L(f)}function mt(){$(f)}function ft(){return L(v)}function vt(){$(v)}function ht(){return L(h)}function yt(){$(h)}function gt(){return L(y)}function wt(){$(y)}function bt(){return L(g)}function At(){$(g)}function St(){return L(w)}function Ct(){$(w)}const kt=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),It=(t,e)=>n=>t[n]!==e[n],Pt=t=>Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp(`^${b}(\\S+)$`).exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{}),Et=(t,e)=>{const{executionId:n,stepId:o,executionFlowId:r}=N(t);if(r&&t!==r)return e.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&B();const i=H();i&&D();const s=Q();s&&V();const c=W();c&&_();const a=G();a&&z();const{redirectAuthCodeChallenge:u,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:l,redirectAuthInitiator:p}=J(),m=K();m&&X();const f=Y();f&&Z();const v=tt();v&&et();const h=nt();f&&ot();const y=rt();y&&it();const g=st();g&&ut();const w=ct();w&&dt();const b=at();b&&lt();const A=pt();A&&mt();const S=ft();S&&vt();const C=ht();C&&yt();const k=gt();k&&wt();const I=bt();I&&At();const P=St();P&&Ct();return{executionId:n,stepId:o,token:i,code:s,isPopup:c,exchangeError:a,redirectAuthCodeChallenge:u,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:l,redirectAuthInitiator:p,ssoQueryParams:{oidcIdpStateId:m,samlIdpStateId:f,wsfedIdpStateId:v,samlIdpUsername:h,descopeIdpInitiated:"true"===y,ssoAppId:g,customAppId:w,oidcLoginHint:C,oidcPrompt:k,oidcErrorRedirectUri:I,oidcResource:P,thirdPartyAppId:b,thirdPartyAppStateId:A,applicationScopes:S}}},Tt=t=>{let e,n;return Object.assign(((...o)=>{return e&&(i=o,(r=e).length===i.length&&r.every(((t,e)=>t===i[e])))||(e=o,n=t(...o)),n;var r,i}),{reset:()=>{e=void 0,n=void 0}})},Ot='*[name]:not([auto-focus="false"]):not([aria-hidden="true"])',jt=(t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector(Ot);setTimeout((()=>{null==e||e.focus()}))}},xt=t=>{t.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var n;const o=()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))};if("true"===e.getAttribute("invalid")||(null===(n=e.value)||void 0===n?void 0:n.length))return void o();const r={timer:void 0},i=t=>{"true"===t.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{t.removeEventListener("click",i),o(),r.timer=void 0}),150),t.addEventListener("click",i,{once:!0})}))}))};function Ut(t,e,n){return new Promise(((o,r)=>{let i=!1;const s=setTimeout((()=>{i=!0,void 0!==n?o(n):r(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{i||(clearTimeout(s),o(t))})).catch((t=>{i||(clearTimeout(s),r(t))}))}))}const Lt=()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0},$t=(t,{oidcIdpStateId:e,samlIdpStateId:n,wsfedIdpStateId:o,samlIdpUsername:r,ssoAppId:i,customAppId:s,oidcLoginHint:c,oidcPrompt:a,oidcErrorRedirectUri:u,oidcResource:d,thirdPartyAppId:l,thirdPartyAppStateId:p,applicationScopes:m})=>!(!t||e||n||o||r||i||s||c||a||u||d||l||p||m),Rt=(t,e,n,o)=>{const r=document.createElement("form");r.method="POST",r.action=t,r.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(r),o(r)},Mt=(t,e,n,o)=>{const r=document.createElement("form");r.method="POST",r.action=t;const i=(t,e)=>{const n=document.createElement("input");return n.type="hidden",n.name=t,n.value=e,n};r.appendChild(i("wa","wsignin1.0")),r.appendChild(i("wresult",e)),r.appendChild(i("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",r.appendChild(s),document.body.appendChild(r),o(r)},Ft=t=>null==t?void 0:t.submit(),Nt=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},qt=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}},Bt=()=>{document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()))},Ht=t=>x.includes(t),Dt={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",activePolicies:"active-policies",availablePolicies:"available-policies"},Qt=(t,e)=>{var n;const o=null==t?void 0:t.componentsDynamicAttrs;if(!o)return;const r=Object.entries(o).find((([t])=>(t=>{var e;return null===(e=t.match(/\[data-name=["']([^"']+)["']\]/))||void 0===e?void 0:e[1]})(t)===e));return null===(n=null==r?void 0:r[1])||void 0===n?void 0:n.attributes},Wt=[{key:"totp",from:t=>t.totp},{key:"notp",from:t=>t.notp},{key:"sentTo",from:t=>t.sentTo},{key:"sso",from:t=>t.sso},{key:"selfProvisionDomains",from:t=>t.selfProvisionDomains},{key:"inboundAppApproveScopes",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:t=>{var e;return null===(e=t.componentsConfig)||void 0===e?void 0:e.sqSetup}},{key:"securityQuestionsVerify",from:t=>{var e;return null===(e=t.componentsConfig)||void 0===e?void 0:e.sqVerify}},{key:"userTenants",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:t=>{var e;return(t=>{if(!t)return;const e=Object.fromEntries(Object.entries(Dt).map((([e,n])=>[e,t[n]])).filter((([,t])=>void 0!==t)));return Object.keys(e).length?e:void 0})(null===(e=t.componentsConfig)||void 0===e?void 0:e.newPassword)}},{key:"recoveryCodes",from:t=>(t=>{const e=Qt(t,"recoveryCodes");if(e)return Array.isArray(e.data)?e.data.map((t=>t.value)):[]})(t.componentsConfig)},{key:"outboundApp",from:t=>(t=>{const e=Qt(t,"outboundApp");if(e)return{label:e.label,iconSrc:e["icon-src"],appId:e["data-descope-outbound-oauth-app-id"]}})(t.componentsConfig)}],Gt=t=>{const e=(n=t.screenState,o=(t,e)=>P.includes(e)||e.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([t,e])=>!o(e,t)))));var n,o;const{screenState:{errorText:r,errorType:i}}=t;(r||i)&&(e.error={text:r,type:i}),t.action&&(e.action=t.action);const s=(t=>{if(!t)return;const e={};return Wt.forEach((({key:n,from:o})=>{const r=o(t);void 0!==r&&(e[n]=r)})),Object.keys(e).length?e:void 0})(t.screenState);return s&&(e.data=s),e},Vt=t=>{const e=Object.assign({},t);return t.inboundAppApproveScopes&&(e.thirdPartyAppApproveScopes=t.inboundAppApproveScopes),e};function _t(t,e){return`${A}.${e?`${t}_${e}`:t}`}const zt=(t,e,n,o)=>{const r=void 0!==window.screenLeft?window.screenLeft:window.screen.left,i=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+r,c=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-o)/2+i,a=function(){const t=navigator.userAgent||"",e=/\b(iPhone)\b/.test(t),n=/Safari/.test(t)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(t);return e&&n}()?"about:blank":"",u=window.open(a,e,`width=${n},height=${o},top=${c},left=${s},scrollbars=yes,resizable=yes`);return u.location.href=t,u.focus(),u};export{Ot as FOCUSABLE_INPUTS_SELECTOR,kt as camelCase,vt as clearApplicationScopesParamFromUrl,V as clearCodeFromUrl,dt as clearCustomAppIdParamFromUrl,it as clearDescopeIDPInitiatedParamFromUrl,z as clearExchangeErrorFromUrl,_ as clearIsPopupFromUrl,At as clearOIDCErrorRedirectUriParamFromUrl,X as clearOIDCIDPParamFromUrl,yt as clearOIDCLoginHintParamFromUrl,wt as clearOIDCPromptParamFromUrl,Ct as clearOIDCResourceParamFromUrl,Bt as clearPreviousExternalInputs,B as clearRunIdsFromUrl,Z as clearSAMLIDPParamFromUrl,ot as clearSAMLIDPUsernameParamFromUrl,ut as clearSSOAppIdParamFromUrl,lt as clearThirdPartyAppIdParamFromUrl,mt as clearThirdPartyAppStateIdParamFromUrl,D as clearTokenFromUrl,et as clearWSFedIDPParamFromUrl,It as createIsChanged,R as fetchContent,F as getAnimationDirection,ft as getApplicationScopesParamFromUrl,Lt as getChromiumVersion,Q as getCodeFromUrl,M as getContentUrl,ct as getCustomAppIdParamFromUrl,rt as getDescopeIDPInitiatedParamFromUrl,Pt as getElementDescopeAttributes,G as getExchangeErrorFromUrl,Nt as getFirstNonEmptyValue,W as getIsPopupFromUrl,bt as getOIDCErrorRedirectUriParamFromUrl,K as getOIDCIDPParamFromUrl,ht as getOIDCLoginHintParamFromUrl,gt as getOIDCPromptParamFromUrl,St as getOIDCResourceParamFromUrl,J as getRedirectAuthFromUrl,N as getRunIdsFromUrl,Y as getSAMLIDPParamFromUrl,nt as getSAMLIDPUsernameParamFromUrl,st as getSSOAppIdParamFromUrl,_t as getScriptResultPath,at as getThirdPartyAppIdParamFromUrl,pt as getThirdPartyAppStateIdParamFromUrl,H as getTokenFromUrl,tt as getWSFedIDPParamFromUrl,jt as handleAutoFocus,xt as handleReportValidityOnBlur,Et as handleUrlParams,Rt as injectSamlIdpForm,Mt as injectWsFedIdpForm,q as isChromium,qt as leadingDebounce,zt as openCenteredPopup,Ht as shouldHandleMarkdown,$t as showFirstScreenOnExecutionInit,Ft as submitForm,Ut as timeoutPromise,Vt as transformScreenInputs,Gt as transformStepStateForCustomScreen,Tt as withMemCache,U as withRetry};
1
+ import{__awaiter as t}from"tslib";import{URL_RUN_IDS_PARAM_NAME as e,URL_TOKEN_PARAM_NAME as n,URL_CODE_PARAM_NAME as o,URL_REDIRECT_MODE_PARAM_NAME as r,URL_ERR_PARAM_NAME as i,OIDC_IDP_STATE_ID_PARAM_NAME as s,SAML_IDP_STATE_ID_PARAM_NAME as c,WSFED_IDP_STATE_ID_PARAM_NAME as a,SAML_IDP_USERNAME_PARAM_NAME as d,DESCOPE_IDP_INITIATED_PARAM_NAME as u,SSO_APP_ID_PARAM_NAME as l,CUSTOM_APP_ID_PARAM_NAME as p,THIRD_PARTY_APP_ID_PARAM_NAME as m,THIRD_PARTY_APP_STATE_ID_PARAM_NAME as f,APPLICATION_SCOPES_PARAM_NAME as v,OIDC_LOGIN_HINT_PARAM_NAME as h,OIDC_PROMPT_PARAM_NAME as y,OIDC_ERROR_REDIRECT_URI_PARAM_NAME as g,OIDC_RESOURCE_PARAM_NAME as w,DESCOPE_ATTRIBUTE_PREFIX as b,SDK_SCRIPT_RESULTS_KEY as A,URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME as S,URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME as C,URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME as k,URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME as I}from"../constants/index.js";import{EXCLUDED_STATE_KEYS as P}from"../constants/customScreens.js";import{Direction as E}from"../types.js";import{OVERRIDE_CONTENT_URL as T,BASE_CONTENT_URL as O,ASSETS_FOLDER as j}from"../constants/content.js";const x=["descope-enriched-text"];function U(e,n,o){return(...r)=>t(this,void 0,void 0,(function*(){let t;const i=o+1;for(let s=0;s<i;s++)try{return yield e(...r)}catch(e){t=e,s<o&&(yield new Promise((t=>{setTimeout(t,n*Math.pow(2,s+1))})))}throw t}))}function L(t){return new URLSearchParams(window.location.search).get(t)}function R(t){if(window.history.replaceState&&L(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function $(e,n){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e} [${t.status}]`);return{body:yield t[n](),headers:Object.fromEntries(t.headers.entries())}}))}function M({projectId:t,filename:e,assetsFolder:n=j,baseUrl:o}){const r=new URL(T||o||O);return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,n,e),r.toString()}function F(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?E.forward:n<o?E.backward:void 0}const N=t=>{let[n="",o=""]=(L(e)||"").split("_");const r=(t=>{var e;return(null===(e=/(.*)\|#\|.*/.exec(t))||void 0===e?void 0:e[1])||""})(n);return(!t||r&&r!==t)&&(n="",o=""),{executionId:n,stepId:o,executionFlowId:r}};function q(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function B(){R(e)}function D(){return L(n)||void 0}function H(){R(n)}function Q(){return L(o)||void 0}function W(){return"popup"===L(r)}function G(){return L(i)||void 0}function V(){R(o)}function _(){R(r)}function z(){R(i)}function J(){return{redirectAuthCodeChallenge:L(S),redirectAuthCallbackUrl:L(C),redirectAuthBackupCallbackUri:L(k),redirectAuthInitiator:L(I)}}function K(){return L(s)}function X(){R(s)}function Y(){return L(c)}function Z(){R(c)}function tt(){return L(a)}function et(){R(a)}function nt(){return L(d)}function ot(){R(d)}function rt(){return L(u)}function it(){R(u)}function st(){return L(l)}function ct(){return L(p)}function at(){return L(m)}function dt(){R(l)}function ut(){R(p)}function lt(){R(m)}function pt(){return L(f)}function mt(){R(f)}function ft(){return L(v)}function vt(){R(v)}function ht(){return L(h)}function yt(){R(h)}function gt(){return L(y)}function wt(){R(y)}function bt(){return L(g)}function At(){R(g)}function St(){return L(w)}function Ct(){R(w)}const kt=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),It=(t,e)=>n=>t[n]!==e[n],Pt=t=>Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp(`^${b}(\\S+)$`).exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{}),Et=(t,e)=>{const{executionId:n,stepId:o,executionFlowId:r}=N(t);if(r&&t!==r)return e.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&B();const i=D();i&&H();const s=Q();s&&V();const c=W();c&&_();const a=G();a&&z();const{redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:l,redirectAuthInitiator:p}=J(),m=K();m&&X();const f=Y();f&&Z();const v=tt();v&&et();const h=nt();f&&ot();const y=rt();y&&it();const g=st();g&&dt();const w=ct();w&&ut();const b=at();b&&lt();const A=pt();A&&mt();const S=ft();S&&vt();const C=ht();C&&yt();const k=gt();k&&wt();const I=bt();I&&At();const P=St();P&&Ct();return{executionId:n,stepId:o,token:i,code:s,isPopup:c,exchangeError:a,redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:l,redirectAuthInitiator:p,ssoQueryParams:{oidcIdpStateId:m,samlIdpStateId:f,wsfedIdpStateId:v,samlIdpUsername:h,descopeIdpInitiated:"true"===y,ssoAppId:g,customAppId:w,oidcLoginHint:C,oidcPrompt:k,oidcErrorRedirectUri:I,oidcResource:P,thirdPartyAppId:b,thirdPartyAppStateId:A,applicationScopes:S}}},Tt=t=>{let e,n;return Object.assign(((...o)=>{return e&&(i=o,(r=e).length===i.length&&r.every(((t,e)=>t===i[e])))||(e=o,n=t(...o)),n;var r,i}),{reset:()=>{e=void 0,n=void 0}})},Ot='*[name]:not([auto-focus="false"]):not([aria-hidden="true"])',jt=(t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector(Ot);setTimeout((()=>{null==e||e.focus()}))}},xt=(t,e)=>{t.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var o;const r=()=>{var t;const o=n.focus;n.focus=()=>{};const r=null===(t=n.reportValidity)||void 0===t?void 0:t.call(n);e&&!1===r&&e(n),setTimeout((()=>{n.focus=o}))};if("true"===n.getAttribute("invalid")||(null===(o=n.value)||void 0===o?void 0:o.length))return void r();const i={timer:void 0},s=t=>{"true"===t.target.getAttribute("formnovalidate")&&(clearTimeout(i.timer),i.timer=void 0)};i.timer=setTimeout((()=>{t.removeEventListener("click",s),r(),i.timer=void 0}),150),t.addEventListener("click",s,{once:!0})}))}))};function Ut(t,e,n){return new Promise(((o,r)=>{let i=!1;const s=setTimeout((()=>{i=!0,void 0!==n?o(n):r(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{i||(clearTimeout(s),o(t))})).catch((t=>{i||(clearTimeout(s),r(t))}))}))}const Lt=()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0},Rt=(t,{oidcIdpStateId:e,samlIdpStateId:n,wsfedIdpStateId:o,samlIdpUsername:r,ssoAppId:i,customAppId:s,oidcLoginHint:c,oidcPrompt:a,oidcErrorRedirectUri:d,oidcResource:u,thirdPartyAppId:l,thirdPartyAppStateId:p,applicationScopes:m})=>!(!t||e||n||o||r||i||s||c||a||d||u||l||p||m),$t=(t,e,n)=>{const o=document.createElement("input");return o.type="hidden",o.name=t,o.value=e,n&&o.setAttribute("role",n),o},Mt=(t,e,n,o)=>{const r=document.createElement("form");r.method="POST",r.action=t,r.appendChild($t("SAMLResponse",e,"saml-response")),r.appendChild($t("RelayState",n,"saml-relay-state"));const i=document.createElement("input");i.type="submit",i.id="SAMLSubmitButton",i.value="Continue",i.style.display="none",r.appendChild(i),document.body.appendChild(r),o(r)},Ft=(t,e,n,o)=>{const r=document.createElement("form");r.method="POST",r.action=t,r.appendChild($t("wa","wsignin1.0")),r.appendChild($t("wresult",e)),r.appendChild($t("wctx",n));const i=document.createElement("input");i.type="submit",i.id="WSFedSubmitButton",i.value="Continue",i.style.display="none",r.appendChild(i),document.body.appendChild(r),o(r)},Nt=t=>null==t?void 0:t.submit(),qt=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Bt=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}},Dt=()=>{document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()))},Ht=t=>x.includes(t),Qt={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",activePolicies:"active-policies",availablePolicies:"available-policies"},Wt=(t,e)=>{var n;const o=null==t?void 0:t.componentsDynamicAttrs;if(!o)return;const r=Object.entries(o).find((([t])=>(t=>{var e;return null===(e=t.match(/\[data-name=["']([^"']+)["']\]/))||void 0===e?void 0:e[1]})(t)===e));return null===(n=null==r?void 0:r[1])||void 0===n?void 0:n.attributes},Gt=[{key:"totp",from:t=>t.totp},{key:"notp",from:t=>t.notp},{key:"sentTo",from:t=>t.sentTo},{key:"sso",from:t=>t.sso},{key:"selfProvisionDomains",from:t=>t.selfProvisionDomains},{key:"inboundAppApproveScopes",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:t=>{var e;return null===(e=t.componentsConfig)||void 0===e?void 0:e.sqSetup}},{key:"securityQuestionsVerify",from:t=>{var e;return null===(e=t.componentsConfig)||void 0===e?void 0:e.sqVerify}},{key:"userTenants",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:t=>{var e,n;return null===(n=null===(e=t.componentsConfig)||void 0===e?void 0:e.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:t=>{var e;return(t=>{if(!t)return;const e=Object.fromEntries(Object.entries(Qt).map((([e,n])=>[e,t[n]])).filter((([,t])=>void 0!==t)));return Object.keys(e).length?e:void 0})(null===(e=t.componentsConfig)||void 0===e?void 0:e.newPassword)}},{key:"recoveryCodes",from:t=>(t=>{const e=Wt(t,"recoveryCodes");if(e)return Array.isArray(e.data)?e.data.map((t=>t.value)):[]})(t.componentsConfig)},{key:"outboundApp",from:t=>(t=>{const e=Wt(t,"outboundApp");if(e)return{label:e.label,iconSrc:e["icon-src"],appId:e["data-descope-outbound-oauth-app-id"]}})(t.componentsConfig)}],Vt=t=>{const e=(n=t.screenState,o=(t,e)=>P.includes(e)||e.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([t,e])=>!o(e,t)))));var n,o;const{screenState:{errorText:r,errorType:i}}=t;(r||i)&&(e.error={text:r,type:i}),t.action&&(e.action=t.action);const s=(t=>{if(!t)return;const e={};return Gt.forEach((({key:n,from:o})=>{const r=o(t);void 0!==r&&(e[n]=r)})),Object.keys(e).length?e:void 0})(t.screenState);return s&&(e.data=s),e},_t=t=>{const e=Object.assign({},t);return t.inboundAppApproveScopes&&(e.thirdPartyAppApproveScopes=t.inboundAppApproveScopes),e};function zt(t,e){return`${A}.${e?`${t}_${e}`:t}`}const Jt=(t,e,n,o)=>{const r=void 0!==window.screenLeft?window.screenLeft:window.screen.left,i=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+r,c=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-o)/2+i,a=function(){const t=navigator.userAgent||"",e=/\b(iPhone)\b/.test(t),n=/Safari/.test(t)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(t);return e&&n}()?"about:blank":"",d=window.open(a,e,`width=${n},height=${o},top=${c},left=${s},scrollbars=yes,resizable=yes`);return d.location.href=t,d.focus(),d};export{Ot as FOCUSABLE_INPUTS_SELECTOR,kt as camelCase,vt as clearApplicationScopesParamFromUrl,V as clearCodeFromUrl,ut as clearCustomAppIdParamFromUrl,it as clearDescopeIDPInitiatedParamFromUrl,z as clearExchangeErrorFromUrl,_ as clearIsPopupFromUrl,At as clearOIDCErrorRedirectUriParamFromUrl,X as clearOIDCIDPParamFromUrl,yt as clearOIDCLoginHintParamFromUrl,wt as clearOIDCPromptParamFromUrl,Ct as clearOIDCResourceParamFromUrl,Dt as clearPreviousExternalInputs,B as clearRunIdsFromUrl,Z as clearSAMLIDPParamFromUrl,ot as clearSAMLIDPUsernameParamFromUrl,dt as clearSSOAppIdParamFromUrl,lt as clearThirdPartyAppIdParamFromUrl,mt as clearThirdPartyAppStateIdParamFromUrl,H as clearTokenFromUrl,et as clearWSFedIDPParamFromUrl,It as createIsChanged,$ as fetchContent,F as getAnimationDirection,ft as getApplicationScopesParamFromUrl,Lt as getChromiumVersion,Q as getCodeFromUrl,M as getContentUrl,ct as getCustomAppIdParamFromUrl,rt as getDescopeIDPInitiatedParamFromUrl,Pt as getElementDescopeAttributes,G as getExchangeErrorFromUrl,qt as getFirstNonEmptyValue,W as getIsPopupFromUrl,bt as getOIDCErrorRedirectUriParamFromUrl,K as getOIDCIDPParamFromUrl,ht as getOIDCLoginHintParamFromUrl,gt as getOIDCPromptParamFromUrl,St as getOIDCResourceParamFromUrl,J as getRedirectAuthFromUrl,N as getRunIdsFromUrl,Y as getSAMLIDPParamFromUrl,nt as getSAMLIDPUsernameParamFromUrl,st as getSSOAppIdParamFromUrl,zt as getScriptResultPath,at as getThirdPartyAppIdParamFromUrl,pt as getThirdPartyAppStateIdParamFromUrl,D as getTokenFromUrl,tt as getWSFedIDPParamFromUrl,jt as handleAutoFocus,xt as handleReportValidityOnBlur,Et as handleUrlParams,Mt as injectSamlIdpForm,Ft as injectWsFedIdpForm,q as isChromium,Bt as leadingDebounce,Jt as openCenteredPopup,Ht as shouldHandleMarkdown,Rt as showFirstScreenOnExecutionInit,Nt as submitForm,Ut as timeoutPromise,_t as transformScreenInputs,Vt as transformStepStateForCustomScreen,Tt as withMemCache,U as withRetry};
2
2
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../src/lib/helpers/helpers.ts"],"sourcesContent":["import {\n ASSETS_FOLDER,\n BASE_CONTENT_URL,\n DESCOPE_ATTRIBUTE_PREFIX,\n URL_CODE_PARAM_NAME,\n URL_ERR_PARAM_NAME,\n URL_RUN_IDS_PARAM_NAME,\n URL_TOKEN_PARAM_NAME,\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n OIDC_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_STATE_ID_PARAM_NAME,\n WSFED_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_USERNAME_PARAM_NAME,\n SSO_APP_ID_PARAM_NAME,\n CUSTOM_APP_ID_PARAM_NAME,\n OIDC_LOGIN_HINT_PARAM_NAME,\n DESCOPE_IDP_INITIATED_PARAM_NAME,\n OVERRIDE_CONTENT_URL,\n OIDC_PROMPT_PARAM_NAME,\n OIDC_RESOURCE_PARAM_NAME,\n OIDC_ERROR_REDIRECT_URI_PARAM_NAME,\n THIRD_PARTY_APP_ID_PARAM_NAME,\n THIRD_PARTY_APP_STATE_ID_PARAM_NAME,\n APPLICATION_SCOPES_PARAM_NAME,\n SDK_SCRIPT_RESULTS_KEY,\n URL_REDIRECT_MODE_PARAM_NAME,\n} from '../constants';\nimport { EXCLUDED_STATE_KEYS } from '../constants/customScreens';\nimport {\n AutoFocusOptions,\n ComponentsConfig,\n CustomScreenData,\n CustomScreenState,\n Direction,\n ScreenState,\n SSOQueryParams,\n StepState,\n} from '../types';\n\nconst MD_COMPONENTS = ['descope-enriched-text'];\n\n/**\n * Wraps an async function with retry logic\n * @param fn - The async function to wrap\n * @param timeoutMs - Time to wait between retries in milliseconds\n * @param maxRetries - Maximum number of retry attempts\n * @returns A new function with retry logic\n */\nexport function withRetry<TArgs extends any[], TReturn>(\n fn: (...args: TArgs) => Promise<TReturn>,\n timeoutMs: number,\n maxRetries: number,\n): (...args: TArgs) => Promise<TReturn> {\n return async (...args: TArgs): Promise<TReturn> => {\n let lastError: any;\n const totalAttempts = maxRetries + 1; // initial attempt + retries\n\n // eslint-disable-next-line no-plusplus\n for (let attempt = 0; attempt < totalAttempts; attempt++) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await fn(...args);\n } catch (error) {\n lastError = error;\n\n // Don't wait after the last attempt\n if (attempt < maxRetries) {\n // eslint-disable-next-line no-await-in-loop\n await new Promise((resolve) => {\n setTimeout(resolve, timeoutMs * Math.pow(2, attempt + 1));\n });\n }\n }\n }\n\n // All attempts failed, throw the last error\n throw lastError;\n };\n}\n\nfunction getUrlParam(paramName: string) {\n const urlParams = new URLSearchParams(window.location.search);\n\n return urlParams.get(paramName);\n}\n\nfunction getFlowUrlParam() {\n return getUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nfunction setFlowUrlParam(id: string) {\n if (window.history.pushState && id !== getFlowUrlParam()) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.set(URL_RUN_IDS_PARAM_NAME, id);\n newUrl.search = search.toString();\n window.history.pushState({}, '', newUrl.toString());\n }\n}\n\nfunction resetUrlParam(paramName: string) {\n if (window.history.replaceState && getUrlParam(paramName)) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.delete(paramName);\n newUrl.search = search.toString();\n window.history.replaceState({}, '', newUrl.toString());\n }\n}\n\nconst getFlowIdFromExecId = (executionId: string) => {\n const regex = /(.*)\\|#\\|.*/;\n return regex.exec(executionId)?.[1] || '';\n};\n\nexport async function fetchContent<T extends 'text' | 'json'>(\n url: string,\n returnType: T,\n): Promise<{\n body: T extends 'json' ? Record<string, any> : string;\n headers: Record<string, string>;\n}> {\n const res = await fetch(url, { cache: 'default' });\n if (!res.ok) {\n throw Error(`Error fetching URL ${url} [${res.status}]`);\n }\n\n return {\n body: await res[returnType || 'text'](),\n headers: Object.fromEntries(res.headers.entries()),\n };\n}\n\nconst pathJoin = (...paths: string[]) => paths.join('/').replace(/\\/+/g, '/'); // preventing duplicate separators\n\nexport function getContentUrl({\n projectId,\n filename,\n assetsFolder = ASSETS_FOLDER,\n baseUrl,\n}: {\n projectId: string;\n filename: string;\n assetsFolder?: string;\n baseUrl?: string;\n}) {\n const url = new URL(OVERRIDE_CONTENT_URL || baseUrl || BASE_CONTENT_URL);\n url.pathname = pathJoin(url.pathname, projectId, assetsFolder, filename);\n\n return url.toString();\n}\n\nexport function getAnimationDirection(\n currentIdxStr: string,\n prevIdxStr: string,\n) {\n if (!prevIdxStr) return undefined;\n\n const currentIdx = +currentIdxStr;\n const prevIdx = +prevIdxStr;\n\n if (Number.isNaN(currentIdx) || Number.isNaN(prevIdx)) return undefined;\n if (currentIdx > prevIdx) return Direction.forward;\n if (currentIdx < prevIdx) return Direction.backward;\n return undefined;\n}\n\nexport const getRunIdsFromUrl = (flowId: string) => {\n let [executionId = '', stepId = ''] = (getFlowUrlParam() || '').split('_');\n const executionFlowId = getFlowIdFromExecId(executionId);\n\n // if the flow id does not match, this execution id is not for this flow\n if (!flowId || (executionFlowId && executionFlowId !== flowId)) {\n executionId = '';\n stepId = '';\n }\n\n return { executionId, stepId, executionFlowId };\n};\n\nexport const setRunIdsOnUrl = (executionId: string, stepId: string) => {\n setFlowUrlParam([executionId, stepId].join('_'));\n};\n\nexport function isChromium() {\n return (\n /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)\n );\n}\n\n// Detect Safari running on iPhone specifically.\nfunction isIphoneSafari() {\n const ua = navigator.userAgent || '';\n const isIphone = /\\b(iPhone)\\b/.test(ua);\n // Safari UA contains 'Safari' and usually 'Version/X', exclude other iOS browsers\n const isSafari =\n /Safari/.test(ua) && !/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(ua);\n\n return isIphone && isSafari;\n}\n\nexport function clearRunIdsFromUrl() {\n resetUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nexport function getTokenFromUrl() {\n return getUrlParam(URL_TOKEN_PARAM_NAME) || undefined;\n}\n\nexport function clearTokenFromUrl() {\n resetUrlParam(URL_TOKEN_PARAM_NAME);\n}\n\nexport function getCodeFromUrl() {\n return getUrlParam(URL_CODE_PARAM_NAME) || undefined;\n}\n\nexport function getIsPopupFromUrl() {\n return getUrlParam(URL_REDIRECT_MODE_PARAM_NAME) === 'popup';\n}\n\nexport function getExchangeErrorFromUrl() {\n return getUrlParam(URL_ERR_PARAM_NAME) || undefined;\n}\n\nexport function clearCodeFromUrl() {\n resetUrlParam(URL_CODE_PARAM_NAME);\n}\n\nexport function clearIsPopupFromUrl() {\n resetUrlParam(URL_REDIRECT_MODE_PARAM_NAME);\n}\n\nexport function clearExchangeErrorFromUrl() {\n resetUrlParam(URL_ERR_PARAM_NAME);\n}\n\nexport function getRedirectAuthFromUrl() {\n const redirectAuthCodeChallenge = getUrlParam(\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n );\n const redirectAuthCallbackUrl = getUrlParam(\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n );\n const redirectAuthBackupCallbackUri = getUrlParam(\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n );\n const redirectAuthInitiator = getUrlParam(\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n );\n return {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n };\n}\n\nexport function getOIDCIDPParamFromUrl() {\n return getUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearOIDCIDPParamFromUrl() {\n resetUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPParamFromUrl() {\n return getUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearSAMLIDPParamFromUrl() {\n resetUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getWSFedIDPParamFromUrl() {\n return getUrlParam(WSFED_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearWSFedIDPParamFromUrl() {\n resetUrlParam(WSFED_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPUsernameParamFromUrl() {\n return getUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function clearSAMLIDPUsernameParamFromUrl() {\n resetUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function getDescopeIDPInitiatedParamFromUrl() {\n return getUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function clearDescopeIDPInitiatedParamFromUrl() {\n resetUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function getSSOAppIdParamFromUrl() {\n return getUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function getCustomAppIdParamFromUrl() {\n return getUrlParam(CUSTOM_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function clearSSOAppIdParamFromUrl() {\n resetUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function clearCustomAppIdParamFromUrl() {\n resetUrlParam(CUSTOM_APP_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppStateIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppStateIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function getApplicationScopesParamFromUrl() {\n return getUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function clearApplicationScopesParamFromUrl() {\n resetUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function getOIDCLoginHintParamFromUrl() {\n return getUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function clearOIDCLoginHintParamFromUrl() {\n resetUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function getOIDCPromptParamFromUrl() {\n return getUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function clearOIDCPromptParamFromUrl() {\n resetUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function getOIDCErrorRedirectUriParamFromUrl() {\n return getUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function clearOIDCErrorRedirectUriParamFromUrl() {\n resetUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function getOIDCResourceParamFromUrl() {\n return getUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport function clearOIDCResourceParamFromUrl() {\n resetUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport const camelCase = (s: string) =>\n s.replace(/-./g, (x) => x[1].toUpperCase());\n\nexport const createIsChanged =\n <T extends Record<string, any>>(state: T, prevState: T) =>\n (attrName: keyof T) =>\n state[attrName] !== prevState[attrName];\n\nexport const getElementDescopeAttributes = (ele: HTMLElement) =>\n Array.from(ele?.attributes || []).reduce((acc, attr) => {\n const descopeAttrName = new RegExp(\n `^${DESCOPE_ATTRIBUTE_PREFIX}(\\\\S+)$`,\n ).exec(attr.name)?.[1];\n\n return !descopeAttrName\n ? acc\n : Object.assign(acc, { [descopeAttrName]: attr.value });\n }, {});\n\nexport const getFlowConfig = (config: Record<string, any>, flowId: string) =>\n config?.flows?.[flowId] || {};\n\nexport const handleUrlParams = (\n flowId: string,\n logger: { debug: (...data: any[]) => void },\n) => {\n const { executionId, stepId, executionFlowId } = getRunIdsFromUrl(flowId);\n\n // if the flow id does not match, we do not want to read & remove any query params\n // because it's probably belongs to another flow\n if (executionFlowId && flowId !== executionFlowId) {\n logger.debug(\n 'Flow id does not match the execution flow id, skipping url params handling',\n );\n return { ssoQueryParams: {} };\n }\n\n if (executionId || stepId) {\n clearRunIdsFromUrl();\n }\n\n const token = getTokenFromUrl();\n if (token) {\n clearTokenFromUrl();\n }\n\n const code = getCodeFromUrl();\n if (code) {\n clearCodeFromUrl();\n }\n\n // this is used for oauth when we want to open the provider login page in a new tab\n const isPopup = getIsPopupFromUrl();\n if (isPopup) {\n clearIsPopupFromUrl();\n }\n\n const exchangeError = getExchangeErrorFromUrl();\n if (exchangeError) {\n clearExchangeErrorFromUrl();\n }\n\n // these query params are retained to allow the flow to be refreshed\n // without losing the redirect auth state\n const {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n } = getRedirectAuthFromUrl();\n\n const oidcIdpStateId = getOIDCIDPParamFromUrl();\n if (oidcIdpStateId) {\n clearOIDCIDPParamFromUrl();\n }\n\n const samlIdpStateId = getSAMLIDPParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPParamFromUrl();\n }\n\n const wsfedIdpStateId = getWSFedIDPParamFromUrl();\n if (wsfedIdpStateId) {\n clearWSFedIDPParamFromUrl();\n }\n\n const samlIdpUsername = getSAMLIDPUsernameParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPUsernameParamFromUrl();\n }\n\n const descopeIdpInitiated = getDescopeIDPInitiatedParamFromUrl();\n if (descopeIdpInitiated) {\n clearDescopeIDPInitiatedParamFromUrl();\n }\n\n const ssoAppId = getSSOAppIdParamFromUrl();\n if (ssoAppId) {\n clearSSOAppIdParamFromUrl();\n }\n\n const customAppId = getCustomAppIdParamFromUrl();\n if (customAppId) {\n clearCustomAppIdParamFromUrl();\n }\n\n const thirdPartyAppId = getThirdPartyAppIdParamFromUrl();\n if (thirdPartyAppId) {\n clearThirdPartyAppIdParamFromUrl();\n }\n\n const thirdPartyAppStateId = getThirdPartyAppStateIdParamFromUrl();\n if (thirdPartyAppStateId) {\n clearThirdPartyAppStateIdParamFromUrl();\n }\n\n const applicationScopes = getApplicationScopesParamFromUrl();\n if (applicationScopes) {\n clearApplicationScopesParamFromUrl();\n }\n\n const oidcLoginHint = getOIDCLoginHintParamFromUrl();\n if (oidcLoginHint) {\n clearOIDCLoginHintParamFromUrl();\n }\n\n const oidcPrompt = getOIDCPromptParamFromUrl();\n if (oidcPrompt) {\n clearOIDCPromptParamFromUrl();\n }\n\n const oidcErrorRedirectUri = getOIDCErrorRedirectUriParamFromUrl();\n if (oidcErrorRedirectUri) {\n clearOIDCErrorRedirectUriParamFromUrl();\n }\n\n const oidcResource = getOIDCResourceParamFromUrl();\n if (oidcResource) {\n clearOIDCResourceParamFromUrl();\n }\n\n const idpInitiatedVal = descopeIdpInitiated === 'true';\n\n return {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n ssoQueryParams: {\n oidcIdpStateId,\n samlIdpStateId,\n wsfedIdpStateId,\n samlIdpUsername,\n descopeIdpInitiated: idpInitiatedVal,\n ssoAppId,\n customAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n },\n };\n};\n\nexport const loadFont = (url: string) => {\n if (!url) return;\n\n const font = document.createElement('link');\n font.href = url;\n font.rel = 'stylesheet';\n document.head.appendChild(font);\n};\n\nconst compareArrays = (array1: any[], array2: any[]) =>\n array1.length === array2.length &&\n array1.every((value: any, index: number) => value === array2[index]);\n\nexport const withMemCache = <I extends any[], O>(fn: (...args: I) => O) => {\n let prevArgs: any[];\n let cache: any;\n return Object.assign(\n (...args: I) => {\n if (prevArgs && compareArrays(prevArgs, args)) return cache as O;\n\n prevArgs = args;\n cache = fn(...args);\n\n return cache as O;\n },\n {\n reset: () => {\n prevArgs = undefined;\n cache = undefined;\n },\n },\n );\n};\n\nexport const FOCUSABLE_INPUTS_SELECTOR =\n '*[name]:not([auto-focus=\"false\"]):not([aria-hidden=\"true\"])';\n\nexport const handleAutoFocus = (\n ele: HTMLElement,\n autoFocus: AutoFocusOptions,\n isFirstScreen: boolean,\n) => {\n if (\n autoFocus === true ||\n (autoFocus === 'skipFirstScreen' && !isFirstScreen)\n ) {\n // focus the first visible input\n const firstVisibleInput: HTMLInputElement = ele.querySelector(\n FOCUSABLE_INPUTS_SELECTOR,\n );\n setTimeout(() => {\n firstVisibleInput?.focus();\n });\n }\n};\n\nexport const handleReportValidityOnBlur = (rootEle: HTMLElement) => {\n rootEle.querySelectorAll('*[name]').forEach((ele: HTMLInputElement) => {\n ele.addEventListener('blur', () => {\n const onBlur = () => {\n // reportValidity also focus the element if it's invalid\n // in order to prevent this we need to override the focus method\n const origFocus = ele.focus;\n // eslint-disable-next-line no-param-reassign\n ele.focus = () => {};\n ele.reportValidity?.();\n setTimeout(() => {\n // eslint-disable-next-line no-param-reassign\n ele.focus = origFocus;\n });\n };\n\n const isInputAlreadyInErrorState = ele.getAttribute('invalid') === 'true';\n\n if (isInputAlreadyInErrorState || ele.value?.length) {\n onBlur();\n return;\n }\n\n // If the input is not in an error state, has no value, and a `formnovalidate` button was clicked,\n // we want to prevent triggering validation.\n // This handles a case where a required input was focused, and the user then clicked a social login button —\n // in that case, we don't want the required error message to flash for a split second.\n const ref = { timer: undefined };\n\n const onClick = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n\n if (target.getAttribute('formnovalidate') === 'true') {\n clearTimeout(ref.timer);\n ref.timer = undefined;\n }\n };\n\n ref.timer = setTimeout(() => {\n rootEle.removeEventListener('click', onClick);\n onBlur();\n ref.timer = undefined;\n }, 150);\n\n rootEle.addEventListener('click', onClick, { once: true });\n });\n });\n};\n\n/**\n * To return a fallback value in case the timeout expires and the promise\n * isn't fulfilled:\n *\n * const promise = loadUserCount();\n * const count = await timeoutPromise(2000, promise, 0);\n *\n * Or without a fallback value to just throw an error if the timeout expires:\n *\n * try {\n * count = await timeoutPromise(2000, promise);\n * }\n *\n * Fallback is returned only in case of timeout, so if the passed promise rejects\n * the fallback value is not used, and the returned promise will throw as well.\n */\nexport function timeoutPromise<T>(\n timeout: number,\n promise: Promise<T>,\n fallback?: T,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n let expired = false;\n const timer = setTimeout(() => {\n expired = true;\n if (fallback !== undefined) {\n resolve(fallback);\n } else {\n reject(new Error(`Promise timed out after ${timeout} ms`));\n }\n }, timeout);\n\n promise\n .then((value) => {\n if (!expired) {\n clearTimeout(timer);\n resolve(value);\n }\n })\n .catch((error) => {\n if (!expired) {\n clearTimeout(timer);\n reject(error);\n }\n });\n });\n}\n\nexport const getChromiumVersion = (): number => {\n const brands = (navigator as any)?.userAgentData?.brands;\n const found = brands?.find(\n ({ brand, version }) => brand === 'Chromium' && parseFloat(version),\n );\n return found ? found.version : 0;\n};\n\n// As an optimization - We can show first screen if we have startScreenId and we don't have any other of the ssoAppId/oidcIdpStateId/samlIdp params\n// - If there startScreenId it means that the sdk can show the first screen and we don't need to wait for the sdk to return the first screen\n// - If there is any one else of the other params (like oidcIdpStateId, ..) - we can't skip this call because descope may decide not to show the first screen (in cases like a user is already logged in)\nexport const showFirstScreenOnExecutionInit = (\n startScreenId: string,\n {\n oidcIdpStateId,\n samlIdpStateId,\n wsfedIdpStateId,\n samlIdpUsername,\n ssoAppId,\n customAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n }: SSOQueryParams,\n): boolean =>\n !!startScreenId &&\n !oidcIdpStateId &&\n !samlIdpStateId &&\n !wsfedIdpStateId &&\n !samlIdpUsername &&\n !ssoAppId &&\n !customAppId &&\n !oidcLoginHint &&\n !oidcPrompt &&\n !oidcErrorRedirectUri &&\n !oidcResource &&\n !thirdPartyAppId &&\n !thirdPartyAppStateId &&\n !applicationScopes;\n\nexport const injectSamlIdpForm = (\n url: string,\n samlResponse: string,\n relayState: string,\n submitCallback: (form: HTMLFormElement) => void,\n) => {\n const formEle = document.createElement('form');\n formEle.method = 'POST';\n formEle.action = url;\n formEle.innerHTML = `\n <input type=\"hidden\" role=\"saml-response\" name=\"SAMLResponse\" value=\"${samlResponse}\" />\n <input type=\"hidden\" role=\"saml-relay-state\" name=\"RelayState\" value=\"${relayState}\" />\n <input style=\"display: none;\" id=\"SAMLSubmitButton\" type=\"submit\" value=\"Continue\" />\n `;\n\n document.body.appendChild(formEle);\n\n submitCallback(formEle);\n};\n\nexport const injectWsFedIdpForm = (\n url: string,\n wresult: string,\n wctx: string,\n submitCallback: (form: HTMLFormElement) => void,\n) => {\n const formEle = document.createElement('form');\n formEle.method = 'POST';\n formEle.action = url;\n\n // Use DOM APIs to set values safely — wresult is raw XML that would break innerHTML interpolation\n const createHiddenInput = (name: string, value: string) => {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n return input;\n };\n\n formEle.appendChild(createHiddenInput('wa', 'wsignin1.0'));\n formEle.appendChild(createHiddenInput('wresult', wresult));\n formEle.appendChild(createHiddenInput('wctx', wctx));\n\n const submitBtn = document.createElement('input');\n submitBtn.type = 'submit';\n submitBtn.id = 'WSFedSubmitButton';\n submitBtn.value = 'Continue';\n submitBtn.style.display = 'none';\n formEle.appendChild(submitBtn);\n\n document.body.appendChild(formEle);\n\n submitCallback(formEle);\n};\n\nexport const submitForm = (formEle: HTMLFormElement) => formEle?.submit();\n\nexport const getFirstNonEmptyValue = (obj: object, keys: string[]) => {\n const firstNonEmptyKey = keys.find((key) => obj[key]);\n return firstNonEmptyKey ? obj[firstNonEmptyKey] : null;\n};\n\nexport const leadingDebounce = <T extends (...args: any[]) => void>(\n func: T,\n wait = 100,\n) => {\n let timeout: NodeJS.Timeout;\n return function executedFunction(...args) {\n if (!timeout) func.apply(this, args);\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n timeout = null;\n }, wait);\n } as T;\n};\n\nexport const clearPreviousExternalInputs = () => {\n document\n .querySelectorAll('[data-hidden-input=\"true\"]')\n .forEach((ele) => ele.remove());\n};\n\nexport const shouldHandleMarkdown = (compName: string) =>\n MD_COMPONENTS.includes(compName);\n\nconst omitBy = <T extends Record<string, any>>(\n obj: T,\n predicate: (value: any, key: keyof T) => boolean,\n): T =>\n Object.fromEntries(\n Object.entries(obj).filter(\n ([key, value]) => !predicate(value, key as keyof T),\n ),\n ) as T;\n\n// Reads the `data-name` value out of a `[data-name=\"x\"]` selector (either quote style).\nconst dataNameOf = (selector: string): string | undefined =>\n selector.match(/\\[data-name=[\"']([^\"']+)[\"']\\]/)?.[1];\n\nconst PASSWORD_POLICY_KEYS: Record<string, string> = {\n minLength: 'data-password-policy-value-minlength',\n strength: 'data-password-policy-value-passwordstrength',\n disallowedChars: 'data-password-policy-value-disallowedchars',\n email: 'data-password-policy-value-email',\n activePolicies: 'active-policies',\n availablePolicies: 'available-policies',\n};\n\n// Renames the backend's password-policy attribute keys to clean names.\n// Returns undefined when the screen has no password policy.\nconst normalizePasswordPolicy = (\n newPassword: Record<string, any> | undefined,\n): Record<string, unknown> | undefined => {\n if (!newPassword) return undefined;\n const policy = Object.fromEntries(\n Object.entries(PASSWORD_POLICY_KEYS)\n .map(([clean, raw]) => [clean, newPassword[raw]])\n .filter(([, v]) => v !== undefined),\n );\n return Object.keys(policy).length ? policy : undefined;\n};\n\n// Reads one `componentsDynamicAttrs` entry by its `[data-name=\"…\"]` name. The backend\n// keys these by CSS selector, so we match on the data-name rather than the raw key.\nconst dynamicAttrsOf = (\n componentsConfig: ComponentsConfig | undefined,\n name: string,\n): Record<string, any> | undefined => {\n const entries = componentsConfig?.componentsDynamicAttrs;\n if (!entries) return undefined;\n const match = Object.entries(entries).find(\n ([selector]) => dataNameOf(selector) === name,\n );\n return match?.[1]?.attributes;\n};\n\nconst recoveryCodesOf = (componentsConfig: ComponentsConfig | undefined) => {\n const attributes = dynamicAttrsOf(componentsConfig, 'recoveryCodes');\n if (!attributes) return undefined;\n return Array.isArray(attributes.data)\n ? attributes.data.map((code: { value: string }) => code.value)\n : [];\n};\n\nconst outboundAppOf = (componentsConfig: ComponentsConfig | undefined) => {\n const attributes = dynamicAttrsOf(componentsConfig, 'outboundApp');\n if (!attributes) return undefined;\n return {\n label: attributes.label,\n iconSrc: attributes['icon-src'],\n appId: attributes['data-descope-outbound-oauth-app-id'],\n };\n};\n\n// The complete, allow-listed contract for `context.data`: one entry per `data` field,\n// each with the `data` key and a `from` reader over the raw screen state. Every field\n// is defined the same way and at the same level. Because we only read the fields listed\n// here, all other screen-state data is left out by construction — internal backend\n// fields, and dynamic-select options (which the backend spreads into componentsConfig\n// under arbitrary flow-defined keys). Exposing those is reserved for a future\n// `data.selects` map. Mirrors the backend `ExternalStateContext` / `ComponentsConfig`\n// structs (orchestrationservice .../domain/context.go).\nconst DATA_FIELDS: {\n key: string;\n from: (screenState: ScreenState) => unknown;\n}[] = [\n // moved verbatim from the top level of the screen state\n { key: 'totp', from: (s) => s.totp },\n { key: 'notp', from: (s) => s.notp },\n { key: 'sentTo', from: (s) => s.sentTo },\n { key: 'sso', from: (s) => s.sso },\n { key: 'selfProvisionDomains', from: (s) => s.selfProvisionDomains },\n // from componentsConfig — renamed, most unwrapped from a `{ data }` / `{ options }` wrapper\n {\n key: 'inboundAppApproveScopes',\n from: (s) => s.componentsConfig?.thirdPartyAppApproveScopes?.data,\n },\n { key: 'securityQuestionsSetup', from: (s) => s.componentsConfig?.sqSetup },\n { key: 'securityQuestionsVerify', from: (s) => s.componentsConfig?.sqVerify },\n {\n key: 'userTenants',\n from: (s) => s.componentsConfig?.userSelectedTenant?.data,\n },\n { key: 'userRoles', from: (s) => s.componentsConfig?.userRoles?.data },\n {\n key: 'ssoApplications',\n from: (s) => s.componentsConfig?.ssoApplications?.data,\n },\n {\n key: 'ssoConfigurations',\n from: (s) => s.componentsConfig?.ssoConfigurations?.data,\n },\n {\n key: 'samlAttributeMappings',\n from: (s) => s.componentsConfig?.samlMappings?.options,\n },\n {\n key: 'oidcAttributeMappings',\n from: (s) => s.componentsConfig?.oidcMappings?.options,\n },\n {\n key: 'samlGroupMappings',\n from: (s) => s.componentsConfig?.samlGroupMappings?.options,\n },\n {\n key: 'passwordPolicy',\n from: (s) => normalizePasswordPolicy(s.componentsConfig?.newPassword),\n },\n // from componentsConfig.componentsDynamicAttrs, matched by [data-name=\"…\"]\n { key: 'recoveryCodes', from: (s) => recoveryCodesOf(s.componentsConfig) },\n { key: 'outboundApp', from: (s) => outboundAppOf(s.componentsConfig) },\n];\n\n/**\n * Build the custom-screen `data` field — all server-produced screen data in one place.\n * Every field is declared in DATA_FIELDS as a `data` key + a reader over the raw screen\n * state; this function just applies them and skips any whose reader returns undefined.\n * Returns undefined when nothing was produced.\n */\nconst buildCustomScreenData = (\n screenState: ScreenState | undefined,\n): CustomScreenData | undefined => {\n if (!screenState) return undefined;\n\n const data: Record<string, unknown> = {};\n DATA_FIELDS.forEach(({ key, from }) => {\n const value = from(screenState);\n if (value !== undefined) data[key] = value;\n });\n\n return Object.keys(data).length ? (data as CustomScreenData) : undefined;\n};\n\nexport const transformStepStateForCustomScreen = (\n state: Partial<StepState>,\n) => {\n const sanitizedState: CustomScreenState = omitBy(\n state.screenState,\n (_, key) => EXCLUDED_STATE_KEYS.includes(key) || key.startsWith('_'),\n );\n\n const {\n screenState: { errorText, errorType },\n } = state;\n\n if (errorText || errorType) {\n sanitizedState.error = { text: errorText, type: errorType };\n }\n\n if (state.action) {\n sanitizedState.action = state.action;\n }\n\n // `data` is SDK-owned and stripped from the raw state via EXCLUDED_STATE_KEYS,\n // so a backend-provided `data` never leaks through — we always set our own below.\n const data = buildCustomScreenData(state.screenState);\n if (data) {\n sanitizedState.data = data;\n }\n\n return sanitizedState;\n};\n\nexport const transformScreenInputs = (inputs: Record<string, any>) => {\n const res = { ...inputs };\n\n if (inputs.inboundAppApproveScopes) {\n res.thirdPartyAppApproveScopes = inputs.inboundAppApproveScopes;\n }\n\n return res;\n};\n\nexport function getScriptResultPath(scriptId: string, resultKey?: string) {\n const path = resultKey ? `${scriptId}_${resultKey}` : scriptId;\n return `${SDK_SCRIPT_RESULTS_KEY}.${path}`;\n}\n\nexport const openCenteredPopup = (\n url: string,\n title: string,\n w: number,\n h: number,\n) => {\n const dualScreenLeft =\n window.screenLeft !== undefined\n ? window.screenLeft\n : (window.screen as any).left;\n const dualScreenTop =\n window.screenTop !== undefined\n ? window.screenTop\n : (window.screen as any).top;\n\n const width =\n window.innerWidth ||\n document.documentElement.clientWidth ||\n window.screen.width;\n const height =\n window.innerHeight ||\n document.documentElement.clientHeight ||\n window.screen.height;\n\n const left = (width - w) / 2 + dualScreenLeft;\n const top = (height - h) / 2 + dualScreenTop;\n\n // Safari on Mac may detect authentication URLs and replace the popup with a native macOS auth dialog.\n // To avoid that, we open the popup with empty string as URL and then populate it with the needed URL.\n // This avoids the native dialog, and uses the web interface for authentication.\n const initialUrl = isIphoneSafari() ? 'about:blank' : '';\n const popup = window.open(\n initialUrl,\n title,\n `width=${w},height=${h},top=${top},left=${left},scrollbars=yes,resizable=yes`,\n );\n\n popup.location.href = url;\n popup.focus();\n\n return popup;\n};\n"],"names":["MD_COMPONENTS","withRetry","fn","timeoutMs","maxRetries","args","__awaiter","this","lastError","totalAttempts","attempt","error","Promise","resolve","setTimeout","Math","pow","getUrlParam","paramName","URLSearchParams","window","location","search","get","resetUrlParam","history","replaceState","newUrl","URL","href","delete","toString","fetchContent","url","returnType","res","fetch","cache","ok","Error","status","body","headers","Object","fromEntries","entries","getContentUrl","projectId","filename","assetsFolder","ASSETS_FOLDER","baseUrl","OVERRIDE_CONTENT_URL","BASE_CONTENT_URL","pathname","paths","join","replace","pathJoin","getAnimationDirection","currentIdxStr","prevIdxStr","currentIdx","prevIdx","Number","isNaN","Direction","forward","backward","getRunIdsFromUrl","flowId","executionId","stepId","URL_RUN_IDS_PARAM_NAME","split","executionFlowId","_a","exec","getFlowIdFromExecId","isChromium","test","navigator","userAgent","vendor","clearRunIdsFromUrl","getTokenFromUrl","URL_TOKEN_PARAM_NAME","undefined","clearTokenFromUrl","getCodeFromUrl","URL_CODE_PARAM_NAME","getIsPopupFromUrl","URL_REDIRECT_MODE_PARAM_NAME","getExchangeErrorFromUrl","URL_ERR_PARAM_NAME","clearCodeFromUrl","clearIsPopupFromUrl","clearExchangeErrorFromUrl","getRedirectAuthFromUrl","redirectAuthCodeChallenge","URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME","redirectAuthCallbackUrl","URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME","redirectAuthBackupCallbackUri","URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME","redirectAuthInitiator","URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME","getOIDCIDPParamFromUrl","OIDC_IDP_STATE_ID_PARAM_NAME","clearOIDCIDPParamFromUrl","getSAMLIDPParamFromUrl","SAML_IDP_STATE_ID_PARAM_NAME","clearSAMLIDPParamFromUrl","getWSFedIDPParamFromUrl","WSFED_IDP_STATE_ID_PARAM_NAME","clearWSFedIDPParamFromUrl","getSAMLIDPUsernameParamFromUrl","SAML_IDP_USERNAME_PARAM_NAME","clearSAMLIDPUsernameParamFromUrl","getDescopeIDPInitiatedParamFromUrl","DESCOPE_IDP_INITIATED_PARAM_NAME","clearDescopeIDPInitiatedParamFromUrl","getSSOAppIdParamFromUrl","SSO_APP_ID_PARAM_NAME","getCustomAppIdParamFromUrl","CUSTOM_APP_ID_PARAM_NAME","getThirdPartyAppIdParamFromUrl","THIRD_PARTY_APP_ID_PARAM_NAME","clearSSOAppIdParamFromUrl","clearCustomAppIdParamFromUrl","clearThirdPartyAppIdParamFromUrl","getThirdPartyAppStateIdParamFromUrl","THIRD_PARTY_APP_STATE_ID_PARAM_NAME","clearThirdPartyAppStateIdParamFromUrl","getApplicationScopesParamFromUrl","APPLICATION_SCOPES_PARAM_NAME","clearApplicationScopesParamFromUrl","getOIDCLoginHintParamFromUrl","OIDC_LOGIN_HINT_PARAM_NAME","clearOIDCLoginHintParamFromUrl","getOIDCPromptParamFromUrl","OIDC_PROMPT_PARAM_NAME","clearOIDCPromptParamFromUrl","getOIDCErrorRedirectUriParamFromUrl","OIDC_ERROR_REDIRECT_URI_PARAM_NAME","clearOIDCErrorRedirectUriParamFromUrl","getOIDCResourceParamFromUrl","OIDC_RESOURCE_PARAM_NAME","clearOIDCResourceParamFromUrl","camelCase","s","x","toUpperCase","createIsChanged","state","prevState","attrName","getElementDescopeAttributes","ele","Array","from","attributes","reduce","acc","attr","descopeAttrName","RegExp","DESCOPE_ATTRIBUTE_PREFIX","name","assign","value","handleUrlParams","logger","debug","ssoQueryParams","token","code","isPopup","exchangeError","oidcIdpStateId","samlIdpStateId","wsfedIdpStateId","samlIdpUsername","descopeIdpInitiated","ssoAppId","customAppId","thirdPartyAppId","thirdPartyAppStateId","applicationScopes","oidcLoginHint","oidcPrompt","oidcErrorRedirectUri","oidcResource","withMemCache","prevArgs","array2","array1","length","every","index","reset","FOCUSABLE_INPUTS_SELECTOR","handleAutoFocus","autoFocus","isFirstScreen","firstVisibleInput","querySelector","focus","handleReportValidityOnBlur","rootEle","querySelectorAll","forEach","addEventListener","onBlur","origFocus","reportValidity","call","getAttribute","ref","timer","onClick","e","target","clearTimeout","removeEventListener","once","timeoutPromise","timeout","promise","fallback","reject","expired","then","catch","getChromiumVersion","brands","userAgentData","found","find","brand","version","parseFloat","showFirstScreenOnExecutionInit","startScreenId","injectSamlIdpForm","samlResponse","relayState","submitCallback","formEle","document","createElement","method","action","innerHTML","appendChild","injectWsFedIdpForm","wresult","wctx","createHiddenInput","input","type","submitBtn","id","style","display","submitForm","submit","getFirstNonEmptyValue","obj","keys","firstNonEmptyKey","key","leadingDebounce","func","wait","apply","clearPreviousExternalInputs","remove","shouldHandleMarkdown","compName","includes","PASSWORD_POLICY_KEYS","minLength","strength","disallowedChars","email","activePolicies","availablePolicies","dynamicAttrsOf","componentsConfig","componentsDynamicAttrs","match","selector","dataNameOf","DATA_FIELDS","totp","notp","sentTo","sso","selfProvisionDomains","_b","thirdPartyAppApproveScopes","data","sqSetup","sqVerify","userSelectedTenant","userRoles","ssoApplications","ssoConfigurations","samlMappings","options","oidcMappings","samlGroupMappings","newPassword","policy","map","clean","raw","filter","v","normalizePasswordPolicy","isArray","recoveryCodesOf","label","iconSrc","appId","outboundAppOf","transformStepStateForCustomScreen","sanitizedState","screenState","predicate","_","EXCLUDED_STATE_KEYS","startsWith","errorText","errorType","text","buildCustomScreenData","transformScreenInputs","inputs","inboundAppApproveScopes","getScriptResultPath","scriptId","resultKey","SDK_SCRIPT_RESULTS_KEY","openCenteredPopup","title","w","h","dualScreenLeft","screenLeft","screen","left","dualScreenTop","screenTop","top","innerWidth","documentElement","clientWidth","width","innerHeight","clientHeight","height","initialUrl","ua","isIphone","isSafari","isIphoneSafari","popup","open"],"mappings":"0mCA0CA,MAAMA,EAAgB,CAAC,kCASPC,EACdC,EACAC,EACAC,GAEA,MAAO,IAAUC,IAAiCC,EAAAC,UAAA,OAAA,GAAA,YAChD,IAAIC,EACJ,MAAMC,EAAgBL,EAAa,EAGnC,IAAK,IAAIM,EAAU,EAAGA,EAAUD,EAAeC,IAC7C,IAEE,aAAaR,KAAMG,EACpB,CAAC,MAAOM,GACPH,EAAYG,EAGRD,EAAUN,UAEN,IAAIQ,SAASC,IACjBC,WAAWD,EAASV,EAAYY,KAAKC,IAAI,EAAGN,EAAU,GAAG,IAG9D,CAIH,MAAMF,CACR,GACF,CAEA,SAASS,EAAYC,GAGnB,OAFkB,IAAIC,gBAAgBC,OAAOC,SAASC,QAErCC,IAAIL,EACvB,CAgBA,SAASM,EAAcN,GACrB,GAAIE,OAAOK,QAAQC,cAAgBT,EAAYC,GAAY,CACzD,MAAMS,EAAS,IAAIC,IAAIR,OAAOC,SAASQ,MACjCP,EAAS,IAAIH,gBAAgBQ,EAAOL,QAC1CA,EAAOQ,OAAOZ,GACdS,EAAOL,OAASA,EAAOS,WACvBX,OAAOK,QAAQC,aAAa,CAAA,EAAI,GAAIC,EAAOI,WAC5C,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,EACtB+U,EAAMjK,QAECiK,CAAK"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/lib/helpers/helpers.ts"],"sourcesContent":["import {\n ASSETS_FOLDER,\n BASE_CONTENT_URL,\n DESCOPE_ATTRIBUTE_PREFIX,\n URL_CODE_PARAM_NAME,\n URL_ERR_PARAM_NAME,\n URL_RUN_IDS_PARAM_NAME,\n URL_TOKEN_PARAM_NAME,\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n OIDC_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_STATE_ID_PARAM_NAME,\n WSFED_IDP_STATE_ID_PARAM_NAME,\n SAML_IDP_USERNAME_PARAM_NAME,\n SSO_APP_ID_PARAM_NAME,\n CUSTOM_APP_ID_PARAM_NAME,\n OIDC_LOGIN_HINT_PARAM_NAME,\n DESCOPE_IDP_INITIATED_PARAM_NAME,\n OVERRIDE_CONTENT_URL,\n OIDC_PROMPT_PARAM_NAME,\n OIDC_RESOURCE_PARAM_NAME,\n OIDC_ERROR_REDIRECT_URI_PARAM_NAME,\n THIRD_PARTY_APP_ID_PARAM_NAME,\n THIRD_PARTY_APP_STATE_ID_PARAM_NAME,\n APPLICATION_SCOPES_PARAM_NAME,\n SDK_SCRIPT_RESULTS_KEY,\n URL_REDIRECT_MODE_PARAM_NAME,\n} from '../constants';\nimport { EXCLUDED_STATE_KEYS } from '../constants/customScreens';\nimport {\n AutoFocusOptions,\n ComponentsConfig,\n CustomScreenData,\n CustomScreenState,\n Direction,\n ScreenState,\n SSOQueryParams,\n StepState,\n} from '../types';\n\nconst MD_COMPONENTS = ['descope-enriched-text'];\n\n/**\n * Wraps an async function with retry logic\n * @param fn - The async function to wrap\n * @param timeoutMs - Time to wait between retries in milliseconds\n * @param maxRetries - Maximum number of retry attempts\n * @returns A new function with retry logic\n */\nexport function withRetry<TArgs extends any[], TReturn>(\n fn: (...args: TArgs) => Promise<TReturn>,\n timeoutMs: number,\n maxRetries: number,\n): (...args: TArgs) => Promise<TReturn> {\n return async (...args: TArgs): Promise<TReturn> => {\n let lastError: any;\n const totalAttempts = maxRetries + 1; // initial attempt + retries\n\n // eslint-disable-next-line no-plusplus\n for (let attempt = 0; attempt < totalAttempts; attempt++) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await fn(...args);\n } catch (error) {\n lastError = error;\n\n // Don't wait after the last attempt\n if (attempt < maxRetries) {\n // eslint-disable-next-line no-await-in-loop\n await new Promise((resolve) => {\n setTimeout(resolve, timeoutMs * Math.pow(2, attempt + 1));\n });\n }\n }\n }\n\n // All attempts failed, throw the last error\n throw lastError;\n };\n}\n\nfunction getUrlParam(paramName: string) {\n const urlParams = new URLSearchParams(window.location.search);\n\n return urlParams.get(paramName);\n}\n\nfunction getFlowUrlParam() {\n return getUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nfunction setFlowUrlParam(id: string) {\n if (window.history.pushState && id !== getFlowUrlParam()) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.set(URL_RUN_IDS_PARAM_NAME, id);\n newUrl.search = search.toString();\n window.history.pushState({}, '', newUrl.toString());\n }\n}\n\nfunction resetUrlParam(paramName: string) {\n if (window.history.replaceState && getUrlParam(paramName)) {\n const newUrl = new URL(window.location.href);\n const search = new URLSearchParams(newUrl.search);\n search.delete(paramName);\n newUrl.search = search.toString();\n window.history.replaceState({}, '', newUrl.toString());\n }\n}\n\nconst getFlowIdFromExecId = (executionId: string) => {\n const regex = /(.*)\\|#\\|.*/;\n return regex.exec(executionId)?.[1] || '';\n};\n\nexport async function fetchContent<T extends 'text' | 'json'>(\n url: string,\n returnType: T,\n): Promise<{\n body: T extends 'json' ? Record<string, any> : string;\n headers: Record<string, string>;\n}> {\n const res = await fetch(url, { cache: 'default' });\n if (!res.ok) {\n throw Error(`Error fetching URL ${url} [${res.status}]`);\n }\n\n return {\n body: await res[returnType || 'text'](),\n headers: Object.fromEntries(res.headers.entries()),\n };\n}\n\nconst pathJoin = (...paths: string[]) => paths.join('/').replace(/\\/+/g, '/'); // preventing duplicate separators\n\nexport function getContentUrl({\n projectId,\n filename,\n assetsFolder = ASSETS_FOLDER,\n baseUrl,\n}: {\n projectId: string;\n filename: string;\n assetsFolder?: string;\n baseUrl?: string;\n}) {\n const url = new URL(OVERRIDE_CONTENT_URL || baseUrl || BASE_CONTENT_URL);\n url.pathname = pathJoin(url.pathname, projectId, assetsFolder, filename);\n\n return url.toString();\n}\n\nexport function getAnimationDirection(\n currentIdxStr: string,\n prevIdxStr: string,\n) {\n if (!prevIdxStr) return undefined;\n\n const currentIdx = +currentIdxStr;\n const prevIdx = +prevIdxStr;\n\n if (Number.isNaN(currentIdx) || Number.isNaN(prevIdx)) return undefined;\n if (currentIdx > prevIdx) return Direction.forward;\n if (currentIdx < prevIdx) return Direction.backward;\n return undefined;\n}\n\nexport const getRunIdsFromUrl = (flowId: string) => {\n let [executionId = '', stepId = ''] = (getFlowUrlParam() || '').split('_');\n const executionFlowId = getFlowIdFromExecId(executionId);\n\n // if the flow id does not match, this execution id is not for this flow\n if (!flowId || (executionFlowId && executionFlowId !== flowId)) {\n executionId = '';\n stepId = '';\n }\n\n return { executionId, stepId, executionFlowId };\n};\n\nexport const setRunIdsOnUrl = (executionId: string, stepId: string) => {\n setFlowUrlParam([executionId, stepId].join('_'));\n};\n\nexport function isChromium() {\n return (\n /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)\n );\n}\n\n// Detect Safari running on iPhone specifically.\nfunction isIphoneSafari() {\n const ua = navigator.userAgent || '';\n const isIphone = /\\b(iPhone)\\b/.test(ua);\n // Safari UA contains 'Safari' and usually 'Version/X', exclude other iOS browsers\n const isSafari =\n /Safari/.test(ua) && !/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(ua);\n\n return isIphone && isSafari;\n}\n\nexport function clearRunIdsFromUrl() {\n resetUrlParam(URL_RUN_IDS_PARAM_NAME);\n}\n\nexport function getTokenFromUrl() {\n return getUrlParam(URL_TOKEN_PARAM_NAME) || undefined;\n}\n\nexport function clearTokenFromUrl() {\n resetUrlParam(URL_TOKEN_PARAM_NAME);\n}\n\nexport function getCodeFromUrl() {\n return getUrlParam(URL_CODE_PARAM_NAME) || undefined;\n}\n\nexport function getIsPopupFromUrl() {\n return getUrlParam(URL_REDIRECT_MODE_PARAM_NAME) === 'popup';\n}\n\nexport function getExchangeErrorFromUrl() {\n return getUrlParam(URL_ERR_PARAM_NAME) || undefined;\n}\n\nexport function clearCodeFromUrl() {\n resetUrlParam(URL_CODE_PARAM_NAME);\n}\n\nexport function clearIsPopupFromUrl() {\n resetUrlParam(URL_REDIRECT_MODE_PARAM_NAME);\n}\n\nexport function clearExchangeErrorFromUrl() {\n resetUrlParam(URL_ERR_PARAM_NAME);\n}\n\nexport function getRedirectAuthFromUrl() {\n const redirectAuthCodeChallenge = getUrlParam(\n URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,\n );\n const redirectAuthCallbackUrl = getUrlParam(\n URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,\n );\n const redirectAuthBackupCallbackUri = getUrlParam(\n URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,\n );\n const redirectAuthInitiator = getUrlParam(\n URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,\n );\n return {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n };\n}\n\nexport function getOIDCIDPParamFromUrl() {\n return getUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearOIDCIDPParamFromUrl() {\n resetUrlParam(OIDC_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPParamFromUrl() {\n return getUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearSAMLIDPParamFromUrl() {\n resetUrlParam(SAML_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getWSFedIDPParamFromUrl() {\n return getUrlParam(WSFED_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearWSFedIDPParamFromUrl() {\n resetUrlParam(WSFED_IDP_STATE_ID_PARAM_NAME);\n}\n\nexport function getSAMLIDPUsernameParamFromUrl() {\n return getUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function clearSAMLIDPUsernameParamFromUrl() {\n resetUrlParam(SAML_IDP_USERNAME_PARAM_NAME);\n}\n\nexport function getDescopeIDPInitiatedParamFromUrl() {\n return getUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function clearDescopeIDPInitiatedParamFromUrl() {\n resetUrlParam(DESCOPE_IDP_INITIATED_PARAM_NAME);\n}\n\nexport function getSSOAppIdParamFromUrl() {\n return getUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function getCustomAppIdParamFromUrl() {\n return getUrlParam(CUSTOM_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function clearSSOAppIdParamFromUrl() {\n resetUrlParam(SSO_APP_ID_PARAM_NAME);\n}\n\nexport function clearCustomAppIdParamFromUrl() {\n resetUrlParam(CUSTOM_APP_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_ID_PARAM_NAME);\n}\n\nexport function getThirdPartyAppStateIdParamFromUrl() {\n return getUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function clearThirdPartyAppStateIdParamFromUrl() {\n resetUrlParam(THIRD_PARTY_APP_STATE_ID_PARAM_NAME);\n}\n\nexport function getApplicationScopesParamFromUrl() {\n return getUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function clearApplicationScopesParamFromUrl() {\n resetUrlParam(APPLICATION_SCOPES_PARAM_NAME);\n}\n\nexport function getOIDCLoginHintParamFromUrl() {\n return getUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function clearOIDCLoginHintParamFromUrl() {\n resetUrlParam(OIDC_LOGIN_HINT_PARAM_NAME);\n}\n\nexport function getOIDCPromptParamFromUrl() {\n return getUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function clearOIDCPromptParamFromUrl() {\n resetUrlParam(OIDC_PROMPT_PARAM_NAME);\n}\n\nexport function getOIDCErrorRedirectUriParamFromUrl() {\n return getUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function clearOIDCErrorRedirectUriParamFromUrl() {\n resetUrlParam(OIDC_ERROR_REDIRECT_URI_PARAM_NAME);\n}\n\nexport function getOIDCResourceParamFromUrl() {\n return getUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport function clearOIDCResourceParamFromUrl() {\n resetUrlParam(OIDC_RESOURCE_PARAM_NAME);\n}\n\nexport const camelCase = (s: string) =>\n s.replace(/-./g, (x) => x[1].toUpperCase());\n\nexport const createIsChanged =\n <T extends Record<string, any>>(state: T, prevState: T) =>\n (attrName: keyof T) =>\n state[attrName] !== prevState[attrName];\n\nexport const getElementDescopeAttributes = (ele: HTMLElement) =>\n Array.from(ele?.attributes || []).reduce((acc, attr) => {\n const descopeAttrName = new RegExp(\n `^${DESCOPE_ATTRIBUTE_PREFIX}(\\\\S+)$`,\n ).exec(attr.name)?.[1];\n\n return !descopeAttrName\n ? acc\n : Object.assign(acc, { [descopeAttrName]: attr.value });\n }, {});\n\nexport const getFlowConfig = (config: Record<string, any>, flowId: string) =>\n config?.flows?.[flowId] || {};\n\nexport const handleUrlParams = (\n flowId: string,\n logger: { debug: (...data: any[]) => void },\n) => {\n const { executionId, stepId, executionFlowId } = getRunIdsFromUrl(flowId);\n\n // if the flow id does not match, we do not want to read & remove any query params\n // because it's probably belongs to another flow\n if (executionFlowId && flowId !== executionFlowId) {\n logger.debug(\n 'Flow id does not match the execution flow id, skipping url params handling',\n );\n return { ssoQueryParams: {} };\n }\n\n if (executionId || stepId) {\n clearRunIdsFromUrl();\n }\n\n const token = getTokenFromUrl();\n if (token) {\n clearTokenFromUrl();\n }\n\n const code = getCodeFromUrl();\n if (code) {\n clearCodeFromUrl();\n }\n\n // this is used for oauth when we want to open the provider login page in a new tab\n const isPopup = getIsPopupFromUrl();\n if (isPopup) {\n clearIsPopupFromUrl();\n }\n\n const exchangeError = getExchangeErrorFromUrl();\n if (exchangeError) {\n clearExchangeErrorFromUrl();\n }\n\n // these query params are retained to allow the flow to be refreshed\n // without losing the redirect auth state\n const {\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n } = getRedirectAuthFromUrl();\n\n const oidcIdpStateId = getOIDCIDPParamFromUrl();\n if (oidcIdpStateId) {\n clearOIDCIDPParamFromUrl();\n }\n\n const samlIdpStateId = getSAMLIDPParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPParamFromUrl();\n }\n\n const wsfedIdpStateId = getWSFedIDPParamFromUrl();\n if (wsfedIdpStateId) {\n clearWSFedIDPParamFromUrl();\n }\n\n const samlIdpUsername = getSAMLIDPUsernameParamFromUrl();\n if (samlIdpStateId) {\n clearSAMLIDPUsernameParamFromUrl();\n }\n\n const descopeIdpInitiated = getDescopeIDPInitiatedParamFromUrl();\n if (descopeIdpInitiated) {\n clearDescopeIDPInitiatedParamFromUrl();\n }\n\n const ssoAppId = getSSOAppIdParamFromUrl();\n if (ssoAppId) {\n clearSSOAppIdParamFromUrl();\n }\n\n const customAppId = getCustomAppIdParamFromUrl();\n if (customAppId) {\n clearCustomAppIdParamFromUrl();\n }\n\n const thirdPartyAppId = getThirdPartyAppIdParamFromUrl();\n if (thirdPartyAppId) {\n clearThirdPartyAppIdParamFromUrl();\n }\n\n const thirdPartyAppStateId = getThirdPartyAppStateIdParamFromUrl();\n if (thirdPartyAppStateId) {\n clearThirdPartyAppStateIdParamFromUrl();\n }\n\n const applicationScopes = getApplicationScopesParamFromUrl();\n if (applicationScopes) {\n clearApplicationScopesParamFromUrl();\n }\n\n const oidcLoginHint = getOIDCLoginHintParamFromUrl();\n if (oidcLoginHint) {\n clearOIDCLoginHintParamFromUrl();\n }\n\n const oidcPrompt = getOIDCPromptParamFromUrl();\n if (oidcPrompt) {\n clearOIDCPromptParamFromUrl();\n }\n\n const oidcErrorRedirectUri = getOIDCErrorRedirectUriParamFromUrl();\n if (oidcErrorRedirectUri) {\n clearOIDCErrorRedirectUriParamFromUrl();\n }\n\n const oidcResource = getOIDCResourceParamFromUrl();\n if (oidcResource) {\n clearOIDCResourceParamFromUrl();\n }\n\n const idpInitiatedVal = descopeIdpInitiated === 'true';\n\n return {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCodeChallenge,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthInitiator,\n ssoQueryParams: {\n oidcIdpStateId,\n samlIdpStateId,\n wsfedIdpStateId,\n samlIdpUsername,\n descopeIdpInitiated: idpInitiatedVal,\n ssoAppId,\n customAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n },\n };\n};\n\nexport const loadFont = (url: string) => {\n if (!url) return;\n\n const font = document.createElement('link');\n font.href = url;\n font.rel = 'stylesheet';\n document.head.appendChild(font);\n};\n\nconst compareArrays = (array1: any[], array2: any[]) =>\n array1.length === array2.length &&\n array1.every((value: any, index: number) => value === array2[index]);\n\nexport const withMemCache = <I extends any[], O>(fn: (...args: I) => O) => {\n let prevArgs: any[];\n let cache: any;\n return Object.assign(\n (...args: I) => {\n if (prevArgs && compareArrays(prevArgs, args)) return cache as O;\n\n prevArgs = args;\n cache = fn(...args);\n\n return cache as O;\n },\n {\n reset: () => {\n prevArgs = undefined;\n cache = undefined;\n },\n },\n );\n};\n\nexport const FOCUSABLE_INPUTS_SELECTOR =\n '*[name]:not([auto-focus=\"false\"]):not([aria-hidden=\"true\"])';\n\nexport const handleAutoFocus = (\n ele: HTMLElement,\n autoFocus: AutoFocusOptions,\n isFirstScreen: boolean,\n) => {\n if (\n autoFocus === true ||\n (autoFocus === 'skipFirstScreen' && !isFirstScreen)\n ) {\n // focus the first visible input\n const firstVisibleInput: HTMLInputElement = ele.querySelector(\n FOCUSABLE_INPUTS_SELECTOR,\n );\n setTimeout(() => {\n firstVisibleInput?.focus();\n });\n }\n};\n\nexport const handleReportValidityOnBlur = (\n rootEle: HTMLElement,\n // Best-effort callback invoked with the input that failed validation on\n // blur, so callers can track client-side validation errors. Never throws\n // into the blur handler.\n onInvalid?: (input: HTMLInputElement) => void,\n) => {\n rootEle.querySelectorAll('*[name]').forEach((ele: HTMLInputElement) => {\n ele.addEventListener('blur', () => {\n const onBlur = () => {\n // reportValidity also focus the element if it's invalid\n // in order to prevent this we need to override the focus method\n const origFocus = ele.focus;\n // eslint-disable-next-line no-param-reassign\n ele.focus = () => {};\n const valid = ele.reportValidity?.();\n if (onInvalid && valid === false) {\n onInvalid(ele);\n }\n setTimeout(() => {\n // eslint-disable-next-line no-param-reassign\n ele.focus = origFocus;\n });\n };\n\n const isInputAlreadyInErrorState = ele.getAttribute('invalid') === 'true';\n\n if (isInputAlreadyInErrorState || ele.value?.length) {\n onBlur();\n return;\n }\n\n // If the input is not in an error state, has no value, and a `formnovalidate` button was clicked,\n // we want to prevent triggering validation.\n // This handles a case where a required input was focused, and the user then clicked a social login button —\n // in that case, we don't want the required error message to flash for a split second.\n const ref = { timer: undefined };\n\n const onClick = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n\n if (target.getAttribute('formnovalidate') === 'true') {\n clearTimeout(ref.timer);\n ref.timer = undefined;\n }\n };\n\n ref.timer = setTimeout(() => {\n rootEle.removeEventListener('click', onClick);\n onBlur();\n ref.timer = undefined;\n }, 150);\n\n rootEle.addEventListener('click', onClick, { once: true });\n });\n });\n};\n\n/**\n * To return a fallback value in case the timeout expires and the promise\n * isn't fulfilled:\n *\n * const promise = loadUserCount();\n * const count = await timeoutPromise(2000, promise, 0);\n *\n * Or without a fallback value to just throw an error if the timeout expires:\n *\n * try {\n * count = await timeoutPromise(2000, promise);\n * }\n *\n * Fallback is returned only in case of timeout, so if the passed promise rejects\n * the fallback value is not used, and the returned promise will throw as well.\n */\nexport function timeoutPromise<T>(\n timeout: number,\n promise: Promise<T>,\n fallback?: T,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n let expired = false;\n const timer = setTimeout(() => {\n expired = true;\n if (fallback !== undefined) {\n resolve(fallback);\n } else {\n reject(new Error(`Promise timed out after ${timeout} ms`));\n }\n }, timeout);\n\n promise\n .then((value) => {\n if (!expired) {\n clearTimeout(timer);\n resolve(value);\n }\n })\n .catch((error) => {\n if (!expired) {\n clearTimeout(timer);\n reject(error);\n }\n });\n });\n}\n\nexport const getChromiumVersion = (): number => {\n const brands = (navigator as any)?.userAgentData?.brands;\n const found = brands?.find(\n ({ brand, version }) => brand === 'Chromium' && parseFloat(version),\n );\n return found ? found.version : 0;\n};\n\n// As an optimization - We can show first screen if we have startScreenId and we don't have any other of the ssoAppId/oidcIdpStateId/samlIdp params\n// - If there startScreenId it means that the sdk can show the first screen and we don't need to wait for the sdk to return the first screen\n// - If there is any one else of the other params (like oidcIdpStateId, ..) - we can't skip this call because descope may decide not to show the first screen (in cases like a user is already logged in)\nexport const showFirstScreenOnExecutionInit = (\n startScreenId: string,\n {\n oidcIdpStateId,\n samlIdpStateId,\n wsfedIdpStateId,\n samlIdpUsername,\n ssoAppId,\n customAppId,\n oidcLoginHint,\n oidcPrompt,\n oidcErrorRedirectUri,\n oidcResource,\n thirdPartyAppId,\n thirdPartyAppStateId,\n applicationScopes,\n }: SSOQueryParams,\n): boolean =>\n !!startScreenId &&\n !oidcIdpStateId &&\n !samlIdpStateId &&\n !wsfedIdpStateId &&\n !samlIdpUsername &&\n !ssoAppId &&\n !customAppId &&\n !oidcLoginHint &&\n !oidcPrompt &&\n !oidcErrorRedirectUri &&\n !oidcResource &&\n !thirdPartyAppId &&\n !thirdPartyAppStateId &&\n !applicationScopes;\n\n// Use DOM APIs to set values safely - these are server-provided values (raw XML,\n// base64, opaque relay state) that would break innerHTML interpolation\nconst createHiddenInput = (name: string, value: string, role?: string) => {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n if (role) {\n input.setAttribute('role', role);\n }\n return input;\n};\n\nexport const injectSamlIdpForm = (\n url: string,\n samlResponse: string,\n relayState: string,\n submitCallback: (form: HTMLFormElement) => void,\n) => {\n const formEle = document.createElement('form');\n formEle.method = 'POST';\n formEle.action = url;\n\n formEle.appendChild(\n createHiddenInput('SAMLResponse', samlResponse, 'saml-response'),\n );\n formEle.appendChild(\n createHiddenInput('RelayState', relayState, 'saml-relay-state'),\n );\n\n const submitBtn = document.createElement('input');\n submitBtn.type = 'submit';\n submitBtn.id = 'SAMLSubmitButton';\n submitBtn.value = 'Continue';\n submitBtn.style.display = 'none';\n formEle.appendChild(submitBtn);\n\n document.body.appendChild(formEle);\n\n submitCallback(formEle);\n};\n\nexport const injectWsFedIdpForm = (\n url: string,\n wresult: string,\n wctx: string,\n submitCallback: (form: HTMLFormElement) => void,\n) => {\n const formEle = document.createElement('form');\n formEle.method = 'POST';\n formEle.action = url;\n\n formEle.appendChild(createHiddenInput('wa', 'wsignin1.0'));\n formEle.appendChild(createHiddenInput('wresult', wresult));\n formEle.appendChild(createHiddenInput('wctx', wctx));\n\n const submitBtn = document.createElement('input');\n submitBtn.type = 'submit';\n submitBtn.id = 'WSFedSubmitButton';\n submitBtn.value = 'Continue';\n submitBtn.style.display = 'none';\n formEle.appendChild(submitBtn);\n\n document.body.appendChild(formEle);\n\n submitCallback(formEle);\n};\n\nexport const submitForm = (formEle: HTMLFormElement) => formEle?.submit();\n\nexport const getFirstNonEmptyValue = (obj: object, keys: string[]) => {\n const firstNonEmptyKey = keys.find((key) => obj[key]);\n return firstNonEmptyKey ? obj[firstNonEmptyKey] : null;\n};\n\nexport const leadingDebounce = <T extends (...args: any[]) => void>(\n func: T,\n wait = 100,\n) => {\n let timeout: NodeJS.Timeout;\n return function executedFunction(...args) {\n if (!timeout) func.apply(this, args);\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n timeout = null;\n }, wait);\n } as T;\n};\n\nexport const clearPreviousExternalInputs = () => {\n document\n .querySelectorAll('[data-hidden-input=\"true\"]')\n .forEach((ele) => ele.remove());\n};\n\nexport const shouldHandleMarkdown = (compName: string) =>\n MD_COMPONENTS.includes(compName);\n\nconst omitBy = <T extends Record<string, any>>(\n obj: T,\n predicate: (value: any, key: keyof T) => boolean,\n): T =>\n Object.fromEntries(\n Object.entries(obj).filter(\n ([key, value]) => !predicate(value, key as keyof T),\n ),\n ) as T;\n\n// Reads the `data-name` value out of a `[data-name=\"x\"]` selector (either quote style).\nconst dataNameOf = (selector: string): string | undefined =>\n selector.match(/\\[data-name=[\"']([^\"']+)[\"']\\]/)?.[1];\n\nconst PASSWORD_POLICY_KEYS: Record<string, string> = {\n minLength: 'data-password-policy-value-minlength',\n strength: 'data-password-policy-value-passwordstrength',\n disallowedChars: 'data-password-policy-value-disallowedchars',\n email: 'data-password-policy-value-email',\n activePolicies: 'active-policies',\n availablePolicies: 'available-policies',\n};\n\n// Renames the backend's password-policy attribute keys to clean names.\n// Returns undefined when the screen has no password policy.\nconst normalizePasswordPolicy = (\n newPassword: Record<string, any> | undefined,\n): Record<string, unknown> | undefined => {\n if (!newPassword) return undefined;\n const policy = Object.fromEntries(\n Object.entries(PASSWORD_POLICY_KEYS)\n .map(([clean, raw]) => [clean, newPassword[raw]])\n .filter(([, v]) => v !== undefined),\n );\n return Object.keys(policy).length ? policy : undefined;\n};\n\n// Reads one `componentsDynamicAttrs` entry by its `[data-name=\"…\"]` name. The backend\n// keys these by CSS selector, so we match on the data-name rather than the raw key.\nconst dynamicAttrsOf = (\n componentsConfig: ComponentsConfig | undefined,\n name: string,\n): Record<string, any> | undefined => {\n const entries = componentsConfig?.componentsDynamicAttrs;\n if (!entries) return undefined;\n const match = Object.entries(entries).find(\n ([selector]) => dataNameOf(selector) === name,\n );\n return match?.[1]?.attributes;\n};\n\nconst recoveryCodesOf = (componentsConfig: ComponentsConfig | undefined) => {\n const attributes = dynamicAttrsOf(componentsConfig, 'recoveryCodes');\n if (!attributes) return undefined;\n return Array.isArray(attributes.data)\n ? attributes.data.map((code: { value: string }) => code.value)\n : [];\n};\n\nconst outboundAppOf = (componentsConfig: ComponentsConfig | undefined) => {\n const attributes = dynamicAttrsOf(componentsConfig, 'outboundApp');\n if (!attributes) return undefined;\n return {\n label: attributes.label,\n iconSrc: attributes['icon-src'],\n appId: attributes['data-descope-outbound-oauth-app-id'],\n };\n};\n\n// The complete, allow-listed contract for `context.data`: one entry per `data` field,\n// each with the `data` key and a `from` reader over the raw screen state. Every field\n// is defined the same way and at the same level. Because we only read the fields listed\n// here, all other screen-state data is left out by construction — internal backend\n// fields, and dynamic-select options (which the backend spreads into componentsConfig\n// under arbitrary flow-defined keys). Exposing those is reserved for a future\n// `data.selects` map. Mirrors the backend `ExternalStateContext` / `ComponentsConfig`\n// structs (orchestrationservice .../domain/context.go).\nconst DATA_FIELDS: {\n key: string;\n from: (screenState: ScreenState) => unknown;\n}[] = [\n // moved verbatim from the top level of the screen state\n { key: 'totp', from: (s) => s.totp },\n { key: 'notp', from: (s) => s.notp },\n { key: 'sentTo', from: (s) => s.sentTo },\n { key: 'sso', from: (s) => s.sso },\n { key: 'selfProvisionDomains', from: (s) => s.selfProvisionDomains },\n // from componentsConfig — renamed, most unwrapped from a `{ data }` / `{ options }` wrapper\n {\n key: 'inboundAppApproveScopes',\n from: (s) => s.componentsConfig?.thirdPartyAppApproveScopes?.data,\n },\n { key: 'securityQuestionsSetup', from: (s) => s.componentsConfig?.sqSetup },\n { key: 'securityQuestionsVerify', from: (s) => s.componentsConfig?.sqVerify },\n {\n key: 'userTenants',\n from: (s) => s.componentsConfig?.userSelectedTenant?.data,\n },\n { key: 'userRoles', from: (s) => s.componentsConfig?.userRoles?.data },\n {\n key: 'ssoApplications',\n from: (s) => s.componentsConfig?.ssoApplications?.data,\n },\n {\n key: 'ssoConfigurations',\n from: (s) => s.componentsConfig?.ssoConfigurations?.data,\n },\n {\n key: 'samlAttributeMappings',\n from: (s) => s.componentsConfig?.samlMappings?.options,\n },\n {\n key: 'oidcAttributeMappings',\n from: (s) => s.componentsConfig?.oidcMappings?.options,\n },\n {\n key: 'samlGroupMappings',\n from: (s) => s.componentsConfig?.samlGroupMappings?.options,\n },\n {\n key: 'passwordPolicy',\n from: (s) => normalizePasswordPolicy(s.componentsConfig?.newPassword),\n },\n // from componentsConfig.componentsDynamicAttrs, matched by [data-name=\"…\"]\n { key: 'recoveryCodes', from: (s) => recoveryCodesOf(s.componentsConfig) },\n { key: 'outboundApp', from: (s) => outboundAppOf(s.componentsConfig) },\n];\n\n/**\n * Build the custom-screen `data` field — all server-produced screen data in one place.\n * Every field is declared in DATA_FIELDS as a `data` key + a reader over the raw screen\n * state; this function just applies them and skips any whose reader returns undefined.\n * Returns undefined when nothing was produced.\n */\nconst buildCustomScreenData = (\n screenState: ScreenState | undefined,\n): CustomScreenData | undefined => {\n if (!screenState) return undefined;\n\n const data: Record<string, unknown> = {};\n DATA_FIELDS.forEach(({ key, from }) => {\n const value = from(screenState);\n if (value !== undefined) data[key] = value;\n });\n\n return Object.keys(data).length ? (data as CustomScreenData) : undefined;\n};\n\nexport const transformStepStateForCustomScreen = (\n state: Partial<StepState>,\n) => {\n const sanitizedState: CustomScreenState = omitBy(\n state.screenState,\n (_, key) => EXCLUDED_STATE_KEYS.includes(key) || key.startsWith('_'),\n );\n\n const {\n screenState: { errorText, errorType },\n } = state;\n\n if (errorText || errorType) {\n sanitizedState.error = { text: errorText, type: errorType };\n }\n\n if (state.action) {\n sanitizedState.action = state.action;\n }\n\n // `data` is SDK-owned and stripped from the raw state via EXCLUDED_STATE_KEYS,\n // so a backend-provided `data` never leaks through — we always set our own below.\n const data = buildCustomScreenData(state.screenState);\n if (data) {\n sanitizedState.data = data;\n }\n\n return sanitizedState;\n};\n\nexport const transformScreenInputs = (inputs: Record<string, any>) => {\n const res = { ...inputs };\n\n if (inputs.inboundAppApproveScopes) {\n res.thirdPartyAppApproveScopes = inputs.inboundAppApproveScopes;\n }\n\n return res;\n};\n\nexport function getScriptResultPath(scriptId: string, resultKey?: string) {\n const path = resultKey ? `${scriptId}_${resultKey}` : scriptId;\n return `${SDK_SCRIPT_RESULTS_KEY}.${path}`;\n}\n\nexport const openCenteredPopup = (\n url: string,\n title: string,\n w: number,\n h: number,\n) => {\n const dualScreenLeft =\n window.screenLeft !== undefined\n ? window.screenLeft\n : (window.screen as any).left;\n const dualScreenTop =\n window.screenTop !== undefined\n ? window.screenTop\n : (window.screen as any).top;\n\n const width =\n window.innerWidth ||\n document.documentElement.clientWidth ||\n window.screen.width;\n const height =\n window.innerHeight ||\n document.documentElement.clientHeight ||\n window.screen.height;\n\n const left = (width - w) / 2 + dualScreenLeft;\n const top = (height - h) / 2 + dualScreenTop;\n\n // Safari on Mac may detect authentication URLs and replace the popup with a native macOS auth dialog.\n // To avoid that, we open the popup with empty string as URL and then populate it with the needed URL.\n // This avoids the native dialog, and uses the web interface for authentication.\n const initialUrl = isIphoneSafari() ? 'about:blank' : '';\n const popup = window.open(\n initialUrl,\n title,\n `width=${w},height=${h},top=${top},left=${left},scrollbars=yes,resizable=yes`,\n );\n\n popup.location.href = url;\n popup.focus();\n\n return popup;\n};\n"],"names":["MD_COMPONENTS","withRetry","fn","timeoutMs","maxRetries","args","__awaiter","this","lastError","totalAttempts","attempt","error","Promise","resolve","setTimeout","Math","pow","getUrlParam","paramName","URLSearchParams","window","location","search","get","resetUrlParam","history","replaceState","newUrl","URL","href","delete","toString","fetchContent","url","returnType","res","fetch","cache","ok","Error","status","body","headers","Object","fromEntries","entries","getContentUrl","projectId","filename","assetsFolder","ASSETS_FOLDER","baseUrl","OVERRIDE_CONTENT_URL","BASE_CONTENT_URL","pathname","paths","join","replace","pathJoin","getAnimationDirection","currentIdxStr","prevIdxStr","currentIdx","prevIdx","Number","isNaN","Direction","forward","backward","getRunIdsFromUrl","flowId","executionId","stepId","URL_RUN_IDS_PARAM_NAME","split","executionFlowId","_a","exec","getFlowIdFromExecId","isChromium","test","navigator","userAgent","vendor","clearRunIdsFromUrl","getTokenFromUrl","URL_TOKEN_PARAM_NAME","undefined","clearTokenFromUrl","getCodeFromUrl","URL_CODE_PARAM_NAME","getIsPopupFromUrl","URL_REDIRECT_MODE_PARAM_NAME","getExchangeErrorFromUrl","URL_ERR_PARAM_NAME","clearCodeFromUrl","clearIsPopupFromUrl","clearExchangeErrorFromUrl","getRedirectAuthFromUrl","redirectAuthCodeChallenge","URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME","redirectAuthCallbackUrl","URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME","redirectAuthBackupCallbackUri","URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME","redirectAuthInitiator","URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME","getOIDCIDPParamFromUrl","OIDC_IDP_STATE_ID_PARAM_NAME","clearOIDCIDPParamFromUrl","getSAMLIDPParamFromUrl","SAML_IDP_STATE_ID_PARAM_NAME","clearSAMLIDPParamFromUrl","getWSFedIDPParamFromUrl","WSFED_IDP_STATE_ID_PARAM_NAME","clearWSFedIDPParamFromUrl","getSAMLIDPUsernameParamFromUrl","SAML_IDP_USERNAME_PARAM_NAME","clearSAMLIDPUsernameParamFromUrl","getDescopeIDPInitiatedParamFromUrl","DESCOPE_IDP_INITIATED_PARAM_NAME","clearDescopeIDPInitiatedParamFromUrl","getSSOAppIdParamFromUrl","SSO_APP_ID_PARAM_NAME","getCustomAppIdParamFromUrl","CUSTOM_APP_ID_PARAM_NAME","getThirdPartyAppIdParamFromUrl","THIRD_PARTY_APP_ID_PARAM_NAME","clearSSOAppIdParamFromUrl","clearCustomAppIdParamFromUrl","clearThirdPartyAppIdParamFromUrl","getThirdPartyAppStateIdParamFromUrl","THIRD_PARTY_APP_STATE_ID_PARAM_NAME","clearThirdPartyAppStateIdParamFromUrl","getApplicationScopesParamFromUrl","APPLICATION_SCOPES_PARAM_NAME","clearApplicationScopesParamFromUrl","getOIDCLoginHintParamFromUrl","OIDC_LOGIN_HINT_PARAM_NAME","clearOIDCLoginHintParamFromUrl","getOIDCPromptParamFromUrl","OIDC_PROMPT_PARAM_NAME","clearOIDCPromptParamFromUrl","getOIDCErrorRedirectUriParamFromUrl","OIDC_ERROR_REDIRECT_URI_PARAM_NAME","clearOIDCErrorRedirectUriParamFromUrl","getOIDCResourceParamFromUrl","OIDC_RESOURCE_PARAM_NAME","clearOIDCResourceParamFromUrl","camelCase","s","x","toUpperCase","createIsChanged","state","prevState","attrName","getElementDescopeAttributes","ele","Array","from","attributes","reduce","acc","attr","descopeAttrName","RegExp","DESCOPE_ATTRIBUTE_PREFIX","name","assign","value","handleUrlParams","logger","debug","ssoQueryParams","token","code","isPopup","exchangeError","oidcIdpStateId","samlIdpStateId","wsfedIdpStateId","samlIdpUsername","descopeIdpInitiated","ssoAppId","customAppId","thirdPartyAppId","thirdPartyAppStateId","applicationScopes","oidcLoginHint","oidcPrompt","oidcErrorRedirectUri","oidcResource","withMemCache","prevArgs","array2","array1","length","every","index","reset","FOCUSABLE_INPUTS_SELECTOR","handleAutoFocus","autoFocus","isFirstScreen","firstVisibleInput","querySelector","focus","handleReportValidityOnBlur","rootEle","onInvalid","querySelectorAll","forEach","addEventListener","onBlur","origFocus","valid","reportValidity","getAttribute","ref","timer","onClick","e","target","clearTimeout","removeEventListener","once","timeoutPromise","timeout","promise","fallback","reject","expired","then","catch","getChromiumVersion","brands","userAgentData","found","find","brand","version","parseFloat","showFirstScreenOnExecutionInit","startScreenId","createHiddenInput","role","input","document","createElement","type","setAttribute","injectSamlIdpForm","samlResponse","relayState","submitCallback","formEle","method","action","appendChild","submitBtn","id","style","display","injectWsFedIdpForm","wresult","wctx","submitForm","submit","getFirstNonEmptyValue","obj","keys","firstNonEmptyKey","key","leadingDebounce","func","wait","apply","clearPreviousExternalInputs","remove","shouldHandleMarkdown","compName","includes","PASSWORD_POLICY_KEYS","minLength","strength","disallowedChars","email","activePolicies","availablePolicies","dynamicAttrsOf","componentsConfig","componentsDynamicAttrs","match","selector","dataNameOf","DATA_FIELDS","totp","notp","sentTo","sso","selfProvisionDomains","_b","thirdPartyAppApproveScopes","data","sqSetup","sqVerify","userSelectedTenant","userRoles","ssoApplications","ssoConfigurations","samlMappings","options","oidcMappings","samlGroupMappings","newPassword","policy","map","clean","raw","filter","v","normalizePasswordPolicy","isArray","recoveryCodesOf","label","iconSrc","appId","outboundAppOf","transformStepStateForCustomScreen","sanitizedState","screenState","predicate","_","EXCLUDED_STATE_KEYS","startsWith","errorText","errorType","text","buildCustomScreenData","transformScreenInputs","inputs","inboundAppApproveScopes","getScriptResultPath","scriptId","resultKey","SDK_SCRIPT_RESULTS_KEY","openCenteredPopup","title","w","h","dualScreenLeft","screenLeft","screen","left","dualScreenTop","screenTop","top","innerWidth","documentElement","clientWidth","width","innerHeight","clientHeight","height","initialUrl","ua","isIphone","isSafari","isIphoneSafari","popup","open"],"mappings":"0mCA0CA,MAAMA,EAAgB,CAAC,kCASPC,EACdC,EACAC,EACAC,GAEA,MAAO,IAAUC,IAAiCC,EAAAC,UAAA,OAAA,GAAA,YAChD,IAAIC,EACJ,MAAMC,EAAgBL,EAAa,EAGnC,IAAK,IAAIM,EAAU,EAAGA,EAAUD,EAAeC,IAC7C,IAEE,aAAaR,KAAMG,EACpB,CAAC,MAAOM,GACPH,EAAYG,EAGRD,EAAUN,UAEN,IAAIQ,SAASC,IACjBC,WAAWD,EAASV,EAAYY,KAAKC,IAAI,EAAGN,EAAU,GAAG,IAG9D,CAIH,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OACkBxQ,IAAtBnE,OAAO4U,WACH5U,OAAO4U,WACN5U,OAAO6U,OAAeC,KACvBC,OACiB5Q,IAArBnE,OAAOgV,UACHhV,OAAOgV,UACNhV,OAAO6U,OAAeI,IAWvBH,IARJ9U,OAAOkV,YACP9G,SAAS+G,gBAAgBC,aACzBpV,OAAO6U,OAAOQ,OAMMZ,GAAK,EAAIE,EACzBM,IALJjV,OAAOsV,aACPlH,SAAS+G,gBAAgBI,cACzBvV,OAAO6U,OAAOW,QAGMd,GAAK,EAAIK,EAKzBU,EA/2BR,WACE,MAAMC,EAAK7R,UAAUC,WAAa,GAC5B6R,EAAW,eAAe/R,KAAK8R,GAE/BE,EACJ,SAAShS,KAAK8R,KAAQ,2CAA2C9R,KAAK8R,GAExE,OAAOC,GAAYC,CACrB,CAu2BqBC,GAAmB,cAAgB,GAChDC,EAAQ9V,OAAO+V,KACnBN,EACAjB,EACA,SAASC,YAAYC,SAASO,UAAYH,kCAM5C,OAHAgB,EAAM7V,SAASQ,KAAOI,EACtBiV,EAAMnK,QAECmK,CAAK"}
@@ -0,0 +1,2 @@
1
+ import{__classPrivateFieldGet as t,__classPrivateFieldSet as i}from"tslib";import{createSingletonMixin as e,compose as s}from"@descope/sdk-helpers";import{loggerMixin as n}from"@descope/sdk-mixins";const h=t=>`${t.screenId}|${t.field}|${t.rule}`,a=()=>{try{return crypto.randomUUID()}catch(t){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},r=(t,i)=>t?t.badInput?"bad-input":t.valueMissing?"required":t.typeMismatch?"email"===i||"url"===i?i:"type-mismatch":t.patternMismatch?"pattern":t.tooShort?"too-short":t.tooLong?"too-long":t.rangeUnderflow||t.rangeOverflow||t.stepMismatch?"range":t.customError?"custom":"unknown":"unknown",o=e((e=>{var o,l,c,d,f,u,m,v,p,g,k,w,M,E,y,W,b,L,T,I;const S=s(n)(e);return I=class extends S{constructor(){super(...arguments),o.add(this),l.set(this,[]),c.set(this,void 0),d.set(this,void 0),f.set(this,new Set),u.set(this,!1),m.set(this,0),v.set(this,void 0),p.set(this,!1),g.set(this,(()=>t(this,o,"m",W).call(this,!1))),k.set(this,(()=>{"hidden"===document.visibilityState&&t(this,o,"m",W).call(this,!0)})),w.set(this,(()=>t(this,o,"m",W).call(this,!0)))}setValidationTrackingEnabled(e){t(this,p,"f")!==e&&(i(this,p,e,"f"),e||t(this,o,"m",y).call(this))}setValidationTrackingSender(t){i(this,v,t,"f")}setValidationTrackingExecution(e){t(this,p,"f")&&e&&t(this,l,"f").length&&(i(this,c,e,"f"),t(this,o,"m",W).call(this,!1))}trackValidationErrors(i,e){var s,n;try{t(this,o,"m",M).call(this,i,e)}catch(t){null===(n=null===(s=this.logger)||void 0===s?void 0:s.debug)||void 0===n||n.call(s,"Failed to track validation errors",String(t))}}teardownValidationTracking(){t(this,o,"m",W).call(this,!1),i(this,m,t(this,m,"f")+1,"f"),t(this,f,"f").forEach(clearTimeout),t(this,f,"f").clear(),t(this,u,"f")&&(i(this,u,!1,"f"),this.removeEventListener("screen-updated",t(this,g,"f")),this.removeEventListener("success",t(this,g,"f")),this.removeEventListener("error",t(this,g,"f")),document.removeEventListener("visibilitychange",t(this,k,"f")),window.removeEventListener("pagehide",t(this,w,"f")))}},l=new WeakMap,c=new WeakMap,d=new WeakMap,f=new WeakMap,u=new WeakMap,m=new WeakMap,v=new WeakMap,p=new WeakMap,g=new WeakMap,k=new WeakMap,w=new WeakMap,o=new WeakSet,M=function(e,s){if(!t(this,p,"f")||!(null==e?void 0:e.length))return;const n=s||{};t(this,o,"m",T).call(this),e.forEach((e=>{if(t(this,l,"f").length>=20)return;const s=((t,i)=>{var e;const s=null===(e=null==t?void 0:t.getAttribute)||void 0===e?void 0:e.call(t,"name");return s?{id:a(),field:s,rule:r(t.validity,t.type),message:t.validationMessage||"",screenId:i.screenId||"",screenName:i.screenName||"",ts:Date.now()}:null})(e,n);if(!s)return;const d=h(s);t(this,l,"f").some((t=>h(t)===d))||(t(this,l,"f").push(s),i(this,c,n.executionId||t(this,c,"f"),"f"),t(this,l,"f").length>=20&&t(this,o,"m",W).call(this,!1))})),t(this,l,"f").length>=20?t(this,o,"m",W).call(this,!1):t(this,o,"m",E).call(this)},E=function(){clearTimeout(t(this,d,"f")),i(this,d,setTimeout((()=>t(this,o,"m",W).call(this,!1)),2e3),"f")},y=function(){clearTimeout(t(this,d,"f")),i(this,m,t(this,m,"f")+1,"f"),t(this,f,"f").forEach(clearTimeout),t(this,f,"f").clear(),i(this,l,[],"f"),i(this,c,void 0,"f")},W=function(e){var s,n;if(clearTimeout(t(this,d,"f")),!t(this,l,"f").length)return void i(this,c,void 0,"f");if(!t(this,c,"f"))return;if(!t(this,v,"f"))return;const h=t(this,l,"f"),a=t(this,c,"f");i(this,l,[],"f"),i(this,c,void 0,"f");try{const i={executionId:a,events:h};e?t(this,v,"f").call(this,i,{keepalive:!0}).catch((()=>{})):t(this,o,"m",b).call(this,i,2,t(this,m,"f"))}catch(t){null===(n=null===(s=this.logger)||void 0===s?void 0:s.debug)||void 0===n||n.call(s,"Failed to send validation events",String(t))}},b=function(i,e,s){t(this,v,"f").call(this,i,{keepalive:!1}).then((n=>{!n.ok&&n.retryable&&e>0&&t(this,o,"m",L).call(this,i,e,s)})).catch((()=>{e>0&&t(this,o,"m",L).call(this,i,e,s)}))},L=function(i,e,s){if(s!==t(this,m,"f"))return;const n=setTimeout((()=>{t(this,f,"f").delete(n),s===t(this,m,"f")&&t(this,o,"m",b).call(this,i,e-1,s)}),800*(2-e+1));t(this,f,"f").add(n)},T=function(){t(this,u,"f")||(i(this,u,!0,"f"),this.addEventListener("screen-updated",t(this,g,"f")),this.addEventListener("success",t(this,g,"f")),this.addEventListener("error",t(this,g,"f")),document.addEventListener("visibilitychange",t(this,k,"f")),window.addEventListener("pagehide",t(this,w,"f")))},I}));export{r as deriveValidationRule,o as validationTrackingMixin};
2
+ //# sourceMappingURL=validationTrackingMixin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validationTrackingMixin.js","sources":["../../../src/lib/mixins/validationTrackingMixin.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { compose, createSingletonMixin } from '@descope/sdk-helpers';\nimport { loggerMixin } from '@descope/sdk-mixins';\n\n// Client-side form validation happens entirely in the browser (native\n// reportValidity/checkValidity) and produces no signal on its own - because an\n// invalid form never submits, the server never sees it. This mixin captures\n// those failures and batches them, so customers get visibility into where users\n// hit friction. Sending is the host's job - see ValidationSender below.\n//\n// Off unless the flow turns it on: the host calls setValidationTrackingEnabled\n// from the flow's config.json entry, and nothing is captured until it does.\n// It never blocks or fails the flow.\n\n/**\n * How a batch reaches the backend. The host supplies this (DescopeWc hands over\n * sdk.flow.event), so the mixin owns capture and batching and knows nothing\n * about transport, URLs or the SDK. Resolves to whether the batch was accepted\n * and whether retrying could ever help.\n */\nexport type ValidationSendResult = { ok: boolean; retryable: boolean };\nexport type ValidationBatch = {\n executionId: string;\n events: ValidationErrorEvent[];\n};\nexport type ValidationSender = (\n batch: ValidationBatch,\n options: { keepalive: boolean },\n) => Promise<ValidationSendResult>;\n\n// Flush the batch after this much inactivity, or once it reaches the cap.\nconst FLUSH_DEBOUNCE_MS = 2000;\nconst MAX_BATCH_SIZE = 20;\n\n// Bounded retry for normal (non-unload) flushes. Each event carries a stable\n// `id`, so the backend/CDP dedups a retried batch (no double-counting).\nconst MAX_SEND_RETRIES = 2;\nconst RETRY_BACKOFF_MS = 800;\n\n/** One captured validation failure, as sent to the backend. */\nexport type ValidationErrorEvent = {\n id: string;\n field: string;\n rule: string;\n message: string;\n screenId: string;\n screenName: string;\n ts: number;\n};\n\n/**\n * Where a batch belongs. Validation only ever happens on a screen, so the\n * screen is the location - there is no step in this model.\n */\ntype FlowContext = {\n executionId?: string;\n screenId?: string;\n screenName?: string;\n};\n\n// Same field failing the same way on the same screen is one signal, however\n// many times it fires (blur then submit).\nconst dedupeKey = (e: ValidationErrorEvent) =>\n `${e.screenId}|${e.field}|${e.rule}`;\n\nconst newId = (): string => {\n try {\n return crypto.randomUUID();\n } catch {\n // very old browsers: good-enough uniqueness for an idempotency key\n return `${Date.now()}-${Math.round(Math.random() * 1e9)}`;\n }\n};\n\n/**\n * Map an input's ValidityState to a machine-readable rule, one rule per native\n * failure so a customer can tell \"not a valid email\" from \"failed the pattern\n * the flow author wrote\" - different problems with different fixes. The exact\n * text the user saw is always in `message` as well. A field with a custom\n * validation message still keeps its native flag, so this stays accurate; only\n * a fully custom validator (setCustomValidity) reports `custom`.\n *\n * `inputType` is the input's `type`, needed because typeMismatch only says the\n * value is the wrong shape, not for what: it fires for `email` and `url` only.\n */\nexport const deriveValidationRule = (\n validity?: ValidityState,\n inputType?: string,\n): string => {\n if (!validity) return 'unknown';\n // Before valueMissing: a control that cannot parse what was typed reports an\n // empty value, so a required field sets BOTH flags (verified in Chromium:\n // type=\"number\" + \"5e\" -> badInput AND valueMissing). Reporting `required`\n // there would claim the user left it blank when they did type something.\n if (validity.badInput) return 'bad-input';\n if (validity.valueMissing) return 'required';\n if (validity.typeMismatch) {\n if (inputType === 'email' || inputType === 'url') return inputType;\n return 'type-mismatch';\n }\n if (validity.patternMismatch) return 'pattern';\n if (validity.tooShort) return 'too-short';\n if (validity.tooLong) return 'too-long';\n if (\n validity.rangeUnderflow ||\n validity.rangeOverflow ||\n validity.stepMismatch\n ) {\n return 'range';\n }\n if (validity.customError) return 'custom';\n return 'unknown';\n};\n\n/** Build one event from a failed input, or null if it has no name to report. */\nconst toEvent = (\n input: HTMLInputElement,\n ctx: FlowContext,\n): ValidationErrorEvent | null => {\n const field = input?.getAttribute?.('name');\n if (!field) return null;\n return {\n id: newId(),\n field,\n rule: deriveValidationRule(input.validity, input.type),\n message: input.validationMessage || '',\n screenId: ctx.screenId || '',\n screenName: ctx.screenName || '',\n ts: Date.now(),\n };\n};\n\nexport const validationTrackingMixin = createSingletonMixin(\n <T extends CustomElementConstructor>(superclass: T) => {\n const BaseClass = compose(loggerMixin)(superclass);\n\n return class ValidationTrackingMixinClass extends BaseClass {\n // Captured events waiting to go out. Flushed on screen change, flow end,\n // page hide, a size cap, or a short inactivity debounce. Each event\n // carries its own screen, so a batch need not be single-screen.\n #buffer: ValidationErrorEvent[] = [];\n\n // The execution the buffer belongs to. Unset until the flow starts: the\n // start screen renders from config.json before /v1/flow/start, and the\n // endpoint only accepts a live execution, so those events wait here. If\n // the flow never starts - the user gave up on the first screen - they are\n // dropped. That is the known abandonment gap.\n #bufferExecutionId?: string;\n\n #flushTimer?: ReturnType<typeof setTimeout>;\n\n // Pending retry timers. A failed flush leaves a chain in flight, and two\n // flushes can fail at once, so this holds more than one.\n #retryTimers = new Set<ReturnType<typeof setTimeout>>();\n\n #listenersAttached = false;\n\n // Bumped whenever in-flight work stops being wanted: tracking switched\n // off, or the component torn down. A send captures the value it started\n // with, so a response that lands after either event cannot resurrect a\n // retry chain the switch/teardown was supposed to end.\n #generation = 0;\n\n // Supplied by the host. Without it nothing can be sent, which is the\n // same safe default as being switched off.\n #send?: ValidationSender;\n\n // Off until the host turns it on from the flow's config.json entry. The\n // default matters: a host that never calls the setter captures nothing,\n // so a missing or stale config can never start collecting on its own.\n #enabled = false;\n\n #boundFlushOnEnd = () => this.#flush(false);\n\n #boundFlushOnHide = () => {\n // Page unload / tab hidden - the abandonment case. Use a keepalive\n // request so it survives the page going away.\n if (document.visibilityState === 'hidden') this.#flush(true);\n };\n\n #boundFlushOnPageHide = () => this.#flush(true);\n\n /**\n * Turn capture on or off. The host calls this from the flow's config,\n * where the setting is per flow and off unless the customer enabled it.\n * Turning it off drops whatever is buffered without sending it.\n */\n setValidationTrackingEnabled(enabled: boolean) {\n if (this.#enabled === enabled) return;\n this.#enabled = enabled;\n if (!enabled) this.#discard();\n }\n\n /** The host tells the mixin how to deliver a batch. */\n setValidationTrackingSender(send: ValidationSender) {\n this.#send = send;\n }\n\n /**\n * The flow now has an execution. Anything captured before it started -\n * on the start screen - can finally be attributed and sent.\n */\n setValidationTrackingExecution(executionId: string) {\n // Nothing held means nothing to attribute. Storing the id anyway would\n // leave it behind for a later batch that belongs to a different\n // execution - see the matching guard in #flush.\n if (!this.#enabled || !executionId || !this.#buffer.length) return;\n this.#bufferExecutionId = executionId;\n this.#flush(false);\n }\n\n /**\n * Public capture entry point. Called by the web-component at the two\n * validation points it already runs (submit + blur), passing the current\n * flow context. Best-effort: any failure here is swallowed so it can\n * never affect the flow.\n */\n trackValidationErrors(inputs: HTMLInputElement[], context: FlowContext) {\n try {\n this.#collect(inputs, context);\n } catch (e) {\n this.logger?.debug?.('Failed to track validation errors', String(e));\n }\n }\n\n #collect(inputs: HTMLInputElement[], context: FlowContext) {\n // Off for this flow, or nothing to report - capture nothing and attach\n // no listeners.\n if (!this.#enabled || !inputs?.length) return;\n const ctx = context || {};\n\n // Attach flush triggers on first real capture (nothing to flush before\n // there is a buffered event, so there's no reason to attach earlier).\n this.#attachListeners();\n\n inputs.forEach((input) => {\n // Still full after the flush below tried to drain it, which means it\n // cannot be sent yet. Hold at the cap so an abandoned start screen\n // cannot grow without bound - dropping the rest is the price.\n if (this.#buffer.length >= MAX_BATCH_SIZE) return;\n const event = toEvent(input, ctx);\n if (!event) return;\n const key = dedupeKey(event);\n if (this.#buffer.some((e) => dedupeKey(e) === key)) return;\n this.#buffer.push(event);\n // Tied to the batch, so it is set only once something is actually in\n // it, and re-set after a flush below empties it. Before the flow\n // starts this stays unset and the buffer just holds.\n this.#bufferExecutionId = ctx.executionId || this.#bufferExecutionId;\n // A deliverable batch is sent as soon as it fills up, and the rest of\n // this submit keeps collecting into a fresh one. A submit with more\n // than MAX_BATCH_SIZE invalid fields then loses nothing.\n if (this.#buffer.length >= MAX_BATCH_SIZE) this.#flush(false);\n });\n\n if (this.#buffer.length >= MAX_BATCH_SIZE) {\n this.#flush(false);\n } else {\n this.#scheduleFlush();\n }\n }\n\n #scheduleFlush() {\n clearTimeout(this.#flushTimer);\n this.#flushTimer = setTimeout(\n () => this.#flush(false),\n FLUSH_DEBOUNCE_MS,\n );\n }\n\n // Drop everything buffered without sending it, and cancel anything\n // already scheduled. Used when capture is switched off. Listeners that\n // were attached while it was on are left in place - they only call\n // #flush, which does nothing on an empty buffer.\n #discard() {\n clearTimeout(this.#flushTimer);\n this.#generation += 1;\n this.#retryTimers.forEach(clearTimeout);\n this.#retryTimers.clear();\n this.#buffer = [];\n this.#bufferExecutionId = undefined;\n }\n\n #flush(isUnload: boolean) {\n clearTimeout(this.#flushTimer);\n // Nothing buffered: drop the execution too. Holding it would outlive\n // the batch it belonged to, and after a flow restart the next\n // start-screen error would be attributed to the finished execution\n // instead of being held for the new one.\n if (!this.#buffer.length) {\n this.#bufferExecutionId = undefined;\n return;\n }\n // No execution yet - hold, don't drop. The endpoint would reject it.\n if (!this.#bufferExecutionId) return;\n\n // No way to deliver yet - hold rather than drain into nothing.\n if (!this.#send) return;\n\n const events = this.#buffer;\n const executionId = this.#bufferExecutionId;\n this.#buffer = [];\n this.#bufferExecutionId = undefined;\n\n try {\n const batch = { executionId, events };\n if (isUnload) {\n // Page is going away: single keepalive shot, retry isn't possible.\n this.#send(batch, { keepalive: true }).catch(() => {});\n } else {\n this.#sendWithRetry(batch, MAX_SEND_RETRIES, this.#generation);\n }\n } catch (e) {\n this.logger?.debug?.('Failed to send validation events', String(e));\n }\n }\n\n // Best-effort send with bounded retry (non-unload flushes only). Gives up\n // quietly after the last attempt. Events carry a stable `id`, so a retried\n // batch is deduped downstream.\n #sendWithRetry(\n batch: ValidationBatch,\n retriesLeft: number,\n generation: number,\n ) {\n this.#send(batch, { keepalive: false })\n .then((res) => {\n // Only retry what can succeed later - a rejected batch will not\n // become accepted, and retrying it just multiplies the load.\n if (!res.ok && res.retryable && retriesLeft > 0) {\n this.#scheduleRetry(batch, retriesLeft, generation);\n }\n })\n .catch(() => {\n // transport failure - worth another go\n if (retriesLeft > 0) {\n this.#scheduleRetry(batch, retriesLeft, generation);\n }\n });\n }\n\n #scheduleRetry(\n batch: ValidationBatch,\n retriesLeft: number,\n generation: number,\n ) {\n // A request already in flight when tracking is switched off - or when\n // the component went away - would otherwise keep retrying past it.\n if (generation !== this.#generation) return;\n const attempt = MAX_SEND_RETRIES - retriesLeft + 1;\n const timer = setTimeout(() => {\n this.#retryTimers.delete(timer);\n if (generation !== this.#generation) return;\n this.#sendWithRetry(batch, retriesLeft - 1, generation);\n }, RETRY_BACKOFF_MS * attempt);\n this.#retryTimers.add(timer);\n }\n\n #attachListeners() {\n if (this.#listenersAttached) return;\n this.#listenersAttached = true;\n // Flush when the funnel context changes or the flow ends.\n this.addEventListener('screen-updated', this.#boundFlushOnEnd);\n this.addEventListener('success', this.#boundFlushOnEnd);\n this.addEventListener('error', this.#boundFlushOnEnd);\n // Abandonment: capture on the way out (keepalive request).\n document.addEventListener('visibilitychange', this.#boundFlushOnHide);\n window.addEventListener('pagehide', this.#boundFlushOnPageHide);\n }\n\n // Called by the host's disconnectedCallback: flush anything buffered and\n // detach listeners. This mixin intentionally does NOT override\n // connectedCallback/disconnectedCallback - several mixins in the compose\n // chain already do, and a third override trips a TS intersection typing\n // issue. Listeners are attached lazily on first capture instead.\n teardownValidationTracking() {\n // Anything still held never got an execution - #flush leaves it, and\n // the component is going away, so it is dropped with the instance.\n this.#flush(false);\n // Drop any retry still waiting out its backoff - the component is gone.\n // Bumping the generation also covers a send still in flight, whose\n // response would otherwise schedule a fresh timer after this cleanup.\n this.#generation += 1;\n this.#retryTimers.forEach(clearTimeout);\n this.#retryTimers.clear();\n if (!this.#listenersAttached) return;\n this.#listenersAttached = false;\n this.removeEventListener('screen-updated', this.#boundFlushOnEnd);\n this.removeEventListener('success', this.#boundFlushOnEnd);\n this.removeEventListener('error', this.#boundFlushOnEnd);\n document.removeEventListener(\n 'visibilitychange',\n this.#boundFlushOnHide,\n );\n window.removeEventListener('pagehide', this.#boundFlushOnPageHide);\n }\n };\n },\n);\n"],"names":["dedupeKey","e","screenId","field","rule","newId","crypto","randomUUID","_a","Date","now","Math","round","random","deriveValidationRule","validity","inputType","badInput","valueMissing","typeMismatch","patternMismatch","tooShort","tooLong","rangeUnderflow","rangeOverflow","stepMismatch","customError","validationTrackingMixin","createSingletonMixin","superclass","BaseClass","compose","loggerMixin","constructor","_ValidationTrackingMixinClass_buffer","set","this","_ValidationTrackingMixinClass_bufferExecutionId","_ValidationTrackingMixinClass_flushTimer","_ValidationTrackingMixinClass_retryTimers","Set","_ValidationTrackingMixinClass_listenersAttached","_ValidationTrackingMixinClass_generation","_ValidationTrackingMixinClass_send","_ValidationTrackingMixinClass_enabled","_ValidationTrackingMixinClass_boundFlushOnEnd","__classPrivateFieldGet","_ValidationTrackingMixinClass_instances","_ValidationTrackingMixinClass_flush","call","_ValidationTrackingMixinClass_boundFlushOnHide","document","visibilityState","_ValidationTrackingMixinClass_boundFlushOnPageHide","setValidationTrackingEnabled","enabled","__classPrivateFieldSet","_ValidationTrackingMixinClass_discard","setValidationTrackingSender","send","setValidationTrackingExecution","executionId","length","trackValidationErrors","inputs","context","_c","_b","logger","debug","String","teardownValidationTracking","forEach","clearTimeout","clear","removeEventListener","window","_ValidationTrackingMixinClass_collect","ctx","_ValidationTrackingMixinClass_attachListeners","input","event","getAttribute","id","type","message","validationMessage","screenName","ts","toEvent","key","some","push","_ValidationTrackingMixinClass_scheduleFlush","setTimeout","undefined","isUnload","events","batch","keepalive","catch","_ValidationTrackingMixinClass_sendWithRetry","retriesLeft","generation","then","res","ok","retryable","_ValidationTrackingMixinClass_scheduleRetry","timer","delete","add","addEventListener"],"mappings":"sMA+BA,MA+BMA,EAAaC,GACjB,GAAGA,EAAEC,YAAYD,EAAEE,SAASF,EAAEG,OAE1BC,EAAQ,KACZ,IACE,OAAOC,OAAOC,YACf,CAAC,MAAAC,GAEA,MAAO,GAAGC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACzC,GAcUC,EAAuB,CAClCC,EACAC,IAEKD,EAKDA,EAASE,SAAiB,YAC1BF,EAASG,aAAqB,WAC9BH,EAASI,aACO,UAAdH,GAAuC,QAAdA,EAA4BA,EAClD,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K/D,EAAAV,KAAuBK,EAAA,OAC3Be,EAAApB,KAAIK,GAAsB,EAAI,KAE9BL,KAAK4E,iBAAiB,iBAAkBlE,EAAAV,KAAqBS,EAAA,MAC7DT,KAAK4E,iBAAiB,UAAWlE,EAAAV,KAAqBS,EAAA,MACtDT,KAAK4E,iBAAiB,QAASlE,EAAAV,KAAqBS,EAAA,MAEpDM,SAAS6D,iBAAiB,mBAAoBlE,EAAAV,KAAsBc,EAAA,MACpE0B,OAAOoC,iBAAiB,WAAYlE,EAAAV,KAA0BiB,EAAA,MAC/D,EA4BD7C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../src/lib/types.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport type { JWTResponse } from '@descope/web-js-sdk';\nimport { createSdk } from '@descope/web-js-sdk';\n\nexport type SdkConfig = Parameters<typeof createSdk>[0];\nexport type Sdk = ReturnType<typeof createSdk>;\n\nexport type SdkFlowNext = Sdk['flow']['next'];\n\nexport type ComponentsDynamicAttrs = {\n attributes: Record<string, any>;\n};\n\nexport type ComponentsConfig = Record<string, any> & {\n componentsDynamicAttrs?: Record<string, ComponentsDynamicAttrs>;\n};\nexport type CssVars = Record<string, any>;\n\ntype KeepArgsByIndex<F, Indices extends readonly number[]> = F extends (\n ...args: infer A\n) => infer R\n ? (...args: PickArgsByIndex<A, Indices>) => R\n : never;\n\ntype PickArgsByIndex<\n All extends readonly any[],\n Indices extends readonly number[],\n> = {\n [K in keyof Indices]: Indices[K] extends keyof All ? All[Indices[K]] : never;\n};\n\ntype Project = {\n name: string;\n};\n\nexport enum Direction {\n backward = 'backward',\n forward = 'forward',\n}\n\nexport type LastAuthState = NonNullable<\n NextFnReturnPromiseValue['data']['lastAuth']\n> & {\n loginId?: string;\n name?: string;\n lastUsedPerScreen?: Record<string, string>;\n};\n\nexport type RealtimeOperandKind = 'value' | 'form' | 'list';\n\n// Operators the SDK is allowed to evaluate locally. The server's\n// clientSupportedRealtimeOperators must stay in sync — anything outside this\n// list is pre-evaluated server-side and shipped as a value operand.\n//\n// is-email / is-phone are intentionally absent: the server validates them\n// with dedicated libraries (contact.IsValid*); the client has no equivalent,\n// so the server keeps these CCs server-only.\nexport type RealtimeOperator =\n | 'equal'\n | 'not-equal'\n | 'contains'\n | 'doesnt-contains'\n | 'greater-than'\n | 'greater-than-or-equal'\n | 'less-than'\n | 'less-than-or-equal'\n | 'empty'\n | 'not-empty'\n | 'is-true'\n | 'is-false'\n | 'in'\n | 'not-in'\n | 'matches';\n\nexport interface RealtimeOperand {\n kind: RealtimeOperandKind;\n // Form is the context key the client looks up from the live form snapshot\n // (e.g. \"form.phone\"). Set only when kind === 'form'.\n form?: string;\n // Items is the operand list when kind === 'list'. Each element is a nested\n // operand — either a form placeholder or a resolved literal. Used when the\n // server detects an `in` / `not-in` / `contains` predicate whose array\n // contains `{{form.X}}` references; the client resolves them at eval time.\n items?: RealtimeOperand[];\n // Pre-resolved literal. Set only when kind === 'value', and may legitimately\n // be false / 0 / \"\" — do not treat absence as \"no value\" without checking\n // kind first.\n value?: unknown;\n}\n\nexport interface RealtimeAtomicCondition {\n operator: RealtimeOperator;\n target?: RealtimeOperand;\n predicate?: RealtimeOperand;\n}\n\nexport interface RealtimeRule {\n logicalOr?: boolean;\n atomicConditions: RealtimeAtomicCondition[];\n}\n\nexport interface RealtimeComponentsCondition {\n id?: string;\n componentIds: string[];\n action: string;\n rules: RealtimeRule[];\n}\n\n// the server sends the full user object; only the fields the SDK reads are\n// typed here\nexport interface ScreenStateUser {\n email?: string;\n loginIds?: string[];\n [key: string]: unknown;\n}\n\nexport interface ScreenState {\n errorText?: string;\n errorType?: string;\n componentsConfig?: ComponentsConfig;\n cssVars?: CssVars;\n form?: Record<string, string>;\n inputs?: Record<string, string>; // Backward compatibility\n lastAuth?: LastAuthState;\n project?: Project;\n totp?: { image?: string; provisionUrl?: string };\n notp?: { image?: string; redirectUrl?: string };\n selfProvisionDomains?: unknown;\n user?: ScreenStateUser;\n sso?: unknown;\n dynamicSelects?: unknown;\n keysInUse?: unknown;\n genericForm?: unknown;\n linkId?: unknown;\n sentTo?: unknown;\n clientScripts?: ClientScript[];\n // map of component IDs to their state — the FULL last-wins verdict over\n // all CCs (server-only + client-eligible) the BE evaluated at screen-init.\n // Used by `applyComponentsState` for the first DOM paint.\n componentsState?: Record<string, string>;\n // Subset of `componentsState` contributed by SERVER-ONLY CCs — those the\n // client cannot re-evaluate locally (operators on the server-only\n // allow-list like `is-email`, or rules referencing context the client\n // doesn't have). Parallels `componentsState` in structure but excludes\n // contributions from client-eligible CCs that also ship in\n // `realtimeComponentsConditions`.\n //\n // The realtime layer uses this as the fallback action to restore when a\n // realtime CC stops firing on a touched component — without it the SDK\n // can't tell whether the action in `componentsState` came from a\n // server-only CC (must persist) or from a realtime CC also re-shipped\n // (must clear).\n //\n // Absent on old backends; new SDKs fall back to a legacy heuristic that\n // infers the same information from `componentsState`, so the old-BE /\n // new-SDK combination still works correctly.\n serverOnlyComponentsState?: Record<string, string>;\n // Client-evaluable visibility conditions, populated only by new backends.\n // Absent on old backends; new SDKs ignore when absent.\n realtimeComponentsConditions?: RealtimeComponentsCondition[];\n}\n\nexport type SSOQueryParams = {\n oidcIdpStateId?: string;\n samlIdpStateId?: string;\n wsfedIdpStateId?: string;\n samlIdpUsername?: string;\n descopeIdpInitiated?: boolean;\n ssoAppId?: string;\n customAppId?: string;\n thirdPartyAppId: string;\n thirdPartyAppStateId?: string;\n applicationScopes?: string;\n} & OIDCOptions;\n\nexport type OIDCOptions = {\n oidcLoginHint?: string;\n oidcPrompt?: string;\n oidcErrorRedirectUri?: string;\n oidcResource?: string;\n};\n\nexport type FlowState = {\n flowId: string;\n projectId: string;\n baseUrl: string;\n tenant: string;\n stepId: string;\n stepName: string;\n executionId: string;\n action: string;\n redirectTo: string;\n redirectIsPopup: boolean;\n openInNewTabUrl?: string;\n redirectUrl: string;\n screenId: string;\n screenState: ScreenState;\n token: string;\n code: string;\n isPopup: boolean;\n exchangeError: string;\n webauthnTransactionId: string;\n webauthnOptions: string;\n redirectAuthCodeChallenge: string;\n redirectAuthCallbackUrl: string;\n redirectAuthBackupCallbackUri: string;\n redirectAuthInitiator: string;\n deferredRedirect: boolean;\n deferredPolling: boolean;\n locale: string;\n samlIdpResponseUrl: string;\n samlIdpResponseSamlResponse: string;\n samlIdpResponseRelayState: string;\n wsFedIdpResponseUrl: string;\n wsFedIdpResponseWresult: string;\n wsFedIdpResponseWctx: string;\n nativeResponseType: string;\n nativePayload: Record<string, any>;\n reqTimestamp: number;\n} & SSOQueryParams;\n\nexport type StepState = {\n screenState: ScreenState;\n screenId: string;\n stepName: string;\n htmlFilename: string;\n htmlLocaleFilename: string;\n next: NextFn;\n direction: Direction | undefined;\n samlIdpUsername: string;\n action?: string;\n locale?: string;\n} & OIDCOptions;\n\nexport type CustomScreenState = Omit<\n ScreenState,\n // Removed from the top level of the custom-screen context:\n // - cssVars/componentsConfig/inputs/clientScripts: internal.\n // - errorText/errorType: reshaped into `error`.\n // - the rest: server-produced screen data, relocated under `data`.\n | 'cssVars'\n | 'componentsConfig'\n | 'inputs'\n | 'errorText'\n | 'errorType'\n | 'clientScripts'\n | 'totp'\n | 'notp'\n | 'sentTo'\n | 'sso'\n | 'selfProvisionDomains'\n> & {\n error?: {\n text: ScreenState['errorText'];\n type: ScreenState['errorType'];\n };\n action?: string;\n /**\n * All server-produced screen data, in one place. Previously this data was spread\n * across the top level and a deeply-nested, selector-keyed `componentsConfig`.\n * Only known, documented fields are exposed (renamed/normalized); anything else is\n * dropped. SDK-owned/reserved — a value with this key coming from the backend is ignored.\n */\n data?: CustomScreenData;\n};\n\n/**\n * Cleaned view of the flow screen's `componentsConfig`. Every field is optional and\n * only present when the screen actually produces it.\n */\nexport type CustomScreenData = {\n /** TOTP MFA setup: QR image + provisioning URL. */\n totp?: { image?: string; provisionUrl?: string };\n /** Notification-OTP setup: image + redirect URL. */\n notp?: { image?: string; redirectUrl?: string };\n /** Where the OTP/code was sent — masked email and/or phone. */\n sentTo?: { maskedEmail?: string; maskedPhone?: string };\n /** SSO (SAML) service-provider config for SSO-setup screens. */\n sso?: { acsUrl?: string; descopeEntityId?: string; spMetadataUrl?: string };\n /** Email domains allowed to self-provision into the tenant. */\n selfProvisionDomains?: string;\n /** OAuth scopes an inbound (third-party) app is asking the user to approve. */\n inboundAppApproveScopes?: { desc: string; id: string; required: boolean }[];\n /** Password rules to show/enforce on a password screen. */\n passwordPolicy?: {\n minLength?: string;\n strength?: string;\n disallowedChars?: string;\n email?: string;\n activePolicies?: string;\n availablePolicies?: string;\n };\n /** Security questions to set up, plus how many are required. */\n securityQuestionsSetup?: {\n questions?: { id: string; text: string }[];\n count?: number;\n };\n /** Security questions to verify the user against. */\n securityQuestionsVerify?: { questions?: { id: string; text: string }[] };\n /** Tenants the user can pick from (tenant-selection screen). */\n userTenants?: { label: string; value: string }[];\n /** SSO applications the user can pick from. */\n ssoApplications?: { label: string; value: string }[];\n /** SSO configurations the user can pick from. */\n ssoConfigurations?: { label: string; value: string }[];\n /** Roles the user can pick from. */\n userRoles?: { label: string; value: string }[];\n /** SAML attribute-mapping options (SSO-setup screens). */\n samlAttributeMappings?: { label: string; value: string }[];\n /** OIDC attribute-mapping options (SSO-setup screens). */\n oidcAttributeMappings?: { label: string; value: string }[];\n /** SAML group-mapping options (SSO-setup screens). */\n samlGroupMappings?: { label: string; value: string }[];\n /** Generated MFA recovery codes to display to the user. */\n recoveryCodes?: string[];\n /** Outbound OAuth app button info (label, icon, app id). */\n outboundApp?: { label?: string; iconSrc?: string; appId?: string };\n\n // Contract rule: every key on `data` is an SDK-owned, documented name. We never\n // place arbitrary, flow-author-controlled keys directly on `data`, so adding new\n // named fields stays backwards-compatible (no collisions, no reshape).\n //\n // Reserved for a future addition: dynamic-select options. Their keys are the\n // flow's own select field names (e.g. \"country\"), so they can't be named here —\n // when exposed, they'll go under their own sub-map to keep them collision-free:\n // selects?: Record<string, { label: string; value: string }[]>;\n // Not populated yet (see README). Adding it later is additive, not breaking.\n};\n\nexport type DebugState = {\n isDebug: boolean;\n};\n\nexport interface ScriptElement extends HTMLDivElement {\n moduleRes?: ScriptModule;\n}\n\nexport type ScriptModule = {\n /**\n * Unique identifier of the module.\n */\n id: string;\n /**\n * Notifies the module that it should start any profiling or monitoring.\n */\n start?: () => void;\n /**\n * Notifies the module that it should stop any profiling or monitoring.\n */\n stop?: () => void;\n /**\n * Presents the user with any required interaction to get a refreshed token or state,\n * e.g., a challenge or captcha.\n *\n * Modules should return a value of true if the presentation completed successfully,\n * false if it was cancelled by the user, and throw an error in case of failure.\n *\n * This is called before form submission (via a next call) after a button click.\n */\n present?: () => Promise<boolean>;\n /**\n * Refreshes any tokens or state that might be needed before form submission.\n *\n * Modules should throw an error in case of failure.\n */\n refresh?: () => Promise<void>;\n};\n\nexport type ClientScript = {\n id: string;\n initArgs: Record<string, any>;\n resultKey?: string;\n};\n\nexport type NextFn = KeepArgsByIndex<SdkFlowNext, [2, 5]> & {\n isCustomScreen?: boolean;\n};\nexport type NextFnReturnPromiseValue = Awaited<ReturnType<NextFn>>;\n\nexport type DebuggerMessage = {\n title: string;\n description?: string;\n};\n\nexport type FlowStateUpdateFn = (state: FlowState) => void;\n\ntype Operator =\n | 'equal'\n | 'not-equal'\n | 'contains'\n | 'greater-than'\n | 'greater-than-or-equal'\n | 'less-than'\n | 'less-than-or-equal'\n | 'empty'\n | 'not-empty'\n | 'is-true'\n | 'is-false'\n | 'in'\n | 'not-in'\n | 'in-range'\n | 'not-in-range'\n | 'devised-by';\n\nexport interface ClientConditionResult {\n screenId: string;\n screenName: string;\n clientScripts?: ClientScript[];\n componentsConfig?: ComponentsConfig;\n interactionId: string;\n}\n\nexport interface ClientCondition {\n operator: Operator;\n key: string;\n predicate?: string | number;\n met: ClientConditionResult;\n unmet?: ClientConditionResult;\n}\n\nexport type AutoFocusOptions = true | false | 'skipFirstScreen';\n\nexport type ThemeOptions = 'light' | 'dark' | 'os';\n\nexport type Key =\n | 'lastAuth.loginId'\n | 'idpInitiated'\n | 'externalToken'\n | 'abTestingKey';\n\ntype CheckFunction = (ctx: Context, predicate?: string | number) => boolean;\n\nexport type ConditionsMap = {\n [key in Key]: {\n [operator in Operator]?: CheckFunction;\n };\n};\n\nexport interface Context {\n loginId?: string;\n code?: string;\n token?: string;\n abTestingKey?: number;\n lastAuth?: LastAuthState;\n}\n\nexport type DescopeUI = Record<string, () => Promise<void>> & {\n componentsThemeManager: Record<string, any>;\n};\n\ntype Font = {\n family: string[];\n label: string;\n url?: string;\n};\n\ntype ThemeTemplate = {\n fonts: {\n font1: Font;\n font2: Font;\n };\n};\n\ntype ThemeColor = {\n main: string;\n dark: string;\n light: string;\n highlight: string;\n contrast: string;\n};\n\nexport type OverrideTheme = {\n globals?: {\n colors?: {\n primary?: ThemeColor;\n secondary?: ThemeColor;\n };\n };\n};\n\nexport type OverrideThemes = {\n dark?: OverrideTheme;\n light?: OverrideTheme;\n};\n\nexport type FlowConfig = {\n startScreenId?: string;\n startScreenName?: string;\n version: number;\n targetLocales?: string[];\n conditions?: ClientCondition[];\n condition?: ClientCondition;\n fingerprintEnabled?: boolean;\n fingerprintKey?: string;\n sdkScripts?: [\n {\n id: string;\n initArgs: Record<string, any>;\n resultKey?: string;\n },\n ];\n clientScripts?: ClientScript[];\n componentsConfig?: ComponentsConfig;\n};\n\nexport interface ProjectConfiguration {\n componentsVersion: string;\n cssTemplate: {\n dark: ThemeTemplate;\n light: ThemeTemplate;\n };\n flows: {\n [key: string]: FlowConfig; // dynamic key names for flows\n };\n}\n\nexport type FlowStatus = 'loading' | 'error' | 'success' | 'ready' | 'initial';\n\nexport type CustomStorage = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n};\n\nexport type FlowJWTResponse = JWTResponse & {\n flowOutput?: Record<string, any>;\n};\n"],"names":["Direction"],"mappings":"IAoCYA,GAAZ,SAAYA,GACVA,EAAA,SAAA,WACAA,EAAA,QAAA,SACD,CAHD,CAAYA,IAAAA,EAGX,CAAA"}
1
+ {"version":3,"file":"types.js","sources":["../../src/lib/types.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport type { JWTResponse } from '@descope/web-js-sdk';\nimport { createSdk } from '@descope/web-js-sdk';\n\nexport type SdkConfig = Parameters<typeof createSdk>[0];\nexport type Sdk = ReturnType<typeof createSdk>;\n\nexport type SdkFlowNext = Sdk['flow']['next'];\n\nexport type ComponentsDynamicAttrs = {\n attributes: Record<string, any>;\n};\n\nexport type ComponentsConfig = Record<string, any> & {\n componentsDynamicAttrs?: Record<string, ComponentsDynamicAttrs>;\n};\nexport type CssVars = Record<string, any>;\n\ntype KeepArgsByIndex<F, Indices extends readonly number[]> = F extends (\n ...args: infer A\n) => infer R\n ? (...args: PickArgsByIndex<A, Indices>) => R\n : never;\n\ntype PickArgsByIndex<\n All extends readonly any[],\n Indices extends readonly number[],\n> = {\n [K in keyof Indices]: Indices[K] extends keyof All ? All[Indices[K]] : never;\n};\n\ntype Project = {\n name: string;\n};\n\nexport enum Direction {\n backward = 'backward',\n forward = 'forward',\n}\n\nexport type LastAuthState = NonNullable<\n NextFnReturnPromiseValue['data']['lastAuth']\n> & {\n loginId?: string;\n name?: string;\n lastUsedPerScreen?: Record<string, string>;\n};\n\nexport type RealtimeOperandKind = 'value' | 'form' | 'list';\n\n// Operators the SDK is allowed to evaluate locally. The server's\n// clientSupportedRealtimeOperators must stay in sync — anything outside this\n// list is pre-evaluated server-side and shipped as a value operand.\n//\n// is-email / is-phone are intentionally absent: the server validates them\n// with dedicated libraries (contact.IsValid*); the client has no equivalent,\n// so the server keeps these CCs server-only.\nexport type RealtimeOperator =\n | 'equal'\n | 'not-equal'\n | 'contains'\n | 'doesnt-contains'\n | 'greater-than'\n | 'greater-than-or-equal'\n | 'less-than'\n | 'less-than-or-equal'\n | 'empty'\n | 'not-empty'\n | 'is-true'\n | 'is-false'\n | 'in'\n | 'not-in'\n | 'matches';\n\nexport interface RealtimeOperand {\n kind: RealtimeOperandKind;\n // Form is the context key the client looks up from the live form snapshot\n // (e.g. \"form.phone\"). Set only when kind === 'form'.\n form?: string;\n // Items is the operand list when kind === 'list'. Each element is a nested\n // operand — either a form placeholder or a resolved literal. Used when the\n // server detects an `in` / `not-in` / `contains` predicate whose array\n // contains `{{form.X}}` references; the client resolves them at eval time.\n items?: RealtimeOperand[];\n // Pre-resolved literal. Set only when kind === 'value', and may legitimately\n // be false / 0 / \"\" — do not treat absence as \"no value\" without checking\n // kind first.\n value?: unknown;\n}\n\nexport interface RealtimeAtomicCondition {\n operator: RealtimeOperator;\n target?: RealtimeOperand;\n predicate?: RealtimeOperand;\n}\n\nexport interface RealtimeRule {\n logicalOr?: boolean;\n atomicConditions: RealtimeAtomicCondition[];\n}\n\nexport interface RealtimeComponentsCondition {\n id?: string;\n componentIds: string[];\n action: string;\n rules: RealtimeRule[];\n}\n\n// the server sends the full user object; only the fields the SDK reads are\n// typed here\nexport interface ScreenStateUser {\n email?: string;\n loginIds?: string[];\n [key: string]: unknown;\n}\n\nexport interface ScreenState {\n errorText?: string;\n errorType?: string;\n componentsConfig?: ComponentsConfig;\n cssVars?: CssVars;\n form?: Record<string, string>;\n inputs?: Record<string, string>; // Backward compatibility\n lastAuth?: LastAuthState;\n project?: Project;\n totp?: { image?: string; provisionUrl?: string };\n notp?: { image?: string; redirectUrl?: string };\n selfProvisionDomains?: unknown;\n user?: ScreenStateUser;\n sso?: unknown;\n dynamicSelects?: unknown;\n keysInUse?: unknown;\n genericForm?: unknown;\n linkId?: unknown;\n sentTo?: unknown;\n clientScripts?: ClientScript[];\n // map of component IDs to their state — the FULL last-wins verdict over\n // all CCs (server-only + client-eligible) the BE evaluated at screen-init.\n // Used by `applyComponentsState` for the first DOM paint.\n componentsState?: Record<string, string>;\n // Subset of `componentsState` contributed by SERVER-ONLY CCs — those the\n // client cannot re-evaluate locally (operators on the server-only\n // allow-list like `is-email`, or rules referencing context the client\n // doesn't have). Parallels `componentsState` in structure but excludes\n // contributions from client-eligible CCs that also ship in\n // `realtimeComponentsConditions`.\n //\n // The realtime layer uses this as the fallback action to restore when a\n // realtime CC stops firing on a touched component — without it the SDK\n // can't tell whether the action in `componentsState` came from a\n // server-only CC (must persist) or from a realtime CC also re-shipped\n // (must clear).\n //\n // Absent on old backends; new SDKs fall back to a legacy heuristic that\n // infers the same information from `componentsState`, so the old-BE /\n // new-SDK combination still works correctly.\n serverOnlyComponentsState?: Record<string, string>;\n // Client-evaluable visibility conditions, populated only by new backends.\n // Absent on old backends; new SDKs ignore when absent.\n realtimeComponentsConditions?: RealtimeComponentsCondition[];\n}\n\nexport type SSOQueryParams = {\n oidcIdpStateId?: string;\n samlIdpStateId?: string;\n wsfedIdpStateId?: string;\n samlIdpUsername?: string;\n descopeIdpInitiated?: boolean;\n ssoAppId?: string;\n customAppId?: string;\n thirdPartyAppId: string;\n thirdPartyAppStateId?: string;\n applicationScopes?: string;\n} & OIDCOptions;\n\nexport type OIDCOptions = {\n oidcLoginHint?: string;\n oidcPrompt?: string;\n oidcErrorRedirectUri?: string;\n oidcResource?: string;\n};\n\nexport type FlowState = {\n flowId: string;\n projectId: string;\n baseUrl: string;\n tenant: string;\n stepId: string;\n stepName: string;\n executionId: string;\n action: string;\n redirectTo: string;\n redirectIsPopup: boolean;\n openInNewTabUrl?: string;\n redirectUrl: string;\n screenId: string;\n screenState: ScreenState;\n token: string;\n code: string;\n isPopup: boolean;\n exchangeError: string;\n webauthnTransactionId: string;\n webauthnOptions: string;\n redirectAuthCodeChallenge: string;\n redirectAuthCallbackUrl: string;\n redirectAuthBackupCallbackUri: string;\n redirectAuthInitiator: string;\n deferredRedirect: boolean;\n deferredPolling: boolean;\n locale: string;\n samlIdpResponseUrl: string;\n samlIdpResponseSamlResponse: string;\n samlIdpResponseRelayState: string;\n wsFedIdpResponseUrl: string;\n wsFedIdpResponseWresult: string;\n wsFedIdpResponseWctx: string;\n nativeResponseType: string;\n nativePayload: Record<string, any>;\n reqTimestamp: number;\n} & SSOQueryParams;\n\nexport type StepState = {\n screenState: ScreenState;\n screenId: string;\n stepName: string;\n htmlFilename: string;\n htmlLocaleFilename: string;\n next: NextFn;\n direction: Direction | undefined;\n samlIdpUsername: string;\n action?: string;\n locale?: string;\n} & OIDCOptions;\n\nexport type CustomScreenState = Omit<\n ScreenState,\n // Removed from the top level of the custom-screen context:\n // - cssVars/componentsConfig/inputs/clientScripts: internal.\n // - errorText/errorType: reshaped into `error`.\n // - the rest: server-produced screen data, relocated under `data`.\n | 'cssVars'\n | 'componentsConfig'\n | 'inputs'\n | 'errorText'\n | 'errorType'\n | 'clientScripts'\n | 'totp'\n | 'notp'\n | 'sentTo'\n | 'sso'\n | 'selfProvisionDomains'\n> & {\n error?: {\n text: ScreenState['errorText'];\n type: ScreenState['errorType'];\n };\n action?: string;\n /**\n * All server-produced screen data, in one place. Previously this data was spread\n * across the top level and a deeply-nested, selector-keyed `componentsConfig`.\n * Only known, documented fields are exposed (renamed/normalized); anything else is\n * dropped. SDK-owned/reserved — a value with this key coming from the backend is ignored.\n */\n data?: CustomScreenData;\n};\n\n/**\n * Cleaned view of the flow screen's `componentsConfig`. Every field is optional and\n * only present when the screen actually produces it.\n */\nexport type CustomScreenData = {\n /** TOTP MFA setup: QR image + provisioning URL. */\n totp?: { image?: string; provisionUrl?: string };\n /** Notification-OTP setup: image + redirect URL. */\n notp?: { image?: string; redirectUrl?: string };\n /** Where the OTP/code was sent — masked email and/or phone. */\n sentTo?: { maskedEmail?: string; maskedPhone?: string };\n /** SSO (SAML) service-provider config for SSO-setup screens. */\n sso?: { acsUrl?: string; descopeEntityId?: string; spMetadataUrl?: string };\n /** Email domains allowed to self-provision into the tenant. */\n selfProvisionDomains?: string;\n /** OAuth scopes an inbound (third-party) app is asking the user to approve. */\n inboundAppApproveScopes?: { desc: string; id: string; required: boolean }[];\n /** Password rules to show/enforce on a password screen. */\n passwordPolicy?: {\n minLength?: string;\n strength?: string;\n disallowedChars?: string;\n email?: string;\n activePolicies?: string;\n availablePolicies?: string;\n };\n /** Security questions to set up, plus how many are required. */\n securityQuestionsSetup?: {\n questions?: { id: string; text: string }[];\n count?: number;\n };\n /** Security questions to verify the user against. */\n securityQuestionsVerify?: { questions?: { id: string; text: string }[] };\n /** Tenants the user can pick from (tenant-selection screen). */\n userTenants?: { label: string; value: string }[];\n /** SSO applications the user can pick from. */\n ssoApplications?: { label: string; value: string }[];\n /** SSO configurations the user can pick from. */\n ssoConfigurations?: { label: string; value: string }[];\n /** Roles the user can pick from. */\n userRoles?: { label: string; value: string }[];\n /** SAML attribute-mapping options (SSO-setup screens). */\n samlAttributeMappings?: { label: string; value: string }[];\n /** OIDC attribute-mapping options (SSO-setup screens). */\n oidcAttributeMappings?: { label: string; value: string }[];\n /** SAML group-mapping options (SSO-setup screens). */\n samlGroupMappings?: { label: string; value: string }[];\n /** Generated MFA recovery codes to display to the user. */\n recoveryCodes?: string[];\n /** Outbound OAuth app button info (label, icon, app id). */\n outboundApp?: { label?: string; iconSrc?: string; appId?: string };\n\n // Contract rule: every key on `data` is an SDK-owned, documented name. We never\n // place arbitrary, flow-author-controlled keys directly on `data`, so adding new\n // named fields stays backwards-compatible (no collisions, no reshape).\n //\n // Reserved for a future addition: dynamic-select options. Their keys are the\n // flow's own select field names (e.g. \"country\"), so they can't be named here —\n // when exposed, they'll go under their own sub-map to keep them collision-free:\n // selects?: Record<string, { label: string; value: string }[]>;\n // Not populated yet (see README). Adding it later is additive, not breaking.\n};\n\nexport type DebugState = {\n isDebug: boolean;\n};\n\nexport interface ScriptElement extends HTMLDivElement {\n moduleRes?: ScriptModule;\n}\n\nexport type ScriptModule = {\n /**\n * Unique identifier of the module.\n */\n id: string;\n /**\n * Notifies the module that it should start any profiling or monitoring.\n */\n start?: () => void;\n /**\n * Notifies the module that it should stop any profiling or monitoring.\n */\n stop?: () => void;\n /**\n * Presents the user with any required interaction to get a refreshed token or state,\n * e.g., a challenge or captcha.\n *\n * Modules should return a value of true if the presentation completed successfully,\n * false if it was cancelled by the user, and throw an error in case of failure.\n *\n * This is called before form submission (via a next call) after a button click.\n */\n present?: () => Promise<boolean>;\n /**\n * Refreshes any tokens or state that might be needed before form submission.\n *\n * Modules should throw an error in case of failure.\n */\n refresh?: () => Promise<void>;\n};\n\nexport type ClientScript = {\n id: string;\n initArgs: Record<string, any>;\n resultKey?: string;\n};\n\nexport type NextFn = KeepArgsByIndex<SdkFlowNext, [2, 5]> & {\n isCustomScreen?: boolean;\n};\nexport type NextFnReturnPromiseValue = Awaited<ReturnType<NextFn>>;\n\nexport type DebuggerMessage = {\n title: string;\n description?: string;\n};\n\nexport type FlowStateUpdateFn = (state: FlowState) => void;\n\ntype Operator =\n | 'equal'\n | 'not-equal'\n | 'contains'\n | 'greater-than'\n | 'greater-than-or-equal'\n | 'less-than'\n | 'less-than-or-equal'\n | 'empty'\n | 'not-empty'\n | 'is-true'\n | 'is-false'\n | 'in'\n | 'not-in'\n | 'in-range'\n | 'not-in-range'\n | 'devised-by';\n\nexport interface ClientConditionResult {\n screenId: string;\n screenName: string;\n clientScripts?: ClientScript[];\n componentsConfig?: ComponentsConfig;\n interactionId: string;\n}\n\nexport interface ClientCondition {\n operator: Operator;\n key: string;\n predicate?: string | number;\n met: ClientConditionResult;\n unmet?: ClientConditionResult;\n}\n\nexport type AutoFocusOptions = true | false | 'skipFirstScreen';\n\nexport type ThemeOptions = 'light' | 'dark' | 'os';\n\nexport type Key =\n | 'lastAuth.loginId'\n | 'idpInitiated'\n | 'externalToken'\n | 'abTestingKey';\n\ntype CheckFunction = (ctx: Context, predicate?: string | number) => boolean;\n\nexport type ConditionsMap = {\n [key in Key]: {\n [operator in Operator]?: CheckFunction;\n };\n};\n\nexport interface Context {\n loginId?: string;\n code?: string;\n token?: string;\n abTestingKey?: number;\n lastAuth?: LastAuthState;\n}\n\nexport type DescopeUI = Record<string, () => Promise<void>> & {\n componentsThemeManager: Record<string, any>;\n};\n\ntype Font = {\n family: string[];\n label: string;\n url?: string;\n};\n\ntype ThemeTemplate = {\n fonts: {\n font1: Font;\n font2: Font;\n };\n};\n\ntype ThemeColor = {\n main: string;\n dark: string;\n light: string;\n highlight: string;\n contrast: string;\n};\n\nexport type OverrideTheme = {\n globals?: {\n colors?: {\n primary?: ThemeColor;\n secondary?: ThemeColor;\n };\n };\n};\n\nexport type OverrideThemes = {\n dark?: OverrideTheme;\n light?: OverrideTheme;\n};\n\nexport type FlowConfig = {\n startScreenId?: string;\n startScreenName?: string;\n version: number;\n targetLocales?: string[];\n conditions?: ClientCondition[];\n condition?: ClientCondition;\n fingerprintEnabled?: boolean;\n fingerprintKey?: string;\n // Per-flow switch for client-side validation error tracking. Absent means off.\n clientValidationTrackingEnabled?: boolean;\n sdkScripts?: [\n {\n id: string;\n initArgs: Record<string, any>;\n resultKey?: string;\n },\n ];\n clientScripts?: ClientScript[];\n componentsConfig?: ComponentsConfig;\n};\n\nexport interface ProjectConfiguration {\n componentsVersion: string;\n cssTemplate: {\n dark: ThemeTemplate;\n light: ThemeTemplate;\n };\n flows: {\n [key: string]: FlowConfig; // dynamic key names for flows\n };\n}\n\nexport type FlowStatus = 'loading' | 'error' | 'success' | 'ready' | 'initial';\n\nexport type CustomStorage = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n};\n\nexport type FlowJWTResponse = JWTResponse & {\n flowOutput?: Record<string, any>;\n};\n"],"names":["Direction"],"mappings":"IAoCYA,GAAZ,SAAYA,GACVA,EAAA,SAAA,WACAA,EAAA,QAAA,SACD,CAHD,CAAYA,IAAAA,EAGX,CAAA"}