@monterosa/sdk-identify-kit 2.0.0-rc.3 → 2.0.0-rc.4

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
@@ -9,19 +9,60 @@
9
9
  import { MonterosaSdk } from '@monterosa/sdk-core';
10
10
  import { Unsubscribe, TaskQueue } from '@monterosa/sdk-util';
11
11
  import { Payload } from '@monterosa/sdk-launcher-kit';
12
- import { IdentifyKit, LoginState, Credentials, Signature, UserData, IdentifyOptions, IdentifyAction, IdentifyHook } from './types';
12
+ import { IdentifyKit, LoginState, Credentials, Signature, UserData, IdentifyOptions, IdentifyAction, LoginPolicy } from './types';
13
+ import { Identify } from './identify';
13
14
  /**
14
15
  * @internal
15
16
  */
16
- export declare const taskQueue: TaskQueue;
17
+ export declare const identifyKits: Map<string, Identify>;
17
18
  /**
19
+ * Read the current locally-owned login policy.
20
+ *
21
+ * Returns `'disabled'` by default.
22
+ *
18
23
  * @internal
19
24
  */
20
- export declare function parentAppRequest<T>(identify: IdentifyKit, action: IdentifyAction, payload?: Payload): Promise<T>;
25
+ export declare function getLoginPolicy(): LoginPolicy;
26
+ /**
27
+ * Set the locally-owned login policy.
28
+ *
29
+ * All `Identify` instances at this level honour the same policy; the
30
+ * value is never propagated across the wire (each level of a multi-level
31
+ * integration owns its own policy).
32
+ *
33
+ * Policy gates the Enmasse `loginTask` only — credentials always mirror
34
+ * from upstream regardless of policy. A `'disabled'` level still
35
+ * receives credentials via the module-load pull and the cascading
36
+ * `Login` / `Logout` broadcasts; it just doesn't attempt Enmasse
37
+ * validation against them.
38
+ *
39
+ * When the policy transitions to `'auto'`, enqueues a sync-state task
40
+ * for every existing identify so that any in-flight session is picked
41
+ * up.
42
+ *
43
+ * Idempotent: setting the same policy that's already in effect is a
44
+ * no-op.
45
+ *
46
+ * @param policy - `'auto'` to enable auto-login, `'disabled'` to opt out.
47
+ */
48
+ export declare function setLoginPolicy(policy: LoginPolicy): void;
49
+ /**
50
+ * Whether the user should be auto-logged in on reconnect.
51
+ *
52
+ * True when the user was previously logged in, the policy is `'auto'`,
53
+ * and credentials are available on the identify instance.
54
+ *
55
+ * @internal
56
+ */
57
+ export declare function shouldLoginOnReconnect(identify: IdentifyKit): boolean;
21
58
  /**
22
59
  * @internal
23
60
  */
24
- export declare function registerIdentifyHook(hook: IdentifyHook): void;
61
+ export declare const taskQueue: TaskQueue;
62
+ /**
63
+ * @internal
64
+ */
65
+ export declare function sendParentRequest<T>(action: IdentifyAction, payload?: Payload): Promise<T>;
25
66
  /**
26
67
  * @internal
27
68
  */
