@monterosa/sdk-identify-kit 2.0.0-rc.2 → 2.0.0-rc.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 ADDED
@@ -0,0 +1,1158 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var sdkCore = require('@monterosa/sdk-core');
6
+ var sdkUtil = require('@monterosa/sdk-util');
7
+ var sdkLauncherKit = require('@monterosa/sdk-launcher-kit');
8
+ var sdkConnectKit = require('@monterosa/sdk-connect-kit');
9
+ var sdkInteractInterop = require('@monterosa/sdk-interact-interop');
10
+
11
+ /**
12
+ * @license
13
+ * @monterosa/sdk-identify-kit
14
+ *
15
+ * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.
16
+ *
17
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
18
+ */
19
+ /**
20
+ * @internal
21
+ */
22
+ var IdentifyEvent;
23
+ (function (IdentifyEvent) {
24
+ IdentifyEvent["StateUpdated"] = "state_updated";
25
+ IdentifyEvent["LoginRequested"] = "login_requested";
26
+ IdentifyEvent["LogoutRequested"] = "logout_requested";
27
+ IdentifyEvent["SignatureUpdated"] = "signature_updated";
28
+ IdentifyEvent["UserdataUpdated"] = "userdata_updated";
29
+ IdentifyEvent["CredentialsUpdated"] = "credentials_updated";
30
+ IdentifyEvent["EnmasseLogin"] = "enmasse_login";
31
+ })(IdentifyEvent || (IdentifyEvent = {}));
32
+ /**
33
+ * Defines a set of error codes that may be encountered when using the
34
+ * Identify kit of the Monterosa SDK.
35
+ *
36
+ * @example
37
+ * ```javascript
38
+ * try {
39
+ * // some code that uses the IdentifyKit
40
+ * } catch (err) {
41
+ * if (err.code === IdentifyError.NoCredentials) {
42
+ * // handle missing credentials error
43
+ * } else if (err.code === IdentifyError.NotInitialised) {
44
+ * // handle initialization error
45
+ * } else {
46
+ * // handle other error types
47
+ * }
48
+ * }
49
+ * ```
50
+ *
51
+ * @remarks
52
+ * - The `IdentifyError` enum provides a convenient way to handle errors
53
+ * encountered when using the `IdentifyKit` module. By checking the code
54
+ * property of the caught error against the values of the enum, the error
55
+ * type can be determined and appropriate action taken.
56
+ *
57
+ * - The `IdentifyError` enum is not intended to be instantiated or extended.
58
+ */
59
+ exports.IdentifyError = void 0;
60
+ (function (IdentifyError) {
61
+ /**
62
+ * Indicates an error occurred during the call to the extension API.
63
+ */
64
+ IdentifyError["ExtensionApiError"] = "extension_api_error";
65
+ /**
66
+ * Indicates the extension required by the IdentifyKit is not set up properly.
67
+ */
68
+ IdentifyError["ExtensionNotSetup"] = "extension_not_setup";
69
+ /**
70
+ * Indicates the user's authentication credentials are not available
71
+ * or have expired.
72
+ */
73
+ IdentifyError["NoCredentials"] = "no_credentials";
74
+ /**
75
+ * Indicates the IdentifyKit has not been initialised properly.
76
+ */
77
+ IdentifyError["NotInitialised"] = "not_initialised";
78
+ /**
79
+ * Indicates an error occurred in the parent app.
80
+ */
81
+ IdentifyError["ParentAppError"] = "parent_app_error";
82
+ /**
83
+ * Indicates an unexpected or invalid login state was encountered.
84
+ */
85
+ IdentifyError["UnexpectedState"] = "unexpected_state";
86
+ /**
87
+ * Indicates there is no parent application to delegate to.
88
+ */
89
+ IdentifyError["NoParentApplication"] = "no_parent_application";
90
+ /**
91
+ * Indicates a timeout occurred when communicating with the parent app.
92
+ */
93
+ IdentifyError["ParentTimeoutError"] = "parent_timeout_error";
94
+ })(exports.IdentifyError || (exports.IdentifyError = {}));
95
+ /**
96
+ * @internal
97
+ */
98
+ const IdentifyErrorMessages = {
99
+ [exports.IdentifyError.ExtensionApiError]: (error) => `Identify extension API returned an error: ${error}`,
100
+ [exports.IdentifyError.ExtensionNotSetup]: () => 'Identify extension is not set up for this project',
101
+ [exports.IdentifyError.NoCredentials]: () => 'Identify credentials are not set',
102
+ [exports.IdentifyError.NotInitialised]: () => 'Identify instance is not initialised',
103
+ [exports.IdentifyError.ParentAppError]: (error) => `Parent application error: ${error}`,
104
+ [exports.IdentifyError.UnexpectedState]: (state) => `Unexpected LoginState: ${state}`,
105
+ [exports.IdentifyError.NoParentApplication]: () => 'No parent application available for delegation',
106
+ [exports.IdentifyError.ParentTimeoutError]: (error) => `Parent application timeout: ${error}. Please check if the identify-kit is imported on the parent page.`,
107
+ };
108
+ var IdentifyAction;
109
+ (function (IdentifyAction) {
110
+ IdentifyAction["Login"] = "identifyLogin";
111
+ IdentifyAction["Logout"] = "identifyLogout";
112
+ IdentifyAction["RequestLogin"] = "identifyRequestLogin";
113
+ IdentifyAction["RequestLogout"] = "identifyRequestLogout";
114
+ IdentifyAction["GetUserData"] = "identifyGetUserData";
115
+ IdentifyAction["GetSessionSignature"] = "identifyGetSessionSignature";
116
+ IdentifyAction["SetCredentials"] = "identifySetCredentials";
117
+ IdentifyAction["ClearCredentials"] = "identifyClearCredentials";
118
+ IdentifyAction["OnStateUpdated"] = "identifyOnStateUpdated";
119
+ IdentifyAction["OnCredentialsUpdated"] = "identifyOnCredentialsUpdated";
120
+ IdentifyAction["OnUserDataUpdated"] = "identifyOnUserDataUpdated";
121
+ IdentifyAction["OnSessionSignatureUpdated"] = "identifyOnSessionSignatureUpdated";
122
+ })(IdentifyAction || (IdentifyAction = {}));
123
+
124
+ /**
125
+ * @license
126
+ * @monterosa/sdk-identify-kit
127
+ *
128
+ * Copyright © 2023 Monterosa Productions Limited. All rights reserved.
129
+ *
130
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
131
+ */
132
+ const EXTENSION_ID = 'lvis-id-custom-tab';
133
+ const SIGNATURE_TTL = 10000;
134
+
135
+ /**
136
+ * @license
137
+ * @monterosa/sdk-identify-kit
138
+ *
139
+ * Copyright © 2023 Monterosa Productions Limited. All rights reserved.
140
+ *
141
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
142
+ */
143
+ class Identify extends sdkUtil.Emitter {
144
+ constructor(sdk, options = {}) {
145
+ super();
146
+ this.sdk = sdk;
147
+ this.wasLoggedIn = false;
148
+ this._credentials = null;
149
+ this._signature = null;
150
+ this._userData = null;
151
+ this._state = {
152
+ state: 'logged_out',
153
+ };
154
+ this._options = Object.assign({ strategy: 'email', deviceId: sdkCore.getDeviceId(), version: 1, loginPolicy: 'disabled' }, options);
155
+ }
156
+ static async fetchIdentifyHost(host, projectId) {
157
+ var _a, _b;
158
+ const listings = await sdkInteractInterop.fetchListings(host, projectId);
159
+ const extensionAssets = (_b = (_a = listings.assets) === null || _a === void 0 ? void 0 : _a[EXTENSION_ID]) !== null && _b !== void 0 ? _b : [];
160
+ const endpointAsset = extensionAssets.find(({ name }) => name === 'endpoint');
161
+ if (!endpointAsset) {
162
+ throw sdkUtil.createError(exports.IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);
163
+ }
164
+ return endpointAsset.data;
165
+ }
166
+ get state() {
167
+ return this._state;
168
+ }
169
+ set state(state) {
170
+ if (this._state.state === state.state) {
171
+ return;
172
+ }
173
+ switch (state.state) {
174
+ case 'logged_in':
175
+ this.wasLoggedIn = true;
176
+ break;
177
+ case 'logged_out':
178
+ case 'error':
179
+ this.wasLoggedIn = false;
180
+ break;
181
+ case 'pending':
182
+ // preserve wasLoggedIn value during transitional state
183
+ break;
184
+ default: {
185
+ // Exhaustiveness check: TypeScript errors if a new state is added
186
+ // but not handled. This is a compile-time error.
187
+ //
188
+ // See: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking
189
+ const exhaustiveCheck = state.state;
190
+ throw sdkUtil.createError(exports.IdentifyError.UnexpectedState, IdentifyErrorMessages, String(exhaustiveCheck));
191
+ }
192
+ }
193
+ this._state = state;
194
+ this.emit(IdentifyEvent.StateUpdated, state);
195
+ }
196
+ get options() {
197
+ return this._options;
198
+ }
199
+ set signature(signature) {
200
+ if (this._signature === signature) {
201
+ return;
202
+ }
203
+ this._signature = signature;
204
+ clearTimeout(this.signatureExpireTimeout);
205
+ if (signature !== null) {
206
+ this.signatureExpireTimeout = setTimeout(() => {
207
+ this.signature = null;
208
+ }, SIGNATURE_TTL);
209
+ }
210
+ this.emit(IdentifyEvent.SignatureUpdated, this.signature);
211
+ }
212
+ get signature() {
213
+ return this._signature;
214
+ }
215
+ set credentials(credentials) {
216
+ if (this._credentials === credentials) {
217
+ return;
218
+ }
219
+ this._credentials = credentials;
220
+ this.emit(IdentifyEvent.CredentialsUpdated, credentials);
221
+ }
222
+ get credentials() {
223
+ return this._credentials;
224
+ }
225
+ set userData(data) {
226
+ if (this._userData === data) {
227
+ return;
228
+ }
229
+ this._userData = data;
230
+ clearTimeout(this.userDataExpireTimeout);
231
+ this.emit(IdentifyEvent.UserdataUpdated, data);
232
+ }
233
+ get userData() {
234
+ return this._userData;
235
+ }
236
+ get shouldLoginOnReconnect() {
237
+ return (this.wasLoggedIn &&
238
+ this.options.loginPolicy === 'auto' &&
239
+ this.credentials !== null);
240
+ }
241
+ reset() {
242
+ this.credentials = null;
243
+ this.userData = null;
244
+ this.signature = null;
245
+ this.wasLoggedIn = false;
246
+ }
247
+ async getUrl(path = '') {
248
+ const { options: { host, projectId }, } = this.sdk;
249
+ if (this.host === undefined) {
250
+ this.host = await Identify.fetchIdentifyHost(host, projectId);
251
+ }
252
+ const url = new URL(this.host);
253
+ const { version, deviceId, strategy, provider } = this._options;
254
+ url.pathname = `/v${version}${path}`;
255
+ url.searchParams.set('projectId', projectId);
256
+ url.searchParams.set('deviceId', deviceId);
257
+ url.searchParams.set('strategy', strategy);
258
+ if (provider !== undefined) {
259
+ url.searchParams.set('provider', provider);
260
+ }
261
+ return url.toString();
262
+ }
263
+ }
264
+
265
+ /**
266
+ * @license
267
+ * @monterosa/sdk-identify-kit
268
+ *
269
+ * Copyright © 2025-2026 Monterosa Productions Limited. All rights reserved.
270
+ *
271
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
272
+ */
273
+ const entries = new Map();
274
+ function getExperiences() {
275
+ return Array.from(entries.values()).map((entry) => entry.experience);
276
+ }
277
+ function addExperience(experience, unsubs = []) {
278
+ entries.set(experience.id, {
279
+ experience,
280
+ unsubs: new Set(unsubs),
281
+ });
282
+ }
283
+ function deleteExperience(experience) {
284
+ const entry = entries.get(experience.id);
285
+ if (entry) {
286
+ entry.unsubs.forEach((unsub) => unsub());
287
+ entries.delete(experience.id);
288
+ }
289
+ }
290
+
291
+ /**
292
+ * @license
293
+ * identify-kit
294
+ *
295
+ * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.
296
+ *
297
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
298
+ */
299
+ const identifyKits = new Map();
300
+ const identifyHooks = [];
301
+ /**
302
+ * @internal
303
+ */
304
+ const taskQueue = new sdkUtil.TaskQueue();
305
+ function isSdk(value) {
306
+ return value instanceof sdkCore.Sdk;
307
+ }
308
+ async function api(url, token, method = 'GET') {
309
+ const headers = {
310
+ accept: 'application/json',
311
+ };
312
+ let credentials;
313
+ // Only include Authorization header for bearer token authentication
314
+ // When token is 'cookie', use credentials: 'include' to ensure HttpOnly
315
+ // cookies are sent
316
+ if (token === 'cookie') {
317
+ // Use credentials: 'include' to ensure HttpOnly cookies are sent
318
+ credentials = 'include';
319
+ }
320
+ else {
321
+ headers.Authorization = `Bearer ${token}`;
322
+ }
323
+ const response = await fetch(url, {
324
+ method,
325
+ headers,
326
+ credentials,
327
+ });
328
+ const data = (await response.json());
329
+ if (data.result < 0) {
330
+ throw sdkUtil.createError(exports.IdentifyError.ExtensionApiError, IdentifyErrorMessages, data.message);
331
+ }
332
+ return data;
333
+ }
334
+ /**
335
+ * @internal
336
+ */
337
+ async function parentAppRequest(identify, action, payload) {
338
+ var _a;
339
+ const parentApp = sdkLauncherKit.getParentApplication();
340
+ if (parentApp === null) {
341
+ throw sdkUtil.createError(exports.IdentifyError.NoParentApplication, IdentifyErrorMessages);
342
+ }
343
+ const { host, projectId } = identify.sdk.options;
344
+ // Preserve existing origin (relay) or set from current context (source)
345
+ const origin = (_a = payload === null || payload === void 0 ? void 0 : payload.origin) !== null && _a !== void 0 ? _a : { host, projectId };
346
+ try {
347
+ const response = await sdkLauncherKit.sendSdkRequest(parentApp, action, Object.assign(Object.assign({}, payload), { origin }));
348
+ const { error, data } = response.payload;
349
+ if (error !== undefined) {
350
+ throw sdkUtil.createError(exports.IdentifyError.ParentAppError, IdentifyErrorMessages, error);
351
+ }
352
+ return data;
353
+ }
354
+ catch (err) {
355
+ if (err instanceof sdkUtil.MonterosaError &&
356
+ err.code === sdkLauncherKit.BridgeError.RequestTimeoutError) {
357
+ const errorMessage = sdkUtil.getErrorMessage(err);
358
+ throw sdkUtil.createError(exports.IdentifyError.ParentTimeoutError, IdentifyErrorMessages, errorMessage);
359
+ }
360
+ throw err;
361
+ }
362
+ }
363
+ /**
364
+ * @internal
365
+ */
366
+ function registerIdentifyHook(hook) {
367
+ identifyHooks.push(hook);
368
+ }
369
+ /**
370
+ * @internal
371
+ */
372
+ async function login(identify, credentials) {
373
+ const signature = await getSessionSignatureMemoized(identify, credentials);
374
+ const conn = await sdkConnectKit.getConnect(identify.sdk.options.host);
375
+ await sdkConnectKit.connect(conn);
376
+ await sdkConnectKit.login(conn, ...signature);
377
+ }
378
+ const loginWithRetry = sdkUtil.withRetryAsync(login);
379
+ /**
380
+ * @internal
381
+ */
382
+ async function logout(identify) {
383
+ const conn = await sdkConnectKit.getConnect(identify.sdk.options.host);
384
+ await sdkConnectKit.connect(conn);
385
+ await sdkConnectKit.logout(conn);
386
+ }
387
+ const logoutWithRetry = sdkUtil.withRetryAsync(logout);
388
+ /**
389
+ * @internal
390
+ */
391
+ async function loginTask(identify, credentials) {
392
+ try {
393
+ identify.state = {
394
+ state: 'pending',
395
+ };
396
+ await loginWithRetry(identify, credentials);
397
+ // Update state only if there are no pending tasks in the queue
398
+ if (taskQueue.isEmpty()) {
399
+ identify.state = {
400
+ state: 'logged_in',
401
+ };
402
+ }
403
+ }
404
+ catch (err) {
405
+ taskQueue.clear();
406
+ identify.state = {
407
+ state: 'error',
408
+ error: err instanceof Error ? err.message : 'Unknown error',
409
+ errorType: 'login',
410
+ };
411
+ }
412
+ }
413
+ /**
414
+ * @internal
415
+ */
416
+ async function logoutTask(identify) {
417
+ try {
418
+ identify.state = {
419
+ state: 'pending',
420
+ };
421
+ await logoutWithRetry(identify);
422
+ // Update state only if there are no pending tasks in the queue
423
+ if (taskQueue.isEmpty()) {
424
+ identify.state = {
425
+ state: 'logged_out',
426
+ };
427
+ }
428
+ }
429
+ catch (err) {
430
+ taskQueue.clear();
431
+ identify.state = {
432
+ state: 'error',
433
+ error: err instanceof Error ? err.message : 'Unknown error',
434
+ errorType: 'logout',
435
+ };
436
+ }
437
+ }
438
+ /**
439
+ * @internal
440
+ */
441
+ function enqueueLogin(identify, credentials, prioritise = false) {
442
+ if (identify.options.loginPolicy === 'auto') {
443
+ if (prioritise) {
444
+ taskQueue.enqueueFront(() => loginTask(identify, credentials));
445
+ }
446
+ else {
447
+ taskQueue.enqueue(() => loginTask(identify, credentials));
448
+ }
449
+ }
450
+ for (const experience of getExperiences()) {
451
+ sdkLauncherKit.sendSdkMessage(experience, IdentifyAction.Login, credentials);
452
+ }
453
+ }
454
+ /**
455
+ * @internal
456
+ */
457
+ function enqueueLogout(identify) {
458
+ if (identify.options.loginPolicy === 'auto') {
459
+ taskQueue.enqueue(() => logoutTask(identify));
460
+ }
461
+ for (const experience of getExperiences()) {
462
+ sdkLauncherKit.sendSdkMessage(experience, IdentifyAction.Logout);
463
+ }
464
+ }
465
+ function getIdentify(sdkOrOptions, options) {
466
+ let sdk;
467
+ let identifyOptions;
468
+ if (isSdk(sdkOrOptions)) {
469
+ /**
470
+ * Interface: getIdentify(sdk, options?)
471
+ */
472
+ sdk = sdkOrOptions;
473
+ if (options !== undefined) {
474
+ identifyOptions = options;
475
+ }
476
+ else {
477
+ identifyOptions = {};
478
+ }
479
+ }
480
+ else if (sdkOrOptions !== undefined) {
481
+ /**
482
+ * Interface: getIdentify(options)
483
+ */
484
+ sdk = sdkCore.getSdk();
485
+ identifyOptions = sdkOrOptions;
486
+ }
487
+ else {
488
+ /**
489
+ * Interface: getIdentify()
490
+ */
491
+ sdk = sdkCore.getSdk();
492
+ identifyOptions = {};
493
+ }
494
+ const { options: { projectId }, } = sdk;
495
+ if (identifyKits.has(projectId)) {
496
+ return identifyKits.get(projectId);
497
+ }
498
+ const identify = new Identify(sdk, identifyOptions);
499
+ for (const hook of identifyHooks) {
500
+ hook(identify);
501
+ }
502
+ watchConnectionStatus(identify);
503
+ identifyKits.set(projectId, identify);
504
+ return identify;
505
+ }
506
+ /**
507
+ * A function that requests a user login via the `IdentifyKit` of the Monterosa SDK.
508
+ *
509
+ * @example
510
+ * ```javascript
511
+ * import { configure } from '@monterosa/sdk-core';
512
+ * import { getIdentify, requestLogin } from '@monterosa/sdk-identify-kit';
513
+ *
514
+ * configure({ host: '...', projectId: '...' });
515
+ *
516
+ * try {
517
+ * const identify = getIdentify();
518
+ *
519
+ * await requestLogin(identify);
520
+ *
521
+ * console.log('Login request successful');
522
+ * } catch (err) {
523
+ * console.error('Error requesting login:', error.message)
524
+ * }
525
+ * ```
526
+ *
527
+ * @remarks
528
+ * - If the app is running within a third-party application that uses
529
+ * the Monterosa SDK, the function delegates to the parent app
530
+ * to handle the login process.
531
+ *
532
+ * @param identify - An instance of the `IdentifyKit` class used for user
533
+ * identification.
534
+ * @returns A Promise that resolves with `void` when the login request
535
+ * is completed.
536
+ */
537
+ async function requestLogin(identify) {
538
+ const parentApp = sdkLauncherKit.getParentApplication();
539
+ if (parentApp !== null) {
540
+ await parentAppRequest(identify, IdentifyAction.RequestLogin);
541
+ return;
542
+ }
543
+ identify.emit(IdentifyEvent.LoginRequested);
544
+ }
545
+ /**
546
+ * A function that requests a user login via the `IdentifyKit` of the Space.
547
+ *
548
+ * @example
549
+ * ```javascript
550
+ * import { getSpace } from '@monterosa/sdk-core';
551
+ * import { getIdentify, requestLogout } from '@monterosa/sdk-identify-kit';
552
+ *
553
+ * const space = getSpace('host', 'space-id');
554
+ * const identify = getIdentify(space);
555
+ *
556
+ * try {
557
+ * await requestLogout(identify);
558
+ *
559
+ * console.log('Logout request successful');
560
+ * } catch (err) {
561
+ * console.error('Error requesting logout:', error.message)
562
+ * }
563
+ * ```
564
+ *
565
+ * @remarks
566
+ * - If the app is running within a third-party application that uses
567
+ * the Space, the function delegates to the parent app
568
+ * to handle the logout process.
569
+ *
570
+ * @param identify - An instance of the `IdentifyKit` class used for user
571
+ * identification.
572
+ * @returns A Promise that resolves with `void` when the logout request
573
+ * is completed.
574
+ */
575
+ async function requestLogout(identify) {
576
+ const parentApp = sdkLauncherKit.getParentApplication();
577
+ if (parentApp !== null) {
578
+ await parentAppRequest(identify, IdentifyAction.RequestLogout);
579
+ return;
580
+ }
581
+ identify.emit(IdentifyEvent.LogoutRequested);
582
+ }
583
+ /**
584
+ * @internal
585
+ *
586
+ * Returns a signature for a user session. The signature is based on the
587
+ * user's identifying information provided in the `IdentifyKit` instance.
588
+ *
589
+ * @remarks
590
+ * This function does not handle errors. Callers are responsible for catching
591
+ * and handling failures.
592
+ *
593
+ * @param identify - An instance of the `IdentifyKit` class used for user
594
+ * identification.
595
+ * @param credentials - The credentials of the user.
596
+ *
597
+ * @returns A Promise that resolves to a `Signature` object.
598
+ */
599
+ async function getSessionSignature(identify, credentials) {
600
+ const parentApp = sdkLauncherKit.getParentApplication();
601
+ if (parentApp !== null) {
602
+ const signature = await parentAppRequest(identify, IdentifyAction.GetSessionSignature, credentials);
603
+ return signature;
604
+ }
605
+ if (identify.signature !== null) {
606
+ return identify.signature;
607
+ }
608
+ const url = await identify.getUrl('/user/check');
609
+ const { data } = await api(url, credentials.token);
610
+ const signature = [data.userId, data.timeStamp, data.signature];
611
+ identify.signature = signature;
612
+ return signature;
613
+ }
614
+ /**
615
+ * A memoized version of the `getSessionSignature` function.
616
+ */
617
+ const getSessionSignatureMemoized = sdkUtil.memoizePromise(getSessionSignature, (identify, credentials) => credentials.token, {
618
+ clearOnResolve: true,
619
+ clearOnReject: true,
620
+ });
621
+ /**
622
+ * The function that takes an instance of `IdentifyKit` as its argument and
623
+ * returns a Promise that resolves to a key-value object representing user data.
624
+ *
625
+ * @example
626
+ * ```javascript
627
+ * import { configure } from '@monterosa/sdk-core';
628
+ * import { getIdentify, getUserData } from '@monterosa/sdk-identify-kit';
629
+ *
630
+ * configure({ host: '...', projectId: '...' });
631
+ *
632
+ * const identify = getIdentify();
633
+ * const userData = await getUserData(identify);
634
+ *
635
+ * console.log('User data:', userData);
636
+ * ```
637
+ *
638
+ * @remarks
639
+ * - If the app is running within a third-party application that uses
640
+ * the Monterosa SDK, the function delegates to the parent app
641
+ * to get user data.
642
+ *
643
+ * - If the request is successful, the function resolves with a key-value object
644
+ * representing user data. If not, a `MonterosaError` is thrown.
645
+ *
646
+ * @param identify - An instance of `IdentifyKit` that provides the user
647
+ * identification functionality.
648
+ * @returns A Promise that resolves to a key-value object representing user data.
649
+ * The structure and content of the user data object depend on the identify
650
+ * service provider and may vary. It typically contains information about the user,
651
+ * but the specific fields are determined by the Identify service provider.
652
+ */
653
+ async function getUserData(identify) {
654
+ const parentApp = sdkLauncherKit.getParentApplication();
655
+ if (parentApp !== null) {
656
+ const userData = await parentAppRequest(identify, IdentifyAction.GetUserData);
657
+ return userData;
658
+ }
659
+ // Return cached user data if available
660
+ if (identify.userData !== null) {
661
+ return identify.userData;
662
+ }
663
+ if (identify.credentials === null) {
664
+ throw sdkUtil.createError(exports.IdentifyError.NoCredentials, IdentifyErrorMessages);
665
+ }
666
+ const url = await identify.getUrl('/user');
667
+ const { data } = await api(url, identify.credentials.token);
668
+ identify.userData = data;
669
+ return data;
670
+ }
671
+ /**
672
+ * Sets the user's authentication credentials.
673
+ *
674
+ * @example
675
+ * ```javascript
676
+ * import { configure } from '@monterosa/sdk-core';
677
+ * import { getIdentify, setCredentials } from '@monterosa/sdk-identify-kit';
678
+ *
679
+ * configure({ host: '...', projectId: '...' });
680
+ *
681
+ * const credentials = { token: 'abc123' };
682
+ * const identify = getIdentify();
683
+ *
684
+ * await setCredentials(identify, credentials)
685
+ * ```
686
+ *
687
+ * @remarks
688
+ * - If the app is running within a third-party application that uses
689
+ * the Monterosa SDK, the function delegates to the parent app
690
+ * to set user credentials.
691
+ *
692
+ * - If the request is successful, the function resolves to `void`.
693
+ * If not, a `MonterosaError` is thrown.
694
+ *
695
+ * @param identify - An instance of `IdentifyKit` that provides the user
696
+ * identification functionality.
697
+ * @param credentials - An object representing the user's authentication
698
+ * credentials.
699
+ * @returns A Promise that resolves to `void`.
700
+ */
701
+ async function setCredentials(identify, credentials) {
702
+ const parentApp = sdkLauncherKit.getParentApplication();
703
+ if (parentApp !== null) {
704
+ await parentAppRequest(identify, IdentifyAction.SetCredentials, credentials);
705
+ return;
706
+ }
707
+ const shouldLogin = identify.credentials === null;
708
+ identify.credentials = credentials;
709
+ if (shouldLogin) {
710
+ enqueueLogin(identify, credentials);
711
+ }
712
+ }
713
+ /**
714
+ * Clears the user's authentication credentials.
715
+ *
716
+ * @example
717
+ * ```javascript
718
+ * import { configure } from '@monterosa/sdk-core';
719
+ * import { getIdentify, clearCredentials } from '@monterosa/sdk-identify-kit';
720
+ *
721
+ * configure({ host: '...', projectId: '...' });
722
+ *
723
+ * const identify = getIdentify();
724
+ *
725
+ * await clearCredentials(identify);
726
+ * ```
727
+ *
728
+ * @remarks
729
+ * - If the app is running within a third-party application that uses
730
+ * the Monterosa SDK, the function delegates to the parent app
731
+ * to clear user credentials.
732
+ *
733
+ * - If the request is successful, the function resolves to `void`.
734
+ * If not, a `MonterosaError` is thrown.
735
+ *
736
+ * @param identify - An instance of `IdentifyKit` that provides the user
737
+ * identification functionality.
738
+ * @returns A Promise that resolves to `void`.
739
+ */
740
+ async function clearCredentials(identify) {
741
+ const parentApp = sdkLauncherKit.getParentApplication();
742
+ if (parentApp !== null) {
743
+ await parentAppRequest(identify, IdentifyAction.ClearCredentials);
744
+ return;
745
+ }
746
+ const shouldLogout = identify.credentials !== null;
747
+ identify.credentials = null;
748
+ identify.userData = null;
749
+ identify.signature = null;
750
+ if (shouldLogout) {
751
+ enqueueLogout(identify);
752
+ }
753
+ }
754
+ /**
755
+ * Registers a callback function that will be called whenever the `LoginState`
756
+ * object associated with the `IdentifyKit` instance is updated.
757
+ *
758
+ * @example
759
+ * ```javascript
760
+ * import { configure } from '@monterosa/sdk-core';
761
+ * import { getIdentify, onStateUpdated } from '@monterosa/sdk-identify-kit';
762
+ *
763
+ * configure({ host: '...', projectId: '...' });
764
+ *
765
+ * const identify = getIdentify();
766
+ *
767
+ * const unsubscribe = onStateUpdated(identify, (state) => {
768
+ * console.log("State updated:", state);
769
+ * });
770
+ *
771
+ * // Call unsubscribe() to unregister the callback function
772
+ * // unsubscribe();
773
+ * ```
774
+ *
775
+ * @param identify - An instance of `IdentifyKit` that provides the user
776
+ * identification functionality.
777
+ * @param callback - The callback function to register. This function will be
778
+ * called with the updated `LoginState` object as its only argument.
779
+ * @returns An `Unsubscribe` function that can be called to unregister
780
+ * the callback function.
781
+ */
782
+ function onStateUpdated(identify, callback) {
783
+ return sdkUtil.subscribe(identify, IdentifyEvent.StateUpdated, callback);
784
+ }
785
+ /**
786
+ * Registers a callback function that will be called whenever the `Credentials`
787
+ * object associated with the `IdentifyKit` instance is updated.
788
+ *
789
+ * @example
790
+ * ```javascript
791
+ * import { configure } from '@monterosa/sdk-core';
792
+ * import { getIdentify, onCredentialsUpdated } from '@monterosa/sdk-identify-kit';
793
+ *
794
+ * configure({ host: '...', projectId: '...' });
795
+ *
796
+ * const identify = getIdentify();
797
+ *
798
+ * const unsubscribe = onCredentialsUpdated(identify, (credentials) => {
799
+ * if (credentials !== null) {
800
+ * console.log("Credentials updated:", credentials);
801
+ * } else {
802
+ * console.log("Credentials cleared.");
803
+ * }
804
+ * });
805
+ *
806
+ * // Call unsubscribe() to unregister the callback function
807
+ * // unsubscribe();
808
+ * ```
809
+ *
810
+ * @param identify - An instance of `IdentifyKit` that provides the user
811
+ * identification functionality.
812
+ * @param callback - The callback function to register. This function will be
813
+ * called with the updated `Credentials` object as its only argument.
814
+ * If the value `null` is received, it indicates that the signature has
815
+ * been cleared
816
+ * @returns An `Unsubscribe` function that can be called to unregister
817
+ * the callback function.
818
+ */
819
+ function onCredentialsUpdated(identify, callback) {
820
+ return sdkUtil.subscribe(identify, IdentifyEvent.CredentialsUpdated, callback);
821
+ }
822
+ /**
823
+ * Registers a callback function that will be called whenever the `Signature`
824
+ * object associated with the `IdentifyKit` instance is updated.
825
+ *
826
+ * @example
827
+ * ```javascript
828
+ * import { configure } from '@monterosa/sdk-core';
829
+ * import { getIdentify, onSignatureUpdated } from '@monterosa/sdk-identify-kit';
830
+ *
831
+ * configure({ host: '...', projectId: '...' });
832
+ *
833
+ * const identify = getIdentify();
834
+ *
835
+ * const unsubscribe = onSignatureUpdated(identify, (signature) => {
836
+ * if (signature !== null) {
837
+ * console.log("Signature updated:", signature);
838
+ * } else {
839
+ * console.log("Signature cleared.");
840
+ * }
841
+ * });
842
+ *
843
+ * // Call unsubscribe() to unregister the callback function
844
+ * // unsubscribe();
845
+ * ```
846
+ *
847
+ * @param identify - An instance of `IdentifyKit` that provides the user
848
+ * identification functionality.
849
+ * @param callback - The callback function to register. This function will be
850
+ * called with the updated `Signature` object as its only argument.
851
+ * If the value `null` is received, it indicates that the signature has
852
+ * been cleared
853
+ * @returns An `Unsubscribe` function that can be called to unregister
854
+ * the callback function.
855
+ */
856
+ function onSignatureUpdated(identify, callback) {
857
+ return sdkUtil.subscribe(identify, IdentifyEvent.SignatureUpdated, callback);
858
+ }
859
+ /**
860
+ * Registers a callback function that will be called whenever the `UserData`
861
+ * object associated with the `IdentifyKit` instance is updated.
862
+ *
863
+ * @example
864
+ * ```javascript
865
+ * import { configure } from '@monterosa/sdk-core';
866
+ * import { getIdentify, onUserDataUpdated } from '@monterosa/sdk-identify-kit';
867
+ *
868
+ * configure({ host: '...', projectId: '...' });
869
+ *
870
+ * const identify = getIdentify();
871
+ *
872
+ * const unsubscribe = onUserDataUpdated(identify, (userData) => {
873
+ * if (userData !== null) {
874
+ * console.log("User's data updated:", userData);
875
+ * } else {
876
+ * console.log("User's data cleared.");
877
+ * }
878
+ * });
879
+ *
880
+ * // Call unsubscribe() to unregister the callback function
881
+ * // unsubscribe();
882
+ * ```
883
+ *
884
+ * @param identify - An instance of `IdentifyKit` that provides the user
885
+ * identification functionality.
886
+ * @param callback - The callback function to register. This function will be
887
+ * called with the updated `UserData` object as its only argument.
888
+ * If the value `null` is received, it indicates that the user's data has
889
+ * been cleared
890
+ * @returns An `Unsubscribe` function that can be called to unregister
891
+ * the callback function.
892
+ */
893
+ function onUserDataUpdated(identify, callback) {
894
+ return sdkUtil.subscribe(identify, IdentifyEvent.UserdataUpdated, callback);
895
+ }
896
+ /**
897
+ * Registers a callback function that will be called when a login is requested
898
+ * by an Experience.
899
+ *
900
+ * @example
901
+ * ```javascript
902
+ * import { configure } from '@monterosa/sdk-core';
903
+ * import { getIdentify, onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';
904
+ *
905
+ * configure({ host: '...', projectId: '...' });
906
+ *
907
+ * const identify = getIdentify();
908
+ *
909
+ * const unsubscribe = onLoginRequestedByExperience(identify, () => {
910
+ * showLoginForm();
911
+ * });
912
+ *
913
+ * // Call unsubscribe() to unregister the callback function
914
+ * // unsubscribe();
915
+ * ```
916
+ *
917
+ * @param identify - An instance of `IdentifyKit` that provides the user
918
+ * identification functionality.
919
+ * @param callback - The callback function to register. This function will
920
+ * be called when a login is requested by an Experience.
921
+ * @returns An `Unsubscribe` function that can be called to unregister
922
+ * the callback function.
923
+ */
924
+ function onLoginRequestedByExperience(identify, callback) {
925
+ return sdkUtil.subscribe(identify, IdentifyEvent.LoginRequested, callback);
926
+ }
927
+ /**
928
+ * Registers a callback function that will be called when a logout is requested
929
+ * by an Experience.
930
+ *
931
+ * @example
932
+ * ```javascript
933
+ * import { getSpace } from '@monterosa/sdk-core';
934
+ * import { getIdentify, onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';
935
+ *
936
+ * const space = getSpace('host', 'space-id');
937
+ * const identify = getIdentify(space);
938
+ *
939
+ * const unsubscribe = onLogoutRequestedByExperience(identify, () => {
940
+ * // logout requested by experience
941
+ * // perform logout from Auth service
942
+ * });
943
+ *
944
+ * // Call unsubscribe() to unregister the callback function
945
+ * // unsubscribe();
946
+ * ```
947
+ *
948
+ * @param identify - An instance of `IdentifyKit` that provides the user
949
+ * identification functionality.
950
+ * @param callback - The callback function to register. This function will
951
+ * be called when a logout is requested by an Experience.
952
+ * @returns An `Unsubscribe` function that can be called to unregister
953
+ * the callback function.
954
+ */
955
+ function onLogoutRequestedByExperience(identify, callback) {
956
+ return sdkUtil.subscribe(identify, IdentifyEvent.LogoutRequested, callback);
957
+ }
958
+ /**
959
+ *
960
+ * @internal
961
+ */
962
+ async function watchConnectionStatus(identify) {
963
+ const conn = await sdkConnectKit.getConnect(identify.sdk.options.host);
964
+ sdkConnectKit.onConnected(conn, () => {
965
+ if (identify.shouldLoginOnReconnect) {
966
+ enqueueLogin(identify, identify.credentials, true);
967
+ }
968
+ taskQueue.resume();
969
+ });
970
+ sdkConnectKit.onConnecting(conn, () => {
971
+ taskQueue.pause();
972
+ // If the user was logged in before the connection loss, set the state
973
+ // to pending to notify that the user is no longer logged in and a login
974
+ // attempt will be made when the connection is restored.
975
+ if (identify.state.state === 'logged_in') {
976
+ identify.state = {
977
+ state: 'pending',
978
+ };
979
+ }
980
+ });
981
+ sdkConnectKit.onDisconnected(conn, () => {
982
+ taskQueue.pause();
983
+ taskQueue.clear();
984
+ // If the user was logged in before the connection loss, set the state
985
+ // to logged_out to notify that the user is no longer logged in.
986
+ if (identify.state.state === 'logged_in') {
987
+ identify.state = {
988
+ state: 'logged_out',
989
+ };
990
+ }
991
+ });
992
+ }
993
+
994
+ /**
995
+ * @license
996
+ * @monterosa/sdk-identify-kit
997
+ *
998
+ * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.
999
+ *
1000
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
1001
+ */
1002
+ /**
1003
+ * @internal
1004
+ */
1005
+ function parentMessagesHook(identify) {
1006
+ const parentApp = sdkLauncherKit.getParentApplication();
1007
+ if (parentApp === null) {
1008
+ return () => { };
1009
+ }
1010
+ return sdkLauncherKit.onSdkMessage(parentApp, async (message) => {
1011
+ switch (message.action) {
1012
+ case IdentifyAction.OnCredentialsUpdated: {
1013
+ identify.credentials = message.payload.data;
1014
+ break;
1015
+ }
1016
+ case IdentifyAction.OnSessionSignatureUpdated: {
1017
+ identify.signature = message.payload.data;
1018
+ break;
1019
+ }
1020
+ case IdentifyAction.OnUserDataUpdated: {
1021
+ identify.userData = message.payload.data;
1022
+ break;
1023
+ }
1024
+ case IdentifyAction.Login: {
1025
+ enqueueLogin(identify, message.payload);
1026
+ break;
1027
+ }
1028
+ case IdentifyAction.Logout: {
1029
+ enqueueLogout(identify);
1030
+ break;
1031
+ }
1032
+ }
1033
+ });
1034
+ }
1035
+ /**
1036
+ * Finds an existing SDK with matching projectId, or creates a new one.
1037
+ */
1038
+ function getOrConfigureSdk(host, projectId) {
1039
+ const existingSdk = sdkCore.getSdks().find((sdk) => sdk.options.projectId === projectId);
1040
+ return existingSdk !== null && existingSdk !== void 0 ? existingSdk : sdkCore.configure({ host, projectId }, projectId);
1041
+ }
1042
+ /**
1043
+ * @internal
1044
+ */
1045
+ function handleExperienceEmbedded(experience) {
1046
+ const identify = getIdentify(experience.sdk);
1047
+ // Send login action with current credentials to the new experience if available.
1048
+ // The bridge queues this message until the experience is initialised.
1049
+ if (identify.credentials) {
1050
+ sdkLauncherKit.sendSdkMessage(experience, IdentifyAction.Login, identify.credentials);
1051
+ }
1052
+ const credentialsUpdatedUnsub = onCredentialsUpdated(identify, (data) => {
1053
+ sdkLauncherKit.sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {
1054
+ data,
1055
+ });
1056
+ });
1057
+ const signatureUpdatedUnsub = onSignatureUpdated(identify, (data) => {
1058
+ sdkLauncherKit.sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {
1059
+ data,
1060
+ });
1061
+ });
1062
+ const userDataUpdatedUnsub = onUserDataUpdated(identify, (data) => {
1063
+ sdkLauncherKit.sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {
1064
+ data,
1065
+ });
1066
+ });
1067
+ const sdkMessageUnsub = sdkLauncherKit.onSdkMessage(experience, async (message) => {
1068
+ if (!Object.values(IdentifyAction).includes(message.action)) {
1069
+ return;
1070
+ }
1071
+ // Extract origin context from payload if available.
1072
+ // New clients include origin (host, projectId) to ensure correct project context
1073
+ // in multilevel integrations. Old clients don't send origin, so we fall back
1074
+ // to the experience's SDK to maintain backward compatibility.
1075
+ const { origin } = message.payload;
1076
+ const originSdk = origin
1077
+ ? getOrConfigureSdk(origin.host, origin.projectId)
1078
+ : experience.sdk;
1079
+ const originIdentify = getIdentify(originSdk);
1080
+ const respond = (payload) => sdkLauncherKit.respondToSdkMessage(experience, message, payload);
1081
+ try {
1082
+ switch (message.action) {
1083
+ case IdentifyAction.RequestLogin: {
1084
+ await requestLogin(originIdentify);
1085
+ respond();
1086
+ break;
1087
+ }
1088
+ case IdentifyAction.RequestLogout: {
1089
+ await requestLogout(identify);
1090
+ respond();
1091
+ break;
1092
+ }
1093
+ case IdentifyAction.GetUserData: {
1094
+ const data = await getUserData(identify);
1095
+ respond({ data });
1096
+ break;
1097
+ }
1098
+ case IdentifyAction.GetSessionSignature: {
1099
+ const signature = await getSessionSignatureMemoized(identify, message.payload);
1100
+ respond({ data: signature });
1101
+ break;
1102
+ }
1103
+ case IdentifyAction.SetCredentials: {
1104
+ await setCredentials(originIdentify, {
1105
+ token: message.payload.token,
1106
+ });
1107
+ respond();
1108
+ break;
1109
+ }
1110
+ case IdentifyAction.ClearCredentials: {
1111
+ await clearCredentials(identify);
1112
+ respond();
1113
+ break;
1114
+ }
1115
+ }
1116
+ }
1117
+ catch (err) {
1118
+ respond({
1119
+ error: sdkUtil.getErrorMessage(err),
1120
+ });
1121
+ }
1122
+ });
1123
+ addExperience(experience, [
1124
+ credentialsUpdatedUnsub,
1125
+ signatureUpdatedUnsub,
1126
+ userDataUpdatedUnsub,
1127
+ sdkMessageUnsub,
1128
+ ]);
1129
+ }
1130
+ /**
1131
+ * @internal
1132
+ */
1133
+ function handleExperienceUnmounted(experience) {
1134
+ deleteExperience(experience);
1135
+ }
1136
+ sdkLauncherKit.onStateChanged((experience, state) => {
1137
+ if (state === 'mounted') {
1138
+ handleExperienceEmbedded(experience);
1139
+ }
1140
+ else if (state === 'unmounted') {
1141
+ handleExperienceUnmounted(experience);
1142
+ }
1143
+ });
1144
+ registerIdentifyHook(parentMessagesHook);
1145
+
1146
+ exports.clearCredentials = clearCredentials;
1147
+ exports.getIdentify = getIdentify;
1148
+ exports.getUserData = getUserData;
1149
+ exports.onCredentialsUpdated = onCredentialsUpdated;
1150
+ exports.onLoginRequestedByExperience = onLoginRequestedByExperience;
1151
+ exports.onLogoutRequestedByExperience = onLogoutRequestedByExperience;
1152
+ exports.onSignatureUpdated = onSignatureUpdated;
1153
+ exports.onStateUpdated = onStateUpdated;
1154
+ exports.onUserDataUpdated = onUserDataUpdated;
1155
+ exports.requestLogin = requestLogin;
1156
+ exports.requestLogout = requestLogout;
1157
+ exports.setCredentials = setCredentials;
1158
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/types.ts","../src/constants.ts","../src/identify.ts","../src/experiences.ts","../src/api.ts","../src/bridge.ts"],"sourcesContent":["/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk } from '@monterosa/sdk-core';\nimport { Emitter, Unsubscribe } from '@monterosa/sdk-util';\n\n/**\n * Represents user authentication credentials.\n *\n * @remarks\n * The `token` property can be either the literal `'cookie'` for cookie-based\n * authentication or a string value for bearer token authentication.\n *\n * @example\n * ```javascript\n * // Bearer token authentication\n * const credentials: Credentials = { token: \"abc123\" };\n *\n * // Cookie-based authentication\n * const credentials: Credentials = { token: \"cookie\" };\n * ```\n */\nexport type Credentials = {\n token: 'cookie' | string;\n};\n\n/**\n * A tuple representing a digital signature: `[userId, timestamp, signature]`.\n *\n * @example\n * ```javascript\n * const signature: Signature = [\"user123\", 1646956195, \"abc123\"];\n * ```\n */\nexport type Signature = [userId: string, timestamp: number, signature: string];\n\n/**\n * A key-value object representing user profile data.\n *\n * @remarks\n * Contains `userId`, `timestamp`, and `signature` alongside any\n * additional custom properties.\n *\n * @example\n * ```javascript\n * const userData: UserData = {\n * userId: \"user123\",\n * timeStamp: 1646956195,\n * signature: \"abc123\",\n * name: \"John Doe\",\n * age: 30,\n * email: \"john.doe@example.com\"\n * };\n * ```\n */\nexport type UserData = {\n [key: string]: any;\n};\n\nexport type ResponsePayload<T> = {\n data: T;\n error?: string;\n};\n\n/**\n * @internal\n */\nexport type IdentifyHook = (identify: IdentifyKit) => Unsubscribe;\n\nexport type LoginState = {\n state: 'logged_out' | 'logged_in' | 'pending' | 'error';\n error?: string;\n errorType?: 'login' | 'logout';\n};\n\nexport type LoginPolicy = 'disabled' | 'auto';\n\n/**\n * Configuration options for Identify Kit.\n */\nexport interface IdentifyOptions {\n /**\n * Unique device identifier. Must be persisted and reused across sessions\n * to avoid duplicate user records.\n */\n readonly deviceId?: string;\n /**\n * Authentication strategy. Default: `'email'`.\n */\n readonly strategy?: string;\n /**\n * Identity provider name (e.g. `'aws'` for Cognito).\n */\n readonly provider?: string;\n /**\n * Identify API version. Default: `1`.\n */\n readonly version?: number;\n readonly loginPolicy?: LoginPolicy;\n}\n\n/**\n * Represents an Identify Kit instance. Obtain one via {@link getIdentify}.\n *\n * @remarks\n * This interface is opaque. Interact with it through the standalone\n * functions such as {@link setCredentials}, {@link clearCredentials},\n * and {@link getUserData}.\n */\nexport interface IdentifyKit extends Emitter {\n /**\n * The identify options.\n *\n * @internal\n */\n options: IdentifyOptions;\n /**\n * @internal\n */\n sdk: MonterosaSdk;\n /**\n * @internal\n */\n credentials: Credentials | null;\n /**\n * @internal\n */\n signature: Signature | null;\n /**\n * @internal\n */\n userData: UserData | null;\n /**\n * Whether the user should be automatically logged in when connection is\n * restored. This is true when:\n * - The user was previously logged in successfully\n * - Auto-login is enabled\n * - Credentials are available\n *\n * @internal\n */\n shouldLoginOnReconnect: boolean;\n\n state: LoginState;\n\n /**\n * @internal\n */\n getUrl(path?: string): Promise<string>;\n}\n\nexport interface Response {\n message: string;\n result: number;\n data: {\n [key: string]: any;\n };\n}\n\nexport interface UserResponse extends Response {}\n\nexport interface UserCheckResponse extends Response {\n data: {\n userId: string;\n timeStamp: number;\n signature: string;\n [key: string]: any;\n };\n}\n\n/**\n * @internal\n */\nexport enum IdentifyEvent {\n StateUpdated = 'state_updated',\n LoginRequested = 'login_requested',\n LogoutRequested = 'logout_requested',\n SignatureUpdated = 'signature_updated',\n UserdataUpdated = 'userdata_updated',\n CredentialsUpdated = 'credentials_updated',\n EnmasseLogin = 'enmasse_login',\n}\n\n/**\n * Defines a set of error codes that may be encountered when using the\n * Identify kit of the Monterosa SDK.\n *\n * @example\n * ```javascript\n * try {\n * // some code that uses the IdentifyKit\n * } catch (err) {\n * if (err.code === IdentifyError.NoCredentials) {\n * // handle missing credentials error\n * } else if (err.code === IdentifyError.NotInitialised) {\n * // handle initialization error\n * } else {\n * // handle other error types\n * }\n * }\n * ```\n *\n * @remarks\n * - The `IdentifyError` enum provides a convenient way to handle errors\n * encountered when using the `IdentifyKit` module. By checking the code\n * property of the caught error against the values of the enum, the error\n * type can be determined and appropriate action taken.\n *\n * - The `IdentifyError` enum is not intended to be instantiated or extended.\n */\nexport enum IdentifyError {\n /**\n * Indicates an error occurred during the call to the extension API.\n */\n ExtensionApiError = 'extension_api_error',\n /**\n * Indicates the extension required by the IdentifyKit is not set up properly.\n */\n ExtensionNotSetup = 'extension_not_setup',\n /**\n * Indicates the user's authentication credentials are not available\n * or have expired.\n */\n NoCredentials = 'no_credentials',\n /**\n * Indicates the IdentifyKit has not been initialised properly.\n */\n NotInitialised = 'not_initialised',\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_error',\n /**\n * Indicates an unexpected or invalid login state was encountered.\n */\n UnexpectedState = 'unexpected_state',\n /**\n * Indicates there is no parent application to delegate to.\n */\n NoParentApplication = 'no_parent_application',\n /**\n * Indicates a timeout occurred when communicating with the parent app.\n */\n ParentTimeoutError = 'parent_timeout_error',\n}\n\n/**\n * @internal\n */\nexport const IdentifyErrorMessages = {\n [IdentifyError.ExtensionApiError]: (error: string) =>\n `Identify extension API returned an error: ${error}`,\n [IdentifyError.ExtensionNotSetup]: () =>\n 'Identify extension is not set up for this project',\n [IdentifyError.NoCredentials]: () => 'Identify credentials are not set',\n [IdentifyError.NotInitialised]: () => 'Identify instance is not initialised',\n [IdentifyError.ParentAppError]: (error: string) =>\n `Parent application error: ${error}`,\n [IdentifyError.UnexpectedState]: (state: string) =>\n `Unexpected LoginState: ${state}`,\n [IdentifyError.NoParentApplication]: () =>\n 'No parent application available for delegation',\n [IdentifyError.ParentTimeoutError]: (error: string) =>\n `Parent application timeout: ${error}. Please check if the identify-kit is imported on the parent page.`,\n};\n\nexport enum IdentifyAction {\n Login = 'identifyLogin',\n Logout = 'identifyLogout',\n RequestLogin = 'identifyRequestLogin',\n RequestLogout = 'identifyRequestLogout',\n GetUserData = 'identifyGetUserData',\n GetSessionSignature = 'identifyGetSessionSignature',\n SetCredentials = 'identifySetCredentials',\n ClearCredentials = 'identifyClearCredentials',\n OnStateUpdated = 'identifyOnStateUpdated',\n OnCredentialsUpdated = 'identifyOnCredentialsUpdated',\n OnUserDataUpdated = 'identifyOnUserDataUpdated',\n OnSessionSignatureUpdated = 'identifyOnSessionSignatureUpdated',\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nexport const EXTENSION_ID = 'lvis-id-custom-tab';\n\nexport const SIGNATURE_TTL = 10_000;\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, getDeviceId } from '@monterosa/sdk-core';\nimport { Emitter, createError } from '@monterosa/sdk-util';\nimport { fetchListings } from '@monterosa/sdk-interact-interop';\n\nimport {\n IdentifyKit,\n IdentifyOptions,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n LoginState,\n Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport { EXTENSION_ID, SIGNATURE_TTL } from './constants';\n\nexport default class Identify extends Emitter implements IdentifyKit {\n private wasLoggedIn: boolean = false;\n\n private host?: string;\n private readonly _options: IdentifyOptions;\n\n private _credentials: Credentials | null = null;\n private _signature: Signature | null = null;\n private _userData: UserData | null = null;\n private signatureExpireTimeout!: ReturnType<typeof setTimeout>;\n private userDataExpireTimeout!: ReturnType<typeof setTimeout>;\n\n _state: LoginState = {\n state: 'logged_out',\n };\n\n constructor(public sdk: MonterosaSdk, options: IdentifyOptions = {}) {\n super();\n\n this._options = {\n strategy: 'email',\n deviceId: getDeviceId(),\n version: 1,\n loginPolicy: 'disabled',\n ...options,\n };\n }\n\n private static async fetchIdentifyHost(\n host: string,\n projectId: string,\n ): Promise<string> {\n const listings = await fetchListings(host, projectId);\n const extensionAssets = listings.assets?.[EXTENSION_ID] ?? [];\n\n const endpointAsset = extensionAssets.find(\n ({ name }) => name === 'endpoint',\n );\n\n if (!endpointAsset) {\n throw createError(IdentifyError.ExtensionNotSetup, IdentifyErrorMessages);\n }\n\n return endpointAsset.data;\n }\n\n get state(): LoginState {\n return this._state;\n }\n\n set state(state: LoginState) {\n if (this._state.state === state.state) {\n return;\n }\n\n switch (state.state) {\n case 'logged_in':\n this.wasLoggedIn = true;\n break;\n case 'logged_out':\n case 'error':\n this.wasLoggedIn = false;\n break;\n case 'pending':\n // preserve wasLoggedIn value during transitional state\n break;\n default: {\n // Exhaustiveness check: TypeScript errors if a new state is added\n // but not handled. This is a compile-time error.\n //\n // See: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking\n const exhaustiveCheck: never = state.state;\n\n throw createError(\n IdentifyError.UnexpectedState,\n IdentifyErrorMessages,\n String(exhaustiveCheck),\n );\n }\n }\n\n this._state = state;\n\n this.emit(IdentifyEvent.StateUpdated, state);\n }\n\n get options() {\n return this._options;\n }\n\n set signature(signature: Signature | null) {\n if (this._signature === signature) {\n return;\n }\n\n this._signature = signature;\n\n clearTimeout(this.signatureExpireTimeout);\n\n if (signature !== null) {\n this.signatureExpireTimeout = setTimeout(() => {\n this.signature = null;\n }, SIGNATURE_TTL);\n }\n\n this.emit(IdentifyEvent.SignatureUpdated, this.signature);\n }\n\n get signature(): Signature | null {\n return this._signature;\n }\n\n set credentials(credentials: Credentials | null) {\n if (this._credentials === credentials) {\n return;\n }\n\n this._credentials = credentials;\n\n this.emit(IdentifyEvent.CredentialsUpdated, credentials);\n }\n\n get credentials(): Credentials | null {\n return this._credentials;\n }\n\n set userData(data: UserData | null) {\n if (this._userData === data) {\n return;\n }\n\n this._userData = data;\n\n clearTimeout(this.userDataExpireTimeout);\n\n this.emit(IdentifyEvent.UserdataUpdated, data);\n }\n\n get userData(): UserData | null {\n return this._userData;\n }\n\n get shouldLoginOnReconnect(): boolean {\n return (\n this.wasLoggedIn &&\n this.options.loginPolicy === 'auto' &&\n this.credentials !== null\n );\n }\n\n reset() {\n this.credentials = null;\n this.userData = null;\n this.signature = null;\n this.wasLoggedIn = false;\n }\n\n async getUrl(path: string = '') {\n const {\n options: { host, projectId },\n } = this.sdk;\n\n if (this.host === undefined) {\n this.host = await Identify.fetchIdentifyHost(host, projectId);\n }\n\n const url = new URL(this.host!);\n const { version, deviceId, strategy, provider } = this._options;\n\n url.pathname = `/v${version}${path}`;\n\n url.searchParams.set('projectId', projectId);\n url.searchParams.set('deviceId', deviceId!);\n url.searchParams.set('strategy', strategy!);\n\n if (provider !== undefined) {\n url.searchParams.set('provider', provider);\n }\n\n return url.toString();\n }\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2025-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport type { Unsubscribe } from '@monterosa/sdk-util';\nimport type { Experience } from '@monterosa/sdk-launcher-kit';\n\ntype ExperienceEntry = {\n experience: Experience;\n unsubs: Set<Unsubscribe>;\n};\n\nconst entries = new Map<string, ExperienceEntry>();\n\nexport function getExperiences(): Experience[] {\n return Array.from(entries.values()).map((entry) => entry.experience);\n}\n\nexport function addExperience(\n experience: Experience,\n unsubs: Unsubscribe[] = [],\n) {\n entries.set(experience.id, {\n experience,\n unsubs: new Set(unsubs),\n });\n}\n\nexport function deleteExperience(experience: Experience) {\n const entry = entries.get(experience.id);\n\n if (entry) {\n entry.unsubs.forEach((unsub) => unsub());\n entries.delete(experience.id);\n }\n}\n","/**\n * @license\n * identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, Sdk, getSdk } from '@monterosa/sdk-core';\nimport {\n Unsubscribe,\n TaskQueue,\n subscribe,\n createError,\n withRetryAsync,\n memoizePromise,\n MonterosaError,\n getErrorMessage,\n} from '@monterosa/sdk-util';\nimport {\n getConnect,\n login as connectLogin,\n logout as connectLogout,\n connect,\n onConnected,\n onConnecting,\n onDisconnected,\n} from '@monterosa/sdk-connect-kit';\nimport {\n Payload,\n getParentApplication,\n sendSdkRequest,\n sendSdkMessage,\n BridgeError,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n Response,\n ResponsePayload,\n UserResponse,\n UserCheckResponse,\n LoginState,\n Credentials,\n Signature,\n UserData,\n IdentifyOptions,\n IdentifyAction,\n IdentifyHook,\n IdentifyEvent,\n IdentifyError,\n IdentifyErrorMessages,\n} from './types';\n\nimport Identify from './identify';\nimport { getExperiences } from './experiences';\n\nconst identifyKits: Map<string, Identify> = new Map();\nconst identifyHooks: IdentifyHook[] = [];\n\n/**\n * @internal\n */\nexport const taskQueue = new TaskQueue();\n\nfunction isSdk(value: MonterosaSdk | any): value is MonterosaSdk {\n return value instanceof Sdk;\n}\n\nasync function api<T extends Response>(\n url: string,\n token: Credentials['token'],\n method: string = 'GET',\n): Promise<T> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n };\n\n let credentials: RequestCredentials | undefined;\n\n // Only include Authorization header for bearer token authentication\n // When token is 'cookie', use credentials: 'include' to ensure HttpOnly\n // cookies are sent\n if (token === 'cookie') {\n // Use credentials: 'include' to ensure HttpOnly cookies are sent\n credentials = 'include';\n } else {\n headers.Authorization = `Bearer ${token}`;\n }\n\n const response = await fetch(url, {\n method,\n headers,\n credentials,\n });\n\n const data = (await response.json()) as T;\n\n if (data.result < 0) {\n throw createError(\n IdentifyError.ExtensionApiError,\n IdentifyErrorMessages,\n data.message,\n );\n }\n\n return data;\n}\n\n/**\n * @internal\n */\nexport async function parentAppRequest<T>(\n identify: IdentifyKit,\n action: IdentifyAction,\n payload?: Payload,\n): Promise<T> {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n throw createError(IdentifyError.NoParentApplication, IdentifyErrorMessages);\n }\n\n const { host, projectId } = identify.sdk.options;\n\n // Preserve existing origin (relay) or set from current context (source)\n const origin = payload?.origin ?? { host, projectId };\n\n try {\n const response = await sendSdkRequest(parentApp, action, {\n ...payload,\n origin,\n });\n\n const { error, data } = response.payload as ResponsePayload<T>;\n\n if (error !== undefined) {\n throw createError(\n IdentifyError.ParentAppError,\n IdentifyErrorMessages,\n error,\n );\n }\n\n return data;\n } catch (err) {\n if (\n err instanceof MonterosaError &&\n err.code === BridgeError.RequestTimeoutError\n ) {\n const errorMessage = getErrorMessage(err);\n\n throw createError(\n IdentifyError.ParentTimeoutError,\n IdentifyErrorMessages,\n errorMessage,\n );\n }\n\n throw err;\n }\n}\n\n/**\n * @internal\n */\nexport function registerIdentifyHook(hook: IdentifyHook) {\n identifyHooks.push(hook);\n}\n\n/**\n * @internal\n */\nasync function login(identify: IdentifyKit, credentials: Credentials) {\n const signature = await getSessionSignatureMemoized(identify, credentials);\n\n const conn = await getConnect(identify.sdk.options.host);\n\n await connect(conn);\n await connectLogin(conn, ...signature);\n}\n\nconst loginWithRetry = withRetryAsync(login);\n\n/**\n * @internal\n */\nasync function logout(identify: IdentifyKit) {\n const conn = await getConnect(identify.sdk.options.host);\n\n await connect(conn);\n await connectLogout(conn);\n}\n\nconst logoutWithRetry = withRetryAsync(logout);\n\n/**\n * @internal\n */\nexport async function loginTask(\n identify: IdentifyKit,\n credentials: Credentials,\n) {\n try {\n identify.state = {\n state: 'pending',\n };\n\n await loginWithRetry(identify, credentials);\n\n // Update state only if there are no pending tasks in the queue\n if (taskQueue.isEmpty()) {\n identify.state = {\n state: 'logged_in',\n };\n }\n } catch (err) {\n taskQueue.clear();\n\n identify.state = {\n state: 'error',\n error: err instanceof Error ? err.message : 'Unknown error',\n errorType: 'login',\n };\n }\n}\n\n/**\n * @internal\n */\nexport async function logoutTask(identify: IdentifyKit) {\n try {\n identify.state = {\n state: 'pending',\n };\n\n await logoutWithRetry(identify);\n\n // Update state only if there are no pending tasks in the queue\n if (taskQueue.isEmpty()) {\n identify.state = {\n state: 'logged_out',\n };\n }\n } catch (err) {\n taskQueue.clear();\n\n identify.state = {\n state: 'error',\n error: err instanceof Error ? err.message : 'Unknown error',\n errorType: 'logout',\n };\n }\n}\n\n/**\n * @internal\n */\nexport function enqueueLogin(\n identify: IdentifyKit,\n credentials: Credentials,\n prioritise: boolean = false,\n) {\n if (identify.options.loginPolicy === 'auto') {\n if (prioritise) {\n taskQueue.enqueueFront(() => loginTask(identify, credentials));\n } else {\n taskQueue.enqueue(() => loginTask(identify, credentials));\n }\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Login, credentials);\n }\n}\n\n/**\n * @internal\n */\nexport function enqueueLogout(identify: IdentifyKit) {\n if (identify.options.loginPolicy === 'auto') {\n taskQueue.enqueue(() => logoutTask(identify));\n }\n\n for (const experience of getExperiences()) {\n sendSdkMessage(experience, IdentifyAction.Logout);\n }\n}\n\n/**\n * A factory function that creates a new instance of the `IdentifyKit` class,\n * which is a kit of the Monterosa SDK used for user identification.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * ```\n *\n * @remarks\n * - The `getIdentify` function returns an instance of the `IdentifyKit` class\n * using optional MonterosaSdk instance as a parameter.\n *\n * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate\n * users and perform other user identification-related operations.\n *\n * - Subsequent calls to getIdentify with the same MonterosaSdk instance will return\n * the same `IdentifyKit` instance.\n *\n * @param sdk - An instance of the MonterosaSdk class.\n * @param options - List of `IdentifyKit` options\n * @returns An instance of the `IdentifyKit` class, which is used for user\n * identification.\n */\n\nexport function getIdentify(\n sdk?: MonterosaSdk,\n options?: IdentifyOptions,\n): IdentifyKit;\n\n/**\n * A factory function that creates a new instance of the `IdentifyKit` class,\n * which is a kit of the Monterosa SDK used for user identification.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * ```\n *\n * @remarks\n * - The `getIdentify` function returns an instance of the `IdentifyKit` class\n * using optional MonterosaSdk instance as a parameter.\n *\n * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate\n * users and perform other user identification-related operations.\n *\n * - Subsequent calls to getIdentify with the same MonterosaSdk instance will return\n * the same `IdentifyKit` instance.\n *\n * @param options - List of `IdentifyKit` options\n * @returns An instance of the `IdentifyKit` class, which is used for user\n * identification.\n */\nexport function getIdentify(options?: IdentifyOptions): IdentifyKit;\n\nexport function getIdentify(\n sdkOrOptions?: MonterosaSdk | IdentifyOptions,\n options?: IdentifyOptions,\n): IdentifyKit {\n let sdk: MonterosaSdk;\n let identifyOptions: IdentifyOptions;\n\n if (isSdk(sdkOrOptions)) {\n /**\n * Interface: getIdentify(sdk, options?)\n */\n\n sdk = sdkOrOptions;\n\n if (options !== undefined) {\n identifyOptions = options;\n } else {\n identifyOptions = {};\n }\n } else if (sdkOrOptions !== undefined) {\n /**\n * Interface: getIdentify(options)\n */\n\n sdk = getSdk();\n identifyOptions = sdkOrOptions;\n } else {\n /**\n * Interface: getIdentify()\n */\n\n sdk = getSdk();\n identifyOptions = {};\n }\n\n const {\n options: { projectId },\n } = sdk;\n\n if (identifyKits.has(projectId)) {\n return identifyKits.get(projectId) as Identify;\n }\n\n const identify = new Identify(sdk, identifyOptions);\n\n for (const hook of identifyHooks) {\n hook(identify);\n }\n\n watchConnectionStatus(identify);\n\n identifyKits.set(projectId, identify);\n\n return identify;\n}\n\n/**\n * A function that requests a user login via the `IdentifyKit` of the Monterosa SDK.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, requestLogin } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * try {\n * const identify = getIdentify();\n *\n * await requestLogin(identify);\n *\n * console.log('Login request successful');\n * } catch (err) {\n * console.error('Error requesting login:', error.message)\n * }\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Monterosa SDK, the function delegates to the parent app\n * to handle the login process.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves with `void` when the login request\n * is completed.\n */\nexport async function requestLogin(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(identify, IdentifyAction.RequestLogin);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LoginRequested);\n}\n\n/**\n * A function that requests a user login via the `IdentifyKit` of the Space.\n *\n * @example\n * ```javascript\n * import { getSpace } from '@monterosa/sdk-core';\n * import { getIdentify, requestLogout } from '@monterosa/sdk-identify-kit';\n *\n * const space = getSpace('host', 'space-id');\n * const identify = getIdentify(space);\n *\n * try {\n * await requestLogout(identify);\n *\n * console.log('Logout request successful');\n * } catch (err) {\n * console.error('Error requesting logout:', error.message)\n * }\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Space, the function delegates to the parent app\n * to handle the logout process.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @returns A Promise that resolves with `void` when the logout request\n * is completed.\n */\nexport async function requestLogout(identify: IdentifyKit): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(identify, IdentifyAction.RequestLogout);\n\n return;\n }\n\n identify.emit(IdentifyEvent.LogoutRequested);\n}\n\n/**\n * @internal\n *\n * Returns a signature for a user session. The signature is based on the\n * user's identifying information provided in the `IdentifyKit` instance.\n *\n * @remarks\n * This function does not handle errors. Callers are responsible for catching\n * and handling failures.\n *\n * @param identify - An instance of the `IdentifyKit` class used for user\n * identification.\n * @param credentials - The credentials of the user.\n *\n * @returns A Promise that resolves to a `Signature` object.\n */\nexport async function getSessionSignature(\n identify: IdentifyKit,\n credentials: Credentials,\n): Promise<Signature> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const signature = await parentAppRequest<Signature>(\n identify,\n IdentifyAction.GetSessionSignature,\n credentials,\n );\n\n return signature;\n }\n\n if (identify.signature !== null) {\n return identify.signature;\n }\n\n const url = await identify.getUrl('/user/check');\n\n const { data } = await api<UserCheckResponse>(url, credentials.token);\n\n const signature: Signature = [data.userId, data.timeStamp, data.signature];\n\n identify.signature = signature;\n\n return signature;\n}\n\n/**\n * A memoized version of the `getSessionSignature` function.\n */\nexport const getSessionSignatureMemoized = memoizePromise(\n getSessionSignature,\n (identify: IdentifyKit, credentials: Credentials) => credentials.token,\n {\n clearOnResolve: true,\n clearOnReject: true,\n },\n);\n\n/**\n * The function that takes an instance of `IdentifyKit` as its argument and\n * returns a Promise that resolves to a key-value object representing user data.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, getUserData } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n * const userData = await getUserData(identify);\n *\n * console.log('User data:', userData);\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Monterosa SDK, the function delegates to the parent app\n * to get user data.\n *\n * - If the request is successful, the function resolves with a key-value object\n * representing user data. If not, a `MonterosaError` is thrown.\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @returns A Promise that resolves to a key-value object representing user data.\n * The structure and content of the user data object depend on the identify\n * service provider and may vary. It typically contains information about the user,\n * but the specific fields are determined by the Identify service provider.\n */\nexport async function getUserData(identify: IdentifyKit): Promise<UserData> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n const userData = await parentAppRequest<UserData>(\n identify,\n IdentifyAction.GetUserData,\n );\n\n return userData;\n }\n\n // Return cached user data if available\n if (identify.userData !== null) {\n return identify.userData;\n }\n\n if (identify.credentials === null) {\n throw createError(IdentifyError.NoCredentials, IdentifyErrorMessages);\n }\n\n const url = await identify.getUrl('/user');\n\n const { data } = await api<UserResponse>(url, identify.credentials.token);\n\n identify.userData = data;\n\n return data;\n}\n\n/**\n * Sets the user's authentication credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, setCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const credentials = { token: 'abc123' };\n * const identify = getIdentify();\n *\n * await setCredentials(identify, credentials)\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Monterosa SDK, the function delegates to the parent app\n * to set user credentials.\n *\n * - If the request is successful, the function resolves to `void`.\n * If not, a `MonterosaError` is thrown.\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param credentials - An object representing the user's authentication\n * credentials.\n * @returns A Promise that resolves to `void`.\n */\nexport async function setCredentials(\n identify: IdentifyKit,\n credentials: Credentials,\n): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(\n identify,\n IdentifyAction.SetCredentials,\n credentials,\n );\n\n return;\n }\n\n const shouldLogin = identify.credentials === null;\n\n identify.credentials = credentials;\n\n if (shouldLogin) {\n enqueueLogin(identify, credentials);\n }\n}\n\n/**\n * Clears the user's authentication credentials.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, clearCredentials } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * await clearCredentials(identify);\n * ```\n *\n * @remarks\n * - If the app is running within a third-party application that uses\n * the Monterosa SDK, the function delegates to the parent app\n * to clear user credentials.\n *\n * - If the request is successful, the function resolves to `void`.\n * If not, a `MonterosaError` is thrown.\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @returns A Promise that resolves to `void`.\n */\nexport async function clearCredentials(identify: IdentifyKit) {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await parentAppRequest<void>(identify, IdentifyAction.ClearCredentials);\n\n return;\n }\n\n const shouldLogout = identify.credentials !== null;\n\n identify.credentials = null;\n identify.userData = null;\n identify.signature = null;\n\n if (shouldLogout) {\n enqueueLogout(identify);\n }\n}\n\n/**\n * Registers a callback function that will be called whenever the `LoginState`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onStateUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onStateUpdated(identify, (state) => {\n * console.log(\"State updated:\", state);\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param callback - The callback function to register. This function will be\n * called with the updated `LoginState` object as its only argument.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onStateUpdated(\n identify: IdentifyKit,\n callback: (state: LoginState) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.StateUpdated, callback);\n}\n\n/**\n * Registers a callback function that will be called whenever the `Credentials`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onCredentialsUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onCredentialsUpdated(identify, (credentials) => {\n * if (credentials !== null) {\n * console.log(\"Credentials updated:\", credentials);\n * } else {\n * console.log(\"Credentials cleared.\");\n * }\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param callback - The callback function to register. This function will be\n * called with the updated `Credentials` object as its only argument.\n * If the value `null` is received, it indicates that the signature has\n * been cleared\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onCredentialsUpdated(\n identify: IdentifyKit,\n callback: (credentials: Credentials | null) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.CredentialsUpdated, callback);\n}\n\n/**\n * Registers a callback function that will be called whenever the `Signature`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onSignatureUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onSignatureUpdated(identify, (signature) => {\n * if (signature !== null) {\n * console.log(\"Signature updated:\", signature);\n * } else {\n * console.log(\"Signature cleared.\");\n * }\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param callback - The callback function to register. This function will be\n * called with the updated `Signature` object as its only argument.\n * If the value `null` is received, it indicates that the signature has\n * been cleared\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onSignatureUpdated(\n identify: IdentifyKit,\n callback: (signature: Signature | null) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.SignatureUpdated, callback);\n}\n\n/**\n * Registers a callback function that will be called whenever the `UserData`\n * object associated with the `IdentifyKit` instance is updated.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onUserDataUpdated } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onUserDataUpdated(identify, (userData) => {\n * if (userData !== null) {\n * console.log(\"User's data updated:\", userData);\n * } else {\n * console.log(\"User's data cleared.\");\n * }\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param callback - The callback function to register. This function will be\n * called with the updated `UserData` object as its only argument.\n * If the value `null` is received, it indicates that the user's data has\n * been cleared\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onUserDataUpdated(\n identify: IdentifyKit,\n callback: (userData: UserData | null) => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.UserdataUpdated, callback);\n}\n\n/**\n * Registers a callback function that will be called when a login is requested\n * by an Experience.\n *\n * @example\n * ```javascript\n * import { configure } from '@monterosa/sdk-core';\n * import { getIdentify, onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * configure({ host: '...', projectId: '...' });\n *\n * const identify = getIdentify();\n *\n * const unsubscribe = onLoginRequestedByExperience(identify, () => {\n * showLoginForm();\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param callback - The callback function to register. This function will\n * be called when a login is requested by an Experience.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onLoginRequestedByExperience(\n identify: IdentifyKit,\n callback: () => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.LoginRequested, callback);\n}\n\n/**\n * Registers a callback function that will be called when a logout is requested\n * by an Experience.\n *\n * @example\n * ```javascript\n * import { getSpace } from '@monterosa/sdk-core';\n * import { getIdentify, onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';\n *\n * const space = getSpace('host', 'space-id');\n * const identify = getIdentify(space);\n *\n * const unsubscribe = onLogoutRequestedByExperience(identify, () => {\n * // logout requested by experience\n * // perform logout from Auth service\n * });\n *\n * // Call unsubscribe() to unregister the callback function\n * // unsubscribe();\n * ```\n *\n * @param identify - An instance of `IdentifyKit` that provides the user\n * identification functionality.\n * @param callback - The callback function to register. This function will\n * be called when a logout is requested by an Experience.\n * @returns An `Unsubscribe` function that can be called to unregister\n * the callback function.\n */\nexport function onLogoutRequestedByExperience(\n identify: IdentifyKit,\n callback: () => void,\n): Unsubscribe {\n return subscribe(identify, IdentifyEvent.LogoutRequested, callback);\n}\n\n/**\n *\n * @internal\n */\nexport async function watchConnectionStatus(identify: IdentifyKit) {\n const conn = await getConnect(identify.sdk.options.host);\n\n onConnected(conn, () => {\n if (identify.shouldLoginOnReconnect) {\n enqueueLogin(identify, identify.credentials!, true);\n }\n\n taskQueue.resume();\n });\n\n onConnecting(conn, () => {\n taskQueue.pause();\n\n // If the user was logged in before the connection loss, set the state\n // to pending to notify that the user is no longer logged in and a login\n // attempt will be made when the connection is restored.\n if (identify.state.state === 'logged_in') {\n identify.state = {\n state: 'pending',\n };\n }\n });\n\n onDisconnected(conn, () => {\n taskQueue.pause();\n taskQueue.clear();\n\n // If the user was logged in before the connection loss, set the state\n // to logged_out to notify that the user is no longer logged in.\n if (identify.state.state === 'logged_in') {\n identify.state = {\n state: 'logged_out',\n };\n }\n });\n}\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, configure, getSdks } from '@monterosa/sdk-core';\nimport { getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n Payload,\n Message,\n getParentApplication,\n respondToSdkMessage,\n sendSdkMessage,\n onStateChanged,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n IdentifyKit,\n IdentifyAction,\n Credentials,\n Signature,\n UserData,\n} from './types';\n\nimport {\n getIdentify,\n getUserData,\n getSessionSignatureMemoized,\n setCredentials,\n clearCredentials,\n requestLogin,\n requestLogout,\n enqueueLogin,\n enqueueLogout,\n onCredentialsUpdated,\n onSignatureUpdated,\n onUserDataUpdated,\n registerIdentifyHook,\n} from './api';\n\nimport { addExperience, deleteExperience } from './experiences';\n\n/**\n * @internal\n */\nexport function parentMessagesHook(identify: IdentifyKit) {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n return () => {};\n }\n\n return onSdkMessage(parentApp, async (message: Message) => {\n switch (message.action) {\n case IdentifyAction.OnCredentialsUpdated: {\n identify.credentials = message.payload.data as Credentials;\n break;\n }\n case IdentifyAction.OnSessionSignatureUpdated: {\n identify.signature = message.payload.data as Signature;\n break;\n }\n case IdentifyAction.OnUserDataUpdated: {\n identify.userData = message.payload.data as UserData;\n break;\n }\n case IdentifyAction.Login: {\n enqueueLogin(identify, message.payload as Credentials);\n break;\n }\n case IdentifyAction.Logout: {\n enqueueLogout(identify);\n break;\n }\n }\n });\n}\n\n/**\n * Finds an existing SDK with matching projectId, or creates a new one.\n */\nfunction getOrConfigureSdk(host: string, projectId: string): MonterosaSdk {\n const existingSdk = getSdks().find(\n (sdk) => sdk.options.projectId === projectId,\n );\n\n return existingSdk ?? configure({ host, projectId }, projectId);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceEmbedded(experience: Experience): void {\n const identify = getIdentify(experience.sdk);\n\n // Send login action with current credentials to the new experience if available.\n // The bridge queues this message until the experience is initialised.\n if (identify.credentials) {\n sendSdkMessage(experience, IdentifyAction.Login, identify.credentials);\n }\n\n const credentialsUpdatedUnsub = onCredentialsUpdated(identify, (data) => {\n sendSdkMessage(experience, IdentifyAction.OnCredentialsUpdated, {\n data,\n });\n });\n\n const signatureUpdatedUnsub = onSignatureUpdated(identify, (data) => {\n sendSdkMessage(experience, IdentifyAction.OnSessionSignatureUpdated, {\n data,\n });\n });\n\n const userDataUpdatedUnsub = onUserDataUpdated(identify, (data) => {\n sendSdkMessage(experience, IdentifyAction.OnUserDataUpdated, {\n data,\n });\n });\n\n const sdkMessageUnsub = onSdkMessage(experience, async (message) => {\n if (\n !Object.values(IdentifyAction).includes(message.action as IdentifyAction)\n ) {\n return;\n }\n\n // Extract origin context from payload if available.\n // New clients include origin (host, projectId) to ensure correct project context\n // in multilevel integrations. Old clients don't send origin, so we fall back\n // to the experience's SDK to maintain backward compatibility.\n const { origin } = message.payload as {\n origin?: { host: string; projectId: string };\n };\n\n const originSdk = origin\n ? getOrConfigureSdk(origin.host, origin.projectId)\n : experience.sdk;\n\n const originIdentify = getIdentify(originSdk);\n\n const respond = (payload?: Payload) =>\n respondToSdkMessage(experience, message, payload);\n\n try {\n switch (message.action) {\n case IdentifyAction.RequestLogin: {\n await requestLogin(originIdentify);\n\n respond();\n\n break;\n }\n case IdentifyAction.RequestLogout: {\n await requestLogout(identify);\n\n respond();\n break;\n }\n case IdentifyAction.GetUserData: {\n const data = await getUserData(identify);\n\n respond({ data });\n break;\n }\n case IdentifyAction.GetSessionSignature: {\n const signature = await getSessionSignatureMemoized(\n identify,\n message.payload as Credentials,\n );\n\n respond({ data: signature });\n break;\n }\n case IdentifyAction.SetCredentials: {\n await setCredentials(originIdentify, {\n token: message.payload.token as Credentials['token'],\n });\n\n respond();\n\n break;\n }\n case IdentifyAction.ClearCredentials: {\n await clearCredentials(identify);\n\n respond();\n\n break;\n }\n }\n } catch (err) {\n respond({\n error: getErrorMessage(err),\n });\n }\n });\n\n addExperience(experience, [\n credentialsUpdatedUnsub,\n signatureUpdatedUnsub,\n userDataUpdatedUnsub,\n sdkMessageUnsub,\n ]);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceUnmounted(experience: Experience): void {\n deleteExperience(experience);\n}\n\nonStateChanged((experience, state) => {\n if (state === 'mounted') {\n handleExperienceEmbedded(experience);\n } else if (state === 'unmounted') {\n handleExperienceUnmounted(experience);\n }\n});\n\nregisterIdentifyHook(parentMessagesHook);\n"],"names":["IdentifyError","Emitter","getDeviceId","fetchListings","createError","TaskQueue","Sdk","getParentApplication","sendSdkRequest","MonterosaError","BridgeError","getErrorMessage","getConnect","connect","connectLogin","withRetryAsync","connectLogout","sendSdkMessage","getSdk","memoizePromise","subscribe","onConnected","onConnecting","onDisconnected","onSdkMessage","getSdks","configure","respondToSdkMessage","onStateChanged"],"mappings":";;;;;;;;;;AAAA;;;;;;;AAOG;AAyKH;;AAEG;AACH,IAAY,aAQX,CAAA;AARD,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,cAAA,CAAA,GAAA,eAA8B,CAAA;AAC9B,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,iBAAkC,CAAA;AAClC,IAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,kBAAoC,CAAA;AACpC,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,mBAAsC,CAAA;AACtC,IAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,kBAAoC,CAAA;AACpC,IAAA,aAAA,CAAA,oBAAA,CAAA,GAAA,qBAA0C,CAAA;AAC1C,IAAA,aAAA,CAAA,cAAA,CAAA,GAAA,e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WAAW,EAAE;QAChC,yBAAyB,CAAC,UAAU,CAAC,CAAC;AACvC,KAAA;AACH,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,kBAAkB,CAAC;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@monterosa/sdk-identify-kit",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.3",
4
4
  "description": "Identify Kit for the Monterosa JS SDK",
