@cloudscaile-eng/web-ext-utils 0.0.4 → 0.0.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/README.md +75 -7
- package/dist/cs-ext-utils.untrimmed.d.ts +73 -4
- package/dist/index.d.ts +73 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,13 @@ const hostAPI = initializeHost({
|
|
|
36
36
|
toast: toastFunction,
|
|
37
37
|
getUser: getUserFunction,
|
|
38
38
|
validateUserPermission: validateUserPermissionFunction,
|
|
39
|
-
triggerLogin: triggerLoginFunction
|
|
39
|
+
triggerLogin: triggerLoginFunction,
|
|
40
|
+
triggerLogout: triggerLogoutFunction,
|
|
41
|
+
getCookieConsent: getCookieConsentFunction,
|
|
42
|
+
updateCookieConsent: updateCookieConsentFunction,
|
|
43
|
+
resetCookieConsent: resetCookieConsentFunction,
|
|
44
|
+
trackGA4Event: trackGA4EventFunction,
|
|
45
|
+
getOAuthProviders: getOAuthProvidersFunction
|
|
40
46
|
});
|
|
41
47
|
```
|
|
42
48
|
|
|
@@ -58,10 +64,12 @@ import {
|
|
|
58
64
|
getUser,
|
|
59
65
|
validateUserPermission,
|
|
60
66
|
triggerLogin,
|
|
67
|
+
triggerLogout,
|
|
61
68
|
getCookieConsent,
|
|
62
69
|
updateCookieConsent,
|
|
63
70
|
resetCookieConsent,
|
|
64
|
-
trackGA4Event
|
|
71
|
+
trackGA4Event,
|
|
72
|
+
getOAuthProviders
|
|
65
73
|
} from '@cloudscaile-eng/web-ext-utils';
|
|
66
74
|
|
|
67
75
|
// Create extension object
|
|
@@ -93,9 +101,21 @@ toast(extension, 'Welcome!', 'success');
|
|
|
93
101
|
const user = getUser(extension);
|
|
94
102
|
const permissions = validateUserPermission(extension, ['payment.refund', 'inventory.bill']); // Returns {"payment.refund": true, "inventory.bill": false}
|
|
95
103
|
|
|
96
|
-
// Trigger login
|
|
104
|
+
// Trigger login – redirect only (navigates to auth page, returns after login)
|
|
97
105
|
triggerLogin(extension, { redirect: '/home/dash' });
|
|
98
106
|
|
|
107
|
+
// Trigger login – SSO / social provider
|
|
108
|
+
triggerLogin(extension, { provider: 'google', redirect: '/home/dash' });
|
|
109
|
+
|
|
110
|
+
// Trigger login – email / password (returns { success, data } or { success, error })
|
|
111
|
+
const result = await triggerLogin(extension, { email: 'user@example.com', password: 'secret', redirect: '/home/dash' });
|
|
112
|
+
if (result?.success) {
|
|
113
|
+
console.log('Logged in', result.data);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Trigger logout with redirect
|
|
117
|
+
await triggerLogout(extension, { redirect: '/home/login' });
|
|
118
|
+
|
|
99
119
|
// Cookie consent
|
|
100
120
|
const consent = getCookieConsent(extension); // { status: 'pending', timestamp: null }
|
|
101
121
|
updateCookieConsent(extension, 'accepted');
|
|
@@ -104,6 +124,10 @@ resetCookieConsent(extension);
|
|
|
104
124
|
// Track GA4 events (no-ops if consent not given)
|
|
105
125
|
trackGA4Event(extension, 'login', { method: 'email' });
|
|
106
126
|
trackGA4Event(extension, 'purchase', { item: 'cart', value: 49 });
|
|
127
|
+
|
|
128
|
+
// Get configured OAuth / SSO providers (sorted by order in the host)
|
|
129
|
+
const providers = getOAuthProviders(extension);
|
|
130
|
+
// providers → [{ value: 'google', name: 'Google', displayName: 'Continue with Google', icon: '/icons/google.svg', order: 1 }, ...]
|
|
107
131
|
```
|
|
108
132
|
|
|
109
133
|
## API Reference
|
|
@@ -124,11 +148,12 @@ Initializes shared resources in the host application.
|
|
|
124
148
|
- `config.getUser`: Function to get user information.
|
|
125
149
|
- `config.validateUserPermission`: Function to validate user permissions.
|
|
126
150
|
- `config.triggerLogin`: Function to trigger login in the host.
|
|
127
|
-
- `config.
|
|
151
|
+
- `config.triggerLogout`: Function to trigger logout in the host.
|
|
128
152
|
- `config.getCookieConsent`: Function to retrieve the current cookie consent state.
|
|
129
153
|
- `config.updateCookieConsent`: Function to dispatch consent actions and initialize analytics on acceptance.
|
|
130
154
|
- `config.resetCookieConsent`: Function to reset consent state and stop analytics events.
|
|
131
155
|
- `config.trackGA4Event`: Function to track a GA4 event.
|
|
156
|
+
- `config.getOAuthProviders`: Function to get the list of available OAuth providers.
|
|
132
157
|
|
|
133
158
|
#### Returns
|
|
134
159
|
|
|
@@ -245,17 +270,40 @@ An object mapping each permission to a boolean (e.g., `{"payment.refund": true,
|
|
|
245
270
|
|
|
246
271
|
### `triggerLogin(extension, config)`
|
|
247
272
|
|
|
248
|
-
Triggers the login process in the host application
|
|
273
|
+
Triggers the login process in the host application. Supports three modes:
|
|
274
|
+
|
|
275
|
+
| Mode | Config supplied | Behaviour |
|
|
276
|
+
|---|---|---|
|
|
277
|
+
| Redirect only | `redirect` | Navigates to the auth page; returns to `redirect` after login |
|
|
278
|
+
| SSO / social | `provider` (+ optional `redirect`) | Redirects the browser to the configured SSO URL |
|
|
279
|
+
| Credential login | `email` + `password` (+ optional `redirect`) | Calls the login API, stores tokens and user in Redux |
|
|
249
280
|
|
|
250
281
|
#### Parameters
|
|
251
282
|
|
|
252
283
|
- `extension`: Extension object from `getExtension()`.
|
|
284
|
+
- `config.redirect`: Path to navigate to after a successful login (all modes).
|
|
285
|
+
- `config.email`: User email for direct credential login.
|
|
286
|
+
- `config.password`: User password for direct credential login.
|
|
287
|
+
- `config.provider`: Social / SSO provider identifier (e.g. `'google'`).
|
|
253
288
|
|
|
254
|
-
|
|
289
|
+
**Returns:**
|
|
290
|
+
|
|
291
|
+
`Promise<{ success: true; data: unknown } | { success: false; error: unknown } | undefined>`
|
|
292
|
+
|
|
293
|
+
Returns a result object only for credential login. SSO and redirect flows return `undefined`.
|
|
294
|
+
|
|
295
|
+
### `triggerLogout(extension, config)`
|
|
296
|
+
|
|
297
|
+
Triggers the logout process in the host application for the given extension.
|
|
298
|
+
|
|
299
|
+
#### Parameters
|
|
300
|
+
|
|
301
|
+
- `extension`: Extension object from `getExtension()`.
|
|
302
|
+
- `config.redirect`: Path to navigate to after logout completes.
|
|
255
303
|
|
|
256
304
|
**Returns:**
|
|
257
305
|
|
|
258
|
-
|
|
306
|
+
`Promise<void>`
|
|
259
307
|
|
|
260
308
|
#### `getCookieConsent(extension)`
|
|
261
309
|
|
|
@@ -296,6 +344,26 @@ Tracks a GA4 event. Silently no-ops if analytics has not been initialized (i.e.
|
|
|
296
344
|
- `eventName`: The GA4 event name (e.g. `'login'`, `'purchase'`).
|
|
297
345
|
- `params`: Optional object of event parameters (e.g. `{ method: 'email' }`).
|
|
298
346
|
|
|
347
|
+
#### `getOAuthProviders(extension)`
|
|
348
|
+
|
|
349
|
+
Returns the list of OAuth / SSO login providers configured by the host application.
|
|
350
|
+
|
|
351
|
+
**Parameters:**
|
|
352
|
+
|
|
353
|
+
- `extension`: Extension object from `getExtension()`.
|
|
354
|
+
|
|
355
|
+
**Returns:**
|
|
356
|
+
|
|
357
|
+
An array of `OAuthProvider` objects:
|
|
358
|
+
|
|
359
|
+
| Field | Type | Description |
|
|
360
|
+
|---|---|---|
|
|
361
|
+
| `value` | `string` | Unique provider identifier (e.g. `'google'`) |
|
|
362
|
+
| `name` | `string` | Provider name used as icon alt text |
|
|
363
|
+
| `displayName` | `string` | Label shown on the login button |
|
|
364
|
+
| `icon` | `string` | URL or path to the provider's icon image |
|
|
365
|
+
| `order` | `number` | Sort order relative to other providers |
|
|
366
|
+
|
|
299
367
|
## Error Handling
|
|
300
368
|
|
|
301
369
|
- If the host has not initialized resources, individual resource functions will throw an error.
|
|
@@ -110,6 +110,15 @@ export declare function getExtension(tenant: string, name: string): Extension;
|
|
|
110
110
|
*/
|
|
111
111
|
export declare function getNsForTranslation(extension: Extension, extensionNs: string): string;
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Returns the list of configured OAuth / SSO providers for the given extension,
|
|
115
|
+
* sorted by the host-defined order.
|
|
116
|
+
* @param extension - The extension object.
|
|
117
|
+
* @returns Array of OAuth provider descriptors.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export declare function getOAuthProviders(extension: Extension): OAuthProvider[];
|
|
121
|
+
|
|
113
122
|
/**
|
|
114
123
|
* Returns the Redux store resource for the given extension.
|
|
115
124
|
* @param extension - The extension object.
|
|
@@ -156,12 +165,14 @@ export declare interface HostConfig {
|
|
|
156
165
|
getUser: SharedResources['getUser'];
|
|
157
166
|
validateUserPermission: SharedResources['validateUserPermission'];
|
|
158
167
|
triggerLogin: SharedResources['triggerLogin'];
|
|
168
|
+
triggerLogout: SharedResources['triggerLogout'];
|
|
159
169
|
theme: SharedResources['theme'];
|
|
160
170
|
initialized?: boolean;
|
|
161
171
|
getCookieConsent: SharedResources['getCookieConsent'];
|
|
162
172
|
updateCookieConsent: SharedResources['updateCookieConsent'];
|
|
163
173
|
resetCookieConsent: SharedResources['resetCookieConsent'];
|
|
164
174
|
trackGA4Event: SharedResources['trackGA4Event'];
|
|
175
|
+
getOAuthProviders: SharedResources['getOAuthProviders'];
|
|
165
176
|
}
|
|
166
177
|
|
|
167
178
|
/**
|
|
@@ -177,10 +188,12 @@ export declare interface HostConfig {
|
|
|
177
188
|
* - getUser: Function to get the user information from the host
|
|
178
189
|
* - validateUserPermission: Function to validate user permissions in the host
|
|
179
190
|
* - triggerLogin: Function to trigger login in the host
|
|
191
|
+
* - triggerLogout: Function to trigger logout in the host
|
|
180
192
|
* - getCookieConsent: Function to retrieve the current cookie consent state
|
|
181
193
|
* - updateCookieConsent: Function to dispatch consent actions and initialize analytics on acceptance
|
|
182
194
|
* - resetCookieConsent: Function to reset consent state and stop analytics events
|
|
183
195
|
* - trackGA4Event: Function to track a GA4 event
|
|
196
|
+
* - getOAuthProviders: Function to get the list of available OAuth providers
|
|
184
197
|
* @throws Will throw an error if any required configuration is missing
|
|
185
198
|
* @returns Object with method to access shared resources
|
|
186
199
|
* @public
|
|
@@ -206,6 +219,18 @@ export declare type InjectedReducer = {
|
|
|
206
219
|
*/
|
|
207
220
|
export declare function injectReducers(extension: Extension, params: InjectedReducer): boolean;
|
|
208
221
|
|
|
222
|
+
/**
|
|
223
|
+
* OAuth / SSO login provider descriptor returned by getOAuthProviders
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export declare type OAuthProvider = {
|
|
227
|
+
value: string;
|
|
228
|
+
name: string;
|
|
229
|
+
displayName: string;
|
|
230
|
+
icon: string;
|
|
231
|
+
order: number;
|
|
232
|
+
};
|
|
233
|
+
|
|
209
234
|
/**
|
|
210
235
|
* Configuration for registering translations
|
|
211
236
|
* @public
|
|
@@ -266,13 +291,15 @@ export declare interface SharedResources {
|
|
|
266
291
|
toast: (message: string, type: ToastType) => void;
|
|
267
292
|
getUser: () => User;
|
|
268
293
|
validateUserPermission: (extension: Extension, permissions: string[]) => Record<string, boolean>;
|
|
269
|
-
triggerLogin: (config?: TriggerLoginConfig) =>
|
|
294
|
+
triggerLogin: (config?: TriggerLoginConfig) => Promise<TriggerLoginResult | undefined>;
|
|
295
|
+
triggerLogout: (config?: TriggerLogoutConfig) => Promise<void>;
|
|
270
296
|
theme: Theme;
|
|
271
297
|
initialized: boolean;
|
|
272
298
|
getCookieConsent: () => CookieConsent;
|
|
273
299
|
updateCookieConsent: (status: CookieConsentStatus) => void;
|
|
274
300
|
resetCookieConsent: () => void;
|
|
275
301
|
trackGA4Event: (eventName: string, params?: Record<string, unknown>) => void;
|
|
302
|
+
getOAuthProviders: () => OAuthProvider[];
|
|
276
303
|
}
|
|
277
304
|
|
|
278
305
|
export { StoreEnhancer }
|
|
@@ -310,12 +337,22 @@ export declare function trackGA4Event(extension: Extension, eventName: string, p
|
|
|
310
337
|
|
|
311
338
|
/**
|
|
312
339
|
* Triggers the login process in the host application for the given extension.
|
|
340
|
+
*
|
|
341
|
+
* Supports three modes based on the supplied config:
|
|
342
|
+
* - **SSO / social login**: pass `provider` to redirect the browser to the configured SSO URL.
|
|
343
|
+
* - **Redirect only**: pass only `redirect` (no credentials) to navigate the user to the auth
|
|
344
|
+
* page with an optional `from` state so they return after login.
|
|
345
|
+
* - **Email / password login**: pass `email` and `password` to authenticate directly via the API.
|
|
346
|
+
* On success, tokens, user details, and permissions are stored in the Redux store.
|
|
347
|
+
*
|
|
313
348
|
* @param extension - The extension object.
|
|
314
|
-
* @param config - Optional configuration for
|
|
315
|
-
*
|
|
349
|
+
* @param config - Optional configuration: `redirect` (return path), `email`+`password` for
|
|
350
|
+
* credential login, or `provider` for SSO (e.g. `'google'`).
|
|
351
|
+
* @returns A promise resolving to `{ success: true, data }` on credential login success,
|
|
352
|
+
* `{ success: false, error }` on failure, or `undefined` for redirect / SSO flows.
|
|
316
353
|
* @public
|
|
317
354
|
*/
|
|
318
|
-
export declare function triggerLogin(extension: Extension, config?: TriggerLoginConfig):
|
|
355
|
+
export declare function triggerLogin(extension: Extension, config?: TriggerLoginConfig): Promise<TriggerLoginResult | undefined>;
|
|
319
356
|
|
|
320
357
|
/**
|
|
321
358
|
* Configuration for triggering the login process
|
|
@@ -323,6 +360,38 @@ export declare function triggerLogin(extension: Extension, config?: TriggerLogin
|
|
|
323
360
|
*/
|
|
324
361
|
export declare type TriggerLoginConfig = {
|
|
325
362
|
redirect?: string;
|
|
363
|
+
email?: string;
|
|
364
|
+
password?: string;
|
|
365
|
+
provider?: string;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Result returned by triggerLogin when credentials or SSO provider are supplied
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
export declare type TriggerLoginResult = {
|
|
373
|
+
success: true;
|
|
374
|
+
data: unknown;
|
|
375
|
+
} | {
|
|
376
|
+
success: false;
|
|
377
|
+
error: unknown;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Triggers the logout process in the host application for the given extension.
|
|
382
|
+
* @param extension - The extension object.
|
|
383
|
+
* @param config - Optional configuration: `redirect` (path to navigate to after logout).
|
|
384
|
+
* @returns A promise that resolves once the logout process completes.
|
|
385
|
+
* @public
|
|
386
|
+
*/
|
|
387
|
+
export declare function triggerLogout(extension: Extension, config?: TriggerLogoutConfig): Promise<void>;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Configuration for triggering the logout process
|
|
391
|
+
* @public
|
|
392
|
+
*/
|
|
393
|
+
export declare type TriggerLogoutConfig = {
|
|
394
|
+
redirect?: string;
|
|
326
395
|
};
|
|
327
396
|
|
|
328
397
|
export { Tuple }
|
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,15 @@ export declare function getExtension(tenant: string, name: string): Extension;
|
|
|
110
110
|
*/
|
|
111
111
|
export declare function getNsForTranslation(extension: Extension, extensionNs: string): string;
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Returns the list of configured OAuth / SSO providers for the given extension,
|
|
115
|
+
* sorted by the host-defined order.
|
|
116
|
+
* @param extension - The extension object.
|
|
117
|
+
* @returns Array of OAuth provider descriptors.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export declare function getOAuthProviders(extension: Extension): OAuthProvider[];
|
|
121
|
+
|
|
113
122
|
/**
|
|
114
123
|
* Returns the Redux store resource for the given extension.
|
|
115
124
|
* @param extension - The extension object.
|
|
@@ -156,12 +165,14 @@ export declare interface HostConfig {
|
|
|
156
165
|
getUser: SharedResources['getUser'];
|
|
157
166
|
validateUserPermission: SharedResources['validateUserPermission'];
|
|
158
167
|
triggerLogin: SharedResources['triggerLogin'];
|
|
168
|
+
triggerLogout: SharedResources['triggerLogout'];
|
|
159
169
|
theme: SharedResources['theme'];
|
|
160
170
|
initialized?: boolean;
|
|
161
171
|
getCookieConsent: SharedResources['getCookieConsent'];
|
|
162
172
|
updateCookieConsent: SharedResources['updateCookieConsent'];
|
|
163
173
|
resetCookieConsent: SharedResources['resetCookieConsent'];
|
|
164
174
|
trackGA4Event: SharedResources['trackGA4Event'];
|
|
175
|
+
getOAuthProviders: SharedResources['getOAuthProviders'];
|
|
165
176
|
}
|
|
166
177
|
|
|
167
178
|
/**
|
|
@@ -177,10 +188,12 @@ export declare interface HostConfig {
|
|
|
177
188
|
* - getUser: Function to get the user information from the host
|
|
178
189
|
* - validateUserPermission: Function to validate user permissions in the host
|
|
179
190
|
* - triggerLogin: Function to trigger login in the host
|
|
191
|
+
* - triggerLogout: Function to trigger logout in the host
|
|
180
192
|
* - getCookieConsent: Function to retrieve the current cookie consent state
|
|
181
193
|
* - updateCookieConsent: Function to dispatch consent actions and initialize analytics on acceptance
|
|
182
194
|
* - resetCookieConsent: Function to reset consent state and stop analytics events
|
|
183
195
|
* - trackGA4Event: Function to track a GA4 event
|
|
196
|
+
* - getOAuthProviders: Function to get the list of available OAuth providers
|
|
184
197
|
* @throws Will throw an error if any required configuration is missing
|
|
185
198
|
* @returns Object with method to access shared resources
|
|
186
199
|
* @public
|
|
@@ -206,6 +219,18 @@ export declare type InjectedReducer = {
|
|
|
206
219
|
*/
|
|
207
220
|
export declare function injectReducers(extension: Extension, params: InjectedReducer): boolean;
|
|
208
221
|
|
|
222
|
+
/**
|
|
223
|
+
* OAuth / SSO login provider descriptor returned by getOAuthProviders
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export declare type OAuthProvider = {
|
|
227
|
+
value: string;
|
|
228
|
+
name: string;
|
|
229
|
+
displayName: string;
|
|
230
|
+
icon: string;
|
|
231
|
+
order: number;
|
|
232
|
+
};
|
|
233
|
+
|
|
209
234
|
/**
|
|
210
235
|
* Configuration for registering translations
|
|
211
236
|
* @public
|
|
@@ -266,13 +291,15 @@ export declare interface SharedResources {
|
|
|
266
291
|
toast: (message: string, type: ToastType) => void;
|
|
267
292
|
getUser: () => User;
|
|
268
293
|
validateUserPermission: (extension: Extension, permissions: string[]) => Record<string, boolean>;
|
|
269
|
-
triggerLogin: (config?: TriggerLoginConfig) =>
|
|
294
|
+
triggerLogin: (config?: TriggerLoginConfig) => Promise<TriggerLoginResult | undefined>;
|
|
295
|
+
triggerLogout: (config?: TriggerLogoutConfig) => Promise<void>;
|
|
270
296
|
theme: Theme;
|
|
271
297
|
initialized: boolean;
|
|
272
298
|
getCookieConsent: () => CookieConsent;
|
|
273
299
|
updateCookieConsent: (status: CookieConsentStatus) => void;
|
|
274
300
|
resetCookieConsent: () => void;
|
|
275
301
|
trackGA4Event: (eventName: string, params?: Record<string, unknown>) => void;
|
|
302
|
+
getOAuthProviders: () => OAuthProvider[];
|
|
276
303
|
}
|
|
277
304
|
|
|
278
305
|
export { StoreEnhancer }
|
|
@@ -310,12 +337,22 @@ export declare function trackGA4Event(extension: Extension, eventName: string, p
|
|
|
310
337
|
|
|
311
338
|
/**
|
|
312
339
|
* Triggers the login process in the host application for the given extension.
|
|
340
|
+
*
|
|
341
|
+
* Supports three modes based on the supplied config:
|
|
342
|
+
* - **SSO / social login**: pass `provider` to redirect the browser to the configured SSO URL.
|
|
343
|
+
* - **Redirect only**: pass only `redirect` (no credentials) to navigate the user to the auth
|
|
344
|
+
* page with an optional `from` state so they return after login.
|
|
345
|
+
* - **Email / password login**: pass `email` and `password` to authenticate directly via the API.
|
|
346
|
+
* On success, tokens, user details, and permissions are stored in the Redux store.
|
|
347
|
+
*
|
|
313
348
|
* @param extension - The extension object.
|
|
314
|
-
* @param config - Optional configuration for
|
|
315
|
-
*
|
|
349
|
+
* @param config - Optional configuration: `redirect` (return path), `email`+`password` for
|
|
350
|
+
* credential login, or `provider` for SSO (e.g. `'google'`).
|
|
351
|
+
* @returns A promise resolving to `{ success: true, data }` on credential login success,
|
|
352
|
+
* `{ success: false, error }` on failure, or `undefined` for redirect / SSO flows.
|
|
316
353
|
* @public
|
|
317
354
|
*/
|
|
318
|
-
export declare function triggerLogin(extension: Extension, config?: TriggerLoginConfig):
|
|
355
|
+
export declare function triggerLogin(extension: Extension, config?: TriggerLoginConfig): Promise<TriggerLoginResult | undefined>;
|
|
319
356
|
|
|
320
357
|
/**
|
|
321
358
|
* Configuration for triggering the login process
|
|
@@ -323,6 +360,38 @@ export declare function triggerLogin(extension: Extension, config?: TriggerLogin
|
|
|
323
360
|
*/
|
|
324
361
|
export declare type TriggerLoginConfig = {
|
|
325
362
|
redirect?: string;
|
|
363
|
+
email?: string;
|
|
364
|
+
password?: string;
|
|
365
|
+
provider?: string;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Result returned by triggerLogin when credentials or SSO provider are supplied
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
export declare type TriggerLoginResult = {
|
|
373
|
+
success: true;
|
|
374
|
+
data: unknown;
|
|
375
|
+
} | {
|
|
376
|
+
success: false;
|
|
377
|
+
error: unknown;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Triggers the logout process in the host application for the given extension.
|
|
382
|
+
* @param extension - The extension object.
|
|
383
|
+
* @param config - Optional configuration: `redirect` (path to navigate to after logout).
|
|
384
|
+
* @returns A promise that resolves once the logout process completes.
|
|
385
|
+
* @public
|
|
386
|
+
*/
|
|
387
|
+
export declare function triggerLogout(extension: Extension, config?: TriggerLogoutConfig): Promise<void>;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Configuration for triggering the logout process
|
|
391
|
+
* @public
|
|
392
|
+
*/
|
|
393
|
+
export declare type TriggerLogoutConfig = {
|
|
394
|
+
redirect?: string;
|
|
326
395
|
};
|
|
327
396
|
|
|
328
397
|
export { Tuple }
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,KAAK,EACL,aAAa,EACb,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD;;;GAGG;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AAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC1F,YAAY,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,EACL,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,10 +19,12 @@ const ERROR_MAPS = {
|
|
|
19
19
|
getUser: 'Get User',
|
|
20
20
|
validateUserPermission: 'Validate User Permission',
|
|
21
21
|
triggerLogin: 'Trigger Login',
|
|
22
|
+
triggerLogout: 'Trigger Logout',
|
|
22
23
|
getCookieConsent: 'Get Cookie Consent',
|
|
23
24
|
updateCookieConsent: 'Update Cookie Consent',
|
|
24
25
|
resetCookieConsent: 'Reset Cookie Consent',
|
|
25
|
-
trackGA4Event: 'Track GA4 Event'
|
|
26
|
+
trackGA4Event: 'Track GA4 Event',
|
|
27
|
+
getOAuthProviders: 'Get OAuth Providers'
|
|
26
28
|
};
|
|
27
29
|
/**
|
|
28
30
|
* Initialize the communication package in the host application
|
|
@@ -37,10 +39,12 @@ const ERROR_MAPS = {
|
|
|
37
39
|
* - getUser: Function to get the user information from the host
|
|
38
40
|
* - validateUserPermission: Function to validate user permissions in the host
|
|
39
41
|
* - triggerLogin: Function to trigger login in the host
|
|
42
|
+
* - triggerLogout: Function to trigger logout in the host
|
|
40
43
|
* - getCookieConsent: Function to retrieve the current cookie consent state
|
|
41
44
|
* - updateCookieConsent: Function to dispatch consent actions and initialize analytics on acceptance
|
|
42
45
|
* - resetCookieConsent: Function to reset consent state and stop analytics events
|
|
43
46
|
* - trackGA4Event: Function to track a GA4 event
|
|
47
|
+
* - getOAuthProviders: Function to get the list of available OAuth providers
|
|
44
48
|
* @throws Will throw an error if any required configuration is missing
|
|
45
49
|
* @returns Object with method to access shared resources
|
|
46
50
|
* @public
|
|
@@ -214,9 +218,19 @@ export function validateUserPermission(extension, permissions) {
|
|
|
214
218
|
}
|
|
215
219
|
/**
|
|
216
220
|
* Triggers the login process in the host application for the given extension.
|
|
221
|
+
*
|
|
222
|
+
* Supports three modes based on the supplied config:
|
|
223
|
+
* - **SSO / social login**: pass `provider` to redirect the browser to the configured SSO URL.
|
|
224
|
+
* - **Redirect only**: pass only `redirect` (no credentials) to navigate the user to the auth
|
|
225
|
+
* page with an optional `from` state so they return after login.
|
|
226
|
+
* - **Email / password login**: pass `email` and `password` to authenticate directly via the API.
|
|
227
|
+
* On success, tokens, user details, and permissions are stored in the Redux store.
|
|
228
|
+
*
|
|
217
229
|
* @param extension - The extension object.
|
|
218
|
-
* @param config - Optional configuration for
|
|
219
|
-
*
|
|
230
|
+
* @param config - Optional configuration: `redirect` (return path), `email`+`password` for
|
|
231
|
+
* credential login, or `provider` for SSO (e.g. `'google'`).
|
|
232
|
+
* @returns A promise resolving to `{ success: true, data }` on credential login success,
|
|
233
|
+
* `{ success: false, error }` on failure, or `undefined` for redirect / SSO flows.
|
|
220
234
|
* @public
|
|
221
235
|
*/
|
|
222
236
|
export function triggerLogin(extension, config) {
|
|
@@ -224,6 +238,18 @@ export function triggerLogin(extension, config) {
|
|
|
224
238
|
const triggerLoginResource = getResource('triggerLogin');
|
|
225
239
|
return triggerLoginResource(config);
|
|
226
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Triggers the logout process in the host application for the given extension.
|
|
243
|
+
* @param extension - The extension object.
|
|
244
|
+
* @param config - Optional configuration: `redirect` (path to navigate to after logout).
|
|
245
|
+
* @returns A promise that resolves once the logout process completes.
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
export function triggerLogout(extension, config) {
|
|
249
|
+
validateExtension(extension);
|
|
250
|
+
const triggerLogoutResource = getResource('triggerLogout');
|
|
251
|
+
return triggerLogoutResource(config);
|
|
252
|
+
}
|
|
227
253
|
/**
|
|
228
254
|
* Retrieves the current cookie consent state for the given extension.
|
|
229
255
|
* @param extension - The extension object.
|
|
@@ -271,4 +297,16 @@ export function trackGA4Event(extension, eventName, params = {}) {
|
|
|
271
297
|
const trackGA4EventResource = getResource('trackGA4Event');
|
|
272
298
|
trackGA4EventResource(eventName, params);
|
|
273
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Returns the list of configured OAuth / SSO providers for the given extension,
|
|
302
|
+
* sorted by the host-defined order.
|
|
303
|
+
* @param extension - The extension object.
|
|
304
|
+
* @returns Array of OAuth provider descriptors.
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
export function getOAuthProviders(extension) {
|
|
308
|
+
validateExtension(extension);
|
|
309
|
+
const getOAuthProvidersResource = getResource('getOAuthProviders');
|
|
310
|
+
return getOAuthProvidersResource();
|
|
311
|
+
}
|
|
274
312
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAgOF,2CAA2C;AAE3C,IAAI,WAAW,GAA6B;IAC1C,WAAW,EAAE,KAAK;CACnB,CAAC;AAEF,MAAM,UAAU,GAA0D;IACxE,QAAQ,EAAE,mBAAmB;IAC7B,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,WAAW;IACrB,cAAc,EAAE,iBAAiB;IACjC,mBAAmB,EAAE,sBAAsB;IAC3C,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,UAAU;IACnB,sBAAsB,EAAE,0BAA0B;IAClD,YAAY,EAAE,eAAe;IAC7B,aAAa,EAAE,gBAAgB;IAC/B,gBAAgB,EAAE,oBAAoB;IACtC,mBAAmB,EAAE,uBAAuB;IAC5C,kBAAkB,EAAE,sBAAsB;IAC1C,aAAa,EAAE,iBAAiB;IAChC,iBAAiB,EAAE,qBAAqB;CACzC,CAA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