@@ -31,13 +72,56 @@ export declare function loginTask(identify: IdentifyKit, credentials: Credential
31
72
  */
32
73
  export declare function logoutTask(identify: IdentifyKit): Promise<void>;
33
74
  /**
75
+ * Enqueue a `loginTask` for the given identify when `policy === 'auto'`.
76
+ * The downstream `Login` broadcast is emitted by {@link applyLogin}.
77
+ *
34
78
  * @internal
35
79
  */
36
80
  export declare function enqueueLogin(identify: IdentifyKit, credentials: Credentials, prioritise?: boolean): void;
37
81
  /**
82
+ * Reset the identify's identity-derived caches and enqueue a `logoutTask`
83
+ * when `policy === 'auto'`.
84
+ *
38
85
  * @internal
39
86
  */
40
87
  export declare function enqueueLogout(identify: IdentifyKit): void;
88
+ /**
89
+ * Apply new credentials at this level: update the slot, enqueue a
90
+ * `loginTask` for every existing identify on the null-to-set transition,
91
+ * and broadcast `Login` downstream to every embedded experience.
92
+ *
93
+ * Idempotent on token refresh: re-setting an already-set slot updates
94
+ * the value and broadcasts, but does not re-enqueue logins (their
95
+ * `loginTask` would short-circuit on `state === 'logged_in'` anyway).
96
+ *
97
+ * @internal
98
+ */
99
+ export declare function applyLogin(credentials: Credentials): void;
100
+ /**
101
+ * Clear credentials at this level: null out the slot, enqueue a
102
+ * `logoutTask` for every existing identify on the set-to-null
103
+ * transition, and broadcast `Logout` downstream to every embedded
104
+ * experience.
105
+ *
106
+ * @internal
107
+ */
108
+ export declare function applyLogout(): void;
109
+ /**
110
+ * Pull state from the parent application and apply locally.
111
+ *
112
+ * Fires once at non-root bridge module load, regardless of
113
+ * `loginPolicy` — token presence is the customer-side sign-in state and
114
+ * must mirror upstream whether or not we choose to validate against
115
+ * Enmasse. Best-effort: a missing or non-identify-kit parent silently
116
+ * resolves with no slot change.
117
+ *
118
+ * Uses {@link applyLogin} so the slot update cascades downstream to
119
+ * this level's own embedded experiences and per-identify loginTasks
120
+ * are enqueued under `loginPolicy === 'auto'`.
121
+ *
122
+ * @internal
123
+ */
124
+ export declare function pullStateFromParent(): Promise<void>;
41
125
  /**
42
126
  * A factory function that creates a new instance of the `IdentifyKit` class,
43
127
  * which is a kit of the Monterosa SDK used for user identification.
@@ -59,15 +143,16 @@ export declare function enqueueLogout(identify: IdentifyKit): void;
59
143
  * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate
60
144
  * users and perform other user identification-related operations.
61
145
  *
62
- * - Subsequent calls to getIdentify with the same MonterosaSdk instance will return
63
- * the same `IdentifyKit` instance.
146
+ * - Subsequent calls return the cached `IdentifyKit` instance for the same
147
+ * project. The `options` argument is honoured only on the first call;
148
+ * later calls ignore it and return the instance configured by the first.
64
149
  *
65
150
  * @param sdk - An instance of the MonterosaSdk class.
66
151
  * @param options - List of `IdentifyKit` options
67
152
  * @returns An instance of the `IdentifyKit` class, which is used for user
68
153
  * identification.
69
154
  */
70
- export declare function getIdentify(sdk?: MonterosaSdk, options?: IdentifyOptions): IdentifyKit;
155
+ export declare function getIdentify(sdk?: MonterosaSdk, options?: Partial<IdentifyOptions>): IdentifyKit;
71
156
  /**
72
157
  * A factory function that creates a new instance of the `IdentifyKit` class,
73
158
  * which is a kit of the Monterosa SDK used for user identification.
@@ -89,32 +174,31 @@ export declare function getIdentify(sdk?: MonterosaSdk, options?: IdentifyOption
89
174
  * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate
90
175
  * users and perform other user identification-related operations.
91
176
  *
92
- * - Subsequent calls to getIdentify with the same MonterosaSdk instance will return
93
- * the same `IdentifyKit` instance.
177
+ * - Subsequent calls return the cached `IdentifyKit` instance for the same
178
+ * project. The `options` argument is honoured only on the first call;
179
+ * later calls ignore it and return the instance configured by the first.
94
180
  *
95
181
  * @param options - List of `IdentifyKit` options
96
182
  * @returns An instance of the `IdentifyKit` class, which is used for user
97
183
  * identification.
98
184
  */
99
- export declare function getIdentify(options?: IdentifyOptions): IdentifyKit;
185
+ export declare function getIdentify(options?: Partial<IdentifyOptions>): IdentifyKit;
100
186
  /**
101
- * A function that requests a user login via the `IdentifyKit` of the Monterosa SDK.
187
+ * Requests a user login.
102
188
  *
103
189
  * @example
104
190
  * ```javascript
105
191
  * import { configure } from '@monterosa/sdk-core';
106
- * import { getIdentify, requestLogin } from '@monterosa/sdk-identify-kit';
192
+ * import { requestLogin } from '@monterosa/sdk-identify-kit';
107
193
  *
108
194
  * configure({ host: '...', projectId: '...' });
109
195
  *
110
196
  * try {
111
- * const identify = getIdentify();
112
- *
113
- * await requestLogin(identify);
197
+ * await requestLogin();
114
198
  *
115
199
  * console.log('Login request successful');
116
200
  * } catch (err) {
117
- * console.error('Error requesting login:', error.message)
201
+ * console.error('Error requesting login:', err.message)
118
202
  * }
119
203
  * ```
120
204
  *
@@ -123,43 +207,51 @@ export declare function getIdentify(options?: IdentifyOptions): IdentifyKit;
123
207
  * the Monterosa SDK, the function delegates to the parent app
124
208
  * to handle the login process.
125
209
  *
126
- * @param identify - An instance of the `IdentifyKit` class used for user
127
- * identification.
128
210
  * @returns A Promise that resolves with `void` when the login request
129
211
  * is completed.
130
212
  */
131
- export declare function requestLogin(identify: IdentifyKit): Promise<void>;
213
+ export declare function requestLogin(): Promise<void>;
132
214
  /**
133
- * A function that requests a user login via the `IdentifyKit` of the Space.
215
+ * Read the current credentials, pulling from the parent application when
216
+ * called from an embedded experience.
217
+ *
218
+ * At the root this returns the canonical slot value. At a non-root
219
+ * experience this dispatches a `GetCredentials` request upstream and
220
+ * resolves with the response, ensuring the caller always sees the
221
+ * authoritative value rather than a possibly-stale local mirror.
222
+ *
223
+ * @returns A Promise that resolves to the current credentials, or `null`
224
+ * if none are set.
225
+ */
226
+ export declare function getCredentials(): Promise<Credentials | null>;
227
+ /**
228
+ * Requests a user logout.
134
229
  *
135
230
  * @example
136
231
  * ```javascript
137
- * import { getSpace } from '@monterosa/sdk-core';
138
- * import { getIdentify, requestLogout } from '@monterosa/sdk-identify-kit';
232
+ * import { configure } from '@monterosa/sdk-core';
233
+ * import { requestLogout } from '@monterosa/sdk-identify-kit';
139
234
  *
140
- * const space = getSpace('host', 'space-id');
141
- * const identify = getIdentify(space);
235
+ * configure({ host: '...', projectId: '...' });
142
236
  *
143
237
  * try {
144
- * await requestLogout(identify);
238
+ * await requestLogout();
145
239
  *
146
240
  * console.log('Logout request successful');
147
241
  * } catch (err) {
148
- * console.error('Error requesting logout:', error.message)
242
+ * console.error('Error requesting logout:', err.message)
149
243
  * }
150
244
  * ```
151
245
  *
152
246
  * @remarks
153
247
  * - If the app is running within a third-party application that uses
154
- * the Space, the function delegates to the parent app
248
+ * the Monterosa SDK, the function delegates to the parent app
155
249
  * to handle the logout process.
156
250
  *
157
- * @param identify - An instance of the `IdentifyKit` class used for user
158
- * identification.
159
251
  * @returns A Promise that resolves with `void` when the logout request
160
252
  * is completed.
161
253
  */
162
- export declare function requestLogout(identify: IdentifyKit): Promise<void>;
254
+ export declare function requestLogout(): Promise<void>;
163
255
  /**
164
256
  * @internal
165
257
  *
@@ -178,101 +270,104 @@ export declare function requestLogout(identify: IdentifyKit): Promise<void>;
178
270
  */
179
271
  export declare function getSessionSignature(identify: IdentifyKit, credentials: Credentials): Promise<Signature>;
180
272
  /**
181
- * A memoized version of the `getSessionSignature` function.
273
+ * A memoized version of the `getSessionSignature` function. Memo key is
274
+ * the credentials token, so both leaf-side and bridge-side callers share
275
+ * the same cache for the same token.
182
276
  */
183
277
  export declare const getSessionSignatureMemoized: (...args: any[]) => Promise<Signature>;
184
278
  /**
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.
279
+ * Fetches user data for the given credentials.
280
+ *
281
+ * Credentials are required explicitly so the precondition is visible at
282
+ * the call site — without them the function cannot be called. Obtain a
283
+ * `Credentials` value via {@link getCredentials} or the
284
+ * {@link onCredentialsUpdated} callback.
187
285
  *
188
286
  * @example
189
287
  * ```javascript
190
288
  * import { configure } from '@monterosa/sdk-core';
191
- * import { getIdentify, getUserData } from '@monterosa/sdk-identify-kit';
289
+ * import {
290
+ * getIdentify,
291
+ * getUserData,
292
+ * getCredentials,
293
+ * } from '@monterosa/sdk-identify-kit';
192
294
  *
193
295
  * configure({ host: '...', projectId: '...' });
194
296
  *
195
297
  * const identify = getIdentify();
196
- * const userData = await getUserData(identify);
298
+ * const credentials = await getCredentials();
197
299
  *
198
- * console.log('User data:', userData);
300
+ * if (credentials !== null) {
301
+ * const userData = await getUserData(identify, credentials);
302
+ * console.log('User data:', userData);
303
+ * }
199
304
  * ```
200
305
  *
201
306
  * @remarks
202
- * - If the app is running within a third-party application that uses
203
- * the Monterosa SDK, the function delegates to the parent app
204
- * to get user data.
205
- *
206
- * - If the request is successful, the function resolves with a key-value object
207
- * representing user data. If not, a `MonterosaError` is thrown.
307
+ * Cached on the identify instance after the first successful fetch.
308
+ * Cleared on {@link clearCredentials} via the logout path.
208
309
  *
209
310
  * @param identify - An instance of `IdentifyKit` that provides the user
210
311
  * 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.
312
+ * @param credentials - The user's authentication credentials. The
313
+ * request authorises against the value's token.
314
+ * @returns A Promise that resolves to a key-value object representing
315
+ * user data. The structure and content of the user data object depend
316
+ * on the identify service provider and may vary.
215
317
  */
216
- export declare function getUserData(identify: IdentifyKit): Promise<UserData>;
318
+ export declare function getUserData(identify: IdentifyKit, credentials: Credentials): Promise<UserData>;
217
319
  /**
218
320
  * Sets the user's authentication credentials.
219
321
  *
220
322
  * @example
221
323
  * ```javascript
222
324
  * import { configure } from '@monterosa/sdk-core';
223
- * import { getIdentify, setCredentials } from '@monterosa/sdk-identify-kit';
325
+ * import { setCredentials } from '@monterosa/sdk-identify-kit';
224
326
  *
225
327
  * configure({ host: '...', projectId: '...' });
226
328
  *
227
- * const credentials = { token: 'abc123' };
228
- * const identify = getIdentify();
229
- *
230
- * await setCredentials(identify, credentials)
329
+ * await setCredentials({ token: 'abc123' });
231
330
  * ```
232
331
  *
233
332
  * @remarks
234
- * - If the app is running within a third-party application that uses
235
- * the Monterosa SDK, the function delegates to the parent app
236
- * to set user credentials.
237
- *
238
- * - If the request is successful, the function resolves to `void`.
239
- * If not, a `MonterosaError` is thrown.
333
+ * - At the root of an integration, the credentials are stored locally
334
+ * and a `Login` broadcast is sent to every embedded experience.
335
+ * - When called from an embedded experience, the call is relayed
336
+ * upstream via the `SetCredentials` wire action. The credentials are
337
+ * ultimately applied at the root and propagate back down via the
338
+ * cascading `Login` broadcast.
240
339
  *
241
- * @param identify - An instance of `IdentifyKit` that provides the user
242
- * identification functionality.
243
340
  * @param credentials - An object representing the user's authentication
244
341
  * credentials.
245
- * @returns A Promise that resolves to `void`.
342
+ * @returns A Promise that resolves to `void` once the credentials have
343
+ * been written (root) or the upstream relay has completed (non-root).
246
344
  */
247
- export declare function setCredentials(identify: IdentifyKit, credentials: Credentials): Promise<void>;
345
+ export declare function setCredentials(credentials: Credentials): Promise<void>;
248
346
  /**
249
347
  * Clears the user's authentication credentials.
250
348
  *
251
349
  * @example
252
350
  * ```javascript
253
351
  * import { configure } from '@monterosa/sdk-core';
254
- * import { getIdentify, clearCredentials } from '@monterosa/sdk-identify-kit';
352
+ * import { clearCredentials } from '@monterosa/sdk-identify-kit';
255
353
  *
256
354
  * configure({ host: '...', projectId: '...' });
257
355
  *
258
- * const identify = getIdentify();
259
- *
260
- * await clearCredentials(identify);
356
+ * await clearCredentials();
261
357
  * ```
262
358
  *
263
359
  * @remarks
264
- * - If the app is running within a third-party application that uses
265
- * the Monterosa SDK, the function delegates to the parent app
266
- * to clear user credentials.
267
- *
268
- * - If the request is successful, the function resolves to `void`.
269
- * If not, a `MonterosaError` is thrown.
270
- *
271
- * @param identify - An instance of `IdentifyKit` that provides the user
272
- * identification functionality.
273
- * @returns A Promise that resolves to `void`.
360
+ * - At the root of an integration, the credentials slot is cleared and
361
+ * a `Logout` broadcast is sent to every embedded experience.
362
+ * - When called from an embedded experience, the call is relayed
363
+ * upstream via the `ClearCredentials` wire action. The slot is
364
+ * cleared at the root and the cascading `Logout` broadcast propagates
365
+ * back down.
366
+ *
367
+ * @returns A Promise that resolves to `void` once the slot has been
368
+ * cleared (root) or the upstream relay has completed (non-root).
274
369
  */
275
- export declare function clearCredentials(identify: IdentifyKit): Promise<void>;
370
+ export declare function clearCredentials(): Promise<void>;
276
371
  /**
277
372
  * Registers a callback function that will be called whenever the `LoginState`
278
373
  * object associated with the `IdentifyKit` instance is updated.
@@ -303,19 +398,17 @@ export declare function clearCredentials(identify: IdentifyKit): Promise<void>;
303
398
  */
304
399
  export declare function onStateUpdated(identify: IdentifyKit, callback: (state: LoginState) => void): Unsubscribe;
305
400
  /**
306
- * Registers a callback function that will be called whenever the `Credentials`
307
- * object associated with the `IdentifyKit` instance is updated.
401
+ * Registers a callback function that will be called whenever the
402
+ * credentials slot is updated.
308
403
  *
309
404
  * @example
310
405
  * ```javascript
311
406
  * import { configure } from '@monterosa/sdk-core';
312
- * import { getIdentify, onCredentialsUpdated } from '@monterosa/sdk-identify-kit';
407
+ * import { onCredentialsUpdated } from '@monterosa/sdk-identify-kit';
313
408
  *
314
409
  * configure({ host: '...', projectId: '...' });
315
410
  *
316
- * const identify = getIdentify();
317
- *
318
- * const unsubscribe = onCredentialsUpdated(identify, (credentials) => {
411
+ * const unsubscribe = onCredentialsUpdated((credentials) => {
319
412
  * if (credentials !== null) {
320
413
  * console.log("Credentials updated:", credentials);
321
414
  * } else {
@@ -327,86 +420,14 @@ export declare function onStateUpdated(identify: IdentifyKit, callback: (state:
327
420
  * // unsubscribe();
328
421
  * ```
329
422
  *
330
- * @param identify - An instance of `IdentifyKit` that provides the user
331
- * identification functionality.
332
423
  * @param callback - The callback function to register. This function will be
333
424
  * called with the updated `Credentials` object as its only argument.
334
- * If the value `null` is received, it indicates that the signature has
335
- * been cleared
425
+ * If the value `null` is received, it indicates that the credentials have
426
+ * been cleared.
336
427
  * @returns An `Unsubscribe` function that can be called to unregister
337
428
  * the callback function.
338
429
  */
339
- export declare function onCredentialsUpdated(identify: IdentifyKit, callback: (credentials: Credentials | null) => void): Unsubscribe;
340
- /**
341
- * Registers a callback function that will be called whenever the `Signature`
342
- * object associated with the `IdentifyKit` instance is updated.
343
- *
344
- * @example
345
- * ```javascript
346
- * import { configure } from '@monterosa/sdk-core';
347
- * import { getIdentify, onSignatureUpdated } from '@monterosa/sdk-identify-kit';
348
- *
349
- * configure({ host: '...', projectId: '...' });
350
- *
351
- * const identify = getIdentify();
352
- *
353
- * const unsubscribe = onSignatureUpdated(identify, (signature) => {
354
- * if (signature !== null) {
355
- * console.log("Signature updated:", signature);
356
- * } else {
357
- * console.log("Signature cleared.");
358
- * }
359
- * });
360
- *
361
- * // Call unsubscribe() to unregister the callback function
362
- * // unsubscribe();
363
- * ```
364
- *
365
- * @param identify - An instance of `IdentifyKit` that provides the user
366
- * identification functionality.
367
- * @param callback - The callback function to register. This function will be
368
- * called with the updated `Signature` object as its only argument.
369
- * If the value `null` is received, it indicates that the signature has
370
- * been cleared
371
- * @returns An `Unsubscribe` function that can be called to unregister
372
- * the callback function.
373
- */
374
- export declare function onSignatureUpdated(identify: IdentifyKit, callback: (signature: Signature | null) => void): Unsubscribe;
375
- /**
376
- * Registers a callback function that will be called whenever the `UserData`
377
- * object associated with the `IdentifyKit` instance is updated.
378
- *
379
- * @example
380
- * ```javascript
381
- * import { configure } from '@monterosa/sdk-core';
382
- * import { getIdentify, onUserDataUpdated } from '@monterosa/sdk-identify-kit';
383
- *
384
- * configure({ host: '...', projectId: '...' });
385
- *
386
- * const identify = getIdentify();
387
- *
388
- * const unsubscribe = onUserDataUpdated(identify, (userData) => {
389
- * if (userData !== null) {
390
- * console.log("User's data updated:", userData);
391
- * } else {
392
- * console.log("User's data cleared.");
393
- * }
394
- * });
395
- *
396
- * // Call unsubscribe() to unregister the callback function
397
- * // unsubscribe();
398
- * ```
399
- *
400
- * @param identify - An instance of `IdentifyKit` that provides the user
401
- * identification functionality.
402
- * @param callback - The callback function to register. This function will be
403
- * called with the updated `UserData` object as its only argument.
404
- * If the value `null` is received, it indicates that the user's data has
405
- * been cleared
406
- * @returns An `Unsubscribe` function that can be called to unregister
407
- * the callback function.
408
- */
409
- export declare function onUserDataUpdated(identify: IdentifyKit, callback: (userData: UserData | null) => void): Unsubscribe;
430
+ export declare function onCredentialsUpdated(callback: (credentials: Credentials | null) => void): Unsubscribe;
410
431
  /**
411
432
  * Registers a callback function that will be called when a login is requested
412
433
  * by an Experience.
@@ -414,13 +435,11 @@ export declare function onUserDataUpdated(identify: IdentifyKit, callback: (user
414
435
  * @example
415
436
  * ```javascript
416
437
  * import { configure } from '@monterosa/sdk-core';
417
- * import { getIdentify, onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';
438
+ * import { onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';
418
439
  *
419
440
  * configure({ host: '...', projectId: '...' });
420
441
  *
421
- * const identify = getIdentify();
422
- *
423
- * const unsubscribe = onLoginRequestedByExperience(identify, () => {
442
+ * const unsubscribe = onLoginRequestedByExperience(() => {
424
443
  * showLoginForm();
425
444
  * });
426
445
  *
@@ -428,27 +447,24 @@ export declare function onUserDataUpdated(identify: IdentifyKit, callback: (user
428
447
  * // unsubscribe();
429
448
  * ```
430
449
  *
431
- * @param identify - An instance of `IdentifyKit` that provides the user
432
- * identification functionality.
433
450
  * @param callback - The callback function to register. This function will
434
451
  * be called when a login is requested by an Experience.
435
452
  * @returns An `Unsubscribe` function that can be called to unregister
436
453
  * the callback function.
437
454
  */
438
- export declare function onLoginRequestedByExperience(identify: IdentifyKit, callback: () => void): Unsubscribe;
455
+ export declare function onLoginRequestedByExperience(callback: () => void): Unsubscribe;
439
456
  /**
440
457
  * Registers a callback function that will be called when a logout is requested
441
458
  * by an Experience.
442
459
  *
443
460
  * @example
444
461
  * ```javascript
445
- * import { getSpace } from '@monterosa/sdk-core';
446
- * import { getIdentify, onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';
462
+ * import { configure } from '@monterosa/sdk-core';
463
+ * import { onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';
447
464
  *
448
- * const space = getSpace('host', 'space-id');
449
- * const identify = getIdentify(space);
465
+ * configure({ host: '...', projectId: '...' });
450
466
  *
451
- * const unsubscribe = onLogoutRequestedByExperience(identify, () => {
467
+ * const unsubscribe = onLogoutRequestedByExperience(() => {
452
468
  * // logout requested by experience
453
469
  * // perform logout from Auth service
454
470
  * });
@@ -457,14 +473,12 @@ export declare function onLoginRequestedByExperience(identify: IdentifyKit, call
457
473
  * // unsubscribe();
458
474
  * ```
459
475
  *
460
- * @param identify - An instance of `IdentifyKit` that provides the user
461
- * identification functionality.
462
476
  * @param callback - The callback function to register. This function will
463
477
  * be called when a logout is requested by an Experience.
464
478
  * @returns An `Unsubscribe` function that can be called to unregister
465
479
  * the callback function.
466
480
  */
467
- export declare function onLogoutRequestedByExperience(identify: IdentifyKit, callback: () => void): Unsubscribe;
481
+ export declare function onLogoutRequestedByExperience(callback: () => void): Unsubscribe;
468
482
  /**
469
483
  *
470
484
  * @internal
package/dist/bridge.d.ts CHANGED
@@ -6,12 +6,17 @@
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';
10
- import { IdentifyKit } from './types';
9
+ import { Experience, ExperienceState, Message } from '@monterosa/sdk-launcher-kit';
11
10
  /**
11
+ * Process an incoming `Login` / `Logout` broadcast from the parent
12
+ * application. Updates the local credentials slot, enqueues login/logout
13
+ * for every existing identify, and forwards the broadcast downstream to
14
+ * this level's own embedded experiences — the mechanism that cascades a
15
+ * root-level `setCredentials` through every nested experience.
16
+ *
12
17
  * @internal
13
18
  */
14
- export declare function parentMessagesHook(identify: IdentifyKit): () => void;
19
+ export declare function handleParentMessage(message: Message): void;
15
20
  /**
16
21
  * @internal
17
22
  */
@@ -20,3 +25,7 @@ export declare function handleExperienceEmbedded(experience: Experience): void;
20
25
  * @internal
21
26
  */
22
27
  export declare function handleExperienceUnmounted(experience: Experience): void;
28
+ /**
29
+ * @internal
30
+ */
31
+ export declare function handleExperienceStateChange(experience: Experience, state: ExperienceState): void;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license
3
+ * @monterosa/sdk-identify-kit
4
+ *
5
+ * Copyright © 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 { Emitter, Unsubscribe } from '@monterosa/sdk-util';
10
+ import { Credentials } from './types';
11
+ /**
12
+ * Root-owned credentials slot.
13
+ *
14
+ * Single source of truth at the root of an integration; an internal
15
+ * mirror at every other level, kept in sync via `Login` / `Logout`
16
+ * broadcasts. Not exposed publicly — public access flows through
17
+ * `setCredentials` / `getCredentials` / `clearCredentials` and
18
+ * `onCredentialsUpdated`.
19
+ *
20
+ * @internal
21
+ */
22
+ export declare class CredentialsStore extends Emitter {
23
+ private static instance;
24
+ private _credentials;
25
+ private constructor();
26
+ static getInstance(): CredentialsStore;
27
+ get credentials(): Credentials | null;
28
+ set credentials(next: Credentials | null);
29
+ subscribe(handler: (value: Credentials | null) => void): Unsubscribe;
30
+ reset(): void;
31
+ }