5
5
  "author": "Monterosa Productions Limited <hello@monterosa.co.uk> (https://www.monterosa.co/)",
6
- "main": "./dist/index.js",
6
+ "main": "./dist/index.cjs",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js",
12
- "default": "./dist/index.js"
12
+ "require": "./dist/index.cjs",
13
+ "default": "./dist/index.cjs"
13
14
  }
14
15
  },
15
16
  "files": [
@@ -32,12 +33,12 @@
32
33
  ],
33
34
  "license": "MIT",
34
35
  "dependencies": {
35
- "@monterosa/sdk-connect-kit": "2.0.0-rc.2",
36
- "@monterosa/sdk-core": "2.0.0-rc.2",
37
- "@monterosa/sdk-interact-interop": "2.0.0-rc.2",
38
- "@monterosa/sdk-interact-kit": "2.0.0-rc.2",
39
- "@monterosa/sdk-launcher-kit": "2.0.0-rc.2",
40
- "@monterosa/sdk-util": "2.0.0-rc.2"
36
+ "@monterosa/sdk-connect-kit": "2.0.0-rc.3",
37
+ "@monterosa/sdk-core": "2.0.0-rc.3",
38
+ "@monterosa/sdk-interact-interop": "2.0.0-rc.3",
39
+ "@monterosa/sdk-interact-kit": "2.0.0-rc.3",
40
+ "@monterosa/sdk-launcher-kit": "2.0.0-rc.3",
41
+ "@monterosa/sdk-util": "2.0.0-rc.3"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@rollup/plugin-json": "^4.1.0",
@@ -58,5 +59,5 @@
58
59
  "publishConfig": {
59
60
  "access": "public"
60
61
  },
61
- "gitHead": "0e2d4cd71055bf0ab38ec5a73d6040c55151da1c"
62
+ "gitHead": "d692ad26af0b5ea7cd7b664168bffa069f9ab911"
62
63
  }