@descope/web-component 4.5.0 → 4.5.2

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.
Files changed (55) hide show
  1. package/dist/cjs/debugger-wc.js.map +1 -1
  2. package/dist/cjs/descope-wc/BaseDescopeWc.js +1 -1
  3. package/dist/cjs/descope-wc/BaseDescopeWc.js.map +1 -1
  4. package/dist/cjs/descope-wc/DescopeWc.js +1 -1
  5. package/dist/cjs/descope-wc/DescopeWc.js.map +1 -1
  6. package/dist/cjs/helpers/abTestingKey.js.map +1 -1
  7. package/dist/cjs/helpers/conditions.js.map +1 -1
  8. package/dist/cjs/helpers/flowInputs.js.map +1 -1
  9. package/dist/cjs/helpers/helpers.js.map +1 -1
  10. package/dist/cjs/helpers/lastAuth.js.map +1 -1
  11. package/dist/cjs/helpers/oidcSession.js.map +1 -1
  12. package/dist/cjs/helpers/positionHelpers.js.map +1 -1
  13. package/dist/cjs/helpers/realtime-conditions/applier.js.map +1 -1
  14. package/dist/cjs/helpers/realtime-conditions/evaluator.js.map +1 -1
  15. package/dist/cjs/helpers/state.js.map +1 -1
  16. package/dist/cjs/helpers/storage.js.map +1 -1
  17. package/dist/cjs/helpers/templates.js.map +1 -1
  18. package/dist/cjs/helpers/webauthn.js.map +1 -1
  19. package/dist/cjs/mixins/componentConditionsMixin.js.map +1 -1
  20. package/dist/cjs/mixins/duplicateFlowWarningMixin.js.map +1 -1
  21. package/dist/cjs/mixins/formMountMixin.js.map +1 -1
  22. package/dist/cjs/mixins/passwordManagerMixin.js.map +1 -1
  23. package/dist/cjs/mixins/validationTrackingMixin.js.map +1 -1
  24. package/dist/cjs/types.js.map +1 -1
  25. package/dist/esm/constants/customScreens.js.map +1 -1
  26. package/dist/esm/debugger-wc.js.map +1 -1
  27. package/dist/esm/descope-wc/BaseDescopeWc.js +1 -1
  28. package/dist/esm/descope-wc/BaseDescopeWc.js.map +1 -1
  29. package/dist/esm/descope-wc/DescopeWc.js +1 -1
  30. package/dist/esm/descope-wc/DescopeWc.js.map +1 -1
  31. package/dist/esm/helpers/abTestingKey.js.map +1 -1
  32. package/dist/esm/helpers/conditions.js.map +1 -1
  33. package/dist/esm/helpers/flowInputs.js.map +1 -1
  34. package/dist/esm/helpers/helpers.js +1 -1
  35. package/dist/esm/helpers/helpers.js.map +1 -1
  36. package/dist/esm/helpers/lastAuth.js +1 -1
  37. package/dist/esm/helpers/lastAuth.js.map +1 -1
  38. package/dist/esm/helpers/oidcSession.js +1 -1
  39. package/dist/esm/helpers/oidcSession.js.map +1 -1
  40. package/dist/esm/helpers/positionHelpers.js.map +1 -1
  41. package/dist/esm/helpers/realtime-conditions/applier.js.map +1 -1
  42. package/dist/esm/helpers/realtime-conditions/evaluator.js.map +1 -1
  43. package/dist/esm/helpers/state.js.map +1 -1
  44. package/dist/esm/helpers/storage.js.map +1 -1
  45. package/dist/esm/helpers/templates.js.map +1 -1
  46. package/dist/esm/helpers/webauthn.js.map +1 -1
  47. package/dist/esm/mixins/componentConditionsMixin.js.map +1 -1
  48. package/dist/esm/mixins/duplicateFlowWarningMixin.js.map +1 -1
  49. package/dist/esm/mixins/formMountMixin.js.map +1 -1
  50. package/dist/esm/mixins/passwordManagerMixin.js.map +1 -1
  51. package/dist/esm/mixins/validationTrackingMixin.js.map +1 -1
  52. package/dist/esm/types.js.map +1 -1
  53. package/dist/index.d.ts +87 -87
  54. package/dist/index.js +2 -2
  55. package/package.json +2 -2
