@monterosa/sdk-identify-kit 2.0.0-rc.1 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -163,9 +163,12 @@ export declare function requestLogout(identify: IdentifyKit): Promise<void>;
163
163
  /**
164
164
  * @internal
165
165
  *
166
- * Internal function to get a fresh session signature.
167
- * This function does not handle errors callers are responsible
168
- * for catching and handling failures.
166
+ * Returns a signature for a user session. The signature is based on the
167
+ * user's identifying information provided in the `IdentifyKit` instance.
168
+ *
169
+ * @remarks
170
+ * This function does not handle errors. Callers are responsible for catching
171
+ * and handling failures.
169
172
  *
170
173
  * @param identify - An instance of the `IdentifyKit` class used for user
171
174
  * identification.
@@ -428,7 +431,7 @@ export declare function onUserDataUpdated(identify: IdentifyKit, callback: (user
428
431
  * @param identify - An instance of `IdentifyKit` that provides the user
429
432
  * identification functionality.
430
433
  * @param callback - The callback function to register. This function will
431
- * be called when a login is requested by an experience.
434
+ * be called when a login is requested by an Experience.
432
435
  * @returns An `Unsubscribe` function that can be called to unregister
433
436
  * the callback function.
434
437
  */
@@ -457,7 +460,7 @@ export declare function onLoginRequestedByExperience(identify: IdentifyKit, call
457
460
  * @param identify - An instance of `IdentifyKit` that provides the user
458
461
  * identification functionality.
459
462
  * @param callback - The callback function to register. This function will
460
- * be called when a logout is requested by an experience.
463
+ * be called when a logout is requested by an Experience.
461
464
  * @returns An `Unsubscribe` function that can be called to unregister
462
465
  * the callback function.
463
466
  */
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Handles user authentication and identity management.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  /**
2
7
  * @license
3
8
  * @monterosa/sdk-identify-kit
@@ -6,11 +11,6 @@
6
11
  *
7
12
  * More details on the license can be found at https://www.monterosa.co/sdk/license
8
13
  */
9
- /**
10
- * Monterosa SDK / Identify Kit
11
- *
12
- * @packageDocumentation
13
- */
14
14
  import './bridge';
15
15
  export { getIdentify, requestLogin, requestLogout, getUserData, setCredentials, clearCredentials, onStateUpdated, onCredentialsUpdated, onSignatureUpdated, onUserDataUpdated, onLoginRequestedByExperience, onLogoutRequestedByExperience, } from './api';
16
16
  export { Credentials, Signature, UserData, IdentifyKit, IdentifyOptions, IdentifyError, LoginState, LoginPolicy, } from './types';
@@ -68,7 +68,7 @@ var IdentifyError;
68
68
  */
69
69
  IdentifyError["NoCredentials"] = "no_credentials";
70
70
  /**
71
- * Indicates the IdentifyKit has not been initialized properly.
71
+ * Indicates the IdentifyKit has not been initialised properly.
72
72
  */
73
73
  IdentifyError["NotInitialised"] = "not_initialised";
74
74
  /**
@@ -579,9 +579,12 @@ async function requestLogout(identify) {
579
579
  /**
580
580
  * @internal
581
581
  *
582
- * Internal function to get a fresh session signature.
583
- * This function does not handle errors callers are responsible
584
- * for catching and handling failures.
582
+ * Returns a signature for a user session. The signature is based on the
583
+ * user's identifying information provided in the `IdentifyKit` instance.
584
+ *
585
+ * @remarks
586
+ * This function does not handle errors. Callers are responsible for catching
587
+ * and handling failures.
585
588
  *
586
589
  * @param identify - An instance of the `IdentifyKit` class used for user
587
590
  * identification.
@@ -910,7 +913,7 @@ function onUserDataUpdated(identify, callback) {
910
913
  * @param identify - An instance of `IdentifyKit` that provides the user
911
914
  * identification functionality.
912
915
  * @param callback - The callback function to register. This function will
913
- * be called when a login is requested by an experience.
916
+ * be called when a login is requested by an Experience.
914
917
  * @returns An `Unsubscribe` function that can be called to unregister
915
918
  * the callback function.
916
919
  */
@@ -941,7 +944,7 @@ function onLoginRequestedByExperience(identify, callback) {
941
944
  * @param identify - An instance of `IdentifyKit` that provides the user
942
945
  * identification functionality.
943
946
  * @param callback - The callback function to register. This function will
944
- * be called when a logout is requested by an experience.
947
+ * be called when a logout is requested by an Experience.
945
948
  * @returns An `Unsubscribe` function that can be called to unregister
946
949
  * the callback function.
947
950
  */
@@ -1137,4 +1140,4 @@ onStateChanged((experience, state) => {
1137
1140
  registerIdentifyHook(parentMessagesHook);
1138
1141
 
1139
1142
  export { IdentifyError, clearCredentials, getIdentify, getUserData, onCredentialsUpdated, onLoginRequestedByExperience, onLogoutRequestedByExperience, onSignatureUpdated, onStateUpdated, onUserDataUpdated, requestLogin, requestLogout, setCredentials };
1140
- //# sourceMappingURL=index.esm.js.map
1143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/experiences.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, Unsubscribe } 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\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\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 * Configuration options for Identify Kit.\n */\nexport interface IdentifyOptions {\n /**\n * Unique device identifier. Must be persisted and reused across sessions\n * to avoid duplicate user records.\n */\n readonly deviceId?: string;\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 readonly loginPolicy?: LoginPolicy;\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 * The identify options.\n *\n * @internal\n */\n options: IdentifyOptions;\n /**\n * @internal\n */\n sdk: MonterosaSdk;\n /**\n * @internal\n */\n credentials: Credentials | null;\n /**\n * @internal\n */\n signature: Signature | null;\n /**\n * @internal\n */\n userData: UserData | null;\n /**\n * Whether the user should be automatically logged in when connection is\n * restored. This is true when:\n * - The user was previously logged in successfully\n * - Auto-login is enabled\n * - Credentials are available\n *\n * @internal\n */\n shouldLoginOnReconnect: 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 SignatureUpdated = 'signature_updated',\n UserdataUpdated = 'userdata_updated',\n CredentialsUpdated = 'credentials_updated',\n EnmasseLogin = 'enmasse_login',\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 if (err.code === IdentifyError.NotInitialised) {\n * // handle initialization 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 the IdentifyKit has not been initialised properly.\n */\n NotInitialised = 'not_initialised',\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.NotInitialised]: () => 'Identify instance is not initialised',\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 GetUserData = 'identifyGetUserData',\n GetSessionSignature = 'identifyGetSessionSignature',\n SetCredentials = 'identifySetCredentials',\n ClearCredentials = 'identifyClearCredentials',\n OnStateUpdated = 'identifyOnStateUpdated',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\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 Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID, SIGNATURE_TTL } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private wasLoggedIn: boolean = false;\n\n private host?: string;\n private readonly _options: IdentifyOptions;\n\n private _credentials: Credentials | null = null;\n private _signature: Signature | null = null;\n private _userData: UserData | null = null;\n private signatureExpireTimeout!: ReturnType<typeof setTimeout>;\n private userDataExpireTimeout!: ReturnType<typeof setTimeout>;\n\n _state: LoginState = {\n state: 'logged_out',\n };\n\n constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n loginPolicy: 'disabled',\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 'logged_out':\n case 'error':\n this.wasLoggedIn = false;\n break;\n case 'pending':\n // preserve wasLoggedIn value during transitional state\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 this.emit(IdentifyEvent.SignatureUpdated, this.signature);\n }\n\n get signature(): Signature | null {\n return this._signature;\n }\n\n set credentials(credentials: Credentials | null) {\n if (this._credentials === credentials) {\n return;\n }\n\n this._credentials = credentials;\n\n this.emit(IdentifyEvent.CredentialsUpdated, credentials);\n }\n\n get credentials(): Credentials | null {\n return this._credentials;\n }\n\n set userData(data: UserData | null) {\n if (this._userData === data) {\n return;\n }\n\n this._userData = data;\n\n clearTimeout(this.userDataExpireTimeout);\n\n this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\n }\n\n get shouldLoginOnReconnect(): boolean {\n return (\n this.wasLoggedIn &&\n this.options.loginPolicy === 'auto' &&\n this.credentials !== null\n );\n }\n\n reset() {\n this.credentials = null;\n this.userData = null;\n this.signature = null;\n this.wasLoggedIn = false;\n }\n\n async getUrl(path: string = '') {\n const {\n options: { host, projectId },\n } = this.sdk;\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, deviceId, strategy, provider } = this._options;\n\n url.pathname = `/v${version}${path}`;\n\n url.searchParams.set('projectId', projectId);\n url.searchParams.set('deviceId', deviceId!);\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 * 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 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 IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport Identify from './identify';\nimport { getExperiences } from './experiences';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\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 parentAppRequest<T>(\n identify: IdentifyKit,\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 const { host, projectId } = identify.sdk.options;\n\n // Preserve existing origin (relay) or set from current context (source)\n const origin = payload?.origin ?? { host, projectId };\n\n try {\n const response = await sendSdkRequest(parentApp, action, {\n ...payload,\n origin,\n });\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 */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\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 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 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 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 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 * @internal\n */\nexport function enqueueLogin(\n identify: IdentifyKit,\n credentials: Credentials,\n prioritise: boolean = false,\n) {\n if (identify.options.loginPolicy === 'auto') {\n if (prioritise) {\n taskQueue.enqueueFront(() => loginTask(identify, credentials));\n } else {\n taskQueue.enqueue(() => loginTask(identify, credentials));\n }\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Login, credentials);\n }\n}\n\n/**\n * @internal\n */\nexport function enqueueLogout(identify: IdentifyKit) {\n if (identify.options.loginPolicy === 'auto') {\n taskQueue.enqueue(() => logoutTask(identify));\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Logout);\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 to getIdentify with the same MonterosaSdk instance will return\n * the same `IdentifyKit` instance.\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?: 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 to getIdentify with the same MonterosaSdk instance will return\n * the same `IdentifyKit` instance.\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?: IdentifyOptions): IdentifyKit;\n\nexport function getIdentify(\n sdkOrOptions?: MonterosaSdk | IdentifyOptions,\n options?: IdentifyOptions,\n): IdentifyKit {\n let sdk: MonterosaSdk;\n let identifyOptions: 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 {\n options: { projectId },\n } = sdk;\n\n if (identifyKits.has(projectId)) {\n return identifyKits.get(projectId) as Identify;\n }\n\n const identify = new Identify(sdk, identifyOptions);\n\n for (const hook of identifyHooks) {\n hook(identify);\n }\n\n watchConnectionStatus(identify);\n\n identifyKits.set(projectId, identify);\n\n return identify;\n}\n\n/**\n * A function that requests a user login via the `IdentifyKit` of the Monterosa SDK.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, requestLogin } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await requestLogin(identify);\n *\n * console.log('Login request successful');\n * } catch (err) {\n * console.error('Error requesting login:', error.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 * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves with `void` when the login request\n * is completed.\n */\nexport async function requestLogin(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(identify, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user login via the `IdentifyKit` of the Space.\n *\n * @example\n * ```javascript\n * import { getSpace } from '@monterosa/sdk-core';\n * import { getIdentify, requestLogout } from '@monterosa/sdk-identify-kit';\n *\n * const space = getSpace('host', 'space-id');\n * const identify = getIdentify(space);\n *\n * try {\n * await requestLogout(identify);\n *\n * console.log('Logout request successful');\n * } catch (err) {\n * console.error('Error requesting logout:', error.message)\n * }\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Space, the function delegates to the parent app\n * to handle the logout process.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves with `void` when the logout request\n * is completed.\n */\nexport async function requestLogout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(identify, IdentifyAction.RequestLogout);\n\n return;\n }\n\n identify.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 const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n identify,\n IdentifyAction.GetSessionSignature,\n credentials,\n );\n\n return signature;\n }\n\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.\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 * The function that takes an instance of `IdentifyKit` as its argument and\n * returns a Promise that resolves to a key-value object representing user data.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getUserData } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const userData = await getUserData(identify);\n *\n * console.log('User data:', userData);\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 get user data.\n *\n * - If the request is successful, the function resolves with a key-value object\n * representing user data. If not, a `MonterosaError` is thrown.\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @returns A Promise that resolves to a key-value object representing user data.\n * The structure and content of the user data object depend on the identify\n * service provider and may vary. It typically contains information about the user,\n * but the specific fields are determined by the Identify service provider.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n identify,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n // Return cached user data if available\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.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 { getIdentify, setCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const credentials = { token: 'abc123' };\n * const identify = getIdentify();\n *\n * await setCredentials(identify, credentials)\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 set user credentials.\n *\n * - If the request is successful, the function resolves to `void`.\n * If not, a `MonterosaError` is thrown.\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param credentials - An object representing the user's authentication\n * credentials.\n * @returns A Promise that resolves to `void`.\n */\nexport async function setCredentials(\n identify: IdentifyKit,\n credentials: Credentials,\n): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(\n identify,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n const shouldLogin = identify.credentials === null;\n\n identify.credentials = credentials;\n\n if (shouldLogin) {\n enqueueLogin(identify, credentials);\n }\n}\n\n/**\n * Clears the user's authentication credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, clearCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * await clearCredentials(identify);\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 clear user credentials.\n *\n * - If the request is successful, the function resolves to `void`.\n * If not, a `MonterosaError` is thrown.\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @returns A Promise that resolves to `void`.\n */\nexport async function clearCredentials(identify: IdentifyKit) {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(identify, IdentifyAction.ClearCredentials);\n\n return;\n }\n\n const shouldLogout = identify.credentials !== null;\n\n identify.credentials = null;\n identify.userData = null;\n identify.signature = null;\n\n if (shouldLogout) {\n enqueueLogout(identify);\n }\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 `Credentials`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsUpdated(identify, (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 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 `Credentials` object as its only argument.\n * If the value `null` is received, it indicates that the signature has\n * been cleared\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsUpdated(\n identify: IdentifyKit,\n callback: (credentials: Credentials | null) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.CredentialsUpdated, callback);\n}\n\n/**\n * Registers a callback function that will be called whenever the `Signature`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onSignatureUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onSignatureUpdated(identify, (signature) => {\n * if (signature !== null) {\n * console.log(\"Signature updated:\", signature);\n * } else {\n * console.log(\"Signature cleared.\");\n * }\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 `Signature` object as its only argument.\n * If the value `null` is received, it indicates that the signature has\n * been cleared\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onSignatureUpdated(\n identify: IdentifyKit,\n callback: (signature: Signature | null) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.SignatureUpdated, callback);\n}\n\n/**\n * Registers a callback function that will be called whenever the `UserData`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onUserDataUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onUserDataUpdated(identify, (userData) => {\n * if (userData !== null) {\n * console.log(\"User's data updated:\", userData);\n * } else {\n * console.log(\"User's data cleared.\");\n * }\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 `UserData` object as its only argument.\n * If the value `null` is received, it indicates that the user's data has\n * been cleared\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onUserDataUpdated(\n identify: IdentifyKit,\n callback: (userData: UserData | null) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.UserdataUpdated, 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 { getIdentify, onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onLoginRequestedByExperience(identify, () => {\n * showLoginForm();\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\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 identify: IdentifyKit,\n callback: () => void,\n): Unsubscribe {\n return subscribe(identify, 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 { getSpace } from '@monterosa/sdk-core';\n * import { getIdentify, onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * const space = getSpace('host', 'space-id');\n * const identify = getIdentify(space);\n *\n * const unsubscribe = onLogoutRequestedByExperience(identify, () => {\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 identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\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 identify: IdentifyKit,\n callback: () => void,\n): Unsubscribe {\n return subscribe(identify, 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 (identify.shouldLoginOnReconnect) {\n enqueueLogin(identify, identify.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 { MonterosaSdk, configure, getSdks } from '@monterosa/sdk-core';\nimport { getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n Payload,\n Message,\n getParentApplication,\n respondToSdkMessage,\n sendSdkMessage,\n onStateChanged,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignatureMemoized,\n setCredentials,\n clearCredentials,\n requestLogin,\n requestLogout,\n enqueueLogin,\n enqueueLogout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n registerIdentifyHook,\n} from './api';\n\nimport { addExperience, deleteExperience } from './experiences';\n\n/**\n * @internal\n */\nexport function parentMessagesHook(identify: IdentifyKit) {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n return () => {};\n }\n\n return onSdkMessage(parentApp, async (message: Message) => {\n switch (message.action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = message.payload.data as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = message.payload.data as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = message.payload.data as UserData;\n break;\n }\n case IdentifyAction.Login: {\n enqueueLogin(identify, message.payload as Credentials);\n break;\n }\n case IdentifyAction.Logout: {\n enqueueLogout(identify);\n break;\n }\n }\n });\n}\n\n/**\n * Finds an existing SDK with matching projectId, or creates a new one.\n */\nfunction getOrConfigureSdk(host: string, projectId: string): MonterosaSdk {\n const existingSdk = getSdks().find(\n (sdk) => sdk.options.projectId === projectId,\n );\n\n return existingSdk ?? configure({ host, projectId }, projectId);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceEmbedded(experience: Experience): void {\n const identify = getIdentify(experience.sdk);\n\n // Send login action with current credentials to the new experience if available.\n // The bridge queues this message until the experience is initialised.\n if (identify.credentials) {\n sendSdkMessage(experience, IdentifyAction.Login, identify.credentials);\n }\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(identify, (data) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n data,\n });\n });\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (data) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n data,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (data) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n data,\n });\n });\n\n const sdkMessageUnsub = onSdkMessage(experience, async (message) => {\n if (\n !Object.values(IdentifyAction).includes(message.action as IdentifyAction)\n ) {\n return;\n }\n\n // Extract origin context from payload if available.\n // New clients include origin (host, projectId) to ensure correct project context\n // in multilevel integrations. Old clients don't send origin, so we fall back\n // to the experience's SDK to maintain backward compatibility.\n const { origin } = message.payload as {\n origin?: { host: string; projectId: string };\n };\n\n const originSdk = origin\n ? getOrConfigureSdk(origin.host, origin.projectId)\n : experience.sdk;\n\n const originIdentify = getIdentify(originSdk);\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(originIdentify);\n\n respond();\n\n break;\n }\n case IdentifyAction.RequestLogout: {\n await requestLogout(identify);\n\n respond();\n break;\n }\n case IdentifyAction.GetUserData: {\n const data = await getUserData(identify);\n\n respond({ data });\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignatureMemoized(\n identify,\n message.payload as Credentials,\n );\n\n respond({ data: signature });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(originIdentify, {\n token: message.payload.token as Credentials['token'],\n });\n\n respond();\n\n break;\n }\n case IdentifyAction.ClearCredentials: {\n await clearCredentials(identify);\n\n respond();\n\n break;\n }\n }\n } catch (err) {\n respond({\n error: getErrorMessage(err),\n });\n }\n });\n\n addExperience(experience, [\n credentialsUpdatedUnsub,\n signatureUpdatedUnsub,\n userDataUpdatedUnsub,\n sdkMessageUnsub,\n ]);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceUnmounted(experience: Experience): void {\n deleteExperience(experience);\n}\n\nonStateChanged((experience, state) => {\n if (state === 'mounted') {\n handleExperienceEmbedded(experience);\n } else if (state === 'unmounted') {\n handleExperienceUnmounted(experience);\n }\n});\n\nregisterIdentifyHook(parentMessagesHook);\n"],"names":["connectLogin","connectLogout"],"mappings":";;;;;;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QACpB,eAAe;AAChB,KAAA,CAAC,CAAC;AACL,CAAC;AAED;;AAEG;AACG,SAAU,yBAAyB,CAAC,UAAsB,EAAA;IAC9D,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AAED,cAAc,CAAC,CAAC,UAAU,EAAE,KAAK,KAAI;IACnC,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,wBAAwB,CAAC,UAAU,CAAC,CAAC;AACtC,KAAA;SAAM,IAAI,KAAK,KAAK,WAAW,EAAE;QAChC,yBAAyB,CAAC,UAAU,CAAC,CAAC;AACvC,KAAA;AACH,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,kBAAkB,CAAC;;;;"}
package/dist/types.d.ts CHANGED
@@ -9,10 +9,11 @@
9
9
  import { MonterosaSdk } from '@monterosa/sdk-core';
10
10
  import { Emitter, Unsubscribe } from '@monterosa/sdk-util';
11
11
  /**
12
- * The type represents a user credentials. It contains a single property, token,
13
- * which can be either the literal 'cookie' for cookie-based authentication or
14
- * a string value representing the user's authentication token for bearer token
15
- * authentication.
12
+ * Represents user authentication credentials.
13
+ *
14
+ * @remarks
15
+ * The `token` property can be either the literal `'cookie'` for cookie-based
16
+ * authentication or a string value for bearer token authentication.
16
17
  *
17
18
  * @example
18
19
  * ```javascript
@@ -27,10 +28,7 @@ export type Credentials = {
27
28
  token: 'cookie' | string;
28
29
  };
29
30
  /**
30
- *
31
- * The type represents a digital signature. It contains three properties:
32
- * `userId`, `timestamp`, and `signature`. These properties are respectively of
33
- * type `string`, `number`, and `string`.
31
+ * A tuple representing a digital signature: `[userId, timestamp, signature]`.
34
32
  *
35
33
  * @example
36
34
  * ```javascript
@@ -39,11 +37,11 @@ export type Credentials = {
39
37
  */
40
38
  export type Signature = [userId: string, timestamp: number, signature: string];
41
39
  /**
42
- * The type represents a set of user data. It contains key-value object
43
- * representing user data. The structure and content of the user data object
44
- * depend on the identify service provider and may vary. It typically contains
45
- * information about the user, but the specific fields are determined by the
46
- * Identify service provider.
40
+ * A key-value object representing user profile data.
41
+ *
42
+ * @remarks
43
+ * Contains `userId`, `timestamp`, and `signature` alongside any
44
+ * additional custom properties.
47
45
  *
48
46
  * @example
49
47
  * ```javascript
@@ -74,16 +72,36 @@ export type LoginState = {
74
72
  errorType?: 'login' | 'logout';
75
73
  };
76
74
  export type LoginPolicy = 'disabled' | 'auto';
75
+ /**
76
+ * Configuration options for Identify Kit.
77
+ */
77
78
  export interface IdentifyOptions {
79
+ /**
80
+ * Unique device identifier. Must be persisted and reused across sessions
81
+ * to avoid duplicate user records.
82
+ */
78
83
  readonly deviceId?: string;
84
+ /**
85
+ * Authentication strategy. Default: `'email'`.
86
+ */
79
87
  readonly strategy?: string;
88
+ /**
89
+ * Identity provider name (e.g. `'aws'` for Cognito).
90
+ */
80
91
  readonly provider?: string;
92
+ /**
93
+ * Identify API version. Default: `1`.
94
+ */
81
95
  readonly version?: number;
82
96
  readonly loginPolicy?: LoginPolicy;
83
97
  }
84
98
  /**
85
- * The `IdentifyKit` interface provides a set of properties and methods
86
- * for managing user identification.
99
+ * Represents an Identify Kit instance. Obtain one via {@link getIdentify}.
100
+ *
101
+ * @remarks
102
+ * This interface is opaque. Interact with it through the standalone
103
+ * functions such as {@link setCredentials}, {@link clearCredentials},
104
+ * and {@link getUserData}.
87
105
  */
88
106
  export interface IdentifyKit extends Emitter {
89
107
  /**
@@ -195,7 +213,7 @@ export declare enum IdentifyError {
195
213
  */
196
214
  NoCredentials = "no_credentials",
197
215
  /**
198
- * Indicates the IdentifyKit has not been initialized properly.
216
+ * Indicates the IdentifyKit has not been initialised properly.
199
217
  */
200
218
  NotInitialised = "not_initialised",
201
219
  /**
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@monterosa/sdk-identify-kit",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.2",
4
4
  "description": "Identify Kit for the Monterosa JS SDK",
5
5
  "author": "Monterosa Productions Limited <hello@monterosa.co.uk> (https://www.monterosa.co/)",
6
- "main": "dist/index.cjs.js",
7
- "browser": "dist/index.esm.js",
8
- "module": "dist/index.esm.js",
6
+ "main": "./dist/index.js",
9
7
  "types": "./dist/index.d.ts",
10
- "cdn": "../../dist",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
11
15
  "files": [
12
16
  "dist"
13
17
  ],
@@ -19,27 +23,23 @@
19
23
  "test:ci": "jest --color --ci --reporters=jest-junit --coverage",
20
24
  "api-report": "api-extractor run --local --verbose"
21
25
  },
22
- "keywords": [],
26
+ "keywords": [
27
+ "monterosa",
28
+ "sdk",
29
+ "interaction-cloud",
30
+ "identify",
31
+ "authentication"
32
+ ],
23
33
  "license": "MIT",
24
- "peerDependencies": {
25
- "@monterosa/sdk-connect-kit": "0.x",
26
- "@monterosa/sdk-core": "0.x",
27
- "@monterosa/sdk-interact-interop": "0.x",
28
- "@monterosa/sdk-interact-kit": "0.x",
29
- "@monterosa/sdk-launcher-kit": "0.x",
30
- "@monterosa/sdk-util": "0.x"
31
- },
32
34
  "dependencies": {
33
- "@babel/runtime": "^7.15.4",
34
- "@monterosa/sdk-connect-kit": "^2.0.0-rc.1",
35
- "@monterosa/sdk-core": "^2.0.0-rc.1",
36
- "@monterosa/sdk-interact-interop": "^2.0.0-rc.1",
37
- "@monterosa/sdk-interact-kit": "^2.0.0-rc.1",
38
- "@monterosa/sdk-launcher-kit": "^2.0.0-rc.1",
39
- "@monterosa/sdk-util": "^2.0.0-rc.1"
35
+ "@monterosa/sdk-connect-kit": "2.0.0-rc.2",
36
+ "@monterosa/sdk-core": "2.0.0-rc.2",
37
+ "@monterosa/sdk-interact-interop": "2.0.0-rc.2",
38
+ "@monterosa/sdk-interact-kit": "2.0.0-rc.2",
39
+ "@monterosa/sdk-launcher-kit": "2.0.0-rc.2",
40
+ "@monterosa/sdk-util": "2.0.0-rc.2"
40
41
  },
41
42
  "devDependencies": {
42
- "@rollup/plugin-commonjs": "^21.1.0",
43
43
  "@rollup/plugin-json": "^4.1.0",
44
44
  "@rollup/plugin-node-resolve": "^13.3.0",
45
45
  "@rollup/plugin-terser": "^0.4.4",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "7cb580eebfab4fb87632a96519dac2f9762fc8b2"
61
+ "gitHead": "0e2d4cd71055bf0ab38ec5a73d6040c55151da1c"
62
62
  }