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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -2,22 +2,42 @@
2
2
  * @license
3
3
  * identify-kit
4
4
  *
5
- * Copyright © 2023-2024 Monterosa Productions Limited. All rights reserved.
5
+ * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.
6
6
  *
7
7
  * More details on the license can be found at https://www.monterosa.co/sdk/license
8
8
  */
9
9
  import { MonterosaSdk } from '@monterosa/sdk-core';
10
- import { Unsubscribe } from '@monterosa/sdk-util';
11
- import { Payload, ParentApplication } from '@monterosa/sdk-launcher-kit';
12
- import { IdentifyKit, Credentials, Signature, UserData, IdentifyOptions, IdentifyAction, IdentifyHook } from './types';
10
+ import { Unsubscribe, TaskQueue } from '@monterosa/sdk-util';
11
+ import { Payload } from '@monterosa/sdk-launcher-kit';
12
+ import { IdentifyKit, LoginState, Credentials, Signature, UserData, IdentifyOptions, IdentifyAction, IdentifyHook } from './types';
13
13
  /**
14
14
  * @internal
15
15
  */
16
- export declare function parentAppRequest<T>(parentApp: ParentApplication, action: IdentifyAction, payload?: Payload): Promise<T>;
16
+ export declare const taskQueue: TaskQueue;
17
+ /**
18
+ * @internal
19
+ */
20
+ export declare function parentAppRequest<T>(identify: IdentifyKit, action: IdentifyAction, payload?: Payload): Promise<T>;
17
21
  /**
18
22
  * @internal
19
23
  */
20
24
  export declare function registerIdentifyHook(hook: IdentifyHook): void;
25
+ /**
26
+ * @internal
27
+ */
28
+ export declare function loginTask(identify: IdentifyKit, credentials: Credentials): Promise<void>;
29
+ /**
30
+ * @internal
31
+ */
32
+ export declare function logoutTask(identify: IdentifyKit): Promise<void>;
33
+ /**
34
+ * @internal
35
+ */
36
+ export declare function enqueueLogin(identify: IdentifyKit, credentials: Credentials, prioritise?: boolean): void;
37
+ /**
38
+ * @internal
39
+ */
40
+ export declare function enqueueLogout(identify: IdentifyKit): void;
21
41
  /**
22
42
  * A factory function that creates a new instance of the `IdentifyKit` class,
23
43
  * which is a kit of the Monterosa SDK used for user identification.
@@ -141,166 +161,147 @@ export declare function requestLogin(identify: IdentifyKit): Promise<void>;
141
161
  */
142
162
  export declare function requestLogout(identify: IdentifyKit): Promise<void>;
143
163
  /**
144
- * A function that notifies that a user logged in.
145
- *
146
- * @example
147
- * ```javascript
148
- * import { getSpace } from '@monterosa/sdk-core';
149
- * import { getIdentify, notifyUserLoggedIn } from '@monterosa/sdk-identify-kit';
150
- *
151
- * const sdk = getSpace('host', 'sdk-id');
152
- * const identify = getIdentify(sdk);
153
- *
154
- * try {
155
- * await notifyUserLoggedIn(identify);
164
+ * @internal
156
165
  *
157
- * console.log('Notify that the user logged in successfully');
158
- * } catch (err) {
159
- * console.error('Error notifying that the user logged in:', error.message)
160
- * }
161
- * ```
166
+ * Returns a signature for a user session. The signature is based on the
167
+ * user's identifying information provided in the `IdentifyKit` instance.
162
168
  *
163
169
  * @remarks
164
- * - If the app is running within a third-party application that uses
165
- * the Monterosa SDK, the function delegates to the parent app
166
- * to handle the notification process.
170
+ * This function does not handle errors. Callers are responsible for catching
171
+ * and handling failures.
167
172
  *
168
173
  * @param identify - An instance of the `IdentifyKit` class used for user
169
174
  * identification.
170
- * @returns A Promise that resolves with `void` when the notification of the user
171
- * logging in is completed.
175
+ * @param credentials - The credentials of the user.
176
+ *
177
+ * @returns A Promise that resolves to a `Signature` object.
178
+ */
179
+ export declare function getSessionSignature(identify: IdentifyKit, credentials: Credentials): Promise<Signature>;
180
+ /**
181
+ * A memoized version of the `getSessionSignature` function.
172
182
  */