@@ -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 reuse?: 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":"aAoCA,IAAYA,EAAAA,QAGXA,eAAA,GAHWA,EAAAA,QAASA,YAATA,kBAGX,CAAA,IAFC,SAAA,WACAA,EAAA,QAAA"}
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 reuse?: 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":"aAoCA,IAAYA,EAAAA,QAAAA,eAAAA,GAAAA,EAAAA,QAAAA,YAAAA,kBAAS,CAAA,IACnB,SAAA,WACAA,EAAA,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"customScreens.js","sources":["../../../src/lib/constants/customScreens.ts"],"sourcesContent":["// Keys stripped from the top level of the custom-screen context.\n// `cssVars`/`componentsConfig`/`inputs` are internal; `errorText`/`errorType` are\n// reshaped into `error`; `clientScripts` is internal; `data` is SDK-owned (rebuilt in\n// transformStepStateForCustomScreen, so a backend-provided value never leaks). The rest\n// are server-produced screen data relocated under `data`.\nexport const EXCLUDED_STATE_KEYS = [\n 'cssVars',\n 'componentsConfig',\n 'inputs',\n 'errorText',\n 'errorType',\n 'clientScripts',\n 'data',\n 'totp',\n 'notp',\n 'sentTo',\n 'sso',\n 'selfProvisionDomains',\n];\n"],"names":["EXCLUDED_STATE_KEYS"],"mappings":"AAKa,MAAAA,EAAsB,CACjC,UACA,mBACA,SACA,YACA,YACA,gBACA,OACA,OACA,OACA,SACA,MACA"}
1
+ {"version":3,"file":"customScreens.js","sources":["../../../src/lib/constants/customScreens.ts"],"sourcesContent":["// Keys stripped from the top level of the custom-screen context.\n// `cssVars`/`componentsConfig`/`inputs` are internal; `errorText`/`errorType` are\n// reshaped into `error`; `clientScripts` is internal; `data` is SDK-owned (rebuilt in\n// transformStepStateForCustomScreen, so a backend-provided value never leaks). The rest\n// are server-produced screen data relocated under `data`.\nexport const EXCLUDED_STATE_KEYS = [\n 'cssVars',\n 'componentsConfig',\n 'inputs',\n 'errorText',\n 'errorType',\n 'clientScripts',\n 'data',\n 'totp',\n 'notp',\n 'sentTo',\n 'sso',\n 'selfProvisionDomains',\n];\n"],"names":["EXCLUDED_STATE_KEYS"],"mappings":"AAKO,MAAMA,EAAsB,CACjC,UACA,mBACA,SACA,YACA,YACA,gBACA,OACA,OACA,OACA,SACA,MACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"debugger-wc.js","sources":["../../src/lib/debugger-wc.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { compose, escapeHtml } from '@descope/sdk-helpers';\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport {\n addOnResize,\n dragElement,\n limitCoordinateToScreenBoundaries,\n State,\n} from './helpers';\nimport { DebuggerMessage } from './types';\n\nconst INITIAL_POS_THRESHOLD = 32;\nconst INITIAL_WIDTH = 300;\nconst INITIAL_HEIGHT = 200;\nconst MIN_SIZE = 200;\n\nconst template = document.createElement('template');\ntemplate.innerHTML = `\n<div class=\"debugger\">\n <div class=\"header\">\n <span>Debugger messages</span>\n </div>\n <div class=\"content\">\n <div class=\"empty-state\">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;\n\nconst icon = `<svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z\" fill=\"#ED404A\"/>\n</svg>\n`;\n\nconst style = `\n .debugger {\n all: initial;\n width: ${INITIAL_WIDTH}px;\n height: ${INITIAL_HEIGHT}px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: \"Helvetica Neue\", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: ${MIN_SIZE}px;\n max-width: 600px;\n max-height: calc(100% - ${INITIAL_POS_THRESHOLD * 2}px);\n min-height: ${MIN_SIZE}px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: \"\";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n`;\n\ntype MessagesState = { messages: DebuggerMessage[] };\n\nconst BaseClass = compose(injectStyleMixin)(HTMLElement);\n\nclass Debugger extends BaseClass {\n #messagesState = new State<MessagesState>({ messages: [] });\n\n #rootEle: HTMLDivElement;\n\n #contentEle: HTMLDivElement;\n\n #headerEle: HTMLDivElement;\n\n #eventsCbRefs = {\n resize: this.#onWindowResize.bind(this),\n };\n\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n\n this.#rootEle = this.shadowRoot.querySelector<HTMLDivElement>('.debugger');\n this.#contentEle = this.#rootEle.querySelector<HTMLDivElement>('.content');\n this.#headerEle = this.#rootEle.querySelector<HTMLDivElement>('.header');\n\n this.#initStyle();\n }\n\n #initStyle() {\n this.injectStyle(style);\n\n this.#rootEle.style.top = `${INITIAL_POS_THRESHOLD}px`;\n this.#rootEle.style.left = `${\n window.innerWidth - INITIAL_WIDTH - INITIAL_POS_THRESHOLD\n }px`;\n }\n\n updateData(data: DebuggerMessage | DebuggerMessage[]) {\n this.#messagesState.update((state) => ({\n messages: state.messages.concat(data),\n }));\n }\n\n #onNewMessages(data: MessagesState) {\n this.#renderMessages(data);\n this.#setCollapsibleMessages();\n }\n\n #renderMessages(data: MessagesState) {\n this.#contentEle.innerHTML = data.messages\n .map(\n (message) => `\n <div class=\"msg\">\n ${icon}\n <div class=\"msg_content\">\n <div class=\"msg_title\">\n ${escapeHtml(message.title)}\n </div>\n <div class=\"msg_desc\">\n ${escapeHtml(message.description)}\n </div>\n </div>\n <div class=\"chevron\"></div>\n </div>\n `,\n )\n .join('');\n }\n\n #setCollapsibleMessages() {\n this.#contentEle.querySelectorAll('.msg').forEach((ele: HTMLElement) => {\n const descEle = ele.querySelector('.msg_desc');\n const lineHeight = 20;\n const isScroll = descEle.scrollWidth > descEle.clientWidth;\n const isMultiLine = descEle.clientHeight > lineHeight;\n const isCollapsible = isScroll || isMultiLine;\n\n if (isCollapsible) {\n ele.classList.add('collapsible');\n ele.onclick = (e: MouseEvent) => {\n // message description should not toggle collapse\n if (!(e.target as HTMLElement).classList.contains('msg_desc')) {\n ele.classList.toggle('collapsed');\n }\n };\n } else {\n ele.classList.remove('collapsible');\n ele.onclick = null;\n }\n });\n }\n\n #onWindowResize() {\n // when window is resizing we want to make sure debugger is still visible\n const [left, top] = limitCoordinateToScreenBoundaries(\n this.#rootEle,\n Number.parseInt(this.#rootEle.style.left, 10),\n Number.parseInt(this.#rootEle.style.top, 10),\n { top: 'all', bottom: 100, left: 100, right: 100 },\n );\n this.#rootEle.style.top = `${top}px`;\n this.#rootEle.style.left = `${left}px`;\n }\n\n async init() {\n super.init?.();\n dragElement(this.#rootEle, this.#headerEle, {\n top: 'all',\n bottom: 100,\n left: 100,\n right: 100,\n });\n\n window.addEventListener('resize', this.#eventsCbRefs.resize);\n\n addOnResize(this.#rootEle);\n this.#rootEle.onresize = this.#setCollapsibleMessages.bind(this);\n\n this.#messagesState.subscribe(this.#onNewMessages.bind(this));\n }\n\n disconnectedCallback() {\n this.#messagesState.unsubscribeAll();\n window.removeEventListener('resize', this.#eventsCbRefs.resize);\n }\n}\n\nif (!customElements.get('descope-debugger')) {\n customElements.define('descope-debugger', Debugger);\n}\nexport default Debugger;\n"],"names":["template","document","createElement","innerHTML","BaseClass","compose","injectStyleMixin","HTMLElement","Debugger","constructor","super","_Debugger_messagesState","set","this","State","messages","_Debugger_rootEle","_Debugger_contentEle","_Debugger_headerEle","_Debugger_eventsCbRefs","resize","__classPrivateFieldGet","_Debugger_instances","_Debugger_onWindowResize","bind","attachShadow","mode","shadowRoot","appendChild","content","cloneNode","__classPrivateFieldSet","querySelector","_Debugger_initStyle","call","updateData","data","update","state","concat","init","_a","_super","dragElement","top","bottom","left","right","window","addEventListener","addOnResize","onresize","_Debugger_setCollapsibleMessages","subscribe","_Debugger_onNewMessages","disconnectedCallback","unsubscribeAll","removeEventListener","injectStyle","style","innerWidth","_Debugger_renderMessages","map","message","escapeHtml","title","description","join","querySelectorAll","forEach","ele","descEle","isScroll","scrollWidth","clientWidth","isMultiLine","clientHeight","classList","add","onclick","e","target","contains","toggle","remove","limitCoordinateToScreenBoundaries","Number","parseInt","customElements","get","define"],"mappings":"uiBAWA,MAKMA,EAAWC,SAASC,cAAc,YACxCF,EAASG,UAAY,sNAarB,MAiHMC,EAAYC,EAAQC,EAARD,CAA0BE,aAE5C,MAAMC,UAAiBJ,EAarB,WAAAK,GACEC,oBAbFC,EAAiBC,IAAAC,KAAA,IAAIC,EAAqB,CAAEC,SAAU,MAEtDC,EAAyBJ,IAAAC,UAAA,GAEzBI,EAA4BL,IAAAC,UAAA,GAE5BK,EAA2BN,IAAAC,UAAA,GAE3BM,EAAgBP,IAAAC,KAAA,CACdO,OAAQC,EAAAR,KAAIS,EAAA,IAAAC,GAAiBC,KAAKX,QAMlCA,KAAKY,aAAa,CAAEC,KAAM,SAC1Bb,KAAKc,WAAWC,YAAY5B,EAAS6B,QAAQC,WAAU,IAEvDC,EA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GAAJlB,KAAArB,KACF,aAEgBuB,GACdf,EAAAR,KAAgBI,EAAA,KAACd,UAAYiC,EAAKrB,SAC/B+C,KACEC,GAAY,qlDAKTC,EAAWD,EAAQE,qEAGnBD,EAAWD,EAAQG,kGAOxBC,KAAK,GACV,EAACf,EAAA,WAGC/B,EAAAR,KAAII,EAAA,KAAamD,iBAAiB,QAAQC,SAASC,IACjD,MAAMC,EAAUD,EAAItC,cAAc,aAE5BwC,EAAWD,EAAQE,YAAcF,EAAQG,YACzCC,EAAcJ,EAAQK,aAFT,GAGGJ,GAAYG,GAGhCL,EAAIO,UAAUC,IAAI,eAClBR,EAAIS,QAAWC,IAEPA,EAAEC,OAAuBJ,UAAUK,SAAS,aAChDZ,EAAIO,UAAUM,OAAO,YACtB,IAGHb,EAAIO,UAAUO,OAAO,eACrBd,EAAIS,QAAU,KACf,GAEL,EAACxD,EAAA,WAIC,MAAOuB,EAAMF,GAAOyC,EAClBhE,EAAAR,KAAaG,EAAA,KACbsE,OAAOC,SAASlE,EAAAR,KAAaG,EAAA,KAAC2C,MAAMb,KAAM,IAC1CwC,OAAOC,SAASlE,EAAAR,KAAIG,EAAA,KAAU2C,MAAMf,IAAK,IACzC,CAAEA,IAAK,MAAOC,OAAQ,IAAKC,KAAM,IAAKC,MAAO,MAE/C1B,EAAAR,KAAaG,EAAA,KAAC2C,MAAMf,IAAM,GAAGA,MAC7BvB,EAAAR,KAAaG,EAAA,KAAC2C,MAAMb,KAAO,GAAGA,KAChC,EAyBG0C,eAAeC,IAAI,qBACtBD,eAAeE,OAAO,mBAAoBlF"}
1
+ {"version":3,"file":"debugger-wc.js","sources":["../../src/lib/debugger-wc.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { compose, escapeHtml } from '@descope/sdk-helpers';\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport {\n addOnResize,\n dragElement,\n limitCoordinateToScreenBoundaries,\n State,\n} from './helpers';\nimport { DebuggerMessage } from './types';\n\nconst INITIAL_POS_THRESHOLD = 32;\nconst INITIAL_WIDTH = 300;\nconst INITIAL_HEIGHT = 200;\nconst MIN_SIZE = 200;\n\nconst template = document.createElement('template');\ntemplate.innerHTML = `\n<div class=\"debugger\">\n <div class=\"header\">\n <span>Debugger messages</span>\n </div>\n <div class=\"content\">\n <div class=\"empty-state\">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;\n\nconst icon = `<svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z\" fill=\"#ED404A\"/>\n</svg>\n`;\n\nconst style = `\n .debugger {\n all: initial;\n width: ${INITIAL_WIDTH}px;\n height: ${INITIAL_HEIGHT}px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: \"Helvetica Neue\", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: ${MIN_SIZE}px;\n max-width: 600px;\n max-height: calc(100% - ${INITIAL_POS_THRESHOLD * 2}px);\n min-height: ${MIN_SIZE}px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: \"\";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n`;\n\ntype MessagesState = { messages: DebuggerMessage[] };\n\nconst BaseClass = compose(injectStyleMixin)(HTMLElement);\n\nclass Debugger extends BaseClass {\n #messagesState = new State<MessagesState>({ messages: [] });\n\n #rootEle: HTMLDivElement;\n\n #contentEle: HTMLDivElement;\n\n #headerEle: HTMLDivElement;\n\n #eventsCbRefs = {\n resize: this.#onWindowResize.bind(this),\n };\n\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n\n this.#rootEle = this.shadowRoot.querySelector<HTMLDivElement>('.debugger');\n this.#contentEle = this.#rootEle.querySelector<HTMLDivElement>('.content');\n this.#headerEle = this.#rootEle.querySelector<HTMLDivElement>('.header');\n\n this.#initStyle();\n }\n\n #initStyle() {\n this.injectStyle(style);\n\n this.#rootEle.style.top = `${INITIAL_POS_THRESHOLD}px`;\n this.#rootEle.style.left = `${\n window.innerWidth - INITIAL_WIDTH - INITIAL_POS_THRESHOLD\n }px`;\n }\n\n updateData(data: DebuggerMessage | DebuggerMessage[]) {\n this.#messagesState.update((state) => ({\n messages: state.messages.concat(data),\n }));\n }\n\n #onNewMessages(data: MessagesState) {\n this.#renderMessages(data);\n this.#setCollapsibleMessages();\n }\n\n #renderMessages(data: MessagesState) {\n this.#contentEle.innerHTML = data.messages\n .map(\n (message) => `\n <div class=\"msg\">\n ${icon}\n <div class=\"msg_content\">\n <div class=\"msg_title\">\n ${escapeHtml(message.title)}\n </div>\n <div class=\"msg_desc\">\n ${escapeHtml(message.description)}\n </div>\n </div>\n <div class=\"chevron\"></div>\n </div>\n `,\n )\n .join('');\n }\n\n #setCollapsibleMessages() {\n this.#contentEle.querySelectorAll('.msg').forEach((ele: HTMLElement) => {\n const descEle = ele.querySelector('.msg_desc');\n const lineHeight = 20;\n const isScroll = descEle.scrollWidth > descEle.clientWidth;\n const isMultiLine = descEle.clientHeight > lineHeight;\n const isCollapsible = isScroll || isMultiLine;\n\n if (isCollapsible) {\n ele.classList.add('collapsible');\n ele.onclick = (e: MouseEvent) => {\n // message description should not toggle collapse\n if (!(e.target as HTMLElement).classList.contains('msg_desc')) {\n ele.classList.toggle('collapsed');\n }\n };\n } else {\n ele.classList.remove('collapsible');\n ele.onclick = null;\n }\n });\n }\n\n #onWindowResize() {\n // when window is resizing we want to make sure debugger is still visible\n const [left, top] = limitCoordinateToScreenBoundaries(\n this.#rootEle,\n Number.parseInt(this.#rootEle.style.left, 10),\n Number.parseInt(this.#rootEle.style.top, 10),\n { top: 'all', bottom: 100, left: 100, right: 100 },\n );\n this.#rootEle.style.top = `${top}px`;\n this.#rootEle.style.left = `${left}px`;\n }\n\n async init() {\n super.init?.();\n dragElement(this.#rootEle, this.#headerEle, {\n top: 'all',\n bottom: 100,\n left: 100,\n right: 100,\n });\n\n window.addEventListener('resize', this.#eventsCbRefs.resize);\n\n addOnResize(this.#rootEle);\n this.#rootEle.onresize = this.#setCollapsibleMessages.bind(this);\n\n this.#messagesState.subscribe(this.#onNewMessages.bind(this));\n }\n\n disconnectedCallback() {\n this.#messagesState.unsubscribeAll();\n window.removeEventListener('resize', this.#eventsCbRefs.resize);\n }\n}\n\nif (!customElements.get('descope-debugger')) {\n customElements.define('descope-debugger', Debugger);\n}\nexport default Debugger;\n"],"names":["template","document","createElement","innerHTML","BaseClass","compose","injectStyleMixin","HTMLElement","Debugger","constructor","super","_Debugger_messagesState","set","this","State","messages","_Debugger_rootEle","_Debugger_contentEle","_Debugger_headerEle","_Debugger_eventsCbRefs","resize","__classPrivateFieldGet","_Debugger_instances","_Debugger_onWindowResize","bind","attachShadow","mode","shadowRoot","appendChild","content","cloneNode","__classPrivateFieldSet","querySelector","_Debugger_initStyle","call","updateData","data","update","state","concat","init","_a","_super","dragElement","top","bottom","left","right","window","addEventListener","addOnResize","onresize","_Debugger_setCollapsibleMessages","subscribe","_Debugger_onNewMessages","disconnectedCallback","unsubscribeAll","removeEventListener","injectStyle","style","innerWidth","_Debugger_renderMessages","map","message","escapeHtml","title","description","join","querySelectorAll","forEach","ele","descEle","isScroll","scrollWidth","clientWidth","isMultiLine","clientHeight","classList","add","onclick","e","target","contains","toggle","remove","limitCoordinateToScreenBoundaries","Number","parseInt","customElements","get","define"],"mappings":"uiBAWA,MAKMA,EAAWC,SAASC,cAAc,YACxCF,EAASG,UAAY,sNAarB,MAiHMC,EAAYC,EAAQC,EAARD,CAA0BE,aAE5C,MAAMC,UAAiBJ,EAarB,WAAAK,GACEC,oBAbFC,EAAAC,IAAAC,KAAiB,IAAIC,EAAqB,CAAEC,SAAU,MAEtDC,EAAAJ,IAAAC,UAAA,GAEAI,EAAAL,IAAAC,UAAA,GAEAK,EAAAN,IAAAC,UAAA,GAEAM,EAAAP,IAAAC,KAAgB,CACdO,OAAQC,EAAAR,KAAIS,EAAA,IAAAC,GAAiBC,KAAKX,QAMlCA,KAAKY,aAAa,CAAEC,KAAM,SAC1Bb,KAAKc,WAAWC,YAAY5B,EAAS6B,QAAQC,WAAU,IAEvDC,EAAAlB,KAAIG,EAAYH,KAAKc,WAAWK,cAA8B,aAAY,KAC1ED,EAAAlB,KAAII,EAAeI,EAAAR,KAAIG,EAAA,KAAUgB,cAA8B,YAAW,KAC1ED,EAAAlB,KAAIK,EAAcG,EAAAR,KAAIG,EAAA,KAAUgB,cAA8B,WAAU,KAExEX,EAAAR,KAAIS,EAAA,IAAAW,GAAWC,KAAfrB,KACF,CAWA,UAAAsB,CAAWC,GACTf,EAAAR,KAAIF,EAAA,KAAgB0B,QAAQC,IAAK,CAC/BvB,SAAUuB,EAAMvB,SAASwB,OAAOH,MAEpC,CA+DM,IAAAI,0GACM,QAAVC,EAAAC,EAAMF,YAAI,IAAAC,GAAAA,EAAAP,KAAArB,MACV8B,EAAYtB,EAAAR,KAAI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OAAO,YACvB,IAGFb,EAAIO,UAAUO,OAAO,eACrBd,EAAIS,QAAU,KAChB,GAEJ,EAACxD,EAAA,WAIC,MAAOuB,EAAMF,GAAOyC,EAClBhE,EAAAR,KAAIG,EAAA,KACJsE,OAAOC,SAASlE,EAAAR,KAAIG,EAAA,KAAU2C,MAAMb,KAAM,IAC1CwC,OAAOC,SAASlE,EAAAR,KAAIG,EAAA,KAAU2C,MAAMf,IAAK,IACzC,CAAEA,IAAK,MAAOC,OAAQ,IAAKC,KAAM,IAAKC,MAAO,MAE/C1B,EAAAR,KAAIG,EAAA,KAAU2C,MAAMf,IAAM,GAAGA,MAC7BvB,EAAAR,KAAIG,EAAA,KAAU2C,MAAMb,KAAO,GAAGA,KAChC,EAyBG0C,eAAeC,IAAI,qBACtBD,eAAeE,OAAO,mBAAoBlF"}
@@ -1,2 +1,2 @@
1
- import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as s}from"@descope/sdk-helpers";import{staticResourcesMixin as r}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as o}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import{telemetryMixin as a}from"@descope/sdk-mixins/telemetry-mixin";import{createSdk as u,getSessionToken as l}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as d}from"../constants/index.js";import{handleUrlParams as h,clearRunIdsFromUrl as c,camelCase as f,getRunIdsFromUrl as g,getContentUrl as p,fetchContent as m,withRetry as v}from"../helpers/helpers.js";import b from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as w}from"../helpers/storage.js";import{transformFlowInputFormData as k,extractNestedAttribute as y}from"../helpers/flowInputs.js";import{formMountMixin as C}from"../mixins/formMountMixin.js";import{componentConditionsMixin as x}from"../mixins/componentConditionsMixin.js";import{duplicateFlowWarningMixin as A}from"../mixins/duplicateFlowWarningMixin.js";import{passwordManagerMixin as j}from"../mixins/passwordManagerMixin.js";import{validationTrackingMixin as I}from"../mixins/validationTrackingMixin.js";import{CONFIG_FILENAME as E,PREV_VER_ASSETS_FOLDER as M}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as S}from"../constants/general.js";var L,U,O,W,P,D,N,T,F,K,R,z,J,V,B,H,q,$,Q,G,X,Y,Z,_,tt,et;const it=s(o,r,C,x,A,j,n,a,I)(HTMLElement);class st extends it{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","send-session-token","style-id"]}constructor(s){super(),L.add(this),this.sdkVersion="4.5.0",O.set(this,!1),W.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,L,"m",et).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},P.set(this,new b),D.set(this,new b),N.set(this,{}),this.getComponentsContext=()=>t(this,N,"f"),this.nextRequestStatus=new b({isLoading:!1}),T.set(this,void 0),F.set(this,{popstate:t(this,L,"m",V).bind(this),componentsContext:t(this,L,"m",G).bind(this)}),K.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),X.set(this,void 0),Y.set(this,void 0),i(this,K,s,"f"),t(this,L,"m",z).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return k(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return y(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t(this,W,"f")}set customStorage(t){if(t&&"function"!=typeof t.getItem)throw new Error("Custom storage must have a getItem method");if(t&&"function"!=typeof t.setItem)throw new Error("Custom storage must have a setItem method");if(t&&"function"!=typeof t.removeItem)throw new Error("Custom storage must have a removeItem method");i(this,W,t,"f"),w(t)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=t(this,Y,"f"))||void 0===e||e.call(this),i(this,X,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=d.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||o)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const u=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=s.init)||void 0===e?void 0:e.call(this),t(this,D,"f").subscribe(t(this,L,"m",tt).bind(this)),t(this,D,"f").update({isDebug:this.debug}),t(this,L,"m",J).call(this),yield t(this,L,"m",$).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const r=yield this.getConfig();if("isMissingConfig"in r&&r.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:o,stepId:n,token:a,code:u,isPopup:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p,ssoQueryParams:m}=h(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",t(this,F,"f").popstate),window.addEventListener("components-context",t(this,F,"f").componentsContext),t(this,P,"f").subscribe(t(this,L,"m",q).bind(this)),t(this,P,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:o,token:a,code:u,isPopup:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p},m)),i(this,O,!0,"f")}))}disconnectedCallback(){var e;t(this,P,"f").unsubscribeAll(),t(this,D,"f").unsubscribeAll(),t(this,L,"m",_).call(this),window.removeEventListener("popstate",t(this,F,"f").popstate),window.removeEventListener("components-context",t(this,F,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,s){var r;if(null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,i,s),this.shadowRoot.isConnected&&t(this,O,"f")&&i!==s&&U.observedAttributes.includes(e)){t(this,L,"m",J).call(this);const r=null===i;t(this,P,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return r||(n=null,o=null,c()),{[f(e)]:s,stepId:o,executionId:n}})),t(this,D,"f").update({isDebug:this.debug})}}}U=st,O=new WeakMap,W=new WeakMap,P=new WeakMap,D=new WeakMap,N=new WeakMap,T=new WeakMap,F=new WeakMap,K=new WeakMap,X=new WeakMap,Y=new WeakMap,L=new WeakSet,R=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},z=function(){t(this,L,"m",R).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},J=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];U.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[f(e)])throw Error(`${e} cannot be empty`)}))},V=function(){const{stepId:e,executionId:i}=g(this.flowId);t(this,P,"f").update({stepId:e,executionId:i})},B=function(i,s){u&&"function"==typeof u||this.logger.error("SDK was not loaded properly",u,JSON.stringify(u));const r=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},U.sdkConfigOverrides),{projectId:i,baseUrl:s});t(this,W,"f")&&(r.customStorage=t(this,W,"f")),this.sdk=u(r);const o={start:1,next:7};["start","next"].forEach((i=>{const s=this.sdk.flow[i],r=v(s,1e3,3);this.sdk.flow[i]=(...s)=>e(this,void 0,void 0,(function*(){const e=[...s],n=o[i],a=t(this,L,"m",H).call(this,e[n]);void 0!==a&&(e[n]=a);try{return yield r(...e)}catch(t){return this.logger.error(`Error in sdk flow ${i} function`,t),{error:{errorCode:S,errorDescription:t.toString()}}}}))}));const n=this.sdk.flow.start;this.sdk.flow.start=(...i)=>e(this,void 0,void 0,(function*(){return yield t(this,L,"m",Z).call(this),n.apply(this.sdk.flow,i)}))},H=function(t){if(!this.sendSessionToken)return t;const e=null==l?void 0:l(this.storagePrefix);return e?Object.assign(Object.assign({},null!=t?t:{}),{sessionJwt:e}):t},q=function(i,s,r){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:s}=i;if(r("projectId")||r("baseUrl")){if(!e)return;t(this,L,"m",B).call(this,e,s)}t(this,K,"f").call(this,i)}))},$=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,L,"m",Q).call(this))}))},Q=function(){return e(this,void 0,void 0,(function*(){const t=p({projectId:this.projectId,filename:E,assetsFolder:M,baseUrl:this.baseStaticUrl});try{return yield m(t,"json"),!0}catch(t){return!1}}))},G=function(e){i(this,N,Object.assign(Object.assign({},t(this,N,"f")),e.detail),"f")},Z=function(){return this.lazyStart?(t(this,X,"f")||i(this,X,new Promise((t=>{i(this,Y,t,"f")})),"f"),t(this,X,"f")):Promise.resolve()},_=function(){var e;null===(e=t(this,T,"f"))||void 0===e||e.remove(),i(this,T,null,"f")},tt=function(s){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,T,document.createElement("descope-debugger"),"f"),Object.assign(t(this,T,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,T,"f"))):t(this,L,"m",_).call(this)}))},et=function(e,i){var s;e&&this.debug&&(null===(s=t(this,T,"f"))||void 0===s||s.updateData({title:e,description:i}))},st.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.5.0"}};export{st as default};
1
+ import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as s}from"@descope/sdk-helpers";import{staticResourcesMixin as r}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as o}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import{telemetryMixin as a}from"@descope/sdk-mixins/telemetry-mixin";import{createSdk as u,getSessionToken as l}from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as d}from"../constants/index.js";import{handleUrlParams as h,clearRunIdsFromUrl as c,camelCase as f,getRunIdsFromUrl as g,getContentUrl as p,fetchContent as m,withRetry as v}from"../helpers/helpers.js";import b from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{setCustomStorage as w}from"../helpers/storage.js";import{transformFlowInputFormData as k,extractNestedAttribute as y}from"../helpers/flowInputs.js";import{formMountMixin as C}from"../mixins/formMountMixin.js";import{componentConditionsMixin as x}from"../mixins/componentConditionsMixin.js";import{duplicateFlowWarningMixin as A}from"../mixins/duplicateFlowWarningMixin.js";import{passwordManagerMixin as j}from"../mixins/passwordManagerMixin.js";import{validationTrackingMixin as I}from"../mixins/validationTrackingMixin.js";import{CONFIG_FILENAME as E,PREV_VER_ASSETS_FOLDER as M}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as S}from"../constants/general.js";var L,U,O,W,P,D,N,T,F,K,R,z,J,V,B,H,q,$,Q,G,X,Y,Z,_,tt,et;const it=s(o,r,C,x,A,j,n,a,I)(HTMLElement);class st extends it{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","send-session-token","style-id"]}constructor(s){super(),L.add(this),this.sdkVersion="4.5.2",O.set(this,!1),W.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,L,"m",et).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},P.set(this,new b),D.set(this,new b),N.set(this,{}),this.getComponentsContext=()=>t(this,N,"f"),this.nextRequestStatus=new b({isLoading:!1}),T.set(this,void 0),F.set(this,{popstate:t(this,L,"m",V).bind(this),componentsContext:t(this,L,"m",G).bind(this)}),K.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),X.set(this,void 0),Y.set(this,void 0),i(this,K,s,"f"),t(this,L,"m",z).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return k(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return y(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t(this,W,"f")}set customStorage(t){if(t&&"function"!=typeof t.getItem)throw new Error("Custom storage must have a getItem method");if(t&&"function"!=typeof t.setItem)throw new Error("Custom storage must have a setItem method");if(t&&"function"!=typeof t.removeItem)throw new Error("Custom storage must have a removeItem method");i(this,W,t,"f"),w(t)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=t(this,Y,"f"))||void 0===e||e.call(this),i(this,X,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=d.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||o)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const u=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=s.init)||void 0===e?void 0:e.call(this),t(this,D,"f").subscribe(t(this,L,"m",tt).bind(this)),t(this,D,"f").update({isDebug:this.debug}),t(this,L,"m",J).call(this),yield t(this,L,"m",$).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const r=yield this.getConfig();if("isMissingConfig"in r&&r.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:o,stepId:n,token:a,code:u,isPopup:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p,ssoQueryParams:m}=h(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",t(this,F,"f").popstate),window.addEventListener("components-context",t(this,F,"f").componentsContext),t(this,P,"f").subscribe(t(this,L,"m",q).bind(this)),t(this,P,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:o,token:a,code:u,isPopup:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p},m)),i(this,O,!0,"f")}))}disconnectedCallback(){var e;t(this,P,"f").unsubscribeAll(),t(this,D,"f").unsubscribeAll(),t(this,L,"m",_).call(this),window.removeEventListener("popstate",t(this,F,"f").popstate),window.removeEventListener("components-context",t(this,F,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,s){var r;if(null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,i,s),this.shadowRoot.isConnected&&t(this,O,"f")&&i!==s&&U.observedAttributes.includes(e)){t(this,L,"m",J).call(this);const r=null===i;t(this,P,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return r||(n=null,o=null,c()),{[f(e)]:s,stepId:o,executionId:n}})),t(this,D,"f").update({isDebug:this.debug})}}}U=st,O=new WeakMap,W=new WeakMap,P=new WeakMap,D=new WeakMap,N=new WeakMap,T=new WeakMap,F=new WeakMap,K=new WeakMap,X=new WeakMap,Y=new WeakMap,L=new WeakSet,R=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},z=function(){t(this,L,"m",R).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},J=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];U.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[f(e)])throw Error(`${e} cannot be empty`)}))},V=function(){const{stepId:e,executionId:i}=g(this.flowId);t(this,P,"f").update({stepId:e,executionId:i})},B=function(i,s){u&&"function"==typeof u||this.logger.error("SDK was not loaded properly",u,JSON.stringify(u));const r=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},U.sdkConfigOverrides),{projectId:i,baseUrl:s});t(this,W,"f")&&(r.customStorage=t(this,W,"f")),this.sdk=u(r);const o={start:1,next:7};["start","next"].forEach((i=>{const s=this.sdk.flow[i],r=v(s,1e3,3);this.sdk.flow[i]=(...s)=>e(this,void 0,void 0,(function*(){const e=[...s],n=o[i],a=t(this,L,"m",H).call(this,e[n]);void 0!==a&&(e[n]=a);try{return yield r(...e)}catch(t){return this.logger.error(`Error in sdk flow ${i} function`,t),{error:{errorCode:S,errorDescription:t.toString()}}}}))}));const n=this.sdk.flow.start;this.sdk.flow.start=(...i)=>e(this,void 0,void 0,(function*(){return yield t(this,L,"m",Z).call(this),n.apply(this.sdk.flow,i)}))},H=function(t){if(!this.sendSessionToken)return t;const e=null==l?void 0:l(this.storagePrefix);return e?Object.assign(Object.assign({},null!=t?t:{}),{sessionJwt:e}):t},q=function(i,s,r){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:s}=i;if(r("projectId")||r("baseUrl")){if(!e)return;t(this,L,"m",B).call(this,e,s)}t(this,K,"f").call(this,i)}))},$=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,L,"m",Q).call(this))}))},Q=function(){return e(this,void 0,void 0,(function*(){const t=p({projectId:this.projectId,filename:E,assetsFolder:M,baseUrl:this.baseStaticUrl});try{return yield m(t,"json"),!0}catch(t){return!1}}))},G=function(e){i(this,N,Object.assign(Object.assign({},t(this,N,"f")),e.detail),"f")},Z=function(){return this.lazyStart?(t(this,X,"f")||i(this,X,new Promise((t=>{i(this,Y,t,"f")})),"f"),t(this,X,"f")):Promise.resolve()},_=function(){var e;null===(e=t(this,T,"f"))||void 0===e||e.remove(),i(this,T,null,"f")},tt=function(s){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,T,document.createElement("descope-debugger"),"f"),Object.assign(t(this,T,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,T,"f"))):t(this,L,"m",_).call(this)}))},et=function(e,i){var s;e&&this.debug&&(null===(s=t(this,T,"f"))||void 0===s||s.updateData({title:e,description:i}))},st.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.5.2"}};export{st as default};
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { telemetryMixin } from '@descope/sdk-mixins/telemetry-mixin';\nimport { createSdk, getSessionToken } from '@descope/web-js-sdk';\nimport type { FlowNextOptions, FlowStartOptions } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n withRetry,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport {\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n validationTrackingMixin,\n} from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n injectStyleMixin,\n telemetryMixin,\n validationTrackingMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n ];\n }\n\n sdkVersion = BUILD_VERSION;\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get sendSessionToken() {\n return this.getAttribute('send-session-token') === 'true';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n 'theme-override',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // Position of the `options` argument in core-js-sdk's flow calls:\n // flow.start(flowId, options, conditionInteractionId, interactionId, componentsVersion, flowVersions, input, isCustomScreen)\n // flow.next(executionId, stepId, interactionId, version, componentsVersion, input, isCustomScreen, options)\n // We rely on these positions staying fixed - core-js-sdk keeps them stable\n // for backwards compatibility, and new params are only appended at the end\n const flowOptionsArgIdx = { start: 1, next: 7 };\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n const fnWithRetry = withRetry(origFn, 1000, 3);\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n const callArgs = [...args] as Parameters<typeof origFn>;\n const optionsIdx = flowOptionsArgIdx[key];\n const options = this.#injectSessionJwt(callArgs[optionsIdx]);\n if (options !== undefined) {\n callArgs[optionsIdx] = options;\n }\n try {\n const resp = await fnWithRetry(...callArgs);\n return resp;\n } catch (e) {\n this.logger.error(`Error in sdk flow ${key} function`, e);\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n\n // While `lazy-start` is set, hold every flow start call until start() is\n // called. Wrapping the sdk fn holds all call sites at once, and sits outside\n // the wrapper above so the session JWT is read when the call is really sent.\n const startFn = this.sdk.flow.start;\n this.sdk.flow.start = async (\n ...args: Parameters<typeof startFn>\n ): ReturnType<typeof startFn> => {\n await this.#waitForStart();\n\n return startFn.apply(this.sdk.flow, args);\n };\n }\n\n // adds the current session JWT to a flow request options (opt-in via the\n // send-session-token attribute), so the flow can read its validated claims\n // through the sessionJwtClaims context key. Accepts only the flow start/next\n // options types and preserves the given type on return. The token is read\n // via the standalone helper - the wrapping SDKs (e.g. react-sdk) override\n // the inner sdk with persistTokens: false, so the instance getter is absent\n #injectSessionJwt<T extends FlowStartOptions | FlowNextOptions>(\n options?: T,\n ): T | undefined {\n if (!this.sendSessionToken) return options;\n const sessionToken = getSessionToken?.(this.storagePrefix);\n if (!sessionToken) return options;\n return { ...(options ?? {}), sessionJwt: sessionToken } as T;\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n // Holds the flow's start call, so a host can preload a flow (config,\n // components, first screen) without creating a flow execution - e.g. a modal\n // that builds its flow ahead of being opened. `start()` is then the only way\n // that flow starts.\n get lazyStart() {\n return this.getAttribute('lazy-start') === 'true';\n }\n\n #startGate: Promise<void> | undefined;\n\n #releaseStartGate: (() => void) | undefined;\n\n // resolves immediately unless `lazy-start` is set, in which case it waits for\n // start()\n #waitForStart(): Promise<void> {\n if (!this.lazyStart) return Promise.resolve();\n\n if (!this.#startGate) {\n this.#startGate = new Promise((resolve) => {\n this.#releaseStartGate = resolve;\n });\n }\n\n return this.#startGate;\n }\n\n // Start a flow rendered with `lazy-start`. Safe to call before the flow\n // reached the held start call - it then goes through on arrival. The gate is\n // latched open rather than re-armed, so a flow restart (e.g. restart-on-error)\n // is not left waiting for another call.\n start() {\n this.#releaseStartGate?.();\n this.#startGate = Promise.resolve();\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n handleKeyPress() {\n this.logger.debug('Enable key press handler');\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n disableKeyPressHandler() {\n this.logger.debug('Disable key press handler');\n this.rootElement.onkeydown = null;\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.projectId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n // Forward to the composed mixin chain so each mixin's\n // disconnectedCallback (e.g. componentConditionsMixin) gets to clean up.\n // Without this, mixin disconnectedCallbacks are dead code.\n super.disconnectedCallback?.();\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n // Forward to the composed mixin chain first so other mixins always receive\n // the callback, regardless of the early return below.\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","componentConditionsMixin","duplicateFlowWarningMixin","passwordManagerMixin","injectStyleMixin","telemetryMixin","validationTrackingMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","this","sdkVersion","_BaseDescopeWc_init","set","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","_BaseDescopeWc_startGate","_BaseDescopeWc_releaseStartGate","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","client","JSON","parse","getAttribute","e","redirectUrl","undefined","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","sendSessionToken","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","lazyStart","start","Promise","resolve","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","flowId","_c","version","getTargetLocales","targetLocales","map","toLowerCase","handleKeyPress","rootElement","onkeydown","isLinkEleFocused","shadowRoot","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","includes","localName","_d","key","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","disableKeyPressHandler","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","projectId","window","_BaseDescopeWc_onFlowChange","Object","assign","baseUrl","tenant","tenantId","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","isConnected","_a","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","flowOptionsArgIdx","next","origFn","flow","fnWithRetry","withRetry","args","__awaiter","callArgs","optionsIdx","options","_BaseDescopeWc_injectSessionJwt","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","startFn","_BaseDescopeWc_waitForStart","apply","sessionToken","getSessionToken","sessionJwt","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","import","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","baseHeaders"],"mappings":"yiDAyDA,MAAMA,GAAYC,EAChBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EATgBT,CAUhBU,aAGF,MAAMC,WAAsBZ,GAC1B,6BAAWa,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,qBACA,WAEH,CAiED,WAAAC,CAAYC,GACVC,oBAhEFC,KAAUC,WAAG,QAUbC,EAAAC,IAAAH,MAAQ,GAERI,EAA0CD,IAAAH,UAAA,GAE1CA,KAAUK,WAAe,UAEzBL,KAAAM,cAAgB,CACdC,MAAO,CAACC,EAAiBC,EAAc,MACrCT,KAAKU,OAAOH,MAAMC,EAASC,EAAa,IAAIE,OAC5CC,EAAAZ,eAAAa,KAAAb,KAA6BQ,EAASC,EAAY,EAEpDK,KAAM,CAACN,EAAiBC,EAAc,MACpCT,KAAKU,OAAOI,KAAKN,EAASC,EAAY,EAExCM,KAAM,CAACP,EAAiBC,EAAc,GAAIO,EAAa,CAAA,KACrDhB,KAAKU,OAAOK,KAAKP,EAASC,EAAaO,EAAM,EAE/CC,MAAO,CAACT,EAAiBC,EAAc,MACrCT,KAAKU,OAAOO,MAAMT,EAASC,EAAY,GAI3CS,EAAaf,IAAAH,KAAA,IAAImB,GAEjBC,EAAcjB,IAAAH,KAAA,IAAImB,GAElBE,EAAAlB,IAAAH,KAAqB,CAAA,GAErBA,KAAAsB,qBAAuB,IAAMV,EAAAZ,YAE7BA,KAAiBuB,kBAAG,IAAIJ,EAA8B,CAAEK,WAAW,IAQnEC,EAEEtB,IAAAH,UAAA,GAEF0B,EAAgBvB,IAAAH,KAAA,CACd2B,SAAUf,EAAAZ,KAAI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AO,IACPC,OAAQ,QACRC,MAAO,QACPC,cAAe,OACfC,OAAQ,cAIJC,OAAO,qBAEb3D,SAAS4D,KAAKxD,YAAYlK,EAAAZ,KAAiByB,EAAA,OAE3Cb,EAAAZ,KAAI4B,EAAA,IAAA8H,GAAJ7I,KAAAb,QAIoB,EAAAuO,GAAA,SAAAC,EAAe/N,SACjC+N,GAASxO,KAAKiB,QACC,QAAjBkC,EAAAvC,EAAAZ,KAAiByB,EAAA,YAAA,IAAA0B,GAAAA,EAAEsL,WAAW,CAAED,QAAO/N,gBAC3C,EAxdOd,GAAA2L,mBAAyC,CAC9CoD,YAAa,CACX,qBAAsB,gBACtB,wBAAyB"}
1
+ {"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { telemetryMixin } from '@descope/sdk-mixins/telemetry-mixin';\nimport { createSdk, getSessionToken } from '@descope/web-js-sdk';\nimport type { FlowNextOptions, FlowStartOptions } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n withRetry,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport {\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n validationTrackingMixin,\n} from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n injectStyleMixin,\n telemetryMixin,\n validationTrackingMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n ];\n }\n\n sdkVersion = BUILD_VERSION;\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get sendSessionToken() {\n return this.getAttribute('send-session-token') === 'true';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n 'theme-override',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // Position of the `options` argument in core-js-sdk's flow calls:\n // flow.start(flowId, options, conditionInteractionId, interactionId, componentsVersion, flowVersions, input, isCustomScreen)\n // flow.next(executionId, stepId, interactionId, version, componentsVersion, input, isCustomScreen, options)\n // We rely on these positions staying fixed - core-js-sdk keeps them stable\n // for backwards compatibility, and new params are only appended at the end\n const flowOptionsArgIdx = { start: 1, next: 7 };\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n const fnWithRetry = withRetry(origFn, 1000, 3);\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n const callArgs = [...args] as Parameters<typeof origFn>;\n const optionsIdx = flowOptionsArgIdx[key];\n const options = this.#injectSessionJwt(callArgs[optionsIdx]);\n if (options !== undefined) {\n callArgs[optionsIdx] = options;\n }\n try {\n const resp = await fnWithRetry(...callArgs);\n return resp;\n } catch (e) {\n this.logger.error(`Error in sdk flow ${key} function`, e);\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n\n // While `lazy-start` is set, hold every flow start call until start() is\n // called. Wrapping the sdk fn holds all call sites at once, and sits outside\n // the wrapper above so the session JWT is read when the call is really sent.\n const startFn = this.sdk.flow.start;\n this.sdk.flow.start = async (\n ...args: Parameters<typeof startFn>\n ): ReturnType<typeof startFn> => {\n await this.#waitForStart();\n\n return startFn.apply(this.sdk.flow, args);\n };\n }\n\n // adds the current session JWT to a flow request options (opt-in via the\n // send-session-token attribute), so the flow can read its validated claims\n // through the sessionJwtClaims context key. Accepts only the flow start/next\n // options types and preserves the given type on return. The token is read\n // via the standalone helper - the wrapping SDKs (e.g. react-sdk) override\n // the inner sdk with persistTokens: false, so the instance getter is absent\n #injectSessionJwt<T extends FlowStartOptions | FlowNextOptions>(\n options?: T,\n ): T | undefined {\n if (!this.sendSessionToken) return options;\n const sessionToken = getSessionToken?.(this.storagePrefix);\n if (!sessionToken) return options;\n return { ...(options ?? {}), sessionJwt: sessionToken } as T;\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n // Holds the flow's start call, so a host can preload a flow (config,\n // components, first screen) without creating a flow execution - e.g. a modal\n // that builds its flow ahead of being opened. `start()` is then the only way\n // that flow starts.\n get lazyStart() {\n return this.getAttribute('lazy-start') === 'true';\n }\n\n #startGate: Promise<void> | undefined;\n\n #releaseStartGate: (() => void) | undefined;\n\n // resolves immediately unless `lazy-start` is set, in which case it waits for\n // start()\n #waitForStart(): Promise<void> {\n if (!this.lazyStart) return Promise.resolve();\n\n if (!this.#startGate) {\n this.#startGate = new Promise((resolve) => {\n this.#releaseStartGate = resolve;\n });\n }\n\n return this.#startGate;\n }\n\n // Start a flow rendered with `lazy-start`. Safe to call before the flow\n // reached the held start call - it then goes through on arrival. The gate is\n // latched open rather than re-armed, so a flow restart (e.g. restart-on-error)\n // is not left waiting for another call.\n start() {\n this.#releaseStartGate?.();\n this.#startGate = Promise.resolve();\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n handleKeyPress() {\n this.logger.debug('Enable key press handler');\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n disableKeyPressHandler() {\n this.logger.debug('Disable key press handler');\n this.rootElement.onkeydown = null;\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.projectId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n // Forward to the composed mixin chain so each mixin's\n // disconnectedCallback (e.g. componentConditionsMixin) gets to clean up.\n // Without this, mixin disconnectedCallbacks are dead code.\n super.disconnectedCallback?.();\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n // Forward to the composed mixin chain first so other mixins always receive\n // the callback, regardless of the early return below.\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","componentConditionsMixin","duplicateFlowWarningMixin","passwordManagerMixin","injectStyleMixin","telemetryMixin","validationTrackingMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","this","sdkVersion","_BaseDescopeWc_init","set","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","_BaseDescopeWc_startGate","_BaseDescopeWc_releaseStartGate","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","client","JSON","parse","getAttribute","e","redirectUrl","undefined","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","sendSessionToken","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","lazyStart","start","Promise","resolve","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","flowId","_c","version","getTargetLocales","targetLocales","map","toLowerCase","handleKeyPress","rootElement","onkeydown","isLinkEleFocused","shadowRoot","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","includes","localName","_d","key","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","disableKeyPressHandler","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","projectId","window","_BaseDescopeWc_onFlowChange","Object","assign","baseUrl","tenant","tenantId","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","isConnected","_a","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","flowOptionsArgIdx","next","origFn","flow","fnWithRetry","withRetry","args","__awaiter","callArgs","optionsIdx","options","_BaseDescopeWc_injectSessionJwt","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","startFn","_BaseDescopeWc_waitForStart","apply","sessionToken","getSessionToken","sessionJwt","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","import","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","baseHeaders"],"mappings":"yiDAyDA,MAAMA,GAAYC,EAChBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EATgBT,CAUhBU,aAGF,MAAMC,WAAsBZ,GAC1B,6BAAWa,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,qBACA,WAEJ,CAiEA,WAAAC,CAAYC,GACVC,oBAhEFC,KAAAC,WAAa,QAUbC,EAAAC,IAAAH,MAAQ,GAERI,EAAAD,IAAAH,UAAA,GAEAA,KAAAK,WAAyB,UAEzBL,KAAAM,cAAgB,CACdC,MAAO,CAACC,EAAiBC,EAAc,MACrCT,KAAKU,OAAOH,MAAMC,EAASC,EAAa,IAAIE,OAC5CC,EAAAZ,eAA4Ba,KAA5Bb,KAA6BQ,EAASC,EAAY,EAEpDK,KAAM,CAACN,EAAiBC,EAAc,MACpCT,KAAKU,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