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

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,52 @@
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 login policy.
28
+ *
29
+ * - `'auto'`: the SDK automatically logs the user in whenever
30
+ * credentials are available.
31
+ * - `'disabled'`: credentials are tracked but no automatic login is
32
+ * attempted.
33
+ *
34
+ * Each level of a multi-level integration owns its own policy; the
35
+ * value is never propagated to embedded experiences. Idempotent:
36
+ * setting the same policy is a no-op.
37
+ *
38
+ * @param policy - `'auto'` or `'disabled'`.
39
+ */
40
+ export declare function setLoginPolicy(policy: LoginPolicy): void;
21
41
  /**
42
+ * Whether the user should be auto-logged in on reconnect.
43
+ *
44
+ * True when the user was previously logged in, the policy is `'auto'`,
45
+ * and credentials are available on the identify instance.
46
+ *
22
47
  * @internal
23
48
  */
24
- export declare function registerIdentifyHook(hook: IdentifyHook): void;
49
+ export declare function shouldLoginOnReconnect(identify: IdentifyKit): boolean;
50
+ /**
51
+ * @internal
52
+ */
53
+ export declare const taskQueue: TaskQueue;
54
+ /**
55
+ * @internal
56
+ */
57
+ export declare function sendParentRequest<T>(action: IdentifyAction, payload?: Payload): Promise<T>;
25
58
  /**
26
59
  * @internal
27
60
  */