173
- export declare function notifyUserLoggedIn(identify: IdentifyKit): Promise<void>;
183
+ export declare const getSessionSignatureMemoized: (...args: any[]) => Promise<Signature>;
174
184
  /**
175
- * A function that notifies that a user logged out.
185
+ * The function that takes an instance of `IdentifyKit` as its argument and
186
+ * returns a Promise that resolves to a key-value object representing user data.
176
187
  *
177
188
  * @example
178
189
  * ```javascript
179
- * import { getSpace } from '@monterosa/sdk-core';
180
- * import { getIdentify, notifyUserLoggedOut } from '@monterosa/sdk-identify-kit';
190
+ * import { configure } from '@monterosa/sdk-core';
191
+ * import { getIdentify, getUserData } from '@monterosa/sdk-identify-kit';
181
192
  *
182
- * const sdk = getSpace('host', 'sdk-id');
183
- * const identify = getIdentify(sdk);
193
+ * configure({ host: '...', projectId: '...' });
184
194
  *
185
- * try {
186
- * await notifyUserLoggedOut(identify);
195
+ * const identify = getIdentify();
196
+ * const userData = await getUserData(identify);
187
197
  *
188
- * console.log('Notify that the user logged out successfully');
189
- * } catch (err) {
190
- * console.error('Error notifying that the user logged out:', error.message)
191
- * }
198
+ * console.log('User data:', userData);
192
199
  * ```
193
200
  *
194
201
  * @remarks
195
202
  * - If the app is running within a third-party application that uses
196
203
  * the Monterosa SDK, the function delegates to the parent app
197
- * to handle the notification process.
204
+ * to get user data.
198
205
  *
199
- * @param identify - An instance of the `IdentifyKit` class used for user
200
- * identification.
201
- * @returns A Promise that resolves with `void` when the notification of the user
202
- * logging out is completed.
206
+ * - If the request is successful, the function resolves with a key-value object
207
+ * representing user data. If not, a `MonterosaError` is thrown.
208
+ *
209
+ * @param identify - An instance of `IdentifyKit` that provides the user
210
+ * identification functionality.
211
+ * @returns A Promise that resolves to a key-value object representing user data.
212
+ * The structure and content of the user data object depend on the identify
213
+ * service provider and may vary. It typically contains information about the user,
214
+ * but the specific fields are determined by the Identify service provider.
203
215
  */
204
- export declare function notifyUserLoggedOut(identify: IdentifyKit): Promise<void>;
216
+ export declare function getUserData(identify: IdentifyKit): Promise<UserData>;
205
217
  /**
206
- * Returns a signature for a user session. The signature is based on the
207
- * user's identifying information provided in the `IdentifyKit` instance.
218
+ * Sets the user's authentication credentials.
208
219
  *
209
220
  * @example
210
221
  * ```javascript
211
222
  * import { configure } from '@monterosa/sdk-core';
212
- * import { getIdentify, getSession } from '@monterosa/sdk-identify-kit';
213
- * import { getConnect, login } from '@monterosa/sdk-connect-kit';
223
+ * import { getIdentify, setCredentials } from '@monterosa/sdk-identify-kit';
214
224
  *
215
225
  * configure({ host: '...', projectId: '...' });
216
226
  *
227
+ * const credentials = { token: 'abc123' };
217
228
  * const identify = getIdentify();
218
- * const session = await getSession(identify);
219
229
  *
220
- * const connect = await getConnect();
221
- * await login(connect, ...session);
230
+ * await setCredentials(identify, credentials)
222
231
  * ```
223
232
  *
224
233
  * @remarks
225
234
  * - If the app is running within a third-party application that uses
226
235
  * the Monterosa SDK, the function delegates to the parent app
227
- * to get session signature.
236
+ * to set user credentials.
228
237
  *
229
- * - If the request is successful, the function resolves with `Signature`.
238
+ * - If the request is successful, the function resolves to `void`.
230
239
  * If not, a `MonterosaError` is thrown.
231
240
  *
232
- * - The function can be used to fetch a signature for a user session that
233
- * can be used to authenticate user with `ConnectKit`.
234
- *
235
- * @param identify - An instance of the `IdentifyKit` class used for user
236
- * identification.
237
- * @returns A Promise that resolves to an object of type `Signature`.
241
+ * @param identify - An instance of `IdentifyKit` that provides the user
242
+ * identification functionality.
243
+ * @param credentials - An object representing the user's authentication
244
+ * credentials.
245
+ * @returns A Promise that resolves to `void`.
238
246
  */
