@monterosa/sdk-identify-kit 0.18.5 → 0.18.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
+ import { getDeviceId, Sdk, getSdk, configure, getSdks } from '@monterosa/sdk-core';
1
2
  import { Emitter, createError, subscribe, getErrorMessage } from '@monterosa/sdk-util';
2
- import { sendSdkRequest, getParentApplication, registerEmbedHook, sendSdkMessage, onSdkMessage, respondToSdkMessage } from '@monterosa/sdk-launcher-kit';
3
- import { getDeviceId, Sdk, getSdk } from '@monterosa/sdk-core';
3
+ import { getParentApplication, sendSdkRequest, registerEmbedHook, sendSdkMessage, onSdkMessage, respondToSdkMessage } from '@monterosa/sdk-launcher-kit';
4
4
  import { fetchListings } from '@monterosa/sdk-interact-interop';
5
5
 
6
6
  /*! *****************************************************************************
@@ -89,7 +89,7 @@ function __generator(thisArg, body) {
89
89
  * identify-kit
90
90
  *
91
91
  * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21
92
- * Copyright © 2023 Monterosa. All rights reserved.
92
+ * Copyright © 2023-2026 Monterosa. All rights reserved.
93
93
  *
94
94
  * More details on the license can be found at https://www.monterosa.co/sdk/license
95
95
  */
@@ -157,6 +157,10 @@ var IdentifyError;
157
157
  * Indicates an error occurred in the parent app.
158
158
  */
159
159
  IdentifyError["ParentAppError"] = "parent_app_error";
160
+ /**
161
+ * Indicates there is no parent application to delegate to.
162
+ */
163
+ IdentifyError["NoParentApplication"] = "no_parent_application";
160
164
  })(IdentifyError || (IdentifyError = {}));
