@monterosa/sdk-identify-kit 0.18.2 → 0.18.3

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/index.cjs.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var sdkUtil = require('@monterosa/sdk-util');
5
6
  var sdkLauncherKit = require('@monterosa/sdk-launcher-kit');
6
7
  var sdkCore = require('@monterosa/sdk-core');
7
- var sdkUtil = require('@monterosa/sdk-util');
8
- var sdkInteractKit = require('@monterosa/sdk-interact-kit');
8
+ var sdkInteractInterop = require('@monterosa/sdk-interact-interop');
9
9
 
10
10
  /*! *****************************************************************************
11
11
  Copyright (c) Microsoft Corporation.
@@ -247,7 +247,7 @@ var Identify = /** @class */ (function (_super) {
247
247
  var listings;
248
248
  return __generator(this, function (_a) {
249
249
  switch (_a.label) {
250
- case 0: return [4 /*yield*/, sdkInteractKit.fetchListings(host, projectId)];
250
+ case 0: return [4 /*yield*/, sdkInteractInterop.fetchListings(host, projectId)];
251
251
  case 1:
252
252
  listings = _a.sent();
253
253
  if (!Object.prototype.hasOwnProperty.call(listings.assets, EXTENSION_ID)) {
@@ -1063,13 +1063,11 @@ function onExperienceEmbed(experience) {
1063
1063
  case 12: return [3 /*break*/, 14];
1064
1064
  case 13:
1065
1065
  err_1 = _b.sent();
1066
- if (err_1 instanceof Error) {
1067
- sdkLauncherKit.respondToSdkMessage(experience, message, {
1068
- result: 'failure',
1069
- message: err_1.message,
1070
- data: {},
1071
- });
1072
- }
1066
+ sdkLauncherKit.respondToSdkMessage(experience, message, {
1067
+ result: 'failure',
1068
+ message: sdkUtil.getErrorMessage(err_1),
1069
+ data: {},
1070
+ });
1073
1071
  return [3 /*break*/, 14];
1074
1072
  case 14: return [2 /*return*/];
1075
1073
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * public_types.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 * The type represents a user credentials. It contains a single property, token,\n * which is a string value representing the user's authentication token.\n *\n * @example\n * ```javascript\n * const credentials: Credentials = { token: \"abc123\" };\n * ```\n */\nexport type Credentials = {\n token: string;\n};\n\n/**\n *\n * The type represents a digital signature. It contains three properties:\n * `userId`, `timestamp`, and `signature`. These properties are respectively of\n * type `string`, `number`, and `string`.\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 * The type represents a set of user data. It contains three properties:\n * `userId`, `timestamp`, and `signature`. In addition, it allows for any\n * number of additional properties to be defined using TypeScript's index\n * signature syntax. The `userId` property is a string value representing\n * the user's unique identifier. The `timestamp` property is a number value\n * representing the time when the user's data was last updated. The `signature`\n * property is a string value representing the digital signature of the user's\n * data.\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 result: 'success' | 'failure';\n data: T;\n message: string;\n};\n\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\n\nexport interface IdentifyOptions {\n readonly deviceId?: string;\n readonly strategy?: string;\n readonly provider?: string;\n readonly version?: number;\n}\n\n/**\n * The `IdentifyKit` interface provides a set of properties and methods\n * for managing user identification.\n */\nexport interface IdentifyKit extends Emitter {\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 /**\n * @internal\n */\n expireSignature(delay: number): void;\n\n /**\n * @internal\n */\n expireUserData(delay: number): void;\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 LoginRequested = 'login_requested',\n SignatureUpdated = 'signature_updated',\n CredentialsUpdated = 'credentials_updated',\n UserdataUpdated = 'userdata_updated',\n ApiUserCheckFailed = 'api_user_check_failed',\n ApiUserDataFailed = 'api_user_data_failed',\n CredentialsValidationFailed = 'credentials_validation_failed',\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 initialized properly.\n */\n NotInitialised = 'not_initialised',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_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};\n\nexport enum IdentifyAction {\n RequestLogin = 'identifyRequestLogin',\n Logout = 'identifyLogout',\n GetSessionSignature = 'identifyGetSessionSignature',\n GetUserData = 'identifyGetUserData',\n SetCredentials = 'identifySetCredentials',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\n OnLoginRequestedByExperience = 'identifyOnLoginRequestedByExperience',\n OnCredentialsValidationFailed = 'identifyOnCredentialsValidationFailed',\n}\n","/**\n * @license\n * constants.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-22\n * Copyright © 2023 Monterosa. 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 = 10000;\n\nexport const USER_DATA_TTL = 10000;\n","/**\n * @license\n * identify.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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-kit';\n\nimport {\n IdentifyKit,\n IdentifyOptions,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private host?: string;\n\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 constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n ...options,\n };\n }\n\n expireSignature(delay: number) {\n clearTimeout(this.signatureExpireTimeout);\n\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, delay);\n }\n\n expireUserData(delay: number) {\n clearTimeout(this.userDataExpireTimeout);\n\n this.userDataExpireTimeout = setTimeout(() => {\n this.userData = null;\n }, delay);\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n\n if (!Object.prototype.hasOwnProperty.call(listings.assets, EXTENSION_ID)) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return listings.assets[EXTENSION_ID][0].data;\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 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 // if credentials are updated, user data and signature are cleared\n this.userData = null;\n this.signature = null;\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 this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\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 * api.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 { subscribe, Unsubscribe, createError } from '@monterosa/sdk-util';\nimport {\n Payload,\n ParentApplication,\n getParentApplication,\n sendSdkRequest,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport { SIGNATURE_TTL, USER_DATA_TTL } from './constants';\n\nimport Identify from './identify';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\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: string,\n method: string = 'GET',\n): Promise<T> {\n const response = await fetch(url, {\n method,\n headers: {\n accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\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 parentApp: ParentApplication,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { result, data, message } = response.payload as ResponsePayload<T>;\n\n if (result === 'failure') {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\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 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, logout } 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>(parentApp, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user logout and removing their signature and\n * credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, logout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await logout(identify);\n *\n * console.log('User logged out');\n * } catch (err) {\n * console.error('Error logout:', 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 log the user out.\n *\n * - If the request is successful, the function resolves with void.\n * If not, a MonterosaError is thrown.\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 logout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(parentApp, IdentifyAction.Logout);\n\n return;\n }\n\n identify.signature = null;\n identify.credentials = null;\n}\n\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 * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getSession } from '@monterosa/sdk-identify-kit';\n * import { getConnect, login } from '@monterosa/sdk-connect-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const session = await getSession(identify);\n *\n * const connect = await getConnect();\n * await login(connect, ...session);\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 session signature.\n *\n * - If the request is successful, the function resolves with `Signature`.\n * If not, a `MonterosaError` is thrown.\n *\n * - The function can be used to fetch a signature for a user session that\n * can be used to authenticate user with `ConnectKit`.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves to an object of type `Signature`.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n parentApp,\n IdentifyAction.GetSessionSignature,\n );\n\n return signature;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(\n url,\n identify.credentials.token,\n );\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n identify.expireSignature(SIGNATURE_TTL);\n\n return signature;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserCheckFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\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 `UserData` object.\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 { userId } = await getUserData(identify);\n *\n * console.log(`User id is ${userId}`);\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 `UserData`.\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 a `UserData` object. The `UserData`\n * object contains information about the user, including their `userId`,\n * `timestamp`, and `signature`, as well as any additional properties.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n parentApp,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.credentials.token);\n\n identify.userData = data;\n identify.expireUserData(USER_DATA_TTL);\n\n return data;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserDataFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\n }\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 parentApp,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n identify.credentials = credentials;\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 the credentials validation fails.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsValidationFailed } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsValidationFailed(identify, (error) => {\n * console.log(error);\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 an error occured.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsValidationFailed(\n identify: IdentifyKit,\n callback: (error: string) => void,\n): Unsubscribe {\n return subscribe(\n identify,\n IdentifyEvent.CredentialsValidationFailed,\n callback,\n );\n}\n","/**\n * @license\n * bridge.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-03-07\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe } from '@monterosa/sdk-util';\nimport {\n Experience,\n getParentApplication,\n registerEmbedHook,\n respondToSdkMessage,\n sendSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n IdentifyEvent,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignature,\n setCredentials,\n requestLogin,\n logout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n onCredentialsValidationFailed,\n registerIdentifyHook,\n} from './api';\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, ({ action, payload }) => {\n switch (action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = payload.credentials as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = payload.signature as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = payload.userData as UserData;\n break;\n }\n case IdentifyAction.OnCredentialsValidationFailed: {\n identify.emit(IdentifyEvent.CredentialsValidationFailed, payload.error);\n break;\n }\n }\n });\n}\n\nfunction onExperienceEmbed(experience: Experience): Unsubscribe {\n const identify = getIdentify(experience.sdk);\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(\n identify,\n (credentials) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n credentials,\n });\n },\n );\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (signature) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n signature,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (userData) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n userData,\n });\n });\n\n const validationFailedUnsub = onCredentialsValidationFailed(\n identify,\n (error) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsValidationFailed, {\n error,\n });\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 try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Login request succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.Logout: {\n await logout(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Logout succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignature(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Session signature obtained successfully',\n data: signature,\n });\n break;\n }\n case IdentifyAction.GetUserData: {\n const userData = await getUserData(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'User data obtained successfully',\n data: userData,\n });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(identify, {\n token: message.payload.token as string,\n });\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Credentials updated successfully',\n data: {},\n });\n\n break;\n }\n }\n } catch (err) {\n if (err instanceof Error) {\n respondToSdkMessage(experience, message, {\n result: 'failure',\n message: err.message,\n data: {},\n });\n }\n }\n });\n\n return () => {\n credentialsUpdatedUnsub();\n signatureUpdatedUnsub();\n userDataUpdatedUnsub();\n sdkMessageUnsub();\n validationFailedUnsub();\n };\n}\n\nregisterEmbedHook(onExperienceEmbed);\nregisterIdentifyHook(parentMessagesHook);\n"],"names":["IdentifyError","getDeviceId","fetchListings","createError","Emitter","Sdk","sendSdkRequest","getSdk","getParentApplication","subscribe","onSdkMessage","sendSdkMessage","respondToSdkMessage","registerEmbedHook"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AA6IA;;;AAGA,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,mDAAkC,CAAA;IAClC,uDAAsC,CAAA;IACtC,2DAA0C,CAAA;IAC1C,qDAAoC,CAAA;IACpC,6DAA4C,CAAA;IAC5C,2DAA0C,CAAA;IAC1C,8EAA6D,CAAA;AAC/D,CAAC,EARW,aAAa,KAAb,aAAa,QAQxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BYA;AAAZ,WAAY,aAAa;;;;IAIvB,0DAAyC,CAAA;;;;IAIzC,0DAAyC,CAAA;;;;;IAKzC,iDAAgC,CAAA;;;;IAIhC,mDAAkC,CAAA;;;;IAIlC,oDAAmC,CAAA;AACrC,CAAC,EAtBWA,qBAAa,KAAbA,qBAAa,QAsBxB;AAED;;;AAGO,IAAM,qBAAqB;IAChC,GAACA,qBAAa,CAAC,iBAAiB,IAAG,UAAC,KAAa;QAC/C,OAAA,+CAA6C,KAAO;KAAA;IACtD,GAACA,qBAAa,CAAC,iBAAiB,IAAG;QACjC,OAAA,mDAAmD;KAAA;IACrD,GAACA,qBAAa,CAAC,aAAa,IAAG,cAAM,OAAA,kCAAkC,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,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAe;qBACvC,CAAC,EAAA;;oBAFF,SAEE,CAAC;oBAEHA,kCAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;wBACvC,MAAM,EAAE,SAAS;wBACjB,OAAO,EAAE,kCAAkC;wBAC3C,IAAI,EAAE,EAAE;qBACT,CAAC,CAAC;oBAEH,yBAAM;;;;oBAIV,IAAI,KAAG,YAAY,KAAK,EAAE;wBACxBA,kCAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;4BACvC,MAAM,EAAE,SAAS;4BACjB,OAAO,EAAE,KAAG,CAAC,OAAO;4BACpB,IAAI,EAAE,EAAE;yBACT,CAAC,CAAC;qBACJ;;;;;SAEJ,CAAC,CAAC;IAEH,OAAO;QACL,uBAAuB,EAAE,CAAC;QAC1B,qBAAqB,EAAE,CAAC;QACxB,oBAAoB,EAAE,CAAC;QACvB,eAAe,EAAE,CAAC;QAClB,qBAAqB,EAAE,CAAC;KACzB,CAAC;AACJ,CAAC;AAEDC,gCAAiB,CAAC,iBAAiB,CAAC,CAAC;AACrC,oBAAoB,CAAC,kBAAkB,CAAC;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * public_types.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 * The type represents a user credentials. It contains a single property, token,\n * which is a string value representing the user's authentication token.\n *\n * @example\n * ```javascript\n * const credentials: Credentials = { token: \"abc123\" };\n * ```\n */\nexport type Credentials = {\n token: string;\n};\n\n/**\n *\n * The type represents a digital signature. It contains three properties:\n * `userId`, `timestamp`, and `signature`. These properties are respectively of\n * type `string`, `number`, and `string`.\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 * The type represents a set of user data. It contains three properties:\n * `userId`, `timestamp`, and `signature`. In addition, it allows for any\n * number of additional properties to be defined using TypeScript's index\n * signature syntax. The `userId` property is a string value representing\n * the user's unique identifier. The `timestamp` property is a number value\n * representing the time when the user's data was last updated. The `signature`\n * property is a string value representing the digital signature of the user's\n * data.\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 result: 'success' | 'failure';\n data: T;\n message: string;\n};\n\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\n\nexport interface IdentifyOptions {\n readonly deviceId?: string;\n readonly strategy?: string;\n readonly provider?: string;\n readonly version?: number;\n}\n\n/**\n * The `IdentifyKit` interface provides a set of properties and methods\n * for managing user identification.\n */\nexport interface IdentifyKit extends Emitter {\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 /**\n * @internal\n */\n expireSignature(delay: number): void;\n\n /**\n * @internal\n */\n expireUserData(delay: number): void;\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 LoginRequested = 'login_requested',\n SignatureUpdated = 'signature_updated',\n CredentialsUpdated = 'credentials_updated',\n UserdataUpdated = 'userdata_updated',\n ApiUserCheckFailed = 'api_user_check_failed',\n ApiUserDataFailed = 'api_user_data_failed',\n CredentialsValidationFailed = 'credentials_validation_failed',\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 initialized properly.\n */\n NotInitialised = 'not_initialised',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_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};\n\nexport enum IdentifyAction {\n RequestLogin = 'identifyRequestLogin',\n Logout = 'identifyLogout',\n GetSessionSignature = 'identifyGetSessionSignature',\n GetUserData = 'identifyGetUserData',\n SetCredentials = 'identifySetCredentials',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\n OnLoginRequestedByExperience = 'identifyOnLoginRequestedByExperience',\n OnCredentialsValidationFailed = 'identifyOnCredentialsValidationFailed',\n}\n","/**\n * @license\n * constants.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-22\n * Copyright © 2023 Monterosa. 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 = 10000;\n\nexport const USER_DATA_TTL = 10000;\n","/**\n * @license\n * identify.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private host?: string;\n\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 constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n ...options,\n };\n }\n\n expireSignature(delay: number) {\n clearTimeout(this.signatureExpireTimeout);\n\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, delay);\n }\n\n expireUserData(delay: number) {\n clearTimeout(this.userDataExpireTimeout);\n\n this.userDataExpireTimeout = setTimeout(() => {\n this.userData = null;\n }, delay);\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n\n if (!Object.prototype.hasOwnProperty.call(listings.assets, EXTENSION_ID)) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return listings.assets[EXTENSION_ID][0].data;\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 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 // if credentials are updated, user data and signature are cleared\n this.userData = null;\n this.signature = null;\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 this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\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 * api.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 { subscribe, Unsubscribe, createError } from '@monterosa/sdk-util';\nimport {\n Payload,\n ParentApplication,\n getParentApplication,\n sendSdkRequest,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport { SIGNATURE_TTL, USER_DATA_TTL } from './constants';\n\nimport Identify from './identify';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\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: string,\n method: string = 'GET',\n): Promise<T> {\n const response = await fetch(url, {\n method,\n headers: {\n accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\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 parentApp: ParentApplication,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { result, data, message } = response.payload as ResponsePayload<T>;\n\n if (result === 'failure') {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\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 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, logout } 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>(parentApp, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user logout and removing their signature and\n * credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, logout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await logout(identify);\n *\n * console.log('User logged out');\n * } catch (err) {\n * console.error('Error logout:', 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 log the user out.\n *\n * - If the request is successful, the function resolves with void.\n * If not, a MonterosaError is thrown.\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 logout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(parentApp, IdentifyAction.Logout);\n\n return;\n }\n\n identify.signature = null;\n identify.credentials = null;\n}\n\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 * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getSession } from '@monterosa/sdk-identify-kit';\n * import { getConnect, login } from '@monterosa/sdk-connect-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const session = await getSession(identify);\n *\n * const connect = await getConnect();\n * await login(connect, ...session);\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 session signature.\n *\n * - If the request is successful, the function resolves with `Signature`.\n * If not, a `MonterosaError` is thrown.\n *\n * - The function can be used to fetch a signature for a user session that\n * can be used to authenticate user with `ConnectKit`.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves to an object of type `Signature`.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n parentApp,\n IdentifyAction.GetSessionSignature,\n );\n\n return signature;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(\n url,\n identify.credentials.token,\n );\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n identify.expireSignature(SIGNATURE_TTL);\n\n return signature;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserCheckFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\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 `UserData` object.\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 { userId } = await getUserData(identify);\n *\n * console.log(`User id is ${userId}`);\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 `UserData`.\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 a `UserData` object. The `UserData`\n * object contains information about the user, including their `userId`,\n * `timestamp`, and `signature`, as well as any additional properties.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n parentApp,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.credentials.token);\n\n identify.userData = data;\n identify.expireUserData(USER_DATA_TTL);\n\n return data;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserDataFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\n }\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 parentApp,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n identify.credentials = credentials;\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 the credentials validation fails.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsValidationFailed } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsValidationFailed(identify, (error) => {\n * console.log(error);\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 an error occured.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsValidationFailed(\n identify: IdentifyKit,\n callback: (error: string) => void,\n): Unsubscribe {\n return subscribe(\n identify,\n IdentifyEvent.CredentialsValidationFailed,\n callback,\n );\n}\n","/**\n * @license\n * bridge.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-03-07\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n getParentApplication,\n registerEmbedHook,\n respondToSdkMessage,\n sendSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n IdentifyEvent,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignature,\n setCredentials,\n requestLogin,\n logout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n onCredentialsValidationFailed,\n registerIdentifyHook,\n} from './api';\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, ({ action, payload }) => {\n switch (action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = payload.credentials as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = payload.signature as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = payload.userData as UserData;\n break;\n }\n case IdentifyAction.OnCredentialsValidationFailed: {\n identify.emit(IdentifyEvent.CredentialsValidationFailed, payload.error);\n break;\n }\n }\n });\n}\n\nfunction onExperienceEmbed(experience: Experience): Unsubscribe {\n const identify = getIdentify(experience.sdk);\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(\n identify,\n (credentials) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n credentials,\n });\n },\n );\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (signature) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n signature,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (userData) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n userData,\n });\n });\n\n const validationFailedUnsub = onCredentialsValidationFailed(\n identify,\n (error) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsValidationFailed, {\n error,\n });\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 try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Login request succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.Logout: {\n await logout(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Logout succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignature(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Session signature obtained successfully',\n data: signature,\n });\n break;\n }\n case IdentifyAction.GetUserData: {\n const userData = await getUserData(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'User data obtained successfully',\n data: userData,\n });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(identify, {\n token: message.payload.token as string,\n });\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Credentials updated successfully',\n data: {},\n });\n\n break;\n }\n }\n } catch (err) {\n respondToSdkMessage(experience, message, {\n result: 'failure',\n message: getErrorMessage(err),\n data: {},\n });\n }\n });\n\n return () => {\n credentialsUpdatedUnsub();\n signatureUpdatedUnsub();\n userDataUpdatedUnsub();\n sdkMessageUnsub();\n validationFailedUnsub();\n };\n}\n\nregisterEmbedHook(onExperienceEmbed);\nregisterIdentifyHook(parentMessagesHook);\n"],"names":["IdentifyError","getDeviceId","fetchListings","createError","Emitter","Sdk","sendSdkRequest","getSdk","getParentApplication","subscribe","onSdkMessage","sendSdkMessage","respondToSdkMessage","getErrorMessage","registerEmbedHook"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AEH,OAAO;QACL,uBAAuB,EAAE,CAAC;QAC1B,qBAAqB,EAAE,CAAC;QACxB,oBAAoB,EAAE,CAAC;QACvB,eAAe,EAAE,CAAC;QAClB,qBAAqB,EAAE,CAAC;KACzB,CAAC;AACJ,CAAC;AAEDC,gCAAiB,CAAC,iBAAiB,CAAC,CAAC;AACrC,oBAAoB,CAAC,kBAAkB,CAAC;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
+ import { Emitter, createError, subscribe, getErrorMessage } from '@monterosa/sdk-util';
1
2
  import { sendSdkRequest, getParentApplication, registerEmbedHook, sendSdkMessage, onSdkMessage, respondToSdkMessage } from '@monterosa/sdk-launcher-kit';
2
3
  import { getDeviceId, Sdk, getSdk } from '@monterosa/sdk-core';
3
- import { Emitter, createError, subscribe } from '@monterosa/sdk-util';
4
- import { fetchListings } from '@monterosa/sdk-interact-kit';
4
+ import { fetchListings } from '@monterosa/sdk-interact-interop';
5
5
 
6
6
  /**
7
7
  * @license
@@ -825,13 +825,11 @@ function onExperienceEmbed(experience) {
825
825
  }
826
826
  }
827
827
  catch (err) {
828
- if (err instanceof Error) {
829
- respondToSdkMessage(experience, message, {
830
- result: 'failure',
831
- message: err.message,
832
- data: {},
833
- });
834
- }
828
+ respondToSdkMessage(experience, message, {
829
+ result: 'failure',
830
+ message: getErrorMessage(err),
831
+ data: {},
832
+ });
835
833
  }
836
834
  });
837
835
  return () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm2017.js","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * public_types.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 * The type represents a user credentials. It contains a single property, token,\n * which is a string value representing the user's authentication token.\n *\n * @example\n * ```javascript\n * const credentials: Credentials = { token: \"abc123\" };\n * ```\n */\nexport type Credentials = {\n token: string;\n};\n\n/**\n *\n * The type represents a digital signature. It contains three properties:\n * `userId`, `timestamp`, and `signature`. These properties are respectively of\n * type `string`, `number`, and `string`.\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 * The type represents a set of user data. It contains three properties:\n * `userId`, `timestamp`, and `signature`. In addition, it allows for any\n * number of additional properties to be defined using TypeScript's index\n * signature syntax. The `userId` property is a string value representing\n * the user's unique identifier. The `timestamp` property is a number value\n * representing the time when the user's data was last updated. The `signature`\n * property is a string value representing the digital signature of the user's\n * data.\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 result: 'success' | 'failure';\n data: T;\n message: string;\n};\n\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\n\nexport interface IdentifyOptions {\n readonly deviceId?: string;\n readonly strategy?: string;\n readonly provider?: string;\n readonly version?: number;\n}\n\n/**\n * The `IdentifyKit` interface provides a set of properties and methods\n * for managing user identification.\n */\nexport interface IdentifyKit extends Emitter {\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 /**\n * @internal\n */\n expireSignature(delay: number): void;\n\n /**\n * @internal\n */\n expireUserData(delay: number): void;\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 LoginRequested = 'login_requested',\n SignatureUpdated = 'signature_updated',\n CredentialsUpdated = 'credentials_updated',\n UserdataUpdated = 'userdata_updated',\n ApiUserCheckFailed = 'api_user_check_failed',\n ApiUserDataFailed = 'api_user_data_failed',\n CredentialsValidationFailed = 'credentials_validation_failed',\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 initialized properly.\n */\n NotInitialised = 'not_initialised',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_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};\n\nexport enum IdentifyAction {\n RequestLogin = 'identifyRequestLogin',\n Logout = 'identifyLogout',\n GetSessionSignature = 'identifyGetSessionSignature',\n GetUserData = 'identifyGetUserData',\n SetCredentials = 'identifySetCredentials',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\n OnLoginRequestedByExperience = 'identifyOnLoginRequestedByExperience',\n OnCredentialsValidationFailed = 'identifyOnCredentialsValidationFailed',\n}\n","/**\n * @license\n * constants.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-22\n * Copyright © 2023 Monterosa. 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 = 10000;\n\nexport const USER_DATA_TTL = 10000;\n","/**\n * @license\n * identify.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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-kit';\n\nimport {\n IdentifyKit,\n IdentifyOptions,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private host?: string;\n\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 constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n ...options,\n };\n }\n\n expireSignature(delay: number) {\n clearTimeout(this.signatureExpireTimeout);\n\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, delay);\n }\n\n expireUserData(delay: number) {\n clearTimeout(this.userDataExpireTimeout);\n\n this.userDataExpireTimeout = setTimeout(() => {\n this.userData = null;\n }, delay);\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n\n if (!Object.prototype.hasOwnProperty.call(listings.assets, EXTENSION_ID)) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return listings.assets[EXTENSION_ID][0].data;\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 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 // if credentials are updated, user data and signature are cleared\n this.userData = null;\n this.signature = null;\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 this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\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 * api.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 { subscribe, Unsubscribe, createError } from '@monterosa/sdk-util';\nimport {\n Payload,\n ParentApplication,\n getParentApplication,\n sendSdkRequest,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport { SIGNATURE_TTL, USER_DATA_TTL } from './constants';\n\nimport Identify from './identify';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\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: string,\n method: string = 'GET',\n): Promise<T> {\n const response = await fetch(url, {\n method,\n headers: {\n accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\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 parentApp: ParentApplication,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { result, data, message } = response.payload as ResponsePayload<T>;\n\n if (result === 'failure') {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\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 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, logout } 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>(parentApp, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user logout and removing their signature and\n * credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, logout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await logout(identify);\n *\n * console.log('User logged out');\n * } catch (err) {\n * console.error('Error logout:', 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 log the user out.\n *\n * - If the request is successful, the function resolves with void.\n * If not, a MonterosaError is thrown.\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 logout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(parentApp, IdentifyAction.Logout);\n\n return;\n }\n\n identify.signature = null;\n identify.credentials = null;\n}\n\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 * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getSession } from '@monterosa/sdk-identify-kit';\n * import { getConnect, login } from '@monterosa/sdk-connect-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const session = await getSession(identify);\n *\n * const connect = await getConnect();\n * await login(connect, ...session);\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 session signature.\n *\n * - If the request is successful, the function resolves with `Signature`.\n * If not, a `MonterosaError` is thrown.\n *\n * - The function can be used to fetch a signature for a user session that\n * can be used to authenticate user with `ConnectKit`.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves to an object of type `Signature`.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n parentApp,\n IdentifyAction.GetSessionSignature,\n );\n\n return signature;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(\n url,\n identify.credentials.token,\n );\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n identify.expireSignature(SIGNATURE_TTL);\n\n return signature;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserCheckFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\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 `UserData` object.\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 { userId } = await getUserData(identify);\n *\n * console.log(`User id is ${userId}`);\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 `UserData`.\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 a `UserData` object. The `UserData`\n * object contains information about the user, including their `userId`,\n * `timestamp`, and `signature`, as well as any additional properties.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n parentApp,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.credentials.token);\n\n identify.userData = data;\n identify.expireUserData(USER_DATA_TTL);\n\n return data;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserDataFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\n }\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 parentApp,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n identify.credentials = credentials;\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 the credentials validation fails.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsValidationFailed } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsValidationFailed(identify, (error) => {\n * console.log(error);\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 an error occured.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsValidationFailed(\n identify: IdentifyKit,\n callback: (error: string) => void,\n): Unsubscribe {\n return subscribe(\n identify,\n IdentifyEvent.CredentialsValidationFailed,\n callback,\n );\n}\n","/**\n * @license\n * bridge.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-03-07\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe } from '@monterosa/sdk-util';\nimport {\n Experience,\n getParentApplication,\n registerEmbedHook,\n respondToSdkMessage,\n sendSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n IdentifyEvent,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignature,\n setCredentials,\n requestLogin,\n logout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n onCredentialsValidationFailed,\n registerIdentifyHook,\n} from './api';\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, ({ action, payload }) => {\n switch (action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = payload.credentials as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = payload.signature as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = payload.userData as UserData;\n break;\n }\n case IdentifyAction.OnCredentialsValidationFailed: {\n identify.emit(IdentifyEvent.CredentialsValidationFailed, payload.error);\n break;\n }\n }\n });\n}\n\nfunction onExperienceEmbed(experience: Experience): Unsubscribe {\n const identify = getIdentify(experience.sdk);\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(\n identify,\n (credentials) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n credentials,\n });\n },\n );\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (signature) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n signature,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (userData) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n userData,\n });\n });\n\n const validationFailedUnsub = onCredentialsValidationFailed(\n identify,\n (error) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsValidationFailed, {\n error,\n });\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 try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Login request succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.Logout: {\n await logout(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Logout succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignature(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Session signature obtained successfully',\n data: signature,\n });\n break;\n }\n case IdentifyAction.GetUserData: {\n const userData = await getUserData(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'User data obtained successfully',\n data: userData,\n });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(identify, {\n token: message.payload.token as string,\n });\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Credentials updated successfully',\n data: {},\n });\n\n break;\n }\n }\n } catch (err) {\n if (err instanceof Error) {\n respondToSdkMessage(experience, message, {\n result: 'failure',\n message: err.message,\n data: {},\n });\n }\n }\n });\n\n return () => {\n credentialsUpdatedUnsub();\n signatureUpdatedUnsub();\n userDataUpdatedUnsub();\n sdkMessageUnsub();\n validationFailedUnsub();\n };\n}\n\nregisterEmbedHook(onExperienceEmbed);\nregisterIdentifyHook(parentMessagesHook);\n"],"names":[],"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,OAAO,CAAC,KAAe;qBACvC,CAAC,CAAC;oBAEH,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;wBACvC,MAAM,EAAE,SAAS;wBACjB,OAAO,EAAE,kCAAkC;wBAC3C,IAAI,EAAE,EAAE;qBACT,CAAC,CAAC;oBAEH,MAAM;iBACP;aACF;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,YAAY,KAAK,EAAE;gBACxB,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;oBACvC,MAAM,EAAE,SAAS;oBACjB,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,IAAI,EAAE,EAAE;iBACT,CAAC,CAAC;aACJ;SACF;KACF,CAAC,CAAC;IAEH,OAAO;QACL,uBAAuB,EAAE,CAAC;QAC1B,qBAAqB,EAAE,CAAC;QACxB,oBAAoB,EAAE,CAAC;QACvB,eAAe,EAAE,CAAC;QAClB,qBAAqB,EAAE,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;AACrC,oBAAoB,CAAC,kBAAkB,CAAC;;;;"}
1
+ {"version":3,"file":"index.esm2017.js","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * public_types.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 * The type represents a user credentials. It contains a single property, token,\n * which is a string value representing the user's authentication token.\n *\n * @example\n * ```javascript\n * const credentials: Credentials = { token: \"abc123\" };\n * ```\n */\nexport type Credentials = {\n token: string;\n};\n\n/**\n *\n * The type represents a digital signature. It contains three properties:\n * `userId`, `timestamp`, and `signature`. These properties are respectively of\n * type `string`, `number`, and `string`.\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 * The type represents a set of user data. It contains three properties:\n * `userId`, `timestamp`, and `signature`. In addition, it allows for any\n * number of additional properties to be defined using TypeScript's index\n * signature syntax. The `userId` property is a string value representing\n * the user's unique identifier. The `timestamp` property is a number value\n * representing the time when the user's data was last updated. The `signature`\n * property is a string value representing the digital signature of the user's\n * data.\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 result: 'success' | 'failure';\n data: T;\n message: string;\n};\n\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\n\nexport interface IdentifyOptions {\n readonly deviceId?: string;\n readonly strategy?: string;\n readonly provider?: string;\n readonly version?: number;\n}\n\n/**\n * The `IdentifyKit` interface provides a set of properties and methods\n * for managing user identification.\n */\nexport interface IdentifyKit extends Emitter {\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 /**\n * @internal\n */\n expireSignature(delay: number): void;\n\n /**\n * @internal\n */\n expireUserData(delay: number): void;\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 LoginRequested = 'login_requested',\n SignatureUpdated = 'signature_updated',\n CredentialsUpdated = 'credentials_updated',\n UserdataUpdated = 'userdata_updated',\n ApiUserCheckFailed = 'api_user_check_failed',\n ApiUserDataFailed = 'api_user_data_failed',\n CredentialsValidationFailed = 'credentials_validation_failed',\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 initialized properly.\n */\n NotInitialised = 'not_initialised',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_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};\n\nexport enum IdentifyAction {\n RequestLogin = 'identifyRequestLogin',\n Logout = 'identifyLogout',\n GetSessionSignature = 'identifyGetSessionSignature',\n GetUserData = 'identifyGetUserData',\n SetCredentials = 'identifySetCredentials',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\n OnLoginRequestedByExperience = 'identifyOnLoginRequestedByExperience',\n OnCredentialsValidationFailed = 'identifyOnCredentialsValidationFailed',\n}\n","/**\n * @license\n * constants.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-22\n * Copyright © 2023 Monterosa. 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 = 10000;\n\nexport const USER_DATA_TTL = 10000;\n","/**\n * @license\n * identify.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private host?: string;\n\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 constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n ...options,\n };\n }\n\n expireSignature(delay: number) {\n clearTimeout(this.signatureExpireTimeout);\n\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, delay);\n }\n\n expireUserData(delay: number) {\n clearTimeout(this.userDataExpireTimeout);\n\n this.userDataExpireTimeout = setTimeout(() => {\n this.userData = null;\n }, delay);\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n\n if (!Object.prototype.hasOwnProperty.call(listings.assets, EXTENSION_ID)) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return listings.assets[EXTENSION_ID][0].data;\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 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 // if credentials are updated, user data and signature are cleared\n this.userData = null;\n this.signature = null;\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 this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\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 * api.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 { subscribe, Unsubscribe, createError } from '@monterosa/sdk-util';\nimport {\n Payload,\n ParentApplication,\n getParentApplication,\n sendSdkRequest,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport { SIGNATURE_TTL, USER_DATA_TTL } from './constants';\n\nimport Identify from './identify';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\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: string,\n method: string = 'GET',\n): Promise<T> {\n const response = await fetch(url, {\n method,\n headers: {\n accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\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 parentApp: ParentApplication,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { result, data, message } = response.payload as ResponsePayload<T>;\n\n if (result === 'failure') {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\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 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, logout } 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>(parentApp, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user logout and removing their signature and\n * credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, logout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await logout(identify);\n *\n * console.log('User logged out');\n * } catch (err) {\n * console.error('Error logout:', 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 log the user out.\n *\n * - If the request is successful, the function resolves with void.\n * If not, a MonterosaError is thrown.\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 logout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(parentApp, IdentifyAction.Logout);\n\n return;\n }\n\n identify.signature = null;\n identify.credentials = null;\n}\n\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 * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getSession } from '@monterosa/sdk-identify-kit';\n * import { getConnect, login } from '@monterosa/sdk-connect-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const session = await getSession(identify);\n *\n * const connect = await getConnect();\n * await login(connect, ...session);\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 session signature.\n *\n * - If the request is successful, the function resolves with `Signature`.\n * If not, a `MonterosaError` is thrown.\n *\n * - The function can be used to fetch a signature for a user session that\n * can be used to authenticate user with `ConnectKit`.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves to an object of type `Signature`.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n parentApp,\n IdentifyAction.GetSessionSignature,\n );\n\n return signature;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(\n url,\n identify.credentials.token,\n );\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n identify.expireSignature(SIGNATURE_TTL);\n\n return signature;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserCheckFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\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 `UserData` object.\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 { userId } = await getUserData(identify);\n *\n * console.log(`User id is ${userId}`);\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 `UserData`.\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 a `UserData` object. The `UserData`\n * object contains information about the user, including their `userId`,\n * `timestamp`, and `signature`, as well as any additional properties.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n parentApp,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.credentials.token);\n\n identify.userData = data;\n identify.expireUserData(USER_DATA_TTL);\n\n return data;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserDataFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\n }\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 parentApp,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n identify.credentials = credentials;\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 the credentials validation fails.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsValidationFailed } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsValidationFailed(identify, (error) => {\n * console.log(error);\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 an error occured.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsValidationFailed(\n identify: IdentifyKit,\n callback: (error: string) => void,\n): Unsubscribe {\n return subscribe(\n identify,\n IdentifyEvent.CredentialsValidationFailed,\n callback,\n );\n}\n","/**\n * @license\n * bridge.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-03-07\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n getParentApplication,\n registerEmbedHook,\n respondToSdkMessage,\n sendSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n IdentifyEvent,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignature,\n setCredentials,\n requestLogin,\n logout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n onCredentialsValidationFailed,\n registerIdentifyHook,\n} from './api';\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, ({ action, payload }) => {\n switch (action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = payload.credentials as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = payload.signature as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = payload.userData as UserData;\n break;\n }\n case IdentifyAction.OnCredentialsValidationFailed: {\n identify.emit(IdentifyEvent.CredentialsValidationFailed, payload.error);\n break;\n }\n }\n });\n}\n\nfunction onExperienceEmbed(experience: Experience): Unsubscribe {\n const identify = getIdentify(experience.sdk);\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(\n identify,\n (credentials) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n credentials,\n });\n },\n );\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (signature) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n signature,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (userData) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n userData,\n });\n });\n\n const validationFailedUnsub = onCredentialsValidationFailed(\n identify,\n (error) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsValidationFailed, {\n error,\n });\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 try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Login request succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.Logout: {\n await logout(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Logout succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignature(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Session signature obtained successfully',\n data: signature,\n });\n break;\n }\n case IdentifyAction.GetUserData: {\n const userData = await getUserData(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'User data obtained successfully',\n data: userData,\n });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(identify, {\n token: message.payload.token as string,\n });\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Credentials updated successfully',\n data: {},\n });\n\n break;\n }\n }\n } catch (err) {\n respondToSdkMessage(experience, message, {\n result: 'failure',\n message: getErrorMessage(err),\n data: {},\n });\n }\n });\n\n return () => {\n credentialsUpdatedUnsub();\n signatureUpdatedUnsub();\n userDataUpdatedUnsub();\n sdkMessageUnsub();\n validationFailedUnsub();\n };\n}\n\nregisterEmbedHook(onExperienceEmbed);\nregisterIdentifyHook(parentMessagesHook);\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;AA6IA;;;AAGA,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,mDAAkC,CAAA;IAClC,uDAAsC,CAAA;IACtC,2DAA0C,CAAA;IAC1C,qDAAoC,CAAA;IACpC,6DAA4C,CAAA;IAC5C,2DAA0C,CAAA;IA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;aACF;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;gBACvC,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC;gBAC7B,IAAI,EAAE,EAAE;aACT,CAAC,CAAC;SACJ;KACF,CAAC,CAAC;IAEH,OAAO;QACL,uBAAuB,EAAE,CAAC;QAC1B,qBAAqB,EAAE,CAAC;QACxB,oBAAoB,EAAE,CAAC;QACvB,eAAe,EAAE,CAAC;QAClB,qBAAqB,EAAE,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;AACrC,oBAAoB,CAAC,kBAAkB,CAAC;;;;"}
@@ -1,7 +1,7 @@
1
+ import { Emitter, createError, subscribe, getErrorMessage } from '@monterosa/sdk-util';
1
2
  import { sendSdkRequest, getParentApplication, registerEmbedHook, sendSdkMessage, onSdkMessage, respondToSdkMessage } from '@monterosa/sdk-launcher-kit';
2
3
  import { getDeviceId, Sdk, getSdk } from '@monterosa/sdk-core';
3
- import { Emitter, createError, subscribe } from '@monterosa/sdk-util';
4
- import { fetchListings } from '@monterosa/sdk-interact-kit';
4
+ import { fetchListings } from '@monterosa/sdk-interact-interop';
5
5
 
6
6
  /*! *****************************************************************************
7
7
  Copyright (c) Microsoft Corporation.
@@ -1059,13 +1059,11 @@ function onExperienceEmbed(experience) {
1059
1059
  case 12: return [3 /*break*/, 14];
1060
1060
  case 13:
1061
1061
  err_1 = _b.sent();
1062
- if (err_1 instanceof Error) {
1063
- respondToSdkMessage(experience, message, {
1064
- result: 'failure',
1065
- message: err_1.message,
1066
- data: {},
1067
- });
1068
- }
1062
+ respondToSdkMessage(experience, message, {
1063
+ result: 'failure',
1064
+ message: getErrorMessage(err_1),
1065
+ data: {},
1066
+ });
1069
1067
  return [3 /*break*/, 14];
1070
1068
  case 14: return [2 /*return*/];
1071
1069
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm5.js","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * public_types.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 * The type represents a user credentials. It contains a single property, token,\n * which is a string value representing the user's authentication token.\n *\n * @example\n * ```javascript\n * const credentials: Credentials = { token: \"abc123\" };\n * ```\n */\nexport type Credentials = {\n token: string;\n};\n\n/**\n *\n * The type represents a digital signature. It contains three properties:\n * `userId`, `timestamp`, and `signature`. These properties are respectively of\n * type `string`, `number`, and `string`.\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 * The type represents a set of user data. It contains three properties:\n * `userId`, `timestamp`, and `signature`. In addition, it allows for any\n * number of additional properties to be defined using TypeScript's index\n * signature syntax. The `userId` property is a string value representing\n * the user's unique identifier. The `timestamp` property is a number value\n * representing the time when the user's data was last updated. The `signature`\n * property is a string value representing the digital signature of the user's\n * data.\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 result: 'success' | 'failure';\n data: T;\n message: string;\n};\n\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\n\nexport interface IdentifyOptions {\n readonly deviceId?: string;\n readonly strategy?: string;\n readonly provider?: string;\n readonly version?: number;\n}\n\n/**\n * The `IdentifyKit` interface provides a set of properties and methods\n * for managing user identification.\n */\nexport interface IdentifyKit extends Emitter {\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 /**\n * @internal\n */\n expireSignature(delay: number): void;\n\n /**\n * @internal\n */\n expireUserData(delay: number): void;\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 LoginRequested = 'login_requested',\n SignatureUpdated = 'signature_updated',\n CredentialsUpdated = 'credentials_updated',\n UserdataUpdated = 'userdata_updated',\n ApiUserCheckFailed = 'api_user_check_failed',\n ApiUserDataFailed = 'api_user_data_failed',\n CredentialsValidationFailed = 'credentials_validation_failed',\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 initialized properly.\n */\n NotInitialised = 'not_initialised',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_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};\n\nexport enum IdentifyAction {\n RequestLogin = 'identifyRequestLogin',\n Logout = 'identifyLogout',\n GetSessionSignature = 'identifyGetSessionSignature',\n GetUserData = 'identifyGetUserData',\n SetCredentials = 'identifySetCredentials',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\n OnLoginRequestedByExperience = 'identifyOnLoginRequestedByExperience',\n OnCredentialsValidationFailed = 'identifyOnCredentialsValidationFailed',\n}\n","/**\n * @license\n * constants.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-22\n * Copyright © 2023 Monterosa. 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 = 10000;\n\nexport const USER_DATA_TTL = 10000;\n","/**\n * @license\n * identify.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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-kit';\n\nimport {\n IdentifyKit,\n IdentifyOptions,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private host?: string;\n\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 constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n ...options,\n };\n }\n\n expireSignature(delay: number) {\n clearTimeout(this.signatureExpireTimeout);\n\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, delay);\n }\n\n expireUserData(delay: number) {\n clearTimeout(this.userDataExpireTimeout);\n\n this.userDataExpireTimeout = setTimeout(() => {\n this.userData = null;\n }, delay);\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n\n if (!Object.prototype.hasOwnProperty.call(listings.assets, EXTENSION_ID)) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return listings.assets[EXTENSION_ID][0].data;\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 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 // if credentials are updated, user data and signature are cleared\n this.userData = null;\n this.signature = null;\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 this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\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 * api.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 { subscribe, Unsubscribe, createError } from '@monterosa/sdk-util';\nimport {\n Payload,\n ParentApplication,\n getParentApplication,\n sendSdkRequest,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport { SIGNATURE_TTL, USER_DATA_TTL } from './constants';\n\nimport Identify from './identify';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\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: string,\n method: string = 'GET',\n): Promise<T> {\n const response = await fetch(url, {\n method,\n headers: {\n accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\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 parentApp: ParentApplication,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { result, data, message } = response.payload as ResponsePayload<T>;\n\n if (result === 'failure') {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\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 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, logout } 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>(parentApp, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user logout and removing their signature and\n * credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, logout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await logout(identify);\n *\n * console.log('User logged out');\n * } catch (err) {\n * console.error('Error logout:', 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 log the user out.\n *\n * - If the request is successful, the function resolves with void.\n * If not, a MonterosaError is thrown.\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 logout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(parentApp, IdentifyAction.Logout);\n\n return;\n }\n\n identify.signature = null;\n identify.credentials = null;\n}\n\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 * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getSession } from '@monterosa/sdk-identify-kit';\n * import { getConnect, login } from '@monterosa/sdk-connect-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const session = await getSession(identify);\n *\n * const connect = await getConnect();\n * await login(connect, ...session);\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 session signature.\n *\n * - If the request is successful, the function resolves with `Signature`.\n * If not, a `MonterosaError` is thrown.\n *\n * - The function can be used to fetch a signature for a user session that\n * can be used to authenticate user with `ConnectKit`.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves to an object of type `Signature`.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n parentApp,\n IdentifyAction.GetSessionSignature,\n );\n\n return signature;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(\n url,\n identify.credentials.token,\n );\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n identify.expireSignature(SIGNATURE_TTL);\n\n return signature;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserCheckFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\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 `UserData` object.\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 { userId } = await getUserData(identify);\n *\n * console.log(`User id is ${userId}`);\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 `UserData`.\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 a `UserData` object. The `UserData`\n * object contains information about the user, including their `userId`,\n * `timestamp`, and `signature`, as well as any additional properties.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n parentApp,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.credentials.token);\n\n identify.userData = data;\n identify.expireUserData(USER_DATA_TTL);\n\n return data;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserDataFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\n }\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 parentApp,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n identify.credentials = credentials;\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 the credentials validation fails.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsValidationFailed } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsValidationFailed(identify, (error) => {\n * console.log(error);\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 an error occured.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsValidationFailed(\n identify: IdentifyKit,\n callback: (error: string) => void,\n): Unsubscribe {\n return subscribe(\n identify,\n IdentifyEvent.CredentialsValidationFailed,\n callback,\n );\n}\n","/**\n * @license\n * bridge.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-03-07\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe } from '@monterosa/sdk-util';\nimport {\n Experience,\n getParentApplication,\n registerEmbedHook,\n respondToSdkMessage,\n sendSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n IdentifyEvent,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignature,\n setCredentials,\n requestLogin,\n logout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n onCredentialsValidationFailed,\n registerIdentifyHook,\n} from './api';\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, ({ action, payload }) => {\n switch (action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = payload.credentials as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = payload.signature as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = payload.userData as UserData;\n break;\n }\n case IdentifyAction.OnCredentialsValidationFailed: {\n identify.emit(IdentifyEvent.CredentialsValidationFailed, payload.error);\n break;\n }\n }\n });\n}\n\nfunction onExperienceEmbed(experience: Experience): Unsubscribe {\n const identify = getIdentify(experience.sdk);\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(\n identify,\n (credentials) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n credentials,\n });\n },\n );\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (signature) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n signature,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (userData) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n userData,\n });\n });\n\n const validationFailedUnsub = onCredentialsValidationFailed(\n identify,\n (error) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsValidationFailed, {\n error,\n });\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 try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Login request succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.Logout: {\n await logout(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Logout succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignature(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Session signature obtained successfully',\n data: signature,\n });\n break;\n }\n case IdentifyAction.GetUserData: {\n const userData = await getUserData(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'User data obtained successfully',\n data: userData,\n });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(identify, {\n token: message.payload.token as string,\n });\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Credentials updated successfully',\n data: {},\n });\n\n break;\n }\n }\n } catch (err) {\n if (err instanceof Error) {\n respondToSdkMessage(experience, message, {\n result: 'failure',\n message: err.message,\n data: {},\n });\n }\n }\n });\n\n return () => {\n credentialsUpdatedUnsub();\n signatureUpdatedUnsub();\n userDataUpdatedUnsub();\n sdkMessageUnsub();\n validationFailedUnsub();\n };\n}\n\nregisterEmbedHook(onExperienceEmbed);\nregisterIdentifyHook(parentMessagesHook);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AA6IA;;;AAGA,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,mDAAkC,CAAA;IAClC,uDAAsC,CAAA;IACtC,2DAA0C,CAAA;IAC1C,qDAAoC,CAAA;IACpC,6DAA4C,CAAA;IAC5C,2DAA0C,CAAA;IAC1C,8EAA6D,CAAA;AAC/D,CAAC,EARW,aAAa,KAAb,aAAa,QAQxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BY;AAAZ,WAAY,aAAa;;;;IAIvB,0DAAyC,CAAA;;;;IAIzC,0DAAyC,CAAA;;;;;IAKzC,iDAAgC,CAAA;;;;IAIhC,mDAAkC,CAAA;;;;IAIlC,oDAAmC,CAAA;AACrC,CAAC,EAtBW,aAAa,KAAb,aAAa,QAsBxB;AAED;;;AAGO,IAAM,qBAAqB;IAChC,GAAC,aAAa,CAAC,iBAAiB,IAAG,UAAC,KAAa;QAC/C,OAAA,+CAA6C,KAAO;KAAA;IACtD,GAAC,aAAa,CAAC,iBAAiB,IAAG;QACjC,OAAA,mDAAmD;KAAA;IACrD,GAAC,aAAa,CAAC,aAAa,IAAG,cAAM,OAAA,kCAAkC,GAAA;IACvE,GAAC,aAAa,CAAC,cAAc,IAAG,cAAM,OAAA,sCAAsC,GAAA;IAC5E,GAAC,a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BACjB,OAAO,EAAE,kCAAkC;wBAC3C,IAAI,EAAE,EAAE;qBACT,CAAC,CAAC;oBAEH,yBAAM;;;;oBAIV,IAAI,KAAG,YAAY,KAAK,EAAE;wBACxB,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;4BACvC,MAAM,EAAE,SAAS;4BACjB,OAAO,EAAE,KAAG,CAAC,OAAO;4BACpB,IAAI,EAAE,EAAE;yBACT,CAAC,CAAC;qBACJ;;;;;SAEJ,CAAC,CAAC;IAEH,OAAO;QACL,uBAAuB,EAAE,CAAC;QAC1B,qBAAqB,EAAE,CAAC;QACxB,oBAAoB,EAAE,CAAC;QACvB,eAAe,EAAE,CAAC;QAClB,qBAAqB,EAAE,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;AACrC,oBAAoB,CAAC,kBAAkB,CAAC;;;;"}
1
+ {"version":3,"file":"index.esm5.js","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * public_types.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 * The type represents a user credentials. It contains a single property, token,\n * which is a string value representing the user's authentication token.\n *\n * @example\n * ```javascript\n * const credentials: Credentials = { token: \"abc123\" };\n * ```\n */\nexport type Credentials = {\n token: string;\n};\n\n/**\n *\n * The type represents a digital signature. It contains three properties:\n * `userId`, `timestamp`, and `signature`. These properties are respectively of\n * type `string`, `number`, and `string`.\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 * The type represents a set of user data. It contains three properties:\n * `userId`, `timestamp`, and `signature`. In addition, it allows for any\n * number of additional properties to be defined using TypeScript's index\n * signature syntax. The `userId` property is a string value representing\n * the user's unique identifier. The `timestamp` property is a number value\n * representing the time when the user's data was last updated. The `signature`\n * property is a string value representing the digital signature of the user's\n * data.\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 result: 'success' | 'failure';\n data: T;\n message: string;\n};\n\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\n\nexport interface IdentifyOptions {\n readonly deviceId?: string;\n readonly strategy?: string;\n readonly provider?: string;\n readonly version?: number;\n}\n\n/**\n * The `IdentifyKit` interface provides a set of properties and methods\n * for managing user identification.\n */\nexport interface IdentifyKit extends Emitter {\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 /**\n * @internal\n */\n expireSignature(delay: number): void;\n\n /**\n * @internal\n */\n expireUserData(delay: number): void;\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 LoginRequested = 'login_requested',\n SignatureUpdated = 'signature_updated',\n CredentialsUpdated = 'credentials_updated',\n UserdataUpdated = 'userdata_updated',\n ApiUserCheckFailed = 'api_user_check_failed',\n ApiUserDataFailed = 'api_user_data_failed',\n CredentialsValidationFailed = 'credentials_validation_failed',\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 initialized properly.\n */\n NotInitialised = 'not_initialised',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_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};\n\nexport enum IdentifyAction {\n RequestLogin = 'identifyRequestLogin',\n Logout = 'identifyLogout',\n GetSessionSignature = 'identifyGetSessionSignature',\n GetUserData = 'identifyGetUserData',\n SetCredentials = 'identifySetCredentials',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\n OnLoginRequestedByExperience = 'identifyOnLoginRequestedByExperience',\n OnCredentialsValidationFailed = 'identifyOnCredentialsValidationFailed',\n}\n","/**\n * @license\n * constants.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-22\n * Copyright © 2023 Monterosa. 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 = 10000;\n\nexport const USER_DATA_TTL = 10000;\n","/**\n * @license\n * identify.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private host?: string;\n\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 constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n ...options,\n };\n }\n\n expireSignature(delay: number) {\n clearTimeout(this.signatureExpireTimeout);\n\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, delay);\n }\n\n expireUserData(delay: number) {\n clearTimeout(this.userDataExpireTimeout);\n\n this.userDataExpireTimeout = setTimeout(() => {\n this.userData = null;\n }, delay);\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n\n if (!Object.prototype.hasOwnProperty.call(listings.assets, EXTENSION_ID)) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return listings.assets[EXTENSION_ID][0].data;\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 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 // if credentials are updated, user data and signature are cleared\n this.userData = null;\n this.signature = null;\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 this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\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 * api.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21\n * Copyright © 2023 Monterosa. 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 { subscribe, Unsubscribe, createError } from '@monterosa/sdk-util';\nimport {\n Payload,\n ParentApplication,\n getParentApplication,\n sendSdkRequest,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport { SIGNATURE_TTL, USER_DATA_TTL } from './constants';\n\nimport Identify from './identify';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\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: string,\n method: string = 'GET',\n): Promise<T> {\n const response = await fetch(url, {\n method,\n headers: {\n accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\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 parentApp: ParentApplication,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { result, data, message } = response.payload as ResponsePayload<T>;\n\n if (result === 'failure') {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\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 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, logout } 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>(parentApp, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user logout and removing their signature and\n * credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, logout } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await logout(identify);\n *\n * console.log('User logged out');\n * } catch (err) {\n * console.error('Error logout:', 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 log the user out.\n *\n * - If the request is successful, the function resolves with void.\n * If not, a MonterosaError is thrown.\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 logout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(parentApp, IdentifyAction.Logout);\n\n return;\n }\n\n identify.signature = null;\n identify.credentials = null;\n}\n\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 * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getSession } from '@monterosa/sdk-identify-kit';\n * import { getConnect, login } from '@monterosa/sdk-connect-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const session = await getSession(identify);\n *\n * const connect = await getConnect();\n * await login(connect, ...session);\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 session signature.\n *\n * - If the request is successful, the function resolves with `Signature`.\n * If not, a `MonterosaError` is thrown.\n *\n * - The function can be used to fetch a signature for a user session that\n * can be used to authenticate user with `ConnectKit`.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves to an object of type `Signature`.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n): Promise<Signature> {\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n parentApp,\n IdentifyAction.GetSessionSignature,\n );\n\n return signature;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(\n url,\n identify.credentials.token,\n );\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n identify.expireSignature(SIGNATURE_TTL);\n\n return signature;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserCheckFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\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 `UserData` object.\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 { userId } = await getUserData(identify);\n *\n * console.log(`User id is ${userId}`);\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 `UserData`.\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 a `UserData` object. The `UserData`\n * object contains information about the user, including their `userId`,\n * `timestamp`, and `signature`, as well as any additional properties.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n parentApp,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n try {\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.credentials.token);\n\n identify.userData = data;\n identify.expireUserData(USER_DATA_TTL);\n\n return data;\n } catch (err) {\n if (err instanceof Error) {\n identify.emit(IdentifyEvent.ApiUserDataFailed, err.message);\n identify.emit(IdentifyEvent.CredentialsValidationFailed, err.message);\n }\n\n throw err;\n }\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 parentApp,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n identify.credentials = credentials;\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 the credentials validation fails.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsValidationFailed } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsValidationFailed(identify, (error) => {\n * console.log(error);\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 an error occured.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsValidationFailed(\n identify: IdentifyKit,\n callback: (error: string) => void,\n): Unsubscribe {\n return subscribe(\n identify,\n IdentifyEvent.CredentialsValidationFailed,\n callback,\n );\n}\n","/**\n * @license\n * bridge.ts\n * identify-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-03-07\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n getParentApplication,\n registerEmbedHook,\n respondToSdkMessage,\n sendSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n IdentifyEvent,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignature,\n setCredentials,\n requestLogin,\n logout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n onCredentialsValidationFailed,\n registerIdentifyHook,\n} from './api';\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, ({ action, payload }) => {\n switch (action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = payload.credentials as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = payload.signature as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = payload.userData as UserData;\n break;\n }\n case IdentifyAction.OnCredentialsValidationFailed: {\n identify.emit(IdentifyEvent.CredentialsValidationFailed, payload.error);\n break;\n }\n }\n });\n}\n\nfunction onExperienceEmbed(experience: Experience): Unsubscribe {\n const identify = getIdentify(experience.sdk);\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(\n identify,\n (credentials) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n credentials,\n });\n },\n );\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (signature) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n signature,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (userData) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n userData,\n });\n });\n\n const validationFailedUnsub = onCredentialsValidationFailed(\n identify,\n (error) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsValidationFailed, {\n error,\n });\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 try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Login request succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.Logout: {\n await logout(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Logout succesful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignature(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Session signature obtained successfully',\n data: signature,\n });\n break;\n }\n case IdentifyAction.GetUserData: {\n const userData = await getUserData(identify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'User data obtained successfully',\n data: userData,\n });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(identify, {\n token: message.payload.token as string,\n });\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Credentials updated successfully',\n data: {},\n });\n\n break;\n }\n }\n } catch (err) {\n respondToSdkMessage(experience, message, {\n result: 'failure',\n message: getErrorMessage(err),\n data: {},\n });\n }\n });\n\n return () => {\n credentialsUpdatedUnsub();\n signatureUpdatedUnsub();\n userDataUpdatedUnsub();\n sdkMessageUnsub();\n validationFailedUnsub();\n };\n}\n\nregisterEmbedHook(onExperienceEmbed);\nregisterIdentifyHook(parentMessagesHook);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AA6IA;;;AAGA,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,mDAAkC,CAAA;IAClC,uDAAsC,CAAA;IACtC,2DAA0C,CAAA;IAC1C,qDAAoC,CAAA;IACpC,6DAA4C,CAAA;IAC5C,2DAA0C,CAAA;IAC1C,8EAA6D,CAAA;AAC/D,CAAC,EARW,aAAa,K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AAU,EAAE,OAAO,EAAE;wBACvC,MAAM,EAAE,SAAS;wBACjB,OAAO,EAAE,yCAAyC;wBAClD,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAC;oBACH,yBAAM;wBAGW,qBAAM,WAAW,CAAC,QAAQ,CAAC,EAAA;;oBAAtC,QAAQ,GAAG,SAA2B;oBAE5C,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;wBACvC,MAAM,EAAE,SAAS;wBACjB,OAAO,EAAE,iCAAiC;wBAC1C,IAAI,EAAE,QAAQ;qBACf,CAAC,CAAC;oBACH,yBAAM;yBAGN,qBAAM,cAAc,CAAC,QAAQ,EAAE;wBAC7B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAe;qBACvC,CAAC,EAAA;;oBAFF,SAEE,CAAC;oBAEH,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;wBACvC,MAAM,EAAE,SAAS;wBACjB,OAAO,EAAE,kCAAkC;wBAC3C,IAAI,EAAE,EAAE;qBACT,CAAC,CAAC;oBAEH,yBAAM;;;;oBAIV,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE;wBACvC,MAAM,EAAE,SAAS;wBACjB,OAAO,EAAE,eAAe,CAAC,KAAG,CAAC;wBAC7B,IAAI,EAAE,EAAE;qBACT,CAAC,CAAC;;;;;SAEN,CAAC,CAAC;IAEH,OAAO;QACL,uBAAuB,EAAE,CAAC;QAC1B,qBAAqB,EAAE,CAAC;QACxB,oBAAoB,EAAE,CAAC;QACvB,eAAe,EAAE,CAAC;QAClB,qBAAqB,EAAE,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;AACrC,oBAAoB,CAAC,kBAAkB,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monterosa/sdk-identify-kit",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
4
4
  "description": "Identify Kit for the Monterosa JS SDK",
5
5
  "author": "Monterosa <hello@monterosa.co.uk> (https://www.monterosa.co/)",
6
6
  "main": "dist/index.cjs.js",
@@ -23,16 +23,18 @@
23
23
  "license": "MIT",
24
24
  "peerDependencies": {
25
25
  "@monterosa/sdk-core": "0.x",
26
+ "@monterosa/sdk-interact-interop": "0.x",
26
27
  "@monterosa/sdk-interact-kit": "0.x",
27
28
  "@monterosa/sdk-launcher-kit": "0.x",
28
29
  "@monterosa/sdk-util": "0.x"
29
30
  },
30
31
  "dependencies": {
31
32
  "@babel/runtime": "^7.15.4",
32
- "@monterosa/sdk-core": "^0.18.2",
33
- "@monterosa/sdk-interact-kit": "^0.18.2",
34
- "@monterosa/sdk-launcher-kit": "^0.18.2",
35
- "@monterosa/sdk-util": "^0.18.2"
33
+ "@monterosa/sdk-core": "^0.18.3",
34
+ "@monterosa/sdk-interact-interop": "^0.18.3",
35
+ "@monterosa/sdk-interact-kit": "^0.18.3",
36
+ "@monterosa/sdk-launcher-kit": "^0.18.3",
37
+ "@monterosa/sdk-util": "^0.18.3"
36
38
  },
37
39
  "devDependencies": {
38
40
  "@rollup/plugin-json": "^4.1.0",
@@ -49,5 +51,5 @@
49
51
  "publishConfig": {
50
52
  "access": "public"
51
53
  },
52
- "gitHead": "326388fa3c7366a0657532f4f2195bdc304a90b2"
54
+ "gitHead": "9751b80f19b914b0b0bbe356b816efddf4ce828b"
53
55
  }