@monterosa/sdk-identify-kit 2.0.0-rc.4 → 2.0.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/experiences.ts","../src/login_policy_store.ts","../src/credentials_store.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk } from '@monterosa/sdk-core';\nimport { Emitter } from '@monterosa/sdk-util';\n\n/**\n * Represents user authentication credentials.\n *\n * @remarks\n * The `token` property can be either the literal `'cookie'` for cookie-based\n * authentication or a string value for bearer token authentication.\n *\n * @example\n * ```javascript\n * // Bearer token authentication\n * const credentials: Credentials = { token: \"abc123\" };\n *\n * // Cookie-based authentication\n * const credentials: Credentials = { token: \"cookie\" };\n * ```\n */\nexport type Credentials = {\n token: 'cookie' | string;\n};\n\n/**\n * A tuple representing a digital signature: `[userId, timestamp, signature]`.\n *\n * @example\n * ```javascript\n * const signature: Signature = [\"user123\", 1646956195, \"abc123\"];\n * ```\n */\nexport type Signature = [userId: string, timestamp: number, signature: string];\n\n/**\n * A key-value object representing user profile data.\n *\n * @remarks\n * Contains `userId`, `timestamp`, and `signature` alongside any\n * additional custom properties.\n *\n * @example\n * ```javascript\n * const userData: UserData = {\n * userId: \"user123\",\n * timeStamp: 1646956195,\n * signature: \"abc123\",\n * name: \"John Doe\",\n * age: 30,\n * email: \"john.doe@example.com\"\n * };\n * ```\n */\nexport type UserData = {\n [key: string]: any;\n};\n\nexport type ResponsePayload<T> = {\n data: T;\n error?: string;\n};\n\nexport type LoginState = {\n state: 'logged_out' | 'logged_in' | 'pending' | 'error';\n error?: string;\n errorType?: 'login' | 'logout';\n};\n\nexport type LoginPolicy = 'disabled' | 'auto';\n\n/**\n * Resolved configuration options for an `Identify` instance. Public APIs\n * that accept user-supplied options (such as {@link getIdentify}) take\n * `Partial<IdentifyOptions>` and apply defaults for any field not\n * supplied.\n *\n * `loginPolicy` is set separately via {@link setLoginPolicy}.\n */\nexport interface IdentifyOptions {\n /**\n * Authentication strategy. Default: `'email'`.\n */\n readonly strategy: string;\n /**\n * Identity provider name (e.g. `'aws'` for Cognito).\n */\n readonly provider?: string;\n /**\n * Identify API version. Default: `1`.\n */\n readonly version: number;\n}\n\n/**\n * Represents an Identify Kit instance. Obtain one via {@link getIdentify}.\n *\n * @remarks\n * This interface is opaque. Interact with it through the standalone\n * functions such as {@link setCredentials}, {@link clearCredentials},\n * and {@link getUserData}.\n */\nexport interface IdentifyKit extends Emitter {\n /**\n * Resolved identity options. `loginPolicy` is not on the instance —\n * see {@link setLoginPolicy}. Credentials are root-owned, accessed\n * via {@link getCredentials}.\n *\n * @internal\n */\n options: IdentifyOptions;\n /**\n * @internal\n */\n sdk: MonterosaSdk;\n /**\n * @internal\n */\n signature: Signature | null;\n /**\n * @internal\n */\n userData: UserData | null;\n /**\n * @internal\n */\n wasLoggedIn: boolean;\n\n state: LoginState;\n\n /**\n * @internal\n */\n getUrl(path?: string): Promise<string>;\n}\n\nexport interface Response {\n message: string;\n result: number;\n data: {\n [key: string]: any;\n };\n}\n\nexport interface UserResponse extends Response {}\n\nexport interface UserCheckResponse extends Response {\n data: {\n userId: string;\n timeStamp: number;\n signature: string;\n [key: string]: any;\n };\n}\n\n/**\n * @internal\n */\nexport enum IdentifyEvent {\n StateUpdated = 'state_updated',\n LoginRequested = 'login_requested',\n LogoutRequested = 'logout_requested',\n CredentialsUpdated = 'credentials_updated',\n LoginPolicyUpdated = 'login_policy_updated',\n}\n\n/**\n * Defines a set of error codes that may be encountered when using the\n * Identify kit of the Monterosa SDK.\n *\n * @example\n * ```javascript\n * try {\n * // some code that uses the IdentifyKit\n * } catch (err) {\n * if (err.code === IdentifyError.NoCredentials) {\n * // handle missing credentials error\n * } else {\n * // handle other error types\n * }\n * }\n * ```\n *\n * @remarks\n * - The `IdentifyError` enum provides a convenient way to handle errors\n * encountered when using the `IdentifyKit` module. By checking the code\n * property of the caught error against the values of the enum, the error\n * type can be determined and appropriate action taken.\n *\n * - The `IdentifyError` enum is not intended to be instantiated or extended.\n */\nexport enum IdentifyError {\n /**\n * Indicates an error occurred during the call to the extension API.\n */\n ExtensionApiError = 'extension_api_error',\n /**\n * Indicates the extension required by the IdentifyKit is not set up properly.\n */\n ExtensionNotSetup = 'extension_not_setup',\n /**\n * Indicates the user's authentication credentials are not available\n * or have expired.\n */\n NoCredentials = 'no_credentials',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_error',\n /**\n * Indicates an unexpected or invalid login state was encountered.\n */\n UnexpectedState = 'unexpected_state',\n /**\n * Indicates there is no parent application to delegate to.\n */\n NoParentApplication = 'no_parent_application',\n /**\n * Indicates a timeout occurred when communicating with the parent app.\n */\n ParentTimeoutError = 'parent_timeout_error',\n}\n\n/**\n * @internal\n */\nexport const IdentifyErrorMessages = {\n [IdentifyError.ExtensionApiError]: (error: string) =>\n `Identify extension API returned an error: ${error}`,\n [IdentifyError.ExtensionNotSetup]: () =>\n 'Identify extension is not set up for this project',\n [IdentifyError.NoCredentials]: () => 'Identify credentials are not set',\n [IdentifyError.ParentAppError]: (error: string) =>\n `Parent application error: ${error}`,\n [IdentifyError.UnexpectedState]: (state: string) =>\n `Unexpected LoginState: ${state}`,\n [IdentifyError.NoParentApplication]: () =>\n 'No parent application available for delegation',\n [IdentifyError.ParentTimeoutError]: (error: string) =>\n `Parent application timeout: ${error}. Please check if the identify-kit is imported on the parent page.`,\n};\n\nexport enum IdentifyAction {\n Login = 'identifyLogin',\n Logout = 'identifyLogout',\n RequestLogin = 'identifyRequestLogin',\n RequestLogout = 'identifyRequestLogout',\n GetCredentials = 'identifyGetCredentials',\n SetCredentials = 'identifySetCredentials',\n ClearCredentials = 'identifyClearCredentials',\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nexport const EXTENSION_ID = 'lvis-id-custom-tab';\n\nexport const SIGNATURE_TTL = 10_000;\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, getDeviceId } from '@monterosa/sdk-core';\nimport { Emitter, createError } from '@monterosa/sdk-util';\nimport { fetchListings } from '@monterosa/sdk-interact-interop';\n\nimport {\n IdentifyKit,\n IdentifyOptions,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n LoginState,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID, SIGNATURE_TTL } from './constants';\n\nexport class Identify extends Emitter implements IdentifyKit {\n wasLoggedIn: boolean = false;\n\n private host?: string;\n private readonly _options: IdentifyOptions;\n\n private _signature: Signature | null = null;\n private _userData: UserData | null = null;\n private signatureExpireTimeout!: ReturnType<typeof setTimeout>;\n\n _state: LoginState = {\n state: 'logged_out',\n };\n\n constructor(\n public sdk: MonterosaSdk,\n options: Partial<IdentifyOptions> = {},\n ) {\n super();\n this._options = {\n strategy: 'email',\n version: 1,\n ...options,\n };\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n const extensionAssets = listings.assets?.[EXTENSION_ID] ?? [];\n\n const endpointAsset = extensionAssets.find(\n ({ name }) => name === 'endpoint',\n );\n\n if (!endpointAsset) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return endpointAsset.data;\n }\n\n get state(): LoginState {\n return this._state;\n }\n\n set state(state: LoginState) {\n if (this._state.state === state.state) {\n return;\n }\n\n switch (state.state) {\n case 'logged_in':\n this.wasLoggedIn = true;\n break;\n case 'error':\n this.wasLoggedIn = false;\n break;\n case 'logged_out':\n case 'pending':\n // preserve wasLoggedIn — these states reflect transient transport\n // state, not a deliberate logout (credentials are the gate for that)\n break;\n default: {\n // Exhaustiveness check: TypeScript errors if a new state is added\n // but not handled. This is a compile-time error.\n //\n // See: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking\n const exhaustiveCheck: never = state.state;\n\n throw createError(\n IdentifyError.UnexpectedState,\n IdentifyErrorMessages,\n String(exhaustiveCheck),\n );\n }\n }\n\n this._state = state;\n\n this.emit(IdentifyEvent.StateUpdated, state);\n }\n\n get options() {\n return this._options;\n }\n\n set signature(signature: Signature | null) {\n if (this._signature === signature) {\n return;\n }\n\n this._signature = signature;\n\n clearTimeout(this.signatureExpireTimeout);\n\n if (signature !== null) {\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, SIGNATURE_TTL);\n }\n }\n\n get signature(): Signature | null {\n return this._signature;\n }\n\n set userData(data: UserData | null) {\n if (this._userData === data) {\n return;\n }\n\n this._userData = data;\n }\n\n get userData(): UserData | null {\n return this._userData;\n }\n\n async getUrl(path: string = ''): Promise<string> {\n const { host, projectId } = this.sdk.options;\n\n if (this.host === undefined) {\n this.host = await Identify.fetchIdentifyHost(host, projectId);\n }\n\n const url = new URL(this.host);\n const { version, strategy, provider } = this._options;\n\n url.pathname = `/v${version}${path}`;\n\n url.searchParams.set('projectId', projectId);\n url.searchParams.set('deviceId', getDeviceId());\n url.searchParams.set('strategy', strategy);\n\n if (provider !== undefined) {\n url.searchParams.set('provider', provider);\n }\n\n return url.toString();\n }\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2025-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport type { Unsubscribe } from '@monterosa/sdk-util';\nimport type { Experience } from '@monterosa/sdk-launcher-kit';\n\ntype ExperienceEntry = {\n experience: Experience;\n unsubs: Set<Unsubscribe>;\n};\n\nconst entries = new Map<string, ExperienceEntry>();\n\nexport function getExperiences(): Experience[] {\n return Array.from(entries.values()).map((entry) => entry.experience);\n}\n\nexport function addExperience(\n experience: Experience,\n unsubs: Unsubscribe[] = [],\n) {\n entries.set(experience.id, {\n experience,\n unsubs: new Set(unsubs),\n });\n}\n\nexport function deleteExperience(experience: Experience) {\n const entry = entries.get(experience.id);\n\n if (entry) {\n entry.unsubs.forEach((unsub) => unsub());\n entries.delete(experience.id);\n }\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter, Unsubscribe, subscribe } from '@monterosa/sdk-util';\n\nimport { IdentifyEvent, LoginPolicy } from './types';\n\n/**\n * Locally-owned login policy.\n *\n * Defaults to `'disabled'`. Set via the public `setLoginPolicy`. Never\n * propagated across the wire — each level owns its own policy.\n *\n * @internal\n */\nexport class LoginPolicyStore extends Emitter {\n private static instance: LoginPolicyStore;\n\n private _policy: LoginPolicy = 'disabled';\n\n private constructor() {\n super();\n }\n\n public static getInstance(): LoginPolicyStore {\n if (!LoginPolicyStore.instance) {\n LoginPolicyStore.instance = new LoginPolicyStore();\n }\n\n return LoginPolicyStore.instance;\n }\n\n get policy(): LoginPolicy {\n return this._policy;\n }\n\n set policy(next: LoginPolicy) {\n if (this._policy === next) {\n return;\n }\n\n this._policy = next;\n this.emit(IdentifyEvent.LoginPolicyUpdated, next);\n }\n\n subscribe(handler: (value: LoginPolicy) => void): Unsubscribe {\n return subscribe(this, IdentifyEvent.LoginPolicyUpdated, handler);\n }\n\n reset(): void {\n this._policy = 'disabled';\n this.off(IdentifyEvent.LoginPolicyUpdated);\n }\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter, Unsubscribe, subscribe } from '@monterosa/sdk-util';\n\nimport { Credentials, IdentifyEvent } from './types';\n\n/**\n * Root-owned credentials slot.\n *\n * Single source of truth at the root of an integration; an internal\n * mirror at every other level, kept in sync via `Login` / `Logout`\n * broadcasts. Not exposed publicly — public access flows through\n * `setCredentials` / `getCredentials` / `clearCredentials` and\n * `onCredentialsUpdated`.\n *\n * @internal\n */\nexport class CredentialsStore extends Emitter {\n private static instance: CredentialsStore;\n\n private _credentials: Credentials | null = null;\n\n private constructor() {\n super();\n }\n\n public static getInstance(): CredentialsStore {\n if (!CredentialsStore.instance) {\n CredentialsStore.instance = new CredentialsStore();\n }\n\n return CredentialsStore.instance;\n }\n\n get credentials(): Credentials | null {\n return this._credentials;\n }\n\n set credentials(next: Credentials | null) {\n if (this._credentials === next) {\n return;\n }\n\n this._credentials = next;\n this.emit(IdentifyEvent.CredentialsUpdated, next);\n }\n\n subscribe(handler: (value: Credentials | null) => void): Unsubscribe {\n return subscribe(this, IdentifyEvent.CredentialsUpdated, handler);\n }\n\n reset(): void {\n this._credentials = null;\n this.off(IdentifyEvent.CredentialsUpdated);\n }\n}\n","/**\n * @license\n * identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, Sdk, getSdk } from '@monterosa/sdk-core';\nimport {\n Unsubscribe,\n TaskQueue,\n Emitter,\n subscribe,\n createError,\n withRetryAsync,\n memoizePromise,\n MonterosaError,\n getErrorMessage,\n} from '@monterosa/sdk-util';\nimport {\n getConnect,\n login as connectLogin,\n logout as connectLogout,\n connect,\n onConnected,\n onConnecting,\n onDisconnected,\n} from '@monterosa/sdk-connect-kit';\nimport {\n Payload,\n getParentApplication,\n sendSdkRequest,\n sendSdkMessage,\n BridgeError,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n LoginState,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n LoginPolicy,\n} from './types';\n\nimport { Identify } from './identify';\nimport { getExperiences } from './experiences';\nimport { LoginPolicyStore } from './login_policy_store';\nimport { CredentialsStore } from './credentials_store';\n\nconst loginPolicyStore = LoginPolicyStore.getInstance();\nconst credentialsStore = CredentialsStore.getInstance();\n\n/**\n * @internal\n */\nexport const identifyKits: Map<string, Identify> = new Map();\n\n/**\n * Emitter for identify request events that are not tied to a specific\n * identify instance (login / logout requests).\n *\n * @internal\n */\nconst requestsEmitter = new Emitter();\n\n/**\n * Read the current locally-owned login policy.\n *\n * Returns `'disabled'` by default.\n *\n * @internal\n */\nexport function getLoginPolicy(): LoginPolicy {\n return loginPolicyStore.policy;\n}\n\n/**\n * Set the locally-owned login policy.\n *\n * All `Identify` instances at this level honour the same policy; the\n * value is never propagated across the wire (each level of a multi-level\n * integration owns its own policy).\n *\n * Policy gates the Enmasse `loginTask` only — credentials always mirror\n * from upstream regardless of policy. A `'disabled'` level still\n * receives credentials via the module-load pull and the cascading\n * `Login` / `Logout` broadcasts; it just doesn't attempt Enmasse\n * validation against them.\n *\n * When the policy transitions to `'auto'`, enqueues a sync-state task\n * for every existing identify so that any in-flight session is picked\n * up.\n *\n * Idempotent: setting the same policy that's already in effect is a\n * no-op.\n *\n * @param policy - `'auto'` to enable auto-login, `'disabled'` to opt out.\n */\nexport function setLoginPolicy(policy: LoginPolicy): void {\n if (loginPolicyStore.policy === policy) {\n return;\n }\n\n loginPolicyStore.policy = policy;\n\n if (policy !== 'auto') {\n return;\n }\n\n // On transition to 'auto': if the local credentials slot already\n // has a value (typical after the non-root module-load pull, or after\n // a setCredentials at the root, or after an upstream Login broadcast\n // has cascaded down), enqueue a login task for each existing\n // identify. If the slot is empty, do nothing — a future credentials\n // arrival via `applyLogin` will trigger the login under this new\n // policy.\n const { credentials } = credentialsStore;\n\n if (credentials === null) {\n return;\n }\n\n for (const identify of identifyKits.values()) {\n enqueueLogin(identify, credentials);\n }\n}\n\n/**\n * Whether the user should be auto-logged in on reconnect.\n *\n * True when the user was previously logged in, the policy is `'auto'`,\n * and credentials are available on the identify instance.\n *\n * @internal\n */\nexport function shouldLoginOnReconnect(identify: IdentifyKit): boolean {\n return (\n identify.wasLoggedIn &&\n getLoginPolicy() === 'auto' &&\n credentialsStore.credentials !== null\n );\n}\n\n/**\n * @internal\n */\nexport const taskQueue = new TaskQueue();\n\nfunction isSdk(value: MonterosaSdk | any): value is MonterosaSdk {\n return value instanceof Sdk;\n}\n\nasync function api<T extends Response>(\n url: string,\n token: Credentials['token'],\n method: string = 'GET',\n): Promise<T> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n };\n\n let credentials: RequestCredentials | undefined;\n\n // Only include Authorization header for bearer token authentication\n // When token is 'cookie', use credentials: 'include' to ensure HttpOnly\n // cookies are sent\n if (token === 'cookie') {\n // Use credentials: 'include' to ensure HttpOnly cookies are sent\n credentials = 'include';\n } else {\n headers.Authorization = `Bearer ${token}`;\n }\n\n const response = await fetch(url, {\n method,\n headers,\n credentials,\n });\n\n const data = (await response.json()) as T;\n\n if (data.result < 0) {\n throw createError(\n IdentifyError.ExtensionApiError,\n IdentifyErrorMessages,\n data.message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport async function sendParentRequest<T>(\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n throw createError(IdentifyError.NoParentApplication, IdentifyErrorMessages);\n }\n\n try {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { error, data } = response.payload as ResponsePayload<T>;\n\n if (error !== undefined) {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n error,\n );\n }\n\n return data;\n } catch (err) {\n if (\n err instanceof MonterosaError &&\n err.code === BridgeError.RequestTimeoutError\n ) {\n const errorMessage = getErrorMessage(err);\n\n throw createError(\n IdentifyError.ParentTimeoutError,\n IdentifyErrorMessages,\n errorMessage,\n );\n }\n\n throw err;\n }\n}\n\n/**\n * @internal\n */\nasync function login(identify: IdentifyKit, credentials: Credentials) {\n const signature = await getSessionSignatureMemoized(identify, credentials);\n\n const conn = await getConnect(identify.sdk.options.host);\n\n await connect(conn);\n await connectLogin(conn, ...signature);\n}\n\nconst loginWithRetry = withRetryAsync(login);\n\n/**\n * @internal\n */\nasync function logout(identify: IdentifyKit) {\n const conn = await getConnect(identify.sdk.options.host);\n\n await connect(conn);\n await connectLogout(conn);\n}\n\nconst logoutWithRetry = withRetryAsync(logout);\n\n/**\n * @internal\n */\nexport async function loginTask(\n identify: IdentifyKit,\n credentials: Credentials,\n) {\n if (identify.state.state === 'logged_in') {\n return;\n }\n\n try {\n identify.state = {\n state: 'pending',\n };\n\n await loginWithRetry(identify, credentials);\n\n // Update state only if there are no pending tasks in the queue\n if (taskQueue.isEmpty()) {\n identify.state = {\n state: 'logged_in',\n };\n }\n } catch (err) {\n // Abandon any pending login/logout/sync tasks on failure — letting\n // them run after an error would put the user in an inconsistent\n // state. Note: this also drops tasks for unrelated identifies that\n // share the queue; acceptable because the typical runtime has one\n // identify per project.\n taskQueue.clear();\n\n identify.state = {\n state: 'error',\n error: err instanceof Error ? err.message : 'Unknown error',\n errorType: 'login',\n };\n }\n}\n\n/**\n * @internal\n */\nexport async function logoutTask(identify: IdentifyKit) {\n if (identify.state.state === 'logged_out') {\n return;\n }\n\n try {\n identify.state = {\n state: 'pending',\n };\n\n await logoutWithRetry(identify);\n\n // Update state only if there are no pending tasks in the queue\n if (taskQueue.isEmpty()) {\n identify.state = {\n state: 'logged_out',\n };\n }\n } catch (err) {\n // Abandon any pending login/logout/sync tasks on failure — see\n // `loginTask` for the rationale.\n taskQueue.clear();\n\n identify.state = {\n state: 'error',\n error: err instanceof Error ? err.message : 'Unknown error',\n errorType: 'logout',\n };\n }\n}\n\n/**\n * Enqueue a `loginTask` for the given identify when `policy === 'auto'`.\n * The downstream `Login` broadcast is emitted by {@link applyLogin}.\n *\n * @internal\n */\nexport function enqueueLogin(\n identify: IdentifyKit,\n credentials: Credentials,\n prioritise: boolean = false,\n) {\n if (getLoginPolicy() !== 'auto') {\n return;\n }\n\n if (prioritise) {\n taskQueue.enqueueFront(() => loginTask(identify, credentials));\n } else {\n taskQueue.enqueue(() => loginTask(identify, credentials));\n }\n}\n\n/**\n * Reset the identify's identity-derived caches and enqueue a `logoutTask`\n * when `policy === 'auto'`.\n *\n * @internal\n */\nexport function enqueueLogout(identify: IdentifyKit) {\n identify.userData = null;\n identify.signature = null;\n\n if (getLoginPolicy() !== 'auto') {\n return;\n }\n\n taskQueue.enqueue(() => logoutTask(identify));\n}\n\n/**\n * Apply new credentials at this level: update the slot, enqueue a\n * `loginTask` for every existing identify on the null-to-set transition,\n * and broadcast `Login` downstream to every embedded experience.\n *\n * Idempotent on token refresh: re-setting an already-set slot updates\n * the value and broadcasts, but does not re-enqueue logins (their\n * `loginTask` would short-circuit on `state === 'logged_in'` anyway).\n *\n * @internal\n */\nexport function applyLogin(credentials: Credentials): void {\n const shouldLogin = credentialsStore.credentials === null;\n\n credentialsStore.credentials = credentials;\n\n if (shouldLogin) {\n for (const identify of identifyKits.values()) {\n enqueueLogin(identify, credentials);\n }\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Login, credentials);\n }\n}\n\n/**\n * Clear credentials at this level: null out the slot, enqueue a\n * `logoutTask` for every existing identify on the set-to-null\n * transition, and broadcast `Logout` downstream to every embedded\n * experience.\n *\n * @internal\n */\nexport function applyLogout(): void {\n const shouldLogout = credentialsStore.credentials !== null;\n\n credentialsStore.credentials = null;\n\n if (shouldLogout) {\n for (const identify of identifyKits.values()) {\n enqueueLogout(identify);\n }\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Logout, {});\n }\n}\n\n/**\n * Pull state from the parent application and apply locally.\n *\n * Fires once at non-root bridge module load, regardless of\n * `loginPolicy` — token presence is the customer-side sign-in state and\n * must mirror upstream whether or not we choose to validate against\n * Enmasse. Best-effort: a missing or non-identify-kit parent silently\n * resolves with no slot change.\n *\n * Uses {@link applyLogin} so the slot update cascades downstream to\n * this level's own embedded experiences and per-identify loginTasks\n * are enqueued under `loginPolicy === 'auto'`.\n *\n * @internal\n */\nexport async function pullStateFromParent(): Promise<void> {\n let credentials: Credentials | null;\n try {\n credentials = await getCredentials();\n } catch {\n return;\n }\n\n if (credentials !== null) {\n applyLogin(credentials);\n }\n}\n\n/**\n * A factory function that creates a new instance of the `IdentifyKit` class,\n * which is a kit of the Monterosa SDK used for user identification.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * ```\n *\n * @remarks\n * - The `getIdentify` function returns an instance of the `IdentifyKit` class\n * using optional MonterosaSdk instance as a parameter.\n *\n * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate\n * users and perform other user identification-related operations.\n *\n * - Subsequent calls return the cached `IdentifyKit` instance for the same\n * project. The `options` argument is honoured only on the first call;\n * later calls ignore it and return the instance configured by the first.\n *\n * @param sdk - An instance of the MonterosaSdk class.\n * @param options - List of `IdentifyKit` options\n * @returns An instance of the `IdentifyKit` class, which is used for user\n * identification.\n */\n\nexport function getIdentify(\n sdk?: MonterosaSdk,\n options?: Partial<IdentifyOptions>,\n): IdentifyKit;\n\n/**\n * A factory function that creates a new instance of the `IdentifyKit` class,\n * which is a kit of the Monterosa SDK used for user identification.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * ```\n *\n * @remarks\n * - The `getIdentify` function returns an instance of the `IdentifyKit` class\n * using optional MonterosaSdk instance as a parameter.\n *\n * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate\n * users and perform other user identification-related operations.\n *\n * - Subsequent calls return the cached `IdentifyKit` instance for the same\n * project. The `options` argument is honoured only on the first call;\n * later calls ignore it and return the instance configured by the first.\n *\n * @param options - List of `IdentifyKit` options\n * @returns An instance of the `IdentifyKit` class, which is used for user\n * identification.\n */\nexport function getIdentify(options?: Partial<IdentifyOptions>): IdentifyKit;\n\nexport function getIdentify(\n sdkOrOptions?: MonterosaSdk | Partial<IdentifyOptions>,\n options?: Partial<IdentifyOptions>,\n): IdentifyKit {\n let sdk: MonterosaSdk;\n let identifyOptions: Partial<IdentifyOptions>;\n\n if (isSdk(sdkOrOptions)) {\n /**\n * Interface: getIdentify(sdk, options?)\n */\n\n sdk = sdkOrOptions;\n\n if (options !== undefined) {\n identifyOptions = options;\n } else {\n identifyOptions = {};\n }\n } else if (sdkOrOptions !== undefined) {\n /**\n * Interface: getIdentify(options)\n */\n\n sdk = getSdk();\n identifyOptions = sdkOrOptions;\n } else {\n /**\n * Interface: getIdentify()\n */\n\n sdk = getSdk();\n identifyOptions = {};\n }\n\n const { projectId } = sdk.options;\n\n if (identifyKits.has(projectId)) {\n return identifyKits.get(projectId) as Identify;\n }\n\n const identify = new Identify(sdk, identifyOptions);\n\n watchConnectionStatus(identify);\n\n identifyKits.set(projectId, identify);\n\n return identify;\n}\n\n/**\n * Requests a user login.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { requestLogin } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * await requestLogin();\n *\n * console.log('Login request successful');\n * } catch (err) {\n * console.error('Error requesting login:', err.message)\n * }\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Monterosa SDK, the function delegates to the parent app\n * to handle the login process.\n *\n * @returns A Promise that resolves with `void` when the login request\n * is completed.\n */\nexport async function requestLogin(): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.RequestLogin);\n return;\n }\n\n requestsEmitter.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * Read the current credentials, pulling from the parent application when\n * called from an embedded experience.\n *\n * At the root this returns the canonical slot value. At a non-root\n * experience this dispatches a `GetCredentials` request upstream and\n * resolves with the response, ensuring the caller always sees the\n * authoritative value rather than a possibly-stale local mirror.\n *\n * @returns A Promise that resolves to the current credentials, or `null`\n * if none are set.\n */\nexport async function getCredentials(): Promise<Credentials | null> {\n if (getParentApplication() === null) {\n return credentialsStore.credentials;\n }\n\n return sendParentRequest<Credentials | null>(IdentifyAction.GetCredentials);\n}\n\n/**\n * Requests a user logout.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { requestLogout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * await requestLogout();\n *\n * console.log('Logout request successful');\n * } catch (err) {\n * console.error('Error requesting logout:', err.message)\n * }\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Monterosa SDK, the function delegates to the parent app\n * to handle the logout process.\n *\n * @returns A Promise that resolves with `void` when the logout request\n * is completed.\n */\nexport async function requestLogout(): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.RequestLogout);\n return;\n }\n\n requestsEmitter.emit(IdentifyEvent.LogoutRequested);\n}\n\n/**\n * @internal\n *\n * Returns a signature for a user session. The signature is based on the\n * user's identifying information provided in the `IdentifyKit` instance.\n *\n * @remarks\n * This function does not handle errors. Callers are responsible for catching\n * and handling failures.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @param credentials - The credentials of the user.\n *\n * @returns A Promise that resolves to a `Signature` object.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n credentials: Credentials,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(url, credentials.token);\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n\n return signature;\n}\n\n/**\n * A memoized version of the `getSessionSignature` function. Memo key is\n * the credentials token, so both leaf-side and bridge-side callers share\n * the same cache for the same token.\n */\nexport const getSessionSignatureMemoized = memoizePromise(\n getSessionSignature,\n (identify: IdentifyKit, credentials: Credentials) => credentials.token,\n {\n clearOnResolve: true,\n clearOnReject: true,\n },\n);\n\n/**\n * Fetches user data for the given credentials.\n *\n * Credentials are required explicitly so the precondition is visible at\n * the call site — without them the function cannot be called. Obtain a\n * `Credentials` value via {@link getCredentials} or the\n * {@link onCredentialsUpdated} callback.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import {\n * getIdentify,\n * getUserData,\n * getCredentials,\n * } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const credentials = await getCredentials();\n *\n * if (credentials !== null) {\n * const userData = await getUserData(identify, credentials);\n * console.log('User data:', userData);\n * }\n * ```\n *\n * @remarks\n * Cached on the identify instance after the first successful fetch.\n * Cleared on {@link clearCredentials} via the logout path.\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param credentials - The user's authentication credentials. The\n * request authorises against the value's token.\n * @returns A Promise that resolves to a key-value object representing\n * user data. The structure and content of the user data object depend\n * on the identify service provider and may vary.\n */\nexport async function getUserData(\n identify: IdentifyKit,\n credentials: Credentials,\n): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, credentials.token);\n\n identify.userData = data;\n\n return data;\n}\n\n/**\n * Sets the user's authentication credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { setCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * await setCredentials({ token: 'abc123' });\n * ```\n *\n * @remarks\n * - At the root of an integration, the credentials are stored locally\n * and a `Login` broadcast is sent to every embedded experience.\n * - When called from an embedded experience, the call is relayed\n * upstream via the `SetCredentials` wire action. The credentials are\n * ultimately applied at the root and propagate back down via the\n * cascading `Login` broadcast.\n *\n * @param credentials - An object representing the user's authentication\n * credentials.\n * @returns A Promise that resolves to `void` once the credentials have\n * been written (root) or the upstream relay has completed (non-root).\n */\nexport async function setCredentials(credentials: Credentials): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.SetCredentials, credentials);\n\n return;\n }\n\n applyLogin(credentials);\n}\n\n/**\n * Clears the user's authentication credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { clearCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * await clearCredentials();\n * ```\n *\n * @remarks\n * - At the root of an integration, the credentials slot is cleared and\n * a `Logout` broadcast is sent to every embedded experience.\n * - When called from an embedded experience, the call is relayed\n * upstream via the `ClearCredentials` wire action. The slot is\n * cleared at the root and the cascading `Logout` broadcast propagates\n * back down.\n *\n * @returns A Promise that resolves to `void` once the slot has been\n * cleared (root) or the upstream relay has completed (non-root).\n */\nexport async function clearCredentials(): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.ClearCredentials);\n\n return;\n }\n\n applyLogout();\n}\n\n/**\n * Registers a callback function that will be called whenever the `LoginState`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onStateUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onStateUpdated(identify, (state) => {\n * console.log(\"State updated:\", state);\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param callback - The callback function to register. This function will be\n * called with the updated `LoginState` object as its only argument.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onStateUpdated(\n identify: IdentifyKit,\n callback: (state: LoginState) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.StateUpdated, callback);\n}\n\n/**\n * Registers a callback function that will be called whenever the\n * credentials slot is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { onCredentialsUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const unsubscribe = onCredentialsUpdated((credentials) => {\n * if (credentials !== null) {\n * console.log(\"Credentials updated:\", credentials);\n * } else {\n * console.log(\"Credentials cleared.\");\n * }\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param callback - The callback function to register. This function will be\n * called with the updated `Credentials` object as its only argument.\n * If the value `null` is received, it indicates that the credentials have\n * been cleared.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsUpdated(\n callback: (credentials: Credentials | null) => void,\n): Unsubscribe {\n return credentialsStore.subscribe(callback);\n}\n\n/**\n * Registers a callback function that will be called when a login is requested\n * by an Experience.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const unsubscribe = onLoginRequestedByExperience(() => {\n * showLoginForm();\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param callback - The callback function to register. This function will\n * be called when a login is requested by an Experience.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onLoginRequestedByExperience(\n callback: () => void,\n): Unsubscribe {\n return subscribe(requestsEmitter, IdentifyEvent.LoginRequested, callback);\n}\n\n/**\n * Registers a callback function that will be called when a logout is requested\n * by an Experience.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const unsubscribe = onLogoutRequestedByExperience(() => {\n * // logout requested by experience\n * // perform logout from Auth service\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param callback - The callback function to register. This function will\n * be called when a logout is requested by an Experience.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onLogoutRequestedByExperience(\n callback: () => void,\n): Unsubscribe {\n return subscribe(requestsEmitter, IdentifyEvent.LogoutRequested, callback);\n}\n\n/**\n *\n * @internal\n */\nexport async function watchConnectionStatus(identify: IdentifyKit) {\n const conn = await getConnect(identify.sdk.options.host);\n\n onConnected(conn, () => {\n if (shouldLoginOnReconnect(identify)) {\n enqueueLogin(identify, credentialsStore.credentials!, true);\n }\n\n taskQueue.resume();\n });\n\n onConnecting(conn, () => {\n taskQueue.pause();\n\n // If the user was logged in before the connection loss, set the state\n // to pending to notify that the user is no longer logged in and a login\n // attempt will be made when the connection is restored.\n if (identify.state.state === 'logged_in') {\n identify.state = {\n state: 'pending',\n };\n }\n });\n\n onDisconnected(conn, () => {\n taskQueue.pause();\n taskQueue.clear();\n\n // If the user was logged in before the connection loss, set the state\n // to logged_out to notify that the user is no longer logged in.\n if (identify.state.state === 'logged_in') {\n identify.state = {\n state: 'logged_out',\n };\n }\n });\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n ExperienceState,\n Payload,\n Message,\n getParentApplication,\n respondToSdkMessage,\n onStateChanged,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport { IdentifyAction, Credentials } from './types';\n\nimport {\n getCredentials,\n requestLogin,\n requestLogout,\n setCredentials,\n clearCredentials,\n applyLogin,\n applyLogout,\n pullStateFromParent,\n} from './api';\nimport { addExperience, deleteExperience } from './experiences';\n\n/**\n * Process an incoming `Login` / `Logout` broadcast from the parent\n * application. Updates the local credentials slot, enqueues login/logout\n * for every existing identify, and forwards the broadcast downstream to\n * this level's own embedded experiences — the mechanism that cascades a\n * root-level `setCredentials` through every nested experience.\n *\n * @internal\n */\nexport function handleParentMessage(message: Message): void {\n switch (message.action) {\n case IdentifyAction.Login: {\n applyLogin(message.payload as Credentials);\n break;\n }\n case IdentifyAction.Logout: {\n applyLogout();\n break;\n }\n }\n}\n\n/**\n * @internal\n */\nexport function handleExperienceEmbedded(experience: Experience): void {\n const sdkMessageUnsub = onSdkMessage(experience, async (message) => {\n if (\n !Object.values(IdentifyAction).includes(message.action as IdentifyAction)\n ) {\n return;\n }\n\n const respond = (payload?: Payload) =>\n respondToSdkMessage(experience, message, payload);\n\n try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin();\n\n respond();\n\n break;\n }\n case IdentifyAction.RequestLogout: {\n await requestLogout();\n\n respond();\n break;\n }\n case IdentifyAction.GetCredentials: {\n const data = await getCredentials();\n\n respond({ data });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(message.payload as Credentials);\n\n respond();\n break;\n }\n case IdentifyAction.ClearCredentials: {\n await clearCredentials();\n\n respond();\n break;\n }\n }\n } catch (err) {\n respond({\n error: getErrorMessage(err),\n });\n }\n });\n\n addExperience(experience, [sdkMessageUnsub]);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceUnmounted(experience: Experience): void {\n deleteExperience(experience);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceStateChange(\n experience: Experience,\n state: ExperienceState,\n): void {\n if (state === 'mounted') {\n handleExperienceEmbedded(experience);\n return;\n }\n\n if (state === 'unmounted') {\n handleExperienceUnmounted(experience);\n }\n}\n\nfunction subscribeToExperienceLifecycle(): void {\n onStateChanged(handleExperienceStateChange);\n}\n\nfunction connectToParentApplication(): void {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n return;\n }\n\n onSdkMessage(parentApp, handleParentMessage);\n pullStateFromParent();\n}\n\nsubscribeToExperienceLifecycle();\nconnectToParentApplication();\n"],"names":["IdentifyError","Emitter","fetchListings","createError","getDeviceId","subscribe","TaskQueue","Sdk","getParentApplication","sendSdkRequest","MonterosaError","BridgeError","getErrorMessage","getConnect","connect","connectLogin","withRetryAsync","connectLogout","sendSdkMessage","getSdk","memoizePromise","onConnected","onConnecting","onDisconnected","onSdkMessage","respondToSdkMessage","onStateChanged"],"mappings":";;;;;;;;;;AAAA;;;;;;;AAOG;AA2JH;;AAEG;AACH,IAAY,aAMX,CAAA;AAND,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,cAAA,CAAA,GAAA,eAA8B,CAAA;AAC9B,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,iBAAkC,CAAA;AAClC,IAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,kBAAoC,CAAA;AACpC,IAAA,aAAA,CAAA,oBAAA,CAAA,GAAA,qBAA0C,CAAA;AAC1C,IAAA,aAAA,CAAA,oBAAA,CAAA,GAAA,sBAA2C,CAAA;AAC7C,CAAC,EANW,aAAa,KAAb,aAAa,GAMxB,EAAA,CAAA,CAAA,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACSA,+BA8BX;AA9BD,CAAA,UAAY,aAAa,EAAA;AACvB;;AAEG;AACH,IAAA,aAAA,CAAA,mBAAA,CAAA,GAAA,qBAAyC,CAAA;AACzC;;AAEG;AACH,IAAA,aAAA,CAAA,mBAAA,CAAA,GAAA,qBAAyC,CAAA;AACzC;;;AAGG;AACH,IAAA,aAAA,CAAA,eAAA,CAAA,GAAA,gBAAgC,CAAA;AAChC;;AAEG;AACH,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,kBAAmC,CAAA;AACnC;;AAEG;AACH,IAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,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tB,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,wBAAwB,CAAC,UAAU,CAAC,CAAC;QACrC,OAAO;AACR,KAAA;IAED,IAAI,KAAK,KAAK,WAAW,EAAE;QACzB,yBAAyB,CAAC,UAAU,CAAC,CAAC;AACvC,KAAA;AACH,CAAC;AAED,SAAS,8BAA8B,GAAA;IACrCc,6BAAc,CAAC,2BAA2B,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,0BAA0B,GAAA;AACjC,IAAA,MAAM,SAAS,GAAGlB,mCAAoB,EAAE,CAAC;IAEzC,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,OAAO;AACR,KAAA;AAED,IAAAgB,2BAAY,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAC7C,IAAA,mBAAmB,EAAE,CAAC;AACxB,CAAC;AAED,8BAA8B,EAAE,CAAC;AACjC,0BAA0B,EAAE;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/experiences.ts","../src/login_policy_store.ts","../src/credentials_store.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk } from '@monterosa/sdk-core';\nimport { Emitter } from '@monterosa/sdk-util';\n\n/**\n * Represents user authentication credentials.\n *\n * @remarks\n * The `token` property can be either the literal `'cookie'` for cookie-based\n * authentication or a string value for bearer token authentication.\n *\n * @example\n * ```javascript\n * // Bearer token authentication\n * const credentials: Credentials = { token: \"abc123\" };\n *\n * // Cookie-based authentication\n * const credentials: Credentials = { token: \"cookie\" };\n * ```\n */\nexport type Credentials = {\n token: 'cookie' | string;\n};\n\n/**\n * A tuple representing a digital signature: `[userId, timestamp, signature]`.\n *\n * @example\n * ```javascript\n * const signature: Signature = [\"user123\", 1646956195, \"abc123\"];\n * ```\n */\nexport type Signature = [userId: string, timestamp: number, signature: string];\n\n/**\n * A key-value object representing user profile data.\n *\n * @remarks\n * Contains `userId`, `timestamp`, and `signature` alongside any\n * additional custom properties.\n *\n * @example\n * ```javascript\n * const userData: UserData = {\n * userId: \"user123\",\n * timeStamp: 1646956195,\n * signature: \"abc123\",\n * name: \"John Doe\",\n * age: 30,\n * email: \"john.doe@example.com\"\n * };\n * ```\n */\nexport type UserData = {\n [key: string]: any;\n};\n\nexport type ResponsePayload<T> = {\n data: T;\n error?: string;\n};\n\nexport type LoginState = {\n state: 'logged_out' | 'logged_in' | 'pending' | 'error';\n error?: string;\n errorType?: 'login' | 'logout';\n};\n\nexport type LoginPolicy = 'disabled' | 'auto';\n\n/**\n * Resolved configuration options for an `Identify` instance. Public APIs\n * that accept user-supplied options (such as {@link getIdentify}) take\n * `Partial<IdentifyOptions>` and apply defaults for any field not\n * supplied.\n *\n * `loginPolicy` is set separately via {@link setLoginPolicy}.\n */\nexport interface IdentifyOptions {\n /**\n * Authentication strategy. Default: `'email'`.\n */\n readonly strategy: string;\n /**\n * Identity provider name (e.g. `'aws'` for Cognito).\n */\n readonly provider?: string;\n /**\n * Identify API version. Default: `1`.\n */\n readonly version: number;\n}\n\n/**\n * Represents an Identify Kit instance. Obtain one via {@link getIdentify}.\n *\n * @remarks\n * This interface is opaque. Interact with it through the standalone\n * functions such as {@link setCredentials}, {@link clearCredentials},\n * and {@link getUserData}.\n */\nexport interface IdentifyKit extends Emitter {\n /**\n * Resolved identity options. `loginPolicy` is not on the instance —\n * see {@link setLoginPolicy}. Credentials are root-owned, accessed\n * via {@link getCredentials}.\n *\n * @internal\n */\n options: IdentifyOptions;\n /**\n * @internal\n */\n sdk: MonterosaSdk;\n /**\n * @internal\n */\n signature: Signature | null;\n /**\n * @internal\n */\n userData: UserData | null;\n /**\n * @internal\n */\n wasLoggedIn: boolean;\n\n state: LoginState;\n\n /**\n * @internal\n */\n getUrl(path?: string): Promise<string>;\n}\n\nexport interface Response {\n message: string;\n result: number;\n data: {\n [key: string]: any;\n };\n}\n\nexport interface UserResponse extends Response {}\n\nexport interface UserCheckResponse extends Response {\n data: {\n userId: string;\n timeStamp: number;\n signature: string;\n [key: string]: any;\n };\n}\n\n/**\n * @internal\n */\nexport enum IdentifyEvent {\n StateUpdated = 'state_updated',\n LoginRequested = 'login_requested',\n LogoutRequested = 'logout_requested',\n CredentialsUpdated = 'credentials_updated',\n LoginPolicyUpdated = 'login_policy_updated',\n}\n\n/**\n * Defines a set of error codes that may be encountered when using the\n * Identify kit of the Monterosa SDK.\n *\n * @example\n * ```javascript\n * try {\n * // some code that uses the IdentifyKit\n * } catch (err) {\n * if (err.code === IdentifyError.NoCredentials) {\n * // handle missing credentials error\n * } else {\n * // handle other error types\n * }\n * }\n * ```\n *\n * @remarks\n * - The `IdentifyError` enum provides a convenient way to handle errors\n * encountered when using the `IdentifyKit` module. By checking the code\n * property of the caught error against the values of the enum, the error\n * type can be determined and appropriate action taken.\n *\n * - The `IdentifyError` enum is not intended to be instantiated or extended.\n */\nexport enum IdentifyError {\n /**\n * Indicates an error occurred during the call to the extension API.\n */\n ExtensionApiError = 'extension_api_error',\n /**\n * Indicates the extension required by the IdentifyKit is not set up properly.\n */\n ExtensionNotSetup = 'extension_not_setup',\n /**\n * Indicates the user's authentication credentials are not available\n * or have expired.\n */\n NoCredentials = 'no_credentials',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_error',\n /**\n * Indicates an unexpected or invalid login state was encountered.\n */\n UnexpectedState = 'unexpected_state',\n /**\n * Indicates there is no parent application to delegate to.\n */\n NoParentApplication = 'no_parent_application',\n /**\n * Indicates a timeout occurred when communicating with the parent app.\n */\n ParentTimeoutError = 'parent_timeout_error',\n}\n\n/**\n * @internal\n */\nexport const IdentifyErrorMessages = {\n [IdentifyError.ExtensionApiError]: (error: string) =>\n `Identify extension API returned an error: ${error}`,\n [IdentifyError.ExtensionNotSetup]: () =>\n 'Identify extension is not set up for this project',\n [IdentifyError.NoCredentials]: () => 'Identify credentials are not set',\n [IdentifyError.ParentAppError]: (error: string) =>\n `Parent application error: ${error}`,\n [IdentifyError.UnexpectedState]: (state: string) =>\n `Unexpected LoginState: ${state}`,\n [IdentifyError.NoParentApplication]: () =>\n 'No parent application available for delegation',\n [IdentifyError.ParentTimeoutError]: (error: string) =>\n `Parent application timeout: ${error}. Please check if the identify-kit is imported on the parent page.`,\n};\n\nexport enum IdentifyAction {\n Login = 'identifyLogin',\n Logout = 'identifyLogout',\n RequestLogin = 'identifyRequestLogin',\n RequestLogout = 'identifyRequestLogout',\n GetCredentials = 'identifyGetCredentials',\n SetCredentials = 'identifySetCredentials',\n ClearCredentials = 'identifyClearCredentials',\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nexport const EXTENSION_ID = 'lvis-id-custom-tab';\n\nexport const SIGNATURE_TTL = 10_000;\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, getDeviceId } from '@monterosa/sdk-core';\nimport { Emitter, createError } from '@monterosa/sdk-util';\nimport { fetchListings } from '@monterosa/sdk-interact-interop';\n\nimport {\n IdentifyKit,\n IdentifyOptions,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n LoginState,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID, SIGNATURE_TTL } from './constants';\n\nexport class Identify extends Emitter implements IdentifyKit {\n wasLoggedIn: boolean = false;\n\n private host?: string;\n private readonly _options: IdentifyOptions;\n\n private _signature: Signature | null = null;\n private _userData: UserData | null = null;\n private signatureExpireTimeout!: ReturnType<typeof setTimeout>;\n\n _state: LoginState = {\n state: 'logged_out',\n };\n\n constructor(\n public sdk: MonterosaSdk,\n options: Partial<IdentifyOptions> = {},\n ) {\n super();\n this._options = {\n strategy: 'email',\n version: 1,\n ...options,\n };\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n const extensionAssets = listings.assets?.[EXTENSION_ID] ?? [];\n\n const endpointAsset = extensionAssets.find(\n ({ name }) => name === 'endpoint',\n );\n\n if (!endpointAsset) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return endpointAsset.data;\n }\n\n get state(): LoginState {\n return this._state;\n }\n\n set state(state: LoginState) {\n if (this._state.state === state.state) {\n return;\n }\n\n switch (state.state) {\n case 'logged_in':\n this.wasLoggedIn = true;\n break;\n case 'error':\n this.wasLoggedIn = false;\n break;\n case 'logged_out':\n case 'pending':\n // preserve wasLoggedIn — these states reflect transient transport\n // state, not a deliberate logout (credentials are the gate for that)\n break;\n default: {\n // Exhaustiveness check: TypeScript errors if a new state is added\n // but not handled. This is a compile-time error.\n //\n // See: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking\n const exhaustiveCheck: never = state.state;\n\n throw createError(\n IdentifyError.UnexpectedState,\n IdentifyErrorMessages,\n String(exhaustiveCheck),\n );\n }\n }\n\n this._state = state;\n\n this.emit(IdentifyEvent.StateUpdated, state);\n }\n\n get options() {\n return this._options;\n }\n\n set signature(signature: Signature | null) {\n if (this._signature === signature) {\n return;\n }\n\n this._signature = signature;\n\n clearTimeout(this.signatureExpireTimeout);\n\n if (signature !== null) {\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, SIGNATURE_TTL);\n }\n }\n\n get signature(): Signature | null {\n return this._signature;\n }\n\n set userData(data: UserData | null) {\n if (this._userData === data) {\n return;\n }\n\n this._userData = data;\n }\n\n get userData(): UserData | null {\n return this._userData;\n }\n\n async getUrl(path: string = ''): Promise<string> {\n const { host, projectId } = this.sdk.options;\n\n if (this.host === undefined) {\n this.host = await Identify.fetchIdentifyHost(host, projectId);\n }\n\n const url = new URL(this.host);\n const { version, strategy, provider } = this._options;\n\n url.pathname = `/v${version}${path}`;\n\n url.searchParams.set('projectId', projectId);\n url.searchParams.set('deviceId', getDeviceId());\n url.searchParams.set('strategy', strategy);\n\n if (provider !== undefined) {\n url.searchParams.set('provider', provider);\n }\n\n return url.toString();\n }\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2025-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport type { Unsubscribe } from '@monterosa/sdk-util';\nimport type { Experience } from '@monterosa/sdk-launcher-kit';\n\ntype ExperienceEntry = {\n experience: Experience;\n unsubs: Set<Unsubscribe>;\n};\n\nconst entries = new Map<string, ExperienceEntry>();\n\nexport function getExperiences(): Experience[] {\n return Array.from(entries.values()).map((entry) => entry.experience);\n}\n\nexport function addExperience(\n experience: Experience,\n unsubs: Unsubscribe[] = [],\n) {\n entries.set(experience.id, {\n experience,\n unsubs: new Set(unsubs),\n });\n}\n\nexport function deleteExperience(experience: Experience) {\n const entry = entries.get(experience.id);\n\n if (entry) {\n entry.unsubs.forEach((unsub) => unsub());\n entries.delete(experience.id);\n }\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter, Unsubscribe, subscribe } from '@monterosa/sdk-util';\n\nimport { IdentifyEvent, LoginPolicy } from './types';\n\n/**\n * Locally-owned login policy.\n *\n * Defaults to `'disabled'`. Set via the public `setLoginPolicy`. Never\n * propagated across the wire — each level owns its own policy.\n *\n * @internal\n */\nexport class LoginPolicyStore extends Emitter {\n private static instance: LoginPolicyStore;\n\n private _policy: LoginPolicy = 'disabled';\n\n private constructor() {\n super();\n }\n\n public static getInstance(): LoginPolicyStore {\n if (!LoginPolicyStore.instance) {\n LoginPolicyStore.instance = new LoginPolicyStore();\n }\n\n return LoginPolicyStore.instance;\n }\n\n get policy(): LoginPolicy {\n return this._policy;\n }\n\n set policy(next: LoginPolicy) {\n if (this._policy === next) {\n return;\n }\n\n this._policy = next;\n this.emit(IdentifyEvent.LoginPolicyUpdated, next);\n }\n\n subscribe(handler: (value: LoginPolicy) => void): Unsubscribe {\n return subscribe(this, IdentifyEvent.LoginPolicyUpdated, handler);\n }\n\n reset(): void {\n this._policy = 'disabled';\n this.off(IdentifyEvent.LoginPolicyUpdated);\n }\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter, Unsubscribe, subscribe } from '@monterosa/sdk-util';\n\nimport { Credentials, IdentifyEvent } from './types';\n\n/**\n * Root-owned credentials store.\n *\n * Single source of truth at the root of an integration; an internal\n * mirror at every other level, kept in sync via `Login` / `Logout`\n * broadcasts. Not exposed publicly — public access flows through\n * `setCredentials` / `getCredentials` / `clearCredentials` and\n * `onCredentialsUpdated`.\n *\n * @internal\n */\nexport class CredentialsStore extends Emitter {\n private static instance: CredentialsStore;\n\n private _credentials: Credentials | null = null;\n\n private constructor() {\n super();\n }\n\n public static getInstance(): CredentialsStore {\n if (!CredentialsStore.instance) {\n CredentialsStore.instance = new CredentialsStore();\n }\n\n return CredentialsStore.instance;\n }\n\n get credentials(): Credentials | null {\n return this._credentials;\n }\n\n set credentials(next: Credentials | null) {\n if (this._credentials === next) {\n return;\n }\n\n this._credentials = next;\n this.emit(IdentifyEvent.CredentialsUpdated, next);\n }\n\n subscribe(handler: (value: Credentials | null) => void): Unsubscribe {\n return subscribe(this, IdentifyEvent.CredentialsUpdated, handler);\n }\n\n reset(): void {\n this._credentials = null;\n this.off(IdentifyEvent.CredentialsUpdated);\n }\n}\n","/**\n * @license\n * identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, Sdk, getSdk } from '@monterosa/sdk-core';\nimport {\n Unsubscribe,\n TaskQueue,\n Emitter,\n subscribe,\n createError,\n withRetryAsync,\n memoizePromise,\n MonterosaError,\n getErrorMessage,\n} from '@monterosa/sdk-util';\nimport {\n getConnect,\n login as connectLogin,\n logout as connectLogout,\n connect,\n onConnected,\n onConnecting,\n onDisconnected,\n} from '@monterosa/sdk-connect-kit';\nimport {\n Payload,\n getParentApplication,\n sendSdkRequest,\n sendSdkMessage,\n BridgeError,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n LoginState,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n LoginPolicy,\n} from './types';\n\nimport { Identify } from './identify';\nimport { getExperiences } from './experiences';\nimport { LoginPolicyStore } from './login_policy_store';\nimport { CredentialsStore } from './credentials_store';\n\nconst loginPolicyStore = LoginPolicyStore.getInstance();\nconst credentialsStore = CredentialsStore.getInstance();\n\n/**\n * @internal\n */\nexport const identifyKits: Map<string, Identify> = new Map();\n\n/**\n * Emitter for identify request events that are not tied to a specific\n * identify instance (login / logout requests).\n *\n * @internal\n */\nconst requestsEmitter = new Emitter();\n\n/**\n * Read the current locally-owned login policy.\n *\n * Returns `'disabled'` by default.\n *\n * @internal\n */\nexport function getLoginPolicy(): LoginPolicy {\n return loginPolicyStore.policy;\n}\n\n/**\n * Set the login policy.\n *\n * - `'auto'`: the SDK automatically logs the user in whenever\n * credentials are available.\n * - `'disabled'`: credentials are tracked but no automatic login is\n * attempted.\n *\n * Each level of a multi-level integration owns its own policy; the\n * value is never propagated to embedded experiences. Idempotent:\n * setting the same policy is a no-op.\n *\n * @param policy - `'auto'` or `'disabled'`.\n */\nexport function setLoginPolicy(policy: LoginPolicy): void {\n if (loginPolicyStore.policy === policy) {\n return;\n }\n\n loginPolicyStore.policy = policy;\n\n if (policy !== 'auto') {\n return;\n }\n\n // On transition to 'auto': if credentials are currently set (typical\n // after the non-root module-load pull, or after a setCredentials at\n // the root, or after an upstream Login broadcast has cascaded down),\n // enqueue a login task for each existing identify. If no credentials\n // are set, do nothing — a future credentials arrival via `applyLogin`\n // will trigger the login under this new policy.\n const { credentials } = credentialsStore;\n\n if (credentials === null) {\n return;\n }\n\n for (const identify of identifyKits.values()) {\n enqueueLogin(identify, credentials);\n }\n}\n\n/**\n * Whether the user should be auto-logged in on reconnect.\n *\n * True when the user was previously logged in, the policy is `'auto'`,\n * and credentials are available on the identify instance.\n *\n * @internal\n */\nexport function shouldLoginOnReconnect(identify: IdentifyKit): boolean {\n return (\n identify.wasLoggedIn &&\n getLoginPolicy() === 'auto' &&\n credentialsStore.credentials !== null\n );\n}\n\n/**\n * @internal\n */\nexport const taskQueue = new TaskQueue();\n\nfunction isSdk(value: MonterosaSdk | any): value is MonterosaSdk {\n return value instanceof Sdk;\n}\n\nasync function api<T extends Response>(\n url: string,\n token: Credentials['token'],\n method: string = 'GET',\n): Promise<T> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n };\n\n let credentials: RequestCredentials | undefined;\n\n // Only include Authorization header for bearer token authentication\n // When token is 'cookie', use credentials: 'include' to ensure HttpOnly\n // cookies are sent\n if (token === 'cookie') {\n // Use credentials: 'include' to ensure HttpOnly cookies are sent\n credentials = 'include';\n } else {\n headers.Authorization = `Bearer ${token}`;\n }\n\n const response = await fetch(url, {\n method,\n headers,\n credentials,\n });\n\n const data = (await response.json()) as T;\n\n if (data.result < 0) {\n throw createError(\n IdentifyError.ExtensionApiError,\n IdentifyErrorMessages,\n data.message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport async function sendParentRequest<T>(\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n throw createError(IdentifyError.NoParentApplication, IdentifyErrorMessages);\n }\n\n try {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { error, data } = response.payload as ResponsePayload<T>;\n\n if (error !== undefined) {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n error,\n );\n }\n\n return data;\n } catch (err) {\n if (\n err instanceof MonterosaError &&\n err.code === BridgeError.RequestTimeoutError\n ) {\n const errorMessage = getErrorMessage(err);\n\n throw createError(\n IdentifyError.ParentTimeoutError,\n IdentifyErrorMessages,\n errorMessage,\n );\n }\n\n throw err;\n }\n}\n\n/**\n * @internal\n */\nasync function login(identify: IdentifyKit, credentials: Credentials) {\n const signature = await getSessionSignatureMemoized(identify, credentials);\n\n const conn = await getConnect(identify.sdk.options.host);\n\n await connect(conn);\n await connectLogin(conn, ...signature);\n}\n\nconst loginWithRetry = withRetryAsync(login);\n\n/**\n * @internal\n */\nasync function logout(identify: IdentifyKit) {\n const conn = await getConnect(identify.sdk.options.host);\n\n await connect(conn);\n await connectLogout(conn);\n}\n\nconst logoutWithRetry = withRetryAsync(logout);\n\n/**\n * @internal\n */\nexport async function loginTask(\n identify: IdentifyKit,\n credentials: Credentials,\n) {\n if (identify.state.state === 'logged_in') {\n return;\n }\n\n try {\n identify.state = {\n state: 'pending',\n };\n\n await loginWithRetry(identify, credentials);\n\n // Update state only if there are no pending tasks in the queue\n if (taskQueue.isEmpty()) {\n identify.state = {\n state: 'logged_in',\n };\n }\n } catch (err) {\n // Abandon any pending login/logout/sync tasks on failure — letting\n // them run after an error would put the user in an inconsistent\n // state. Note: this also drops tasks for unrelated identifies that\n // share the queue; acceptable because the typical runtime has one\n // identify per project.\n taskQueue.clear();\n\n identify.state = {\n state: 'error',\n error: err instanceof Error ? err.message : 'Unknown error',\n errorType: 'login',\n };\n }\n}\n\n/**\n * @internal\n */\nexport async function logoutTask(identify: IdentifyKit) {\n if (identify.state.state === 'logged_out') {\n return;\n }\n\n try {\n identify.state = {\n state: 'pending',\n };\n\n await logoutWithRetry(identify);\n\n // Update state only if there are no pending tasks in the queue\n if (taskQueue.isEmpty()) {\n identify.state = {\n state: 'logged_out',\n };\n }\n } catch (err) {\n // Abandon any pending login/logout/sync tasks on failure — see\n // `loginTask` for the rationale.\n taskQueue.clear();\n\n identify.state = {\n state: 'error',\n error: err instanceof Error ? err.message : 'Unknown error',\n errorType: 'logout',\n };\n }\n}\n\n/**\n * Enqueue a `loginTask` for the given identify when `policy === 'auto'`.\n * The downstream `Login` broadcast is emitted by {@link applyLogin}.\n *\n * @internal\n */\nexport function enqueueLogin(\n identify: IdentifyKit,\n credentials: Credentials,\n prioritise: boolean = false,\n) {\n if (getLoginPolicy() !== 'auto') {\n return;\n }\n\n if (prioritise) {\n taskQueue.enqueueFront(() => loginTask(identify, credentials));\n } else {\n taskQueue.enqueue(() => loginTask(identify, credentials));\n }\n}\n\n/**\n * Reset the identify's identity-derived caches and enqueue a `logoutTask`\n * when `policy === 'auto'`.\n *\n * @internal\n */\nexport function enqueueLogout(identify: IdentifyKit) {\n identify.userData = null;\n identify.signature = null;\n\n if (getLoginPolicy() !== 'auto') {\n return;\n }\n\n taskQueue.enqueue(() => logoutTask(identify));\n}\n\n/**\n * Apply new credentials at this level: update the current credentials,\n * enqueue a `loginTask` for every existing identify on the null-to-set\n * transition, and broadcast `Login` downstream to every embedded\n * experience.\n *\n * Idempotent on token refresh: re-setting when credentials are already\n * present updates the value and broadcasts, but does not re-enqueue\n * logins (their `loginTask` would short-circuit on\n * `state === 'logged_in'` anyway).\n *\n * @internal\n */\nexport function applyLogin(credentials: Credentials): void {\n const shouldLogin = credentialsStore.credentials === null;\n\n credentialsStore.credentials = credentials;\n\n if (shouldLogin) {\n for (const identify of identifyKits.values()) {\n enqueueLogin(identify, credentials);\n }\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Login, credentials);\n }\n}\n\n/**\n * Clear credentials at this level: clear the current credentials,\n * enqueue a `logoutTask` for every existing identify on the\n * set-to-null transition, and broadcast `Logout` downstream to every\n * embedded experience.\n *\n * @internal\n */\nexport function applyLogout(): void {\n const shouldLogout = credentialsStore.credentials !== null;\n\n credentialsStore.credentials = null;\n\n if (shouldLogout) {\n for (const identify of identifyKits.values()) {\n enqueueLogout(identify);\n }\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Logout, {});\n }\n}\n\n/**\n * Pull state from the parent application and apply locally.\n *\n * Fires once at non-root bridge module load, regardless of\n * `loginPolicy` — token presence is the customer-side sign-in state and\n * must mirror upstream whether or not we choose to validate against\n * Enmasse. Best-effort: a missing or non-identify-kit parent silently\n * resolves with no change to the current credentials.\n *\n * Uses {@link applyLogin} so the update cascades downstream to this\n * level's own embedded experiences and per-identify loginTasks are\n * enqueued under `loginPolicy === 'auto'`.\n *\n * @internal\n */\nexport async function pullStateFromParent(): Promise<void> {\n let credentials: Credentials | null;\n try {\n credentials = await getCredentials();\n } catch {\n return;\n }\n\n if (credentials !== null) {\n applyLogin(credentials);\n }\n}\n\n/**\n * Get the IdentifyKit instance for the given SDK / project.\n *\n * The IdentifyKit instance is used to authenticate users and read\n * user data.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * ```\n *\n * @remarks\n * First-call-wins: subsequent calls for the same project return the\n * cached instance and ignore the `options` argument.\n *\n * @param sdk - The Monterosa SDK instance.\n * @param options - IdentifyKit options (applied only on the first call).\n * @returns The IdentifyKit instance for the project.\n */\nexport function getIdentify(\n sdk?: MonterosaSdk,\n options?: Partial<IdentifyOptions>,\n): IdentifyKit;\n\n/**\n * Get the IdentifyKit instance for the configured SDK.\n *\n * The IdentifyKit instance is used to authenticate users and read\n * user data.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * ```\n *\n * @remarks\n * First-call-wins: subsequent calls for the same project return the\n * cached instance and ignore the `options` argument.\n *\n * @param options - IdentifyKit options (applied only on the first call).\n * @returns The IdentifyKit instance for the project.\n */\nexport function getIdentify(options?: Partial<IdentifyOptions>): IdentifyKit;\n\nexport function getIdentify(\n sdkOrOptions?: MonterosaSdk | Partial<IdentifyOptions>,\n options?: Partial<IdentifyOptions>,\n): IdentifyKit {\n let sdk: MonterosaSdk;\n let identifyOptions: Partial<IdentifyOptions>;\n\n if (isSdk(sdkOrOptions)) {\n /**\n * Interface: getIdentify(sdk, options?)\n */\n\n sdk = sdkOrOptions;\n\n if (options !== undefined) {\n identifyOptions = options;\n } else {\n identifyOptions = {};\n }\n } else if (sdkOrOptions !== undefined) {\n /**\n * Interface: getIdentify(options)\n */\n\n sdk = getSdk();\n identifyOptions = sdkOrOptions;\n } else {\n /**\n * Interface: getIdentify()\n */\n\n sdk = getSdk();\n identifyOptions = {};\n }\n\n const { projectId } = sdk.options;\n\n if (identifyKits.has(projectId)) {\n return identifyKits.get(projectId) as Identify;\n }\n\n const identify = new Identify(sdk, identifyOptions);\n\n watchConnectionStatus(identify);\n\n identifyKits.set(projectId, identify);\n\n return identify;\n}\n\n/**\n * Request a user login.\n *\n * When called from an embedded experience, the request is relayed to\n * the parent application — the host that owns the auth UI handles it.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { requestLogin } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * await requestLogin();\n * console.log('Login request successful');\n * } catch (err) {\n * console.error('Error requesting login:', err.message)\n * }\n * ```\n *\n * @returns A Promise that resolves once the login request has been\n * delivered.\n */\nexport async function requestLogin(): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.RequestLogin);\n return;\n }\n\n requestsEmitter.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * Read the current credentials.\n *\n * When called from an embedded experience, fetches the credentials\n * from the parent application so the caller always sees the\n * authoritative value.\n *\n * @returns A Promise that resolves to the current credentials, or\n * `null` if none are set.\n */\nexport async function getCredentials(): Promise<Credentials | null> {\n if (getParentApplication() === null) {\n return credentialsStore.credentials;\n }\n\n return sendParentRequest<Credentials | null>(IdentifyAction.GetCredentials);\n}\n\n/**\n * Request a user logout.\n *\n * When called from an embedded experience, the request is relayed to\n * the parent application — the host that owns the auth UI handles it.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { requestLogout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * await requestLogout();\n * console.log('Logout request successful');\n * } catch (err) {\n * console.error('Error requesting logout:', err.message)\n * }\n * ```\n *\n * @returns A Promise that resolves once the logout request has been\n * delivered.\n */\nexport async function requestLogout(): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.RequestLogout);\n return;\n }\n\n requestsEmitter.emit(IdentifyEvent.LogoutRequested);\n}\n\n/**\n * @internal\n *\n * Returns a signature for a user session. The signature is based on the\n * user's identifying information provided in the `IdentifyKit` instance.\n *\n * @remarks\n * This function does not handle errors. Callers are responsible for catching\n * and handling failures.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @param credentials - The credentials of the user.\n *\n * @returns A Promise that resolves to a `Signature` object.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n credentials: Credentials,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(url, credentials.token);\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n\n return signature;\n}\n\n/**\n * @internal\n *\n * A memoized version of the `getSessionSignature` function. Memo key is\n * the credentials token, so both leaf-side and bridge-side callers share\n * the same cache for the same token.\n */\nexport const getSessionSignatureMemoized = memoizePromise(\n getSessionSignature,\n (identify: IdentifyKit, credentials: Credentials) => credentials.token,\n {\n clearOnResolve: true,\n clearOnReject: true,\n },\n);\n\n/**\n * Fetch user data for the given credentials.\n *\n * Credentials are required explicitly. Obtain a value via\n * {@link getCredentials} or the {@link onCredentialsUpdated} callback.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import {\n * getIdentify,\n * getUserData,\n * getCredentials,\n * } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const credentials = await getCredentials();\n *\n * if (credentials !== null) {\n * const userData = await getUserData(identify, credentials);\n * console.log('User data:', userData);\n * }\n * ```\n *\n * @remarks\n * Cached after the first successful fetch and reset when credentials\n * are cleared.\n *\n * @param identify - The IdentifyKit instance.\n * @param credentials - The user's authentication credentials.\n * @returns A Promise that resolves to a key-value object of user data.\n * The structure depends on the identify service provider.\n */\nexport async function getUserData(\n identify: IdentifyKit,\n credentials: Credentials,\n): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, credentials.token);\n\n identify.userData = data;\n\n return data;\n}\n\n/**\n * Set the user's authentication credentials.\n *\n * The credentials become the active credentials for the entire\n * integration. When called from an embedded experience, the call is\n * relayed to the parent application so that every level of the\n * integration sees the new value.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { setCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * await setCredentials({ token: 'abc123' });\n * ```\n *\n * @param credentials - The user's authentication credentials.\n * @returns A Promise that resolves once the credentials have been\n * applied.\n */\nexport async function setCredentials(credentials: Credentials): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.SetCredentials, credentials);\n\n return;\n }\n\n applyLogin(credentials);\n}\n\n/**\n * Clear the user's authentication credentials.\n *\n * When called from an embedded experience, the call is relayed to the\n * parent application so that every level of the integration is\n * cleared.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { clearCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * await clearCredentials();\n * ```\n *\n * @returns A Promise that resolves once the credentials have been\n * cleared.\n */\nexport async function clearCredentials(): Promise<void> {\n if (getParentApplication() !== null) {\n await sendParentRequest<void>(IdentifyAction.ClearCredentials);\n\n return;\n }\n\n applyLogout();\n}\n\n/**\n * Register a callback for `LoginState` updates on the given identify.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onStateUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onStateUpdated(identify, (state) => {\n * console.log(\"State updated:\", state);\n * });\n * ```\n *\n * @param identify - The IdentifyKit instance.\n * @param callback - Called with the updated `LoginState`.\n * @returns An `Unsubscribe` function.\n */\nexport function onStateUpdated(\n identify: IdentifyKit,\n callback: (state: LoginState) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.StateUpdated, callback);\n}\n\n/**\n * Register a callback for updates to the current credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { onCredentialsUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const unsubscribe = onCredentialsUpdated((credentials) => {\n * if (credentials !== null) {\n * console.log(\"Credentials updated:\", credentials);\n * } else {\n * console.log(\"Credentials cleared.\");\n * }\n * });\n * ```\n *\n * @param callback - Called with the updated `Credentials`, or `null`\n * when credentials are cleared.\n * @returns An `Unsubscribe` function.\n */\nexport function onCredentialsUpdated(\n callback: (credentials: Credentials | null) => void,\n): Unsubscribe {\n return credentialsStore.subscribe(callback);\n}\n\n/**\n * Register a callback for login requests.\n *\n * Fires when {@link requestLogin} is called at this level — whether by\n * local code or relayed up from an embedded experience.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const unsubscribe = onLoginRequestedByExperience(() => {\n * showLoginForm();\n * });\n * ```\n *\n * @param callback - Called when a login is requested.\n * @returns An `Unsubscribe` function.\n */\nexport function onLoginRequestedByExperience(\n callback: () => void,\n): Unsubscribe {\n return subscribe(requestsEmitter, IdentifyEvent.LoginRequested, callback);\n}\n\n/**\n * Register a callback for logout requests.\n *\n * Fires when {@link requestLogout} is called at this level — whether\n * by local code or relayed up from an embedded experience.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const unsubscribe = onLogoutRequestedByExperience(() => {\n * // perform logout from auth service\n * });\n * ```\n *\n * @param callback - Called when a logout is requested.\n * @returns An `Unsubscribe` function.\n */\nexport function onLogoutRequestedByExperience(\n callback: () => void,\n): Unsubscribe {\n return subscribe(requestsEmitter, IdentifyEvent.LogoutRequested, callback);\n}\n\n/**\n * @internal\n */\nexport async function watchConnectionStatus(identify: IdentifyKit) {\n const conn = await getConnect(identify.sdk.options.host);\n\n onConnected(conn, () => {\n if (shouldLoginOnReconnect(identify)) {\n enqueueLogin(identify, credentialsStore.credentials!, true);\n }\n\n taskQueue.resume();\n });\n\n onConnecting(conn, () => {\n taskQueue.pause();\n\n // If the user was logged in before the connection loss, set the state\n // to pending to notify that the user is no longer logged in and a login\n // attempt will be made when the connection is restored.\n if (identify.state.state === 'logged_in') {\n identify.state = {\n state: 'pending',\n };\n }\n });\n\n onDisconnected(conn, () => {\n taskQueue.pause();\n taskQueue.clear();\n\n // If the user was logged in before the connection loss, set the state\n // to logged_out to notify that the user is no longer logged in.\n if (identify.state.state === 'logged_in') {\n identify.state = {\n state: 'logged_out',\n };\n }\n });\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n ExperienceState,\n Payload,\n Message,\n getParentApplication,\n respondToSdkMessage,\n onStateChanged,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport { IdentifyAction, Credentials } from './types';\n\nimport {\n getCredentials,\n requestLogin,\n requestLogout,\n setCredentials,\n clearCredentials,\n applyLogin,\n applyLogout,\n pullStateFromParent,\n} from './api';\nimport { addExperience, deleteExperience } from './experiences';\n\n/**\n * Process an incoming `Login` / `Logout` broadcast from the parent\n * application. Updates the local current credentials, enqueues login/logout\n * for every existing identify, and forwards the broadcast downstream to\n * this level's own embedded experiences — the mechanism that cascades a\n * root-level `setCredentials` through every nested experience.\n *\n * @internal\n */\nexport function handleParentMessage(message: Message): void {\n switch (message.action) {\n case IdentifyAction.Login: {\n applyLogin(message.payload as Credentials);\n break;\n }\n case IdentifyAction.Logout: {\n applyLogout();\n break;\n }\n }\n}\n\n/**\n * @internal\n */\nexport function handleExperienceEmbedded(experience: Experience): void {\n const sdkMessageUnsub = onSdkMessage(experience, async (message) => {\n if (\n !Object.values(IdentifyAction).includes(message.action as IdentifyAction)\n ) {\n return;\n }\n\n const respond = (payload?: Payload) =>\n respondToSdkMessage(experience, message, payload);\n\n try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin();\n\n respond();\n\n break;\n }\n case IdentifyAction.RequestLogout: {\n await requestLogout();\n\n respond();\n break;\n }\n case IdentifyAction.GetCredentials: {\n const data = await getCredentials();\n\n respond({ data });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(message.payload as Credentials);\n\n respond();\n break;\n }\n case IdentifyAction.ClearCredentials: {\n await clearCredentials();\n\n respond();\n break;\n }\n }\n } catch (err) {\n respond({\n error: getErrorMessage(err),\n });\n }\n });\n\n addExperience(experience, [sdkMessageUnsub]);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceUnmounted(experience: Experience): void {\n deleteExperience(experience);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceStateChange(\n experience: Experience,\n state: ExperienceState,\n): void {\n if (state === 'mounted') {\n handleExperienceEmbedded(experience);\n return;\n }\n\n if (state === 'unmounted') {\n handleExperienceUnmounted(experience);\n }\n}\n\nfunction subscribeToExperienceLifecycle(): void {\n onStateChanged(handleExperienceStateChange);\n}\n\nfunction connectToParentApplication(): void {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n return;\n }\n\n onSdkMessage(parentApp, handleParentMessage);\n pullStateFromParent();\n}\n\nsubscribeToExperienceLifecycle();\nconnectToParentApplication();\n"],"names":["IdentifyError","Emitter","fetchListings","createError","getDeviceId","subscribe","TaskQueue","Sdk","getParentApplication","sendSdkRequest","MonterosaError","BridgeError","getErrorMessage","getConnect","connect","connectLogin","withRetryAsync","connectLogout","sendSdkMessage","getSdk","memoizePromise","onConnected","onConnecting","onDisconnected","onSdkMessage","respondToSdkMessage","onStateChanged"],"mappings":";;;;;;;;;;AAAA;;;;;;;AAOG;AA2JH;;AAEG;AACH,IAAY,aAMX,CAAA;AAND,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,cAAA,CAAA,GAAA,eAA8B,CAAA;AAC9B,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,iBAAkC,CAAA;AAClC,IAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,kBAAoC,CAAA;AACpC,IAAA,aAAA,CAAA,oBAAA,CAAA,GAAA,qBAA0C,CAAA;AAC1C,IAAA,aAAA,CAAA,oBAAA,CAAA,GAAA,sBAA2C,CAAA;AAC7C,CAAC,EANW,aAAa,KAAb,aAAa,GAMxB,EAAA,CAAA,CAAA,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACSA,+BA8BX;AA9BD,CAAA,UAAY,aAAa,EAAA;AACvB;;AAEG;AACH,IAAA,a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