161
165
  /**
162
166
  * @internal
@@ -173,6 +177,9 @@ var IdentifyErrorMessages = (_a = {},
173
177
  _a[IdentifyError.ParentAppError] = function (error) {
174
178
  return "Parent application error: " + error;
175
179
  },
180
+ _a[IdentifyError.NoParentApplication] = function () {
181
+ return 'No parent application available for delegation';
182
+ },
176
183
  _a);
177
184
  var IdentifyAction;
178
185
  (function (IdentifyAction) {
@@ -351,7 +358,7 @@ var Identify = /** @class */ (function (_super) {
351
358
  * identify-kit
352
359
  *
353
360
  * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21
354
- * Copyright © 2023 Monterosa. All rights reserved.
361
+ * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.
355
362
  *
356
363
  * More details on the license can be found at https://www.monterosa.co/sdk/license
357
364
  */
@@ -401,15 +408,23 @@ function api(url, token, method) {
401
408
  /**
402
409
  * @internal
403
410
  */
404
- function parentAppRequest(parentApp, action, payload) {
411
+ function parentAppRequest(identify, action, payload) {
412
+ var _a;
405
413
  return __awaiter(this, void 0, void 0, function () {
406
- var response, _a, result, data, message;
407
- return __generator(this, function (_b) {
408
- switch (_b.label) {
409
- case 0: return [4 /*yield*/, sendSdkRequest(parentApp, action, payload)];
414
+ var parentApp, _b, host, projectId, origin, response, _c, result, data, message;
415
+ return __generator(this, function (_d) {
416
+ switch (_d.label) {
417
+ case 0:
418
+ parentApp = getParentApplication();
419
+ if (parentApp === null) {
420
+ throw createError(IdentifyError.NoParentApplication, IdentifyErrorMessages);
421
+ }
422
+ _b = identify.sdk.options, host = _b.host, projectId = _b.projectId;
423
+ origin = (_a = payload === null || payload === void 0 ? void 0 : payload.origin) !== null && _a !== void 0 ? _a : { host: host, projectId: projectId };
424
+ return [4 /*yield*/, sendSdkRequest(parentApp, action, __assign(__assign({}, payload), { origin: origin }))];
410
425
  case 1:
411
- response = _b.sent();
412
- _a = response.payload, result = _a.result, data = _a.data, message = _a.message;
426
+ response = _d.sent();
427
+ _c = response.payload, result = _c.result, data = _c.data, message = _c.message;
413
428
  if (result === 'failure') {
414
429
  throw createError(IdentifyError.ParentAppError, IdentifyErrorMessages, message);
415
430
  }
@@ -504,7 +519,7 @@ function requestLogin(identify) {
504
519
  case 0:
505
520
  parentApp = getParentApplication();
506
521
  if (!(parentApp !== null)) return [3 /*break*/, 2];
507
- return [4 /*yield*/, parentAppRequest(parentApp, IdentifyAction.RequestLogin)];
522
+ return [4 /*yield*/, parentAppRequest(identify, IdentifyAction.RequestLogin)];
508
523
  case 1:
509
524
  _a.sent();
510
525
  return [2 /*return*/];
@@ -558,7 +573,7 @@ function logout(identify) {
558
573
  case 0:
559
574
  parentApp = getParentApplication();
560
575
  if (!(parentApp !== null)) return [3 /*break*/, 2];
561
- return [4 /*yield*/, parentAppRequest(parentApp, IdentifyAction.Logout)];
576
+ return [4 /*yield*/, parentAppRequest(identify, IdentifyAction.Logout)];
562
577
  case 1:
563
578
  _a.sent();
564
579
  return [2 /*return*/];
@@ -615,7 +630,7 @@ function getSessionSignature(identify) {
615
630
  }
616
631
  parentApp = getParentApplication();
617
632
  if (!(parentApp !== null)) return [3 /*break*/, 2];
618
- return [4 /*yield*/, parentAppRequest(parentApp, IdentifyAction.GetSessionSignature)];
633
+ return [4 /*yield*/, parentAppRequest(identify, IdentifyAction.GetSessionSignature)];
619
634
  case 1:
620
635
  signature = _a.sent();
621
636
  return [2 /*return*/, signature];
@@ -690,7 +705,7 @@ function getUserData(identify) {
690
705
  }
691
706
  parentApp = getParentApplication();
692
707
  if (!(parentApp !== null)) return [3 /*break*/, 2];
693
- return [4 /*yield*/, parentAppRequest(parentApp, IdentifyAction.GetUserData)];
708
+ return [4 /*yield*/, parentAppRequest(identify, IdentifyAction.GetUserData)];
694
709
  case 1:
695
710
  userData = _a.sent();
696
711
  return [2 /*return*/, userData];
@@ -760,7 +775,7 @@ function setCredentials(identify, credentials) {
760
775
  case 0:
761
776
  parentApp = getParentApplication();
762
777
  if (!(parentApp !== null)) return [3 /*break*/, 2];
763
- return [4 /*yield*/, parentAppRequest(parentApp, IdentifyAction.SetCredentials, credentials)];
778
+ return [4 /*yield*/, parentAppRequest(identify, IdentifyAction.SetCredentials, credentials)];
764
779
  case 1:
765
780
  _a.sent();
766
781
  return [2 /*return*/];
@@ -950,7 +965,7 @@ function onCredentialsValidationFailed(identify, callback) {
950
965
  * identify-kit
951
966
  *
952
967
  * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-03-07
953
- * Copyright © 2023 Monterosa. All rights reserved.
968
+ * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.
954
969
  *
955
970
  * More details on the license can be found at https://www.monterosa.co/sdk/license
956
971
  */
@@ -984,6 +999,13 @@ function parentMessagesHook(identify) {
984
999
  }
985
1000
  });
986
1001
  }
1002
+ /**
1003
+ * Finds an existing SDK with matching projectId, or creates a new one.
1004
+ */
1005
+ function getOrConfigureSdk(host, projectId) {
1006
+ var existingSdk = getSdks().find(function (sdk) { return sdk.options.projectId === projectId; });
1007
+ return existingSdk !== null && existingSdk !== void 0 ? existingSdk : configure({ host: host, projectId: projectId }, projectId);
1008
+ }
987
1009
  function onExperienceEmbed(experience) {
988
1010
  var _this = this;
989
1011
  var identify = getIdentify(experience.sdk);
@@ -1008,13 +1030,16 @@ function onExperienceEmbed(experience) {
1008
1030
  });
1009
1031
  });
1010
1032
  var sdkMessageUnsub = onSdkMessage(experience, function (message) { return __awaiter(_this, void 0, void 0, function () {
1011
- var _a, signature, userData, err_1;
1033
+ var origin, sdk, originIdentify, _a, signature, userData, err_1;
1012
1034
  return __generator(this, function (_b) {
1013
1035
  switch (_b.label) {
1014
1036
  case 0:
1015
1037
  if (!Object.values(IdentifyAction).includes(message.action)) {
1016
1038
  return [2 /*return*/];
1017
1039
  }
1040
+ origin = message.payload.origin;
1041
+ sdk = getOrConfigureSdk(origin.host, origin.projectId);
1042
+ originIdentify = getIdentify(sdk);
1018
1043
  _b.label = 1;
1019
1044
  case 1:
1020
1045
  _b.trys.push([1, 13, , 14]);
@@ -1027,25 +1052,25 @@ function onExperienceEmbed(experience) {
1027
1052
  case IdentifyAction.SetCredentials: return [3 /*break*/, 10];
1028
1053
  }
1029
1054
  return [3 /*break*/, 12];
1030
- case 2: return [4 /*yield*/, requestLogin(identify)];
1055
+ case 2: return [4 /*yield*/, requestLogin(originIdentify)];
1031
1056
  case 3:
1032
1057
  _b.sent();
1033
1058
  respondToSdkMessage(experience, message, {
1034
1059
  result: 'success',
1035
- message: 'Login request succesful',
1060
+ message: 'Login request successful',
1036
1061
  data: {},
1037
1062
  });
1038
1063
  return [3 /*break*/, 12];
1039
- case 4: return [4 /*yield*/, logout(identify)];
1064
+ case 4: return [4 /*yield*/, logout(originIdentify)];
1040
1065
  case 5:
1041
1066
  _b.sent();
1042
1067
  respondToSdkMessage(experience, message, {
1043
1068
  result: 'success',
1044
- message: 'Logout succesful',
1069
+ message: 'Logout successful',
1045
1070
  data: {},
1046
1071
  });
1047
1072
  return [3 /*break*/, 12];
1048
- case 6: return [4 /*yield*/, getSessionSignature(identify)];
1073
+ case 6: return [4 /*yield*/, getSessionSignature(originIdentify)];
1049
1074
  case 7:
1050
1075
  signature = _b.sent();
1051
1076
  respondToSdkMessage(experience, message, {
@@ -1054,7 +1079,7 @@ function onExperienceEmbed(experience) {
1054
1079
  data: signature,
1055
1080
  });
1056
1081
  return [3 /*break*/, 12];
1057
- case 8: return [4 /*yield*/, getUserData(identify)];
1082
+ case 8: return [4 /*yield*/, getUserData(originIdentify)];
1058
1083
  case 9:
1059
1084
  userData = _b.sent();
1060
1085
  respondToSdkMessage(experience, message, {
@@ -1063,7 +1088,7 @@ function onExperienceEmbed(experience) {
1063
1088
  data: userData,
1064
1089
  });
1065
1090
  return [3 /*break*/, 12];
1066
- case 10: return [4 /*yield*/, setCredentials(identify, {
1091
+ case 10: return [4 /*yield*/, setCredentials(originIdentify, {
1067
1092
  token: message.payload.token,
1068
1093
  })];
1069
1094
  case 11:
@@ -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 can be either the literal 'cookie' for cookie-based authentication or\n * a string value representing the user's authentication token for bearer token\n * authentication.\n *\n * @example\n * ```javascript\n * // Bearer token authentication\n * const credentials: Credentials = { token: \"abc123\" };\n *\n * // Cookie-based authentication\n * const credentials: Credentials = { token: \"cookie\" };\n * ```\n */\nexport type Credentials = {\n token: 'cookie' | string;\n};\n\n/**\n *\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 const extensionAssets = listings.assets?.[EXTENSION_ID] ?? [];\n\n const endpointAsset = extensionAssets.find(\n ({ name }) => name === 'endpoint',\n );\n\n if (!endpointAsset) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return endpointAsset.data;\n }\n\n get 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: Credentials['token'],\n method: string = 'GET',\n): Promise<T> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n };\n\n let credentials: RequestCredentials | undefined;\n\n // Only include Authorization header for bearer token authentication\n // When token is 'cookie', use credentials: 'include' to ensure HttpOnly\n // cookies are sent\n if (token === 'cookie') {\n // Use credentials: 'include' to ensure HttpOnly cookies are sent\n credentials = 'include';\n } else {\n headers.Authorization = `Bearer ${token}`;\n }\n\n const response = await fetch(url, {\n method,\n headers,\n credentials,\n });\n\n const data = (await response.json()) as T;\n\n if (data.result < 0) {\n throw createError(\n IdentifyError.ExtensionApiError,\n IdentifyErrorMessages,\n data.message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport async function parentAppRequest<T>(\n 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 Credentials['token'],\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;;;;;;;;;;;AAmJA;;;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,CAA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,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,KAA6B;qBACrD,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;;;;"}
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-2026 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 can be either the literal 'cookie' for cookie-based authentication or\n * a string value representing the user's authentication token for bearer token\n * authentication.\n *\n * @example\n * ```javascript\n * // Bearer token authentication\n * const credentials: Credentials = { token: \"abc123\" };\n *\n * // Cookie-based authentication\n * const credentials: Credentials = { token: \"cookie\" };\n * ```\n */\nexport type Credentials = {\n token: 'cookie' | string;\n};\n\n/**\n *\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 options: IdentifyOptions;\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 * Indicates there is no parent application to delegate to.\n */\n NoParentApplication = 'no_parent_application',\n}\n\n/**\n * @internal\n */\nexport const IdentifyErrorMessages = {\n [IdentifyError.ExtensionApiError]: (error: string) =>\n `Identify extension API returned an error: ${error}`,\n [IdentifyError.ExtensionNotSetup]: () =>\n 'Identify extension is not set up for this project',\n [IdentifyError.NoCredentials]: () => 'Identify credentials are not set',\n [IdentifyError.NotInitialised]: () => 'Identify instance is not initialised',\n [IdentifyError.ParentAppError]: (error: string) =>\n `Parent application error: ${error}`,\n [IdentifyError.NoParentApplication]: () =>\n 'No parent application available for delegation',\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 const extensionAssets = listings.assets?.[EXTENSION_ID] ?? [];\n\n const endpointAsset = extensionAssets.find(\n ({ name }) => name === 'endpoint',\n );\n\n if (!endpointAsset) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return endpointAsset.data;\n }\n\n get 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-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, Sdk, getSdk } from '@monterosa/sdk-core';\nimport { subscribe, Unsubscribe, createError } from '@monterosa/sdk-util';\nimport {\n Payload,\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: Credentials['token'],\n method: string = 'GET',\n): Promise<T> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n };\n\n let credentials: RequestCredentials | undefined;\n\n // Only include Authorization header for bearer token authentication\n // When token is 'cookie', use credentials: 'include' to ensure HttpOnly\n // cookies are sent\n if (token === 'cookie') {\n // Use credentials: 'include' to ensure HttpOnly cookies are sent\n credentials = 'include';\n } else {\n headers.Authorization = `Bearer ${token}`;\n }\n\n const response = await fetch(url, {\n method,\n headers,\n credentials,\n });\n\n const data = (await response.json()) as T;\n\n if (data.result < 0) {\n throw createError(\n IdentifyError.ExtensionApiError,\n IdentifyErrorMessages,\n data.message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport async function parentAppRequest<T>(\n identify: IdentifyKit,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n throw createError(IdentifyError.NoParentApplication, IdentifyErrorMessages);\n }\n\n const { host, projectId } = identify.sdk.options;\n\n // Preserve existing origin (relay) or set from current context (source)\n const origin = payload?.origin ?? { host, projectId };\n\n const response = await sendSdkRequest(parentApp, action, {\n ...payload,\n origin,\n });\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>(identify, 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>(identify, 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 identify,\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 identify,\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 identify,\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-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, configure, getSdks } from '@monterosa/sdk-core';\nimport { 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\n/**\n * Finds an existing SDK with matching projectId, or creates a new one.\n */\nfunction getOrConfigureSdk(host: string, projectId: string): MonterosaSdk {\n const existingSdk = getSdks().find(\n (sdk) => sdk.options.projectId === projectId,\n );\n\n return existingSdk ?? configure({ host, projectId }, projectId);\n}\n\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 // Get origin context from payload\n const { origin } = message.payload as {\n origin: { host: string; projectId: string };\n };\n\n // Always use origin to get identify for the originating layer's context\n const sdk = getOrConfigureSdk(origin.host, origin.projectId);\n const originIdentify = getIdentify(sdk);\n\n try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(originIdentify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Login request successful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.Logout: {\n await logout(originIdentify);\n\n respondToSdkMessage(experience, message, {\n result: 'success',\n message: 'Logout successful',\n data: {},\n });\n\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignature(originIdentify);\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(originIdentify);\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(originIdentify, {\n token: message.payload.token as Credentials['token'],\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;;;;;;;;;;;AAuJA;;;AAGA,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,mDAAk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C;AACrC,oBAAoB,CAAC,kBAAkB,CAAC;;;;"}
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * identify-kit
5
5
  *
6
6
  * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-21
7
- * Copyright © 2023 Monterosa. All rights reserved.
7
+ * Copyright © 2023-2026 Monterosa. All rights reserved.
8
8
  *
9
9
  * More details on the license can be found at https://www.monterosa.co/sdk/license
10
10
  */
@@ -89,6 +89,10 @@ export interface IdentifyKit extends Emitter {
89
89
  * @internal
90
90
  */
91
91
  sdk: MonterosaSdk;
92
+ /**
93
+ * @internal
94
+ */
95
+ options: IdentifyOptions;
92
96
  /**
93
97
  * @internal
94
98
  */
@@ -191,7 +195,11 @@ export declare enum IdentifyError {
191
195
  /**
192
196
  * Indicates an error occurred in the parent app.
193
197
  */
194
- ParentAppError = "parent_app_error"
198
+ ParentAppError = "parent_app_error",
199
+ /**
200
+ * Indicates there is no parent application to delegate to.
201
+ */
202
+ NoParentApplication = "no_parent_application"
195
203
  }
196
204
  /**
197
205
  * @internal
@@ -202,6 +210,7 @@ export declare const IdentifyErrorMessages: {
202
210
  no_credentials: () => string;
203
211
  not_initialised: () => string;
204
212
  parent_app_error: (error: string) => string;
213
+ no_parent_application: () => string;
205
214
  };
206
215
  export declare enum IdentifyAction {
207
216
  RequestLogin = "identifyRequestLogin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monterosa/sdk-identify-kit",
3
- "version": "0.18.5",
3
+ "version": "0.18.7",
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",
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.15.4",
33
- "@monterosa/sdk-core": "^0.18.5",
34
- "@monterosa/sdk-interact-interop": "^0.18.5",
35
- "@monterosa/sdk-interact-kit": "^0.18.5",
36
- "@monterosa/sdk-launcher-kit": "^0.18.5",
37
- "@monterosa/sdk-util": "^0.18.5"
33
+ "@monterosa/sdk-core": "^0.18.7",
34
+ "@monterosa/sdk-interact-interop": "^0.18.7",
35
+ "@monterosa/sdk-interact-kit": "^0.18.7",
36
+ "@monterosa/sdk-launcher-kit": "^0.18.7",
37
+ "@monterosa/sdk-util": "^0.18.7"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@rollup/plugin-json": "^4.1.0",
@@ -51,5 +51,5 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "5de01ea31c9f7141816ec2c6b3d7493ed8761475"
54
+ "gitHead": "cee6a1ddf6db6c544cf5b7cb7b349d9be45b3893"
55
55
  }