@thunderid/browser 0.0.4 → 0.1.0

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.
Files changed (112) hide show
  1. package/README.md +1 -1
  2. package/dist/FetchHttpClient.d.ts +1 -0
  3. package/dist/FetchHttpClient.d.ts.map +1 -1
  4. package/dist/ThunderIDBrowserClient.d.ts +66 -10
  5. package/dist/ThunderIDBrowserClient.d.ts.map +1 -1
  6. package/dist/cjs/index.js +1333 -3001
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/{__legacy__/constants/hooks.d.ts → constants/Hooks.d.ts} +5 -1
  9. package/dist/constants/Hooks.d.ts.map +1 -0
  10. package/dist/{__legacy__/constants/session-management.d.ts → constants/SPAConstants.d.ts} +11 -2
  11. package/dist/constants/SPAConstants.d.ts.map +1 -0
  12. package/dist/index.d.ts +23 -18
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1568 -3248
  15. package/dist/index.js.map +1 -1
  16. package/dist/models/BrowserConfig.d.ts +46 -0
  17. package/dist/models/BrowserConfig.d.ts.map +1 -0
  18. package/dist/{__legacy__/models/storage.d.ts → models/BrowserStorage.d.ts} +7 -16
  19. package/dist/models/BrowserStorage.d.ts.map +1 -0
  20. package/dist/{__legacy__/models/sign-in.d.ts → models/SignInConfig.d.ts} +9 -1
  21. package/dist/models/SignInConfig.d.ts.map +1 -0
  22. package/dist/{__legacy__/models/sign-out-error.d.ts → models/SignOutError.d.ts} +7 -1
  23. package/dist/models/SignOutError.d.ts.map +1 -0
  24. package/dist/{__legacy__/models/request-custom-grant.d.ts → models/TokenExchangeConfig.d.ts} +8 -3
  25. package/dist/models/TokenExchangeConfig.d.ts.map +1 -0
  26. package/dist/models/config.d.ts +1 -1
  27. package/dist/models/config.d.ts.map +1 -1
  28. package/dist/{__legacy__/stores/session-store.d.ts → stores/LocalStore.d.ts} +6 -2
  29. package/dist/stores/LocalStore.d.ts.map +1 -0
  30. package/dist/{__legacy__/stores/memory-store.d.ts → stores/MemoryStore.d.ts} +6 -2
  31. package/dist/stores/MemoryStore.d.ts.map +1 -0
  32. package/dist/{__legacy__/stores/local-store.d.ts → stores/SessionStore.d.ts} +6 -2
  33. package/dist/stores/SessionStore.d.ts.map +1 -0
  34. package/dist/utils/AuthenticationHelper.d.ts +192 -0
  35. package/dist/utils/AuthenticationHelper.d.ts.map +1 -0
  36. package/dist/utils/SPACryptoUtils.d.ts +68 -0
  37. package/dist/utils/SPACryptoUtils.d.ts.map +1 -0
  38. package/dist/utils/SPAHelper.d.ts +50 -0
  39. package/dist/utils/SPAHelper.d.ts.map +1 -0
  40. package/dist/utils/SPAUtils.d.ts +145 -0
  41. package/dist/utils/SPAUtils.d.ts.map +1 -0
  42. package/dist/{__legacy__/models/session-management-helper.d.ts → utils/SessionManagementHelper.d.ts} +21 -2
  43. package/dist/utils/SessionManagementHelper.d.ts.map +1 -0
  44. package/dist/utils/http.d.ts +12 -25
  45. package/dist/utils/http.d.ts.map +1 -1
  46. package/package.json +6 -4
  47. package/dist/__legacy__/client.d.ts +0 -767
  48. package/dist/__legacy__/client.d.ts.map +0 -1
  49. package/dist/__legacy__/clients/index.d.ts +0 -20
  50. package/dist/__legacy__/clients/index.d.ts.map +0 -1
  51. package/dist/__legacy__/clients/main-thread-client.d.ts +0 -23
  52. package/dist/__legacy__/clients/main-thread-client.d.ts.map +0 -1
  53. package/dist/__legacy__/clients/web-worker-client.d.ts +0 -22
  54. package/dist/__legacy__/clients/web-worker-client.d.ts.map +0 -1
  55. package/dist/__legacy__/constants/errors.d.ts +0 -19
  56. package/dist/__legacy__/constants/errors.d.ts.map +0 -1
  57. package/dist/__legacy__/constants/hooks.d.ts.map +0 -1
  58. package/dist/__legacy__/constants/index.d.ts +0 -24
  59. package/dist/__legacy__/constants/index.d.ts.map +0 -1
  60. package/dist/__legacy__/constants/messages-types.d.ts +0 -52
  61. package/dist/__legacy__/constants/messages-types.d.ts.map +0 -1
  62. package/dist/__legacy__/constants/parameters.d.ts +0 -22
  63. package/dist/__legacy__/constants/parameters.d.ts.map +0 -1
  64. package/dist/__legacy__/constants/session-management.d.ts.map +0 -1
  65. package/dist/__legacy__/constants/storage.d.ts +0 -19
  66. package/dist/__legacy__/constants/storage.d.ts.map +0 -1
  67. package/dist/__legacy__/helpers/authentication-helper.d.ts +0 -59
  68. package/dist/__legacy__/helpers/authentication-helper.d.ts.map +0 -1
  69. package/dist/__legacy__/helpers/index.d.ts +0 -21
  70. package/dist/__legacy__/helpers/index.d.ts.map +0 -1
  71. package/dist/__legacy__/helpers/session-management-helper.d.ts +0 -21
  72. package/dist/__legacy__/helpers/session-management-helper.d.ts.map +0 -1
  73. package/dist/__legacy__/helpers/spa-helper.d.ts +0 -30
  74. package/dist/__legacy__/helpers/spa-helper.d.ts.map +0 -1
  75. package/dist/__legacy__/models/client-config.d.ts +0 -55
  76. package/dist/__legacy__/models/client-config.d.ts.map +0 -1
  77. package/dist/__legacy__/models/client.d.ts +0 -85
  78. package/dist/__legacy__/models/client.d.ts.map +0 -1
  79. package/dist/__legacy__/models/http-client.d.ts +0 -30
  80. package/dist/__legacy__/models/http-client.d.ts.map +0 -1
  81. package/dist/__legacy__/models/index.d.ts +0 -27
  82. package/dist/__legacy__/models/index.d.ts.map +0 -1
  83. package/dist/__legacy__/models/message.d.ts +0 -47
  84. package/dist/__legacy__/models/message.d.ts.map +0 -1
  85. package/dist/__legacy__/models/request-custom-grant.d.ts.map +0 -1
  86. package/dist/__legacy__/models/session-management-helper.d.ts.map +0 -1
  87. package/dist/__legacy__/models/sign-in.d.ts.map +0 -1
  88. package/dist/__legacy__/models/sign-out-error.d.ts.map +0 -1
  89. package/dist/__legacy__/models/storage.d.ts.map +0 -1
  90. package/dist/__legacy__/models/web-worker.d.ts +0 -57
  91. package/dist/__legacy__/models/web-worker.d.ts.map +0 -1
  92. package/dist/__legacy__/stores/index.d.ts +0 -21
  93. package/dist/__legacy__/stores/index.d.ts.map +0 -1
  94. package/dist/__legacy__/stores/local-store.d.ts.map +0 -1
  95. package/dist/__legacy__/stores/memory-store.d.ts.map +0 -1
  96. package/dist/__legacy__/stores/session-store.d.ts.map +0 -1
  97. package/dist/__legacy__/utils/crypto-utils.d.ts +0 -32
  98. package/dist/__legacy__/utils/crypto-utils.d.ts.map +0 -1
  99. package/dist/__legacy__/utils/index.d.ts +0 -20
  100. package/dist/__legacy__/utils/index.d.ts.map +0 -1
  101. package/dist/__legacy__/utils/message-utils.d.ts +0 -38
  102. package/dist/__legacy__/utils/message-utils.d.ts.map +0 -1
  103. package/dist/__legacy__/utils/spa-utils.d.ts +0 -108
  104. package/dist/__legacy__/utils/spa-utils.d.ts.map +0 -1
  105. package/dist/__legacy__/worker/index.d.ts +0 -20
  106. package/dist/__legacy__/worker/index.d.ts.map +0 -1
  107. package/dist/__legacy__/worker/worker-core.d.ts +0 -22
  108. package/dist/__legacy__/worker/worker-core.d.ts.map +0 -1
  109. package/dist/__legacy__/worker/worker-receiver.d.ts +0 -22
  110. package/dist/__legacy__/worker/worker-receiver.d.ts.map +0 -1
  111. package/dist/web.worker.d.ts +0 -20
  112. package/dist/web.worker.d.ts.map +0 -1