239
- export declare function getSessionSignature(identify: IdentifyKit): Promise<Signature>;
247
+ export declare function setCredentials(identify: IdentifyKit, credentials: Credentials): Promise<void>;
240
248
  /**
241
- * The function that takes an instance of `IdentifyKit` as its argument and
242
- * returns a Promise that resolves to a key-value object representing user data.
249
+ * Clears the user's authentication credentials.
243
250
  *
244
251
  * @example
245
252
  * ```javascript
246
253
  * import { configure } from '@monterosa/sdk-core';
247
- * import { getIdentify, getUserData } from '@monterosa/sdk-identify-kit';
254
+ * import { getIdentify, clearCredentials } from '@monterosa/sdk-identify-kit';
248
255
  *
249
256
  * configure({ host: '...', projectId: '...' });
250
257
  *
251
258
  * const identify = getIdentify();
252
- * const userData = await getUserData(identify);
253
259
  *
254
- * console.log('User data:', userData);
260
+ * await clearCredentials(identify);
255
261
  * ```
256
262
  *
257
263
  * @remarks
258
264
  * - If the app is running within a third-party application that uses
259
265
  * the Monterosa SDK, the function delegates to the parent app
260
- * to get user data.
266
+ * to clear user credentials.
261
267
  *
262
- * - If the request is successful, the function resolves with a key-value object
263
- * representing user data. If not, a `MonterosaError` is thrown.
268
+ * - If the request is successful, the function resolves to `void`.
269
+ * If not, a `MonterosaError` is thrown.
264
270
  *
265
271
  * @param identify - An instance of `IdentifyKit` that provides the user
266
272
  * identification functionality.
267
- * @returns A Promise that resolves to a key-value object representing user data.
268
- * The structure and content of the user data object depend on the identify
269
- * service provider and may vary. It typically contains information about the user,
270
- * but the specific fields are determined by the Idenitfy service provider.
273
+ * @returns A Promise that resolves to `void`.
271
274
  */
272
- export declare function getUserData(identify: IdentifyKit): Promise<UserData>;
275
+ export declare function clearCredentials(identify: IdentifyKit): Promise<void>;
273
276
  /**
274
- * Sets the user's authentication credentials.
277
+ * Registers a callback function that will be called whenever the `LoginState`
278
+ * object associated with the `IdentifyKit` instance is updated.
275
279
  *
276
280
  * @example
277
281
  * ```javascript
278
282
  * import { configure } from '@monterosa/sdk-core';
279
- * import { getIdentify, setCredentials } from '@monterosa/sdk-identify-kit';
283
+ * import { getIdentify, onStateUpdated } from '@monterosa/sdk-identify-kit';
280
284
  *
281
285
  * configure({ host: '...', projectId: '...' });
282
286
  *
283
- * const credentials = { token: 'abc123' };
284
287
  * const identify = getIdentify();
285
288
  *
286
- * await setCredentials(identify, credentials)
287
- * ```
288
- *
289
- * @remarks
290
- * - If the app is running within a third-party application that uses
291
- * the Monterosa SDK, the function delegates to the parent app
292
- * to set user credentials.
289
+ * const unsubscribe = onStateUpdated(identify, (state) => {
290
+ * console.log("State updated:", state);
291
+ * });
293
292
  *
294
- * - If the request is successful, the function resolves to `void`.
295
- * If not, a `MonterosaError` is thrown.
293
+ * // Call unsubscribe() to unregister the callback function
294
+ * // unsubscribe();
295
+ * ```
296
296
  *
297
297
  * @param identify - An instance of `IdentifyKit` that provides the user
298
298
  * identification functionality.
299
- * @param credentials - An object representing the user's authentication
300
- * credentials.
301
- * @returns A Promise that resolves to `void`.
299
+ * @param callback - The callback function to register. This function will be
300
+ * called with the updated `LoginState` object as its only argument.
301
+ * @returns An `Unsubscribe` function that can be called to unregister
302
+ * the callback function.
302
303
  */
303
- export declare function setCredentials(identify: IdentifyKit, credentials: Credentials): Promise<void>;
304
+ export declare function onStateUpdated(identify: IdentifyKit, callback: (state: LoginState) => void): Unsubscribe;
304
305
  /**
305
306
  * Registers a callback function that will be called whenever the `Credentials`
306
307
  * object associated with the `IdentifyKit` instance is updated.
@@ -430,7 +431,7 @@ export declare function onUserDataUpdated(identify: IdentifyKit, callback: (user
430
431
  * @param identify - An instance of `IdentifyKit` that provides the user
431
432
  * identification functionality.
432
433
  * @param callback - The callback function to register. This function will
433
- * be called when a login is requested by an experience.
434
+ * be called when a login is requested by an Experience.
434
435
  * @returns An `Unsubscribe` function that can be called to unregister
435
436
  * the callback function.
436
437
  */