@@ -31,16 +64,63 @@ export declare function loginTask(identify: IdentifyKit, credentials: Credential
31
64
  */
32
65
  export declare function logoutTask(identify: IdentifyKit): Promise<void>;
33
66
  /**
67
+ * Enqueue a `loginTask` for the given identify when `policy === 'auto'`.
68
+ * The downstream `Login` broadcast is emitted by {@link applyLogin}.
69
+ *
34
70
  * @internal
35
71
  */
36
72
  export declare function enqueueLogin(identify: IdentifyKit, credentials: Credentials, prioritise?: boolean): void;
37
73
  /**
74
+ * Reset the identify's identity-derived caches and enqueue a `logoutTask`
75
+ * when `policy === 'auto'`.
76
+ *
38
77
  * @internal
39
78
  */
40
79
  export declare function enqueueLogout(identify: IdentifyKit): void;
41
80
  /**
42
- * A factory function that creates a new instance of the `IdentifyKit` class,
43
- * which is a kit of the Monterosa SDK used for user identification.
81
+ * Apply new credentials at this level: update the current credentials,
82
+ * enqueue a `loginTask` for every existing identify on the null-to-set
83
+ * transition, and broadcast `Login` downstream to every embedded
84
+ * experience.
85
+ *
86
+ * Idempotent on token refresh: re-setting when credentials are already
87
+ * present updates the value and broadcasts, but does not re-enqueue
88
+ * logins (their `loginTask` would short-circuit on
89
+ * `state === 'logged_in'` anyway).
90
+ *
91
+ * @internal
92
+ */
93
+ export declare function applyLogin(credentials: Credentials): void;
94
+ /**
95
+ * Clear credentials at this level: clear the current credentials,
96
+ * enqueue a `logoutTask` for every existing identify on the
97
+ * set-to-null transition, and broadcast `Logout` downstream to every
98
+ * embedded experience.
99
+ *
100
+ * @internal
101
+ */
102
+ export declare function applyLogout(): void;
103
+ /**
104
+ * Pull state from the parent application and apply locally.
105
+ *
106
+ * Fires once at non-root bridge module load, regardless of
107
+ * `loginPolicy` — token presence is the customer-side sign-in state and
108
+ * must mirror upstream whether or not we choose to validate against
109
+ * Enmasse. Best-effort: a missing or non-identify-kit parent silently
110
+ * resolves with no change to the current credentials.
111
+ *
112
+ * Uses {@link applyLogin} so the update cascades downstream to this
113
+ * level's own embedded experiences and per-identify loginTasks are
114
+ * enqueued under `loginPolicy === 'auto'`.
115
+ *
116
+ * @internal
117
+ */
118
+ export declare function pullStateFromParent(): Promise<void>;
119
+ /**
120
+ * Get the IdentifyKit instance for the given SDK / project.
121
+ *
122
+ * The IdentifyKit instance is used to authenticate users and read
123
+ * user data.
44
124
  *
45
125
  * @example
46
126
  * ```javascript
@@ -53,24 +133,19 @@ export declare function enqueueLogout(identify: IdentifyKit): void;
53
133
  * ```
54
134
  *
55
135
  * @remarks
56
- * - The `getIdentify` function returns an instance of the `IdentifyKit` class
57
- * using optional MonterosaSdk instance as a parameter.
58
- *
59
- * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate
60
- * users and perform other user identification-related operations.
61
- *
62
- * - Subsequent calls to getIdentify with the same MonterosaSdk instance will return
63
- * the same `IdentifyKit` instance.
136
+ * First-call-wins: subsequent calls for the same project return the
137
+ * cached instance and ignore the `options` argument.
64
138
  *
65
- * @param sdk - An instance of the MonterosaSdk class.
66
- * @param options - List of `IdentifyKit` options
67
- * @returns An instance of the `IdentifyKit` class, which is used for user
68
- * identification.
139
+ * @param sdk - The Monterosa SDK instance.
140
+ * @param options - IdentifyKit options (applied only on the first call).
141
+ * @returns The IdentifyKit instance for the project.
69
142
  */
70
- export declare function getIdentify(sdk?: MonterosaSdk, options?: IdentifyOptions): IdentifyKit;
143
+ export declare function getIdentify(sdk?: MonterosaSdk, options?: Partial<IdentifyOptions>): IdentifyKit;
71
144
  /**
72
- * A factory function that creates a new instance of the `IdentifyKit` class,
73
- * which is a kit of the Monterosa SDK used for user identification.
145
+ * Get the IdentifyKit instance for the configured SDK.
146
+ *
147
+ * The IdentifyKit instance is used to authenticate users and read
148
+ * user data.
74
149
  *
75
150
  * @example
76
151
  * ```javascript
@@ -83,83 +158,74 @@ export declare function getIdentify(sdk?: MonterosaSdk, options?: IdentifyOption
83
158
  * ```
84
159
  *
85
160
  * @remarks
86
- * - The `getIdentify` function returns an instance of the `IdentifyKit` class
87
- * using optional MonterosaSdk instance as a parameter.
88
- *
89
- * - The `IdentifyKit` instance returned by `getIdentify` can be used to authenticate
90
- * users and perform other user identification-related operations.
161
+ * First-call-wins: subsequent calls for the same project return the
162
+ * cached instance and ignore the `options` argument.
91
163
  *
92
- * - Subsequent calls to getIdentify with the same MonterosaSdk instance will return
93
- * the same `IdentifyKit` instance.
94
- *
95
- * @param options - List of `IdentifyKit` options
96
- * @returns An instance of the `IdentifyKit` class, which is used for user
97
- * identification.
164
+ * @param options - IdentifyKit options (applied only on the first call).
165
+ * @returns The IdentifyKit instance for the project.
98
166
  */
99
- export declare function getIdentify(options?: IdentifyOptions): IdentifyKit;
167
+ export declare function getIdentify(options?: Partial<IdentifyOptions>): IdentifyKit;
100
168
  /**
101
- * A function that requests a user login via the `IdentifyKit` of the Monterosa SDK.
169
+ * Request a user login.
170
+ *
171
+ * When called from an embedded experience, the request is relayed to
172
+ * the parent application — the host that owns the auth UI handles it.
102
173
  *
103
174
  * @example
104
175
  * ```javascript
105
176
  * import { configure } from '@monterosa/sdk-core';
106
- * import { getIdentify, requestLogin } from '@monterosa/sdk-identify-kit';
177
+ * import { requestLogin } from '@monterosa/sdk-identify-kit';
107
178
  *
108
179
  * configure({ host: '...', projectId: '...' });
109
180
  *
110
181
  * try {
111
- * const identify = getIdentify();
112
- *
113
- * await requestLogin(identify);
114
- *
182
+ * await requestLogin();
115
183
  * console.log('Login request successful');
116
184
  * } catch (err) {
117
- * console.error('Error requesting login:', error.message)
185
+ * console.error('Error requesting login:', err.message)
118
186
  * }
119
187
  * ```
120
188
  *
121
- * @remarks
122
- * - If the app is running within a third-party application that uses
123
- * the Monterosa SDK, the function delegates to the parent app
124
- * to handle the login process.
189
+ * @returns A Promise that resolves once the login request has been
190
+ * delivered.
191
+ */
192
+ export declare function requestLogin(): Promise<void>;
193
+ /**
194
+ * Read the current credentials.
125
195
  *
126
- * @param identify - An instance of the `IdentifyKit` class used for user
127
- * identification.
128
- * @returns A Promise that resolves with `void` when the login request
129
- * is completed.
196
+ * When called from an embedded experience, fetches the credentials
197
+ * from the parent application so the caller always sees the
198
+ * authoritative value.
199
+ *
200
+ * @returns A Promise that resolves to the current credentials, or
201
+ * `null` if none are set.
130
202
  */
131
- export declare function requestLogin(identify: IdentifyKit): Promise<void>;
203
+ export declare function getCredentials(): Promise<Credentials | null>;
132
204
  /**
133
- * A function that requests a user login via the `IdentifyKit` of the Space.
205
+ * Request a user logout.
206
+ *
207
+ * When called from an embedded experience, the request is relayed to
208
+ * the parent application — the host that owns the auth UI handles it.
134
209
  *
135
210
  * @example
136
211
  * ```javascript
137
- * import { getSpace } from '@monterosa/sdk-core';
138
- * import { getIdentify, requestLogout } from '@monterosa/sdk-identify-kit';
212
+ * import { configure } from '@monterosa/sdk-core';
213
+ * import { requestLogout } from '@monterosa/sdk-identify-kit';
139
214
  *
140
- * const space = getSpace('host', 'space-id');
141
- * const identify = getIdentify(space);
215
+ * configure({ host: '...', projectId: '...' });
142
216
  *
143
217
  * try {
144
- * await requestLogout(identify);
145
- *
218
+ * await requestLogout();
146
219
  * console.log('Logout request successful');
147
220
  * } catch (err) {
148
- * console.error('Error requesting logout:', error.message)
221
+ * console.error('Error requesting logout:', err.message)
149
222
  * }
150
223
  * ```
151
224
  *
152
- * @remarks
153
- * - If the app is running within a third-party application that uses
154
- * the Space, the function delegates to the parent app
155
- * to handle the logout process.
156
- *
157
- * @param identify - An instance of the `IdentifyKit` class used for user
158
- * identification.
159
- * @returns A Promise that resolves with `void` when the logout request
160
- * is completed.
225
+ * @returns A Promise that resolves once the logout request has been
226
+ * delivered.
161
227
  */
162
- export declare function requestLogout(identify: IdentifyKit): Promise<void>;
228
+ export declare function requestLogout(): Promise<void>;
163
229
  /**
164
230
  * @internal
165
231
  *
@@ -178,104 +244,95 @@ export declare function requestLogout(identify: IdentifyKit): Promise<void>;
178
244
  */
179
245
  export declare function getSessionSignature(identify: IdentifyKit, credentials: Credentials): Promise<Signature>;
180
246
  /**
181
- * A memoized version of the `getSessionSignature` function.
247
+ * @internal
248
+ *
249
+ * A memoized version of the `getSessionSignature` function. Memo key is
250
+ * the credentials token, so both leaf-side and bridge-side callers share
251
+ * the same cache for the same token.
182
252
  */
183
253
  export declare const getSessionSignatureMemoized: (...args: any[]) => Promise<Signature>;
184
254
  /**
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.
255
+ * Fetch user data for the given credentials.
256
+ *
257
+ * Credentials are required explicitly. Obtain a value via
258
+ * {@link getCredentials} or the {@link onCredentialsUpdated} callback.
187
259
  *
188
260
  * @example
189
261
  * ```javascript
190
262
  * import { configure } from '@monterosa/sdk-core';
191
- * import { getIdentify, getUserData } from '@monterosa/sdk-identify-kit';
263
+ * import {
264
+ * getIdentify,
265
+ * getUserData,
266
+ * getCredentials,
267
+ * } from '@monterosa/sdk-identify-kit';
192
268
  *
193
269
  * configure({ host: '...', projectId: '...' });
194
270
  *
195
271
  * const identify = getIdentify();
196
- * const userData = await getUserData(identify);
272
+ * const credentials = await getCredentials();
197
273
  *
198
- * console.log('User data:', userData);
274
+ * if (credentials !== null) {
275
+ * const userData = await getUserData(identify, credentials);
276
+ * console.log('User data:', userData);
277
+ * }
199
278
  * ```
200
279
  *
201
280
  * @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.
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.
281
+ * Cached after the first successful fetch and reset when credentials
282
+ * are cleared.
283
+ *
284
+ * @param identify - The IdentifyKit instance.
285
+ * @param credentials - The user's authentication credentials.
286
+ * @returns A Promise that resolves to a key-value object of user data.
287
+ * The structure depends on the identify service provider.
215
288
  */
216
- export declare function getUserData(identify: IdentifyKit): Promise<UserData>;
289
+ export declare function getUserData(identify: IdentifyKit, credentials: Credentials): Promise<UserData>;
217
290
  /**
218
- * Sets the user's authentication credentials.
291
+ * Set the user's authentication credentials.
292
+ *
293
+ * The credentials become the active credentials for the entire
294
+ * integration. When called from an embedded experience, the call is
295
+ * relayed to the parent application so that every level of the
296
+ * integration sees the new value.
219
297
  *
220
298
  * @example
221
299
  * ```javascript
222
300
  * import { configure } from '@monterosa/sdk-core';
223
- * import { getIdentify, setCredentials } from '@monterosa/sdk-identify-kit';
301
+ * import { setCredentials } from '@monterosa/sdk-identify-kit';
224
302
  *
225
303
  * configure({ host: '...', projectId: '...' });
226
304
  *
227
- * const credentials = { token: 'abc123' };
228
- * const identify = getIdentify();
229
- *
230
- * await setCredentials(identify, credentials)
305
+ * await setCredentials({ token: 'abc123' });
231
306
  * ```
232
307
  *
233
- * @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.
240
- *
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`.
308
+ * @param credentials - The user's authentication credentials.
309
+ * @returns A Promise that resolves once the credentials have been
310
+ * applied.
246
311
  */
247
- export declare function setCredentials(identify: IdentifyKit, credentials: Credentials): Promise<void>;
312
+ export declare function setCredentials(credentials: Credentials): Promise<void>;
248
313
  /**
249
- * Clears the user's authentication credentials.
314
+ * Clear the user's authentication credentials.
315
+ *
316
+ * When called from an embedded experience, the call is relayed to the
317
+ * parent application so that every level of the integration is
318
+ * cleared.
250
319
  *
251
320
  * @example
252
321
  * ```javascript
253
322
  * import { configure } from '@monterosa/sdk-core';
254
- * import { getIdentify, clearCredentials } from '@monterosa/sdk-identify-kit';
323
+ * import { clearCredentials } from '@monterosa/sdk-identify-kit';
255
324
  *
256
325
  * configure({ host: '...', projectId: '...' });
257
326
  *
258
- * const identify = getIdentify();
259
- *
260
- * await clearCredentials(identify);
327
+ * await clearCredentials();
261
328
  * ```
262
329
  *
263
- * @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`.
330
+ * @returns A Promise that resolves once the credentials have been
331
+ * cleared.
274
332
  */
275
- export declare function clearCredentials(identify: IdentifyKit): Promise<void>;
333
+ export declare function clearCredentials(): Promise<void>;
276
334
  /**
277
- * Registers a callback function that will be called whenever the `LoginState`
278
- * object associated with the `IdentifyKit` instance is updated.
335
+ * Register a callback for `LoginState` updates on the given identify.
279
336
  *
280
337
  * @example
281
338
  * ```javascript
@@ -289,184 +346,82 @@ export declare function clearCredentials(identify: IdentifyKit): Promise<void>;
289
346
  * const unsubscribe = onStateUpdated(identify, (state) => {
290
347
  * console.log("State updated:", state);
291
348
  * });
292
- *
293
- * // Call unsubscribe() to unregister the callback function
294
- * // unsubscribe();
295
349
  * ```
296
350
  *
297
- * @param identify - An instance of `IdentifyKit` that provides the user
298
- * identification functionality.
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.
351
+ * @param identify - The IdentifyKit instance.
352
+ * @param callback - Called with the updated `LoginState`.
353
+ * @returns An `Unsubscribe` function.
303
354
  */
304
355
  export declare function onStateUpdated(identify: IdentifyKit, callback: (state: LoginState) => void): Unsubscribe;
305
356
  /**
306
- * Registers a callback function that will be called whenever the `Credentials`
307
- * object associated with the `IdentifyKit` instance is updated.
357
+ * Register a callback for updates to the current credentials.
308
358
  *
309
359
  * @example
310
360
  * ```javascript
311
361
  * import { configure } from '@monterosa/sdk-core';
312
- * import { getIdentify, onCredentialsUpdated } from '@monterosa/sdk-identify-kit';
362
+ * import { onCredentialsUpdated } from '@monterosa/sdk-identify-kit';
313
363
  *
314
364
  * configure({ host: '...', projectId: '...' });
315
365
  *
316
- * const identify = getIdentify();
317
- *
318
- * const unsubscribe = onCredentialsUpdated(identify, (credentials) => {
366
+ * const unsubscribe = onCredentialsUpdated((credentials) => {
319
367
  * if (credentials !== null) {
320
368
  * console.log("Credentials updated:", credentials);
321
369
  * } else {
322
370
  * console.log("Credentials cleared.");
323
371
  * }
324
372
  * });
325
- *
326
- * // Call unsubscribe() to unregister the callback function
327
- * // unsubscribe();
328
373
  * ```
329
374
  *
330
- * @param identify - An instance of `IdentifyKit` that provides the user
331
- * identification functionality.
332
- * @param callback - The callback function to register. This function will be
333
- * 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
336
- * @returns An `Unsubscribe` function that can be called to unregister
337
- * the callback function.
375
+ * @param callback - Called with the updated `Credentials`, or `null`
376
+ * when credentials are cleared.
377
+ * @returns An `Unsubscribe` function.
338
378
  */
339
- export declare function onCredentialsUpdated(identify: IdentifyKit, callback: (credentials: Credentials | null) => void): Unsubscribe;
379
+ export declare function onCredentialsUpdated(callback: (credentials: Credentials | null) => void): Unsubscribe;
340
380
  /**
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';
381
+ * Register a callback for login requests.
348
382
  *
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.
383
+ * Fires when {@link requestLogin} is called at this level — whether by
384
+ * local code or relayed up from an embedded experience.
378
385
  *
379
386
  * @example
380
387
  * ```javascript
381
388
  * import { configure } from '@monterosa/sdk-core';
382
- * import { getIdentify, onUserDataUpdated } from '@monterosa/sdk-identify-kit';
389
+ * import { onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';
383
390
  *
384
391
  * configure({ host: '...', projectId: '...' });
385
392
  *
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
- * }
393
+ * const unsubscribe = onLoginRequestedByExperience(() => {
394
+ * showLoginForm();
394
395
  * });
395
- *
396
- * // Call unsubscribe() to unregister the callback function
397
- * // unsubscribe();
398
396
  * ```
399
397
  *
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.
398
+ * @param callback - Called when a login is requested.
399
+ * @returns An `Unsubscribe` function.
408
400
  */
409
- export declare function onUserDataUpdated(identify: IdentifyKit, callback: (userData: UserData | null) => void): Unsubscribe;
401
+ export declare function onLoginRequestedByExperience(callback: () => void): Unsubscribe;
410
402
  /**
411
- * Registers a callback function that will be called when a login is requested
412
- * by an Experience.
403
+ * Register a callback for logout requests.
404
+ *
405
+ * Fires when {@link requestLogout} is called at this level — whether
406
+ * by local code or relayed up from an embedded experience.
413
407
  *
414
408
  * @example
415
409
  * ```javascript
416
410
  * import { configure } from '@monterosa/sdk-core';
417
- * import { getIdentify, onLoginRequestedByExperience } from '@monterosa/sdk-identify-kit';
411
+ * import { onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';
418
412
  *
419
413
  * configure({ host: '...', projectId: '...' });
420
414
  *
421
- * const identify = getIdentify();
422
- *
423
- * const unsubscribe = onLoginRequestedByExperience(identify, () => {
424
- * showLoginForm();
425
- * });
426
- *
427
- * // Call unsubscribe() to unregister the callback function
428
- * // unsubscribe();
429
- * ```
430
- *
431
- * @param identify - An instance of `IdentifyKit` that provides the user
432
- * identification functionality.
433
- * @param callback - The callback function to register. This function will
434
- * be called when a login is requested by an Experience.
435
- * @returns An `Unsubscribe` function that can be called to unregister
436
- * the callback function.
437
- */
438
- export declare function onLoginRequestedByExperience(identify: IdentifyKit, callback: () => void): Unsubscribe;
439
- /**
440
- * Registers a callback function that will be called when a logout is requested
441
- * by an Experience.
442
- *
443
- * @example
444
- * ```javascript
445
- * import { getSpace } from '@monterosa/sdk-core';
446
- * import { getIdentify, onLogoutRequestedByExperience } from '@monterosa/sdk-identify-kit';
447
- *
448
- * const space = getSpace('host', 'space-id');
449
- * const identify = getIdentify(space);
450
- *
451
- * const unsubscribe = onLogoutRequestedByExperience(identify, () => {
452
- * // logout requested by experience
453
- * // perform logout from Auth service
415
+ * const unsubscribe = onLogoutRequestedByExperience(() => {
416
+ * // perform logout from auth service
454
417
  * });
455
- *
456
- * // Call unsubscribe() to unregister the callback function
457
- * // unsubscribe();
458
418
  * ```
459
419
  *
460
- * @param identify - An instance of `IdentifyKit` that provides the user
461
- * identification functionality.
462
- * @param callback - The callback function to register. This function will
463
- * be called when a logout is requested by an Experience.
464
- * @returns An `Unsubscribe` function that can be called to unregister
465
- * the callback function.
420
+ * @param callback - Called when a logout is requested.
421
+ * @returns An `Unsubscribe` function.
466
422
  */
467
- export declare function onLogoutRequestedByExperience(identify: IdentifyKit, callback: () => void): Unsubscribe;
423
+ export declare function onLogoutRequestedByExperience(callback: () => void): Unsubscribe;
468
424
  /**
469
- *
470
425
  * @internal
471
426
  */
472
427
  export declare function watchConnectionStatus(identify: IdentifyKit): Promise<void>;