@@ -1,767 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
- import { AuthClientConfig, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdToken, OIDCEndpoints, User, HttpClient } from '@thunderid/javascript';
19
- import { Hooks } from './constants';
20
- import { AuthenticationHelper } from './helpers';
21
- import { AuthSPAClientConfig, LegacyConfig as Config, HttpRequestConfig, HttpResponse, MainThreadClientConfig, MainThreadClientInterface, SignInConfig, SignOutError, WebWorkerClientConfig, WebWorkerClientInterface } from './models';
22
- import { BrowserStorage } from './models/storage';
23
- /**
24
- * This class provides the necessary methods to implement authentication in a Single Page Application.
25
- * Implements a Multiton pattern to support multi-tenancy scenarios where multiple authentication
26
- * contexts need to coexist in the same application.
27
- *
28
- * @export
29
- * @class ThunderIDSPAClient
30
- */
31
- export declare class ThunderIDSPAClient {
32
- protected static _instances: Map<number, ThunderIDSPAClient>;
33
- protected _client: WebWorkerClientInterface | MainThreadClientInterface | undefined;
34
- protected _storage: BrowserStorage | undefined;
35
- protected _authHelper: typeof AuthenticationHelper;
36
- protected _worker: new () => Worker;
37
- protected _initialized: boolean;
38
- protected _startedInitialize: boolean;
39
- protected _onSignInCallback: (response: User) => void;
40
- protected _onSignOutCallback: () => void;
41
- protected _onSignOutFailedCallback: (error: SignOutError) => void;
42
- protected _onEndUserSession: (response: any) => void;
43
- protected _onInitialize: (response: boolean) => void;
44
- protected _onCustomGrant: Map<string, (response: any) => void>;
45
- protected _instanceId: number;
46
- protected constructor(id: number);
47
- instantiateAuthHelper(authHelper?: typeof AuthenticationHelper): void;
48
- instantiateWorker(worker: new () => Worker): void;
49
- /**
50
- * This method specifies if the `ThunderIDSPAClient` has been initialized or not.
51
- *
52
- * @return {Promise<boolean>} - Resolves to `true` if the client has been initialized.
53
- *
54
- * @memberof ThunderIDSPAClient
55
- *
56
- * @private
57
- */
58
- isInitialized(): Promise<boolean>;
59
- /**
60
- * This method checks if the SDK is initialized and the user is authenticated.
61
- *
62
- * @param validateAuthentication - should user's authenticated status be checked as part of validation
63
- *
64
- * @return {Promise<boolean>} - A Promise that resolves with `true` if the SDK is initialized and the
65
- * user is authenticated.
66
- *
67
- * @memberof ThunderIDSPAClient
68
- *
69
- * @private
70
- */
71
- private _validateMethod;
72
- /**
73
- * This method returns the instance of the client for the specified ID.
74
- * Implements a Multiton pattern to support multiple authentication contexts.
75
- * If an ID is provided, it will return the instance with the given ID.
76
- * If no ID is provided, it will return the default instance (ID: 0).
77
- *
78
- * @param {number} id - Optional unique identifier for the instance.
79
- * @return {ThunderIDSPAClient} - Returns the instance associated with the ID.
80
- *
81
- * @example
82
- * ```
83
- * // Single tenant application (default instance)
84
- * const auth = ThunderIDSPAClient.getInstance();
85
- *
86
- * // Multi-instance application
87
- * const instance1 = ThunderIDSPAClient.getInstance(1);
88
- * const instance2 = ThunderIDSPAClient.getInstance(2);
89
- * ```
90
- *
91
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getinstance
92
- *
93
- * @memberof ThunderIDSPAClient
94
- *
95
- * @preserve
96
- */
97
- static getInstance(id?: number): ThunderIDSPAClient;
98
- /**
99
- * This method checks if an instance exists for the given ID.
100
- *
101
- * @param {number} id - Optional unique identifier for the instance.
102
- * @return {boolean} - Returns true if an instance exists for the ID.
103
- *
104
- * @example
105
- * ```
106
- * if (ThunderIDSPAClient.hasInstance(1)) {
107
- * const auth = ThunderIDSPAClient.getInstance(1);
108
- * }
109
- * ```
110
- *
111
- * @memberof ThunderIDSPAClient
112
- */
113
- static hasInstance(id?: number): boolean;
114
- /**
115
- * This method removes and cleans up a specific instance.
116
- * Useful when an instance is no longer needed.
117
- *
118
- * @param {number} id - Optional unique identifier for the instance to destroy.
119
- * @return {boolean} - Returns true if the instance was found and removed.
120
- *
121
- * @example
122
- * ```
123
- * // Remove a specific instance
124
- * ThunderIDSPAClient.destroyInstance(1);
125
- *
126
- * // Remove the default instance
127
- * ThunderIDSPAClient.destroyInstance();
128
- * ```
129
- *
130
- * @memberof ThunderIDSPAClient
131
- */
132
- static destroyInstance(id?: number): boolean;
133
- /**
134
- * This method returns all active instance IDs.
135
- * Useful for debugging or managing multiple instances.
136
- *
137
- * @return {number[]} - Returns an array of all active instance IDs.
138
- *
139
- * @example
140
- * ```
141
- * const activeInstances = ThunderIDSPAClient.getInstanceKeys();
142
- * console.log('Active instances:', activeInstances);
143
- * ```
144
- *
145
- * @memberof ThunderIDSPAClient
146
- */
147
- static getInstanceKeys(): number[];
148
- /**
149
- * This method removes all instances.
150
- * Useful for cleanup in testing scenarios or application teardown.
151
- *
152
- * @example
153
- * ```
154
- * ThunderIDSPAClient.destroyAllInstances();
155
- * ```
156
- *
157
- * @memberof ThunderIDSPAClient
158
- */
159
- static destroyAllInstances(): void;
160
- /**
161
- * This method returns the instance ID for this client instance.
162
- *
163
- * @return {number} - The instance ID.
164
- *
165
- * @example
166
- * ```
167
- * const auth = ThunderIDSPAClient.getInstance(1);
168
- * console.log(auth.getInstanceId()); // 1
169
- * ```
170
- *
171
- * @memberof ThunderIDSPAClient
172
- *
173
- * @preserve
174
- */
175
- getInstanceId(): number;
176
- /**
177
- * This method initializes the `ThunderIDSPAClient` instance.
178
- *
179
- * @param {ConfigInterface} config The config object to initialize with.
180
- *
181
- * @return {Promise<boolean>} - Resolves to `true` if initialization is successful.
182
- *
183
- * @example
184
- * ```
185
- * auth.initialize({
186
- * afterSignInUrl: "http://localhost:3000/sign-in",
187
- * clientId: "client ID",
188
- * baseUrl: "https://api.asgardeo.io"
189
- * });
190
- * ```
191
- *
192
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#initialize
193
- *
194
- * @memberof ThunderIDSPAClient
195
- *
196
- * @preserve
197
- */
198
- initialize(config: AuthSPAClientConfig, authHelper?: typeof AuthenticationHelper, workerFile?: new () => Worker): Promise<boolean>;
199
- /**
200
- * This method returns a Promise that resolves with the basic user information obtained from the ID token.
201
- *
202
- * @return {Promise<User>} - A promise that resolves with the user information.
203
- *
204
- * @example
205
- * ```
206
- * auth.getUser().then((response) => {
207
- * // console.log(response);
208
- * }).catch((error) => {
209
- * // console.error(error);
210
- * });
211
- * ```
212
- *
213
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getuserinfo
214
- *
215
- * @memberof ThunderIDSPAClient
216
- *
217
- * @preserve
218
- */
219
- getUser(): Promise<User | undefined>;
220
- /**
221
- * This method initiates the authentication flow. This should be called twice.
222
- * 1. To initiate the authentication flow.
223
- * 2. To obtain the access token after getting the authorization code.
224
- *
225
- * To satisfy the second condition, one of the two strategies mentioned below can be used:
226
- * 1. Redirect the user back to the same login page that initiated the authentication flow.
227
- * 2. Call the `signIn()` method in the page the user is redirected to after authentication.
228
- *
229
- * **To fire a callback function after signing in, use the `on()` method.**
230
- * **To learn more about the `on()` method:**
231
- * @see {@link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on}
232
- *
233
- * @param {SignInConfig} config - The sign-in config.
234
- * The `SignInConfig` object has these two attributes in addition to any custom key-value pairs.
235
- * 1. fidp - Specifies the FIDP parameter that is used to take the user directly to an IdP login page.
236
- * 2. forceInit: Specifies if the OIDC Provider Meta Data should be loaded again from the `well-known`
237
- * endpoint.
238
- * 3. Any other parameters that should be appended to the authorization request.
239
- * @param {string} authorizationCode - The authorization code. (Optional)
240
- * @param {string} sessionState - The session state. (Optional)
241
- * @param {string} state - The state. (Optional)
242
- *
243
- * @return {Promise<User>} - A promise that resolves with the user information.
244
- *
245
- * @example
246
- * ```
247
- * auth.signIn();
248
- * ```
249
- *
250
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#signin
251
- *
252
- * @memberof ThunderIDSPAClient
253
- *
254
- * @preserve
255
- */
256
- signIn(config?: SignInConfig, authorizationCode?: string, sessionState?: string, state?: string, tokenRequestConfig?: {
257
- params: Record<string, unknown>;
258
- }): Promise<User | undefined>;
259
- /**
260
- * This method allows you to sign in silently.
261
- * First, this method sends a prompt none request to see if there is an active user session in the identity server.
262
- * If there is one, then it requests the access token and stores it. Else, it returns false.
263
- *
264
- * If this method is to be called on page load and the `signIn` method is also to be called on page load,
265
- * then it is advisable to call this method after the `signIn` call.
266
- *
267
- * @return {Promise<User | boolean>} - A Promise that resolves with the user information after signing in
268
- * or with `false` if the user is not signed in.
269
- *
270
- * @example
271
- *```
272
- * auth.signInSilently()
273
- *```
274
- */
275
- signInSilently(additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
276
- params: Record<string, unknown>;
277
- }): Promise<User | boolean | undefined>;
278
- /**
279
- * This method initiates the sign-out flow.
280
- *
281
- * **To fire a callback function after signing out, use the `on()` method.**
282
- * **To learn more about the `on()` method:**
283
- * @see {@link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on}
284
- *
285
- * @return {Promise<boolean>} - Returns a promise that resolves with `true` if sign out is successful.
286
- *
287
- * @example
288
- * ```
289
- * auth.signOut();
290
- * ```
291
- *
292
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#signout
293
- *
294
- * @memberof ThunderIDSPAClient
295
- *
296
- * @preserve
297
- */
298
- signOut(): Promise<boolean>;
299
- /**
300
- * This method sends an API request to a protected endpoint.
301
- * The access token is automatically attached to the header of the request.
302
- * This is the only way by which protected endpoints can be accessed
303
- * when the web worker is used to store session information.
304
- *
305
- * @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
306
- *
307
- * @return {Promise<HttpResponse>} - Returns a Promise that resolves with the response to the request.
308
- *
309
- * @example
310
- * ```
311
- * const requestConfig = {
312
- * headers: {
313
- * "Accept": "application/json",
314
- * "Access-Control-Allow-Origin": "https://api.asgardeo.io/myaccount",
315
- * "Content-Type": "application/scim+json"
316
- * },
317
- * method: "GET",
318
- * url: "https://api.asgardeo.io/scim2/me"
319
- * };
320
- *
321
- * return auth.httpRequest(requestConfig)
322
- * .then((response) => {
323
- * // console.log(response);
324
- * })
325
- * .catch((error) => {
326
- * // console.error(error);
327
- * });
328
- * ```
329
- *
330
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#httprequest
331
- *
332
- * @memberof ThunderIDSPAClient
333
- *
334
- * @preserve
335
- */
336
- httpRequest(config: HttpRequestConfig): Promise<HttpResponse | undefined>;
337
- /**
338
- * This method sends multiple API requests to a protected endpoint.
339
- * The access token is automatically attached to the header of the request.
340
- * This is the only way by which multiple requests can be sent to protected endpoints
341
- * when the web worker is used to store session information.
342
- *
343
- * @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
344
- *
345
- * @return {Promise<HttpResponse[]>} - Returns a Promise that resolves with the responses to the requests.
346
- *
347
- * @example
348
- * ```
349
- * const requestConfig = {
350
- * headers: {
351
- * "Accept": "application/json",
352
- * "Content-Type": "application/scim+json"
353
- * },
354
- * method: "GET",
355
- * url: "https://api.asgardeo.io/scim2/me"
356
- * };
357
- *
358
- * const requestConfig2 = {
359
- * headers: {
360
- * "Accept": "application/json",
361
- * "Content-Type": "application/scim+json"
362
- * },
363
- * method: "GET",
364
- * url: "https://api.asgardeo.io/scim2/me"
365
- * };
366
- *
367
- * return auth.httpRequest([requestConfig, requestConfig2])
368
- * .then((responses) => {
369
- * response.forEach((response)=>{
370
- * // console.log(response);
371
- * });
372
- * })
373
- * .catch((error) => {
374
- * // console.error(error);
375
- * });
376
- * ```
377
- *
378
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#httprequestall
379
- *
380
- * @memberof ThunderIDSPAClient
381
- *
382
- * @preserve
383
- */
384
- httpRequestAll(config: HttpRequestConfig[]): Promise<HttpResponse[] | undefined>;
385
- /**
386
- * This method allows you to send a request with a custom grant.
387
- *
388
- * @param {CustomGrantRequestParams} config - The request parameters.
389
- *
390
- * @return {Promise<HttpResponse<any> | SignInResponse>} - A Promise that resolves with
391
- * the value returned by the custom grant request.
392
- *
393
- * @example
394
- * ```
395
- * auth.customGrant({
396
- * attachToken: false,
397
- * data: {
398
- * client_id: "{{clientId}}",
399
- * grant_type: "account_switch",
400
- * scope: "{{scope}}",
401
- * token: "{{token}}",
402
- * },
403
- * id: "account-switch",
404
- * returnResponse: true,
405
- * returnsSession: true,
406
- * signInRequired: true
407
- * });
408
- * ```
409
- *
410
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#customgrant
411
- *
412
- * @memberof ThunderIDSPAClient
413
- *
414
- * @preserve
415
- */
416
- exchangeToken(config: TokenExchangeRequestConfig): Promise<Response | User | undefined>;
417
- /**
418
- * This method ends a user session. The access token is revoked and the session information is destroyed.
419
- *
420
- * **To fire a callback function after ending user session, use the `on()` method.**
421
- * **To learn more about the `on()` method:**
422
- * @see {@link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on}
423
- *
424
- * @return {Promise<boolean>} - A promise that resolves with `true` if the process is successful.
425
- *
426
- * @example
427
- * ```
428
- * auth.endUserSession();
429
- * ```
430
- *
431
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#endusersession
432
- *
433
- * @memberof ThunderIDSPAClient
434
- *
435
- * @preserve
436
- */
437
- revokeAccessToken(): Promise<boolean | undefined>;
438
- /**
439
- * This method returns a Promise that resolves with an object containing the service endpoints.
440
- *
441
- * @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
442
- *
443
- * @example
444
- * ```
445
- * auth.getServiceEndpoints().then((endpoints) => {
446
- * // console.log(endpoints);
447
- * }).error((error) => {
448
- * // console.error(error);
449
- * });
450
- * ```
451
- *
452
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getserviceendpoints
453
- *
454
- * @memberof ThunderIDSPAClient
455
- *
456
- * @preserve
457
- */
458
- getOpenIDProviderEndpoints(): Promise<OIDCEndpoints | undefined>;
459
- /**
460
- * This methods returns the Axios http client.
461
- *
462
- * @return {HttpClient} - The Axios HTTP client.
463
- *
464
- * @memberof ThunderIDSPAClient
465
- *
466
- * @preserve
467
- */
468
- getHttpClient(): HttpClient;
469
- /**
470
- * This method decodes a JWT token payload and returns it.
471
- *
472
- * @param {string} token - The token to decode (optional).
473
- *
474
- * @return {Promise<Record<string, unknown>>} - A Promise that resolves with
475
- * the decoded payload of the token.
476
- *
477
- * @example
478
- * ```
479
- * auth.decodeJwtToken<T>(token).then((response)=>{
480
- * // console.log(response);
481
- * }).catch((error)=>{
482
- * // console.error(error);
483
- * });
484
- * ```
485
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#decodetoken
486
- *
487
- * @memberof ThunderIDSPAClient
488
- *
489
- * @preserve
490
- */
491
- decodeJwtToken<T = Record<string, unknown>>(token?: string): Promise<T | undefined>;
492
- /**
493
- * This method decodes the payload of the id token and returns it.
494
- *
495
- * @return {Promise<DecodedIdTokenPayloadInterface>} - A Promise that resolves with
496
- * the decoded payload of the id token.
497
- *
498
- * @example
499
- * ```
500
- * auth.getDecodedIdToken().then((response)=>{
501
- * // console.log(response);
502
- * }).catch((error)=>{
503
- * // console.error(error);
504
- * });
505
- * ```
506
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getdecodedidtoken
507
- *
508
- * @memberof ThunderIDSPAClient
509
- *
510
- * @preserve
511
- */
512
- getDecodedIdToken(sessionId?: string): Promise<IdToken | undefined>;
513
- /**
514
- * This method returns the IsomorphicCrypto instance.
515
- *
516
- * @return {Promise<DecodedIdTokenPayloadInterface>} - A Promise that resolves with
517
- * the IsomorphicCrypto instance.
518
- *
519
- * @example
520
- * ```
521
- * auth.getCrypto().then((response)=>{
522
- * // console.log(response);
523
- * }).catch((error)=>{
524
- * // console.error(error);
525
- * });
526
- * ```
527
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getCrypto
528
- *
529
- * @memberof ThunderIDSPAClient
530
- *
531
- * @preserve
532
- */
533
- getCrypto(): Promise<IsomorphicCrypto | undefined>;
534
- /**
535
- * This method return the ID token.
536
- *
537
- * @return {Promise<string>} - A Promise that resolves with the ID token.
538
- *
539
- * @example
540
- * ```
541
- * const idToken = await auth.getIdToken();
542
- * ```
543
- *
544
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIdToken
545
- *
546
- * @memberof ThunderIDAuthClient
547
- *
548
- * @preserve
549
- */
550
- getIdToken(): Promise<string | undefined>;
551
- /**
552
- * This method return a Promise that resolves with the access token.
553
- *
554
- * **This method will not return the access token if the storage type is set to `webWorker`.**
555
- *
556
- * @return {Promise<string>} - A Promise that resolves with the access token.
557
- *
558
- * @example
559
- * ```
560
- * auth.getAccessToken().then((token) => {
561
- * // console.log(token);
562
- * }).catch((error) => {
563
- * // console.error(error);
564
- * });
565
- * ```
566
- *
567
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getaccesstoken
568
- *
569
- * @memberof ThunderIDSPAClient
570
- *
571
- * @preserve
572
- */
573
- getAccessToken(sessionId?: string): Promise<string>;
574
- /**
575
- * This method return a Promise that resolves with the idp access token.
576
- *
577
- * **This method will not return the access token if the storage type is set to `webWorker`.**
578
- *
579
- * @return {Promise<string>} - A Promise that resolves with the idp access token.
580
- *
581
- * @example
582
- * ```
583
- * auth.getIDPAccessToken().then((token) => {
584
- * // console.log(token);
585
- * }).catch((error) => {
586
- * // console.error(error);
587
- * });
588
- * ```
589
- *
590
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getaccesstoken
591
- *
592
- * @memberof ThunderIDSPAClient
593
- *
594
- * @preserve
595
- */
596
- getIDPAccessToken(): Promise<string>;
597
- /**
598
- * This method return a Promise that resolves with the data layer object.
599
- *
600
- * **This method will not return the data layer object, if the storage type is set to `webWorker`.**
601
- *
602
- * @return {Promise<string>} - A Promise that resolves with the data layer object.
603
- *
604
- * @example
605
- * ```
606
- * auth.getStorageManager().then((dataLayer) => {
607
- * // console.log(dataLayer);
608
- * }).catch((error) => {
609
- * // console.error(error);
610
- * });
611
- * ```
612
- *
613
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getdatalayer
614
- *
615
- * @memberof ThunderIDSPAClient
616
- *
617
- * @preserve
618
- */
619
- getStorageManager(): Promise<StorageManager<MainThreadClientConfig>>;
620
- /**
621
- * This method return a Promise that resolves with the config data stored in the storage.
622
- *
623
- * @return - A Promise that resolves with the config data.
624
- *
625
- * @example
626
- * ```
627
- * auth.getConfigData().then((configData) => {
628
- * // console.log(configData);
629
- * }).catch((error) => {
630
- * // console.error(error);
631
- * });
632
- * ```
633
- *
634
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/main#getConfigData
635
- *
636
- * @memberof ThunderIDSPAClient
637
- *
638
- * @preserve
639
- */
640
- getConfigData(): Promise<AuthClientConfig<MainThreadClientConfig> | AuthClientConfig<WebWorkerClientConfig> | undefined>;
641
- /**
642
- * This method refreshes the access token.
643
- *
644
- * @return {TokenResponseInterface} - A Promise that resolves with an object containing
645
- * information about the refreshed access token.
646
- *
647
- * @example
648
- * ```
649
- * auth.refreshToken().then((response)=>{
650
- * // console.log(response);
651
- * }).catch((error)=>{
652
- * // console.error(error);
653
- * });
654
- * ```
655
- *
656
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#refreshtoken
657
- *
658
- * @memberof ThunderIDSPAClient
659
- *
660
- * @preserve
661
- */
662
- refreshAccessToken(): Promise<User | undefined>;
663
- /**
664
- * This method specifies if the user is authenticated or not.
665
- *
666
- * @return {Promise<boolean>} - A Promise that resolves with `true` if the user is authenticated.
667
- *
668
- * @memberof ThunderIDSPAClient
669
- *
670
- * @preserve
671
- */
672
- isSignedIn(): Promise<boolean | undefined>;
673
- startAutoRefreshToken(): Promise<void>;
674
- /**
675
- * This method specifies if there is an active session in the browser or not.
676
- *
677
- * @return {Promise<boolean>} - A Promise that resolves with `true` if there is a session.
678
- *
679
- * @memberof ThunderIDSPAClient
680
- *
681
- * @preserve
682
- */
683
- isSessionActive(): Promise<boolean | undefined>;
684
- /**
685
- * This method attaches a callback function to an event hook that fires the callback when the event happens.
686
- *
687
- * @param {Hooks.CustomGrant} hook - The name of the hook.
688
- * @param {(response?: any) => void} callback - The callback function.
689
- * @param {string} id (optional) - The id of the hook. This is used when multiple custom grants are used.
690
- *
691
- * @example
692
- * ```
693
- * auth.on("sign-in", (response)=>{
694
- * // console.log(response);
695
- * });
696
- * ```
697
- *
698
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on
699
- *
700
- * @memberof ThunderIDSPAClient
701
- *
702
- * @preserve
703
- */
704
- on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): Promise<void>;
705
- on(hook: Exclude<Hooks, Hooks.CustomGrant>, callback: (response?: any) => void): Promise<void>;
706
- /**
707
- * This method enables callback functions attached to the http client.
708
- *
709
- * @return {Promise<boolean>} - A promise that resolves with True.
710
- *
711
- * @example
712
- * ```
713
- * auth.enableHttpHandler();
714
- * ```
715
- *
716
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#enableHttpHandler
717
- *
718
- * @memberof ThunderIDSPAClient
719
- *
720
- * @preserve
721
- */
722
- enableHttpHandler(): Promise<boolean | undefined>;
723
- /**
724
- * This method disables callback functions attached to the http client.
725
- *
726
- * @return {Promise<boolean>} - A promise that resolves with True.
727
- *
728
- * @example
729
- * ```
730
- * auth.disableHttpHandler();
731
- * ```
732
- *
733
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#disableHttpHandler
734
- *
735
- * @memberof ThunderIDSPAClient
736
- *
737
- * @preserve
738
- */
739
- disableHttpHandler(): Promise<boolean | undefined>;
740
- /**
741
- * This method updates the configuration that was passed into the constructor when instantiating this class.
742
- *
743
- * @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
744
- *
745
- * @example
746
- * ```
747
- * const config = {
748
- * afterSignInUrl: "http://localhost:3000/sign-in",
749
- * clientId: "client ID",
750
- * baseUrl: "https://api.asgardeo.io"
751
- * }
752
- * const auth.reInitialize(config);
753
- * ```
754
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master/lib#reInitialize
755
- *
756
- * @memberof ThunderIDAuthClient
757
- *
758
- * @preserve
759
- */
760
- reInitialize(config: Partial<AuthClientConfig<Config>>): Promise<void>;
761
- /**
762
- * This method clears the session information from the storage.
763
- * @param sessionId - The session ID of the session to be cleared. If not provided, the current session will be cleared.
764
- */
765
- clearSession(sessionId?: string): void;
766
- }
767
- //# sourceMappingURL=client.d.ts.map