@@ -459,92 +460,13 @@ export declare function onLoginRequestedByExperience(identify: IdentifyKit, call
459
460
  * @param identify - An instance of `IdentifyKit` that provides the user
460
461
  * identification functionality.
461
462
  * @param callback - The callback function to register. This function will
462
- * be called when a logout is requested by an experience.
463
+ * be called when a logout is requested by an Experience.
463
464
  * @returns An `Unsubscribe` function that can be called to unregister
464
465
  * the callback function.
465
466
  */
466
467
  export declare function onLogoutRequestedByExperience(identify: IdentifyKit, callback: () => void): Unsubscribe;
467
468
  /**
468
- * Registers a callback function that will be called when the credentials validation fails.
469
- *
470
- * @example
471
- * ```javascript
472
- * import { configure } from '@monterosa/sdk-core';
473
- * import { getIdentify, onCredentialsValidationFailed } from '@monterosa/sdk-identify-kit';
474
- *
475
- * configure({ host: '...', projectId: '...' });
476
469
  *
477
- * const identify = getIdentify();
478
- *
479
- * const unsubscribe = onCredentialsValidationFailed(identify, (error) => {
480
- * console.log(error);
481
- * });
482
- *
483
- * // Call unsubscribe() to unregister the callback function
484
- * // unsubscribe();
485
- * ```
486
- *
487
- * @param identify - An instance of `IdentifyKit` that provides the user
488
- * identification functionality.
489
- * @param callback - The callback function to register. This function will
490
- * be called when an error occured.
491
- * @returns An `Unsubscribe` function that can be called to unregister
492
- * the callback function.
493
- */
494
- export declare function onCredentialsValidationFailed(identify: IdentifyKit, callback: (error: string) => void): Unsubscribe;
495
- /**
496
- * Registers a callback function that will be called when a notification that
497
- * a user is logged in sent.
498
- *
499
- * @example
500
- * ```javascript
501
- * import { getSpace } from '@monterosa/sdk-core';
502
- * import { getIdentify, onUserLoggedIn } from '@monterosa/sdk-identify-kit';
503
- *
504
- * const sdk = getSpace('host', 'sdk-id');
505
- * const identify = getIdentify(sdk);
506
- *
507
- * const unsubscribe = onUserLoggedIn(identify, () => {
508
- * console.log('User logged in successfully');
509
- * });
510
- *
511
- * // Call unsubscribe() to unregister the callback function
512
- * // unsubscribe();
513
- * ```
514
- *
515
- * @param identify - An instance of `IdentifyKit` that provides the user
516
- * identification functionality.
517
- * @param callback - The callback function to register. This function will
518
- * be called when a notification that the user logged in is called.
519
- * @returns An `Unsubscribe` function that can be called to unregister
520
- * the callback function.
521
- */
522
- export declare function onUserLoggedIn(identify: IdentifyKit, callback: () => void): Unsubscribe;
523
- /**
524
- * Registers a callback function that will be called when a notification that
525
- * a user is logged out sent.
526
- *
527
- * @example
528
- * ```javascript
529
- * import { getSpace } from '@monterosa/sdk-core';
530
- * import { getIdentify, onUserLoggedOut } from '@monterosa/sdk-identify-kit';
531
- *
532
- * const sdk = getSpace('host', 'sdk-id');
533
- * const identify = getIdentify(sdk);
534
- *
535
- * const unsubscribe = onUserLoggedOut(identify, () => {
536
- * console.log('User logged out successfully');
537
- * });
538
- *
539
- * // Call unsubscribe() to unregister the callback function
540
- * // unsubscribe();
541
- * ```
542
- *
543
- * @param identify - An instance of `IdentifyKit` that provides the user
544
- * identification functionality.
545
- * @param callback - The callback function to register. This function will
546
- * be called when a notification that the user logged out is called.
547
- * @returns An `Unsubscribe` function that can be called to unregister
548
- * the callback function.
470
+ * @internal
549
471
  */
550
- export declare function onUserLoggedOut(identify: IdentifyKit, callback: () => void): Unsubscribe;
472
+ export declare function watchConnectionStatus(identify: IdentifyKit): Promise<void>;
package/dist/bridge.d.ts CHANGED
@@ -2,12 +2,21 @@
2
2
  * @license
3
3
  * @monterosa/sdk-identify-kit
4
4
  *
5
- * Copyright © 2023-2024 Monterosa Productions Limited. All rights reserved.
5
+ * Copyright © 2023-2026 Monterosa Productions Limited. All rights reserved.
6
6
  *
7
7
  * More details on the license can be found at https://www.monterosa.co/sdk/license
8
8
  */
9
+ import { Experience } from '@monterosa/sdk-launcher-kit';
9
10
  import { IdentifyKit } from './types';
10
11
  /**
11
12
  * @internal
12
13
  */
13
14
  export declare function parentMessagesHook(identify: IdentifyKit): () => void;
15
+ /**
16
+ * @internal
17
+ */
18
+ export declare function handleExperienceEmbedded(experience: Experience): void;
19
+ /**
20
+ * @internal
21
+ */
22
+ export declare function handleExperienceUnmounted(experience: Experience): void;
@@ -8,4 +8,3 @@
8
8
  */
9
9
  export declare const EXTENSION_ID = "lvis-id-custom-tab";
10
10
  export declare const SIGNATURE_TTL = 10000;
11
- export declare const USER_DATA_TTL = 10000;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * @monterosa/sdk-identify-kit
4
+ *
5
+ * Copyright © 2025-2026 Monterosa Productions Limited. All rights reserved.
6
+ *
7
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
8
+ */
9
+ import type { Unsubscribe } from '@monterosa/sdk-util';
10
+ import type { Experience } from '@monterosa/sdk-launcher-kit';
11
+ export declare function getExperiences(): Experience[];
12
+ export declare function addExperience(experience: Experience, unsubs?: Unsubscribe[]): void;
13
+ export declare function deleteExperience(experience: Experience): void;
@@ -2,15 +2,16 @@
2
2
  * @license
3
3
  * @monterosa/sdk-identify-kit
4
4
  *
5
- * Copyright © 2023-2024 Monterosa Productions Limited. All rights reserved.
5
+ * Copyright © 2023 Monterosa Productions Limited. All rights reserved.
6
6
  *
7
7
  * More details on the license can be found at https://www.monterosa.co/sdk/license
8
8
  */
9
9
  import { MonterosaSdk } from '@monterosa/sdk-core';
10
10
  import { Emitter } from '@monterosa/sdk-util';
11
- import { IdentifyKit, IdentifyOptions, Credentials, Signature, UserData } from './types';
11
+ import { IdentifyKit, IdentifyOptions, LoginState, Credentials, Signature, UserData } from './types';
12
12
  export default class Identify extends Emitter implements IdentifyKit {
13
13
  sdk: MonterosaSdk;
14
+ private wasLoggedIn;
14
15
  private host?;
15
16
  private readonly _options;
16
17
  private _credentials;
@@ -18,10 +19,11 @@ export default class Identify extends Emitter implements IdentifyKit {
18
19
  private _userData;
19
20
  private signatureExpireTimeout;
20
21
  private userDataExpireTimeout;
22
+ _state: LoginState;
21
23
  constructor(sdk: MonterosaSdk, options?: IdentifyOptions);
22
- expireSignature(delay: number): void;
23
- expireUserData(delay: number): void;
24
24
  private static fetchIdentifyHost;
25
+ get state(): LoginState;
26
+ set state(state: LoginState);
25
27
  get options(): IdentifyOptions;
26
28
  set signature(signature: Signature | null);
27
29
  get signature(): Signature | null;
@@ -29,5 +31,7 @@ export default class Identify extends Emitter implements IdentifyKit {
29
31
  get credentials(): Credentials | null;
30
32
  set userData(data: UserData | null);
31
33
  get userData(): UserData | null;
34
+ get shouldLoginOnReconnect(): boolean;
35
+ reset(): void;
32
36
  getUrl(path?: string): Promise<string>;
33
37
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Handles user authentication and identity management.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  /**
2
7
  * @license
3
8
  * @monterosa/sdk-identify-kit
@@ -6,11 +11,6 @@
6
11
  *
7
12
  * More details on the license can be found at https://www.monterosa.co/sdk/license
8
13
  */
9
- /**
10
- * Monterosa SDK / Identify Kit
11
- *
12
- * @packageDocumentation
13
- */
14
14
  import './bridge';
15
- export * from './api';
16
- export { Credentials, Signature, UserData, IdentifyKit, IdentifyOptions, IdentifyError, } from './types';
15
+ export { getIdentify, requestLogin, requestLogout, getUserData, setCredentials, clearCredentials, onStateUpdated, onCredentialsUpdated, onSignatureUpdated, onUserDataUpdated, onLoginRequestedByExperience, onLogoutRequestedByExperience, } from './api';
16
+ export { Credentials, Signature, UserData, IdentifyKit, IdentifyOptions, IdentifyError, LoginState, LoginPolicy, } from './types';