@thunderid/react 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.
package/dist/cjs/index.js CHANGED
@@ -107,361 +107,6 @@ const useBrowserUrl = () => {
107
107
  };
108
108
  var useBrowserUrl_default = useBrowserUrl;
109
109
 
110
- //#endregion
111
- //#region src/__temp__/api.ts
112
- var AuthAPI = class AuthAPI {
113
- static DEFAULT_STATE;
114
- authState = AuthAPI.DEFAULT_STATE;
115
- client;
116
- apiInstanceId;
117
- loadingState;
118
- constructor(spaClient, instanceId = 0) {
119
- this.apiInstanceId = instanceId;
120
- this.client = spaClient ?? __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
121
- this.getState = this.getState.bind(this);
122
- this.init = this.init.bind(this);
123
- this.signIn = this.signIn.bind(this);
124
- this.signOut = this.signOut.bind(this);
125
- this.updateState = this.updateState.bind(this);
126
- }
127
- /**
128
- * Get the instance ID for this AuthAPI instance.
129
- * @returns The instance ID used for multi-auth context support.
130
- */
131
- getInstanceId() {
132
- return this.apiInstanceId;
133
- }
134
- setLoadingState(isLoading) {
135
- this.loadingState = isLoading;
136
- }
137
- getLoadingState() {
138
- return this.loadingState;
139
- }
140
- isLoading() {
141
- return this.getLoadingState();
142
- }
143
- /**
144
- * Method to return Auth Client instance authentication state.
145
- *
146
- * @return {AuthStateInterface} Authentication State.
147
- */
148
- getState() {
149
- return this.authState;
150
- }
151
- /**
152
- * Method to initialize the AuthClient instance.
153
- *
154
- * @param {Config} config - `dispatch` function from React Auth Context.
155
- */
156
- async init(config) {
157
- return this.client.initialize(config);
158
- }
159
- /**
160
- * Method to get the configuration data.
161
- *
162
- * @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
163
- */
164
- async getConfigData() {
165
- return this.client.getConfigData();
166
- }
167
- async getStorageManager() {
168
- return this.client.getStorageManager();
169
- }
170
- /**
171
- * Method to get the configuration data.
172
- *
173
- * @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
174
- */
175
- async isInitialized() {
176
- return this.client.isInitialized();
177
- }
178
- /**
179
- * Method to handle user Sign In requests.
180
- *
181
- * @param {any} dispatch - `dispatch` function from React Auth Context.
182
- * @param {AuthStateInterface} state - Current authentication state in React Auth Context.
183
- * @param {any} callback - Action to trigger on successful sign in.
184
- */
185
- async signIn(config, authorizationCode, sessionState, authState, callback, tokenRequestConfig) {
186
- return this.client.signIn(config, authorizationCode, sessionState, authState, tokenRequestConfig).then(async (response) => {
187
- if (!response) return null;
188
- if (await this.client.isSignedIn()) {
189
- const stateToUpdate = {
190
- displayName: response.displayName,
191
- email: response.email,
192
- isLoading: false,
193
- isSignedIn: true,
194
- username: response.username
195
- };
196
- this.updateState(stateToUpdate);
197
- this.setLoadingState(false);
198
- if (callback) callback(response);
199
- }
200
- return response;
201
- }).catch((error) => Promise.reject(error));
202
- }
203
- /**
204
- * Method to handle user Sign Out requests.
205
- *
206
- * @param {any} dispatch - `dispatch` function from React Auth Context.
207
- * @param {AuthStateInterface} state - Current authentication state in React Auth Context.
208
- * @param {any} callback - Action to trigger on successful sign out.
209
- */
210
- signOut(callback) {
211
- return this.client.signOut().then((response) => {
212
- if (callback) callback(response);
213
- return response;
214
- }).catch((error) => Promise.reject(error));
215
- }
216
- /**
217
- * Method to update Auth Client instance authentication state.
218
- *
219
- * @param {AuthStateInterface} state - State values to update in authentication state.
220
- */
221
- updateState(state) {
222
- this.authState = {
223
- ...this.authState,
224
- ...state
225
- };
226
- }
227
- /**
228
- * This method returns a Promise that resolves with the basic user information obtained from the ID token.
229
- *
230
- * @return {Promise<User>} - A promise that resolves with the user information.
231
- */
232
- async getUser() {
233
- return this.client.getUser();
234
- }
235
- /**
236
- * This method sends an API request to a protected endpoint.
237
- * The access token is automatically attached to the header of the request.
238
- * This is the only way by which protected endpoints can be accessed
239
- * when the web worker is used to store session information.
240
- *
241
- * @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
242
- *
243
- * @return {Promise<Response>} - Returns a Promise that resolves with the response to the request.
244
- */
245
- async httpRequest(config) {
246
- return this.client.httpRequest(config);
247
- }
248
- /**
249
- * This method sends multiple API requests to a protected endpoint.
250
- * The access token is automatically attached to the header of the request.
251
- * This is the only way by which multiple requests can be sent to protected endpoints
252
- * when the web worker is used to store session information.
253
- *
254
- * @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
255
- *
256
- * @return {Promise<Response>} - Returns a Promise that resolves with the responses to the requests.
257
- */
258
- async httpRequestAll(configs) {
259
- return this.client.httpRequestAll(configs);
260
- }
261
- /**
262
- * This method allows you to send a request with a custom grant.
263
- *
264
- * @param {CustomGrantRequestParams} config - The request parameters.
265
- *
266
- * @return {Promise<Response | SignInResponse>} - A Promise that resolves with
267
- * the value returned by the custom grant request.
268
- */
269
- exchangeToken(config, callback) {
270
- return this.client.exchangeToken(config).then((response) => {
271
- if (!response) return null;
272
- if (config.returnsSession) this.updateState({
273
- ...this.getState(),
274
- ...response,
275
- isLoading: false,
276
- isSignedIn: true
277
- });
278
- if (callback) callback(response);
279
- return response;
280
- }).catch((error) => Promise.reject(error));
281
- }
282
- /**
283
- * This method ends a user session. The access token is revoked and the session information is destroyed.
284
- *
285
- * @return {Promise<boolean>} - A promise that resolves with `true` if the process is successful.
286
- */
287
- async revokeAccessToken(dispatch) {
288
- return this.client.revokeAccessToken().then(() => {
289
- this.updateState({
290
- ...AuthAPI.DEFAULT_STATE,
291
- isLoading: false
292
- });
293
- dispatch(AuthAPI.DEFAULT_STATE);
294
- return true;
295
- }).catch((error) => Promise.reject(error));
296
- }
297
- /**
298
- * This method returns a Promise that resolves with an object containing the service endpoints.
299
- *
300
- * @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
301
- */
302
- async getOpenIDProviderEndpoints() {
303
- return this.client.getOpenIDProviderEndpoints();
304
- }
305
- /**
306
- * This methods returns the Axios http client.
307
- *
308
- * @return {HttpClient} - The Axios HTTP client.
309
- */
310
- async getHttpClient() {
311
- return this.client.getHttpClient();
312
- }
313
- /**
314
- * This method decodes a JWT token payload and returns it.
315
- *
316
- * @param token - The token to decode.
317
- * @returns The decoded token payload.
318
- */
319
- async decodeJwtToken(token) {
320
- return this.client.decodeJwtToken(token);
321
- }
322
- /**
323
- * This method decodes the payload of the id token and returns it.
324
- *
325
- * @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
326
- * the decoded payload of the id token.
327
- */
328
- async getDecodedIdToken(sessionId) {
329
- return this.client.getDecodedIdToken(sessionId);
330
- }
331
- /**
332
- * This method decodes the payload of the idp id token and returns it.
333
- *
334
- * @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
335
- * the decoded payload of the idp id token.
336
- */
337
- async getDecodedIDPIDToken() {
338
- return this.client.getDecodedIdToken();
339
- }
340
- /**
341
- * This method returns the ID token.
342
- *
343
- * @return {Promise<string>} - A Promise that resolves with the id token.
344
- */
345
- async getIdToken() {
346
- return this.client.getIdToken();
347
- }
348
- /**
349
- * This method return a Promise that resolves with the access token.
350
- *
351
- * **This method will not return the access token if the storage type is set to `webWorker`.**
352
- *
353
- * @return {Promise<string>} - A Promise that resolves with the access token.
354
- */
355
- async getAccessToken(sessionId) {
356
- return this.client.getAccessToken(sessionId);
357
- }
358
- /**
359
- * This method return a Promise that resolves with the idp access token.
360
- *
361
- * **This method will not return the idp access token if the storage type is set to `webWorker`.**
362
- * **This can be used to access the IDP access token when custom auth grant functionalities are used**
363
- *
364
- * @return {Promise<string>} - A Promise that resolves with the idp access token.
365
- */
366
- async getIDPAccessToken() {
367
- return this.client.getIDPAccessToken();
368
- }
369
- /**
370
- * This method refreshes the access token.
371
- *
372
- * @return {TokenResponseInterface} - A Promise that resolves with an object containing
373
- * information about the refreshed access token.
374
- */
375
- async refreshAccessToken() {
376
- return this.client.refreshAccessToken();
377
- }
378
- /**
379
- * This method specifies if the user is authenticated or not.
380
- *
381
- * @return {Promise<boolean>} - A Promise that resolves with `true` if teh user is authenticated.
382
- */
383
- async isSignedIn() {
384
- return this.client.isSignedIn();
385
- }
386
- async startAutoRefreshToken() {
387
- return this.client.startAutoRefreshToken();
388
- }
389
- /**
390
- * This method specifies if the session is active or not.
391
- *
392
- * @return {Promise<boolean>} - A Promise that resolves with `true` if there is an active session.
393
- */
394
- async isSessionActive() {
395
- return this.client.isSessionActive();
396
- }
397
- /**
398
- * This method enables callback functions attached to the http client.
399
- *
400
- * @return {Promise<boolean>} - A promise that resolves with True.
401
- *
402
- */
403
- async enableHttpHandler() {
404
- return this.client.enableHttpHandler();
405
- }
406
- /**
407
- * This method disables callback functions attached to the http client.
408
- *
409
- * @return {Promise<boolean>} - A promise that resolves with True.
410
- */
411
- async disableHttpHandler() {
412
- return this.client.disableHttpHandler();
413
- }
414
- /**
415
- * This method updates the configuration that was passed into the constructor when instantiating this class.
416
- *
417
- * @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
418
- */
419
- async reInitialize(config) {
420
- return this.client.reInitialize(config);
421
- }
422
- on(hook, callback, id) {
423
- if (hook === __thunderid_browser.Hooks.CustomGrant) return this.client.on(hook, callback, id);
424
- return this.client.on(hook, callback);
425
- }
426
- /**
427
- * This method allows you to sign in silently.
428
- * First, this method sends a prompt none request to see if there is an active user session in the identity server.
429
- * If there is one, then it requests the access token and stores it. Else, it returns false.
430
- *
431
- * @return {Promise<User | boolean>} - A Promise that resolves with the user information after signing in
432
- * or with `false` if the user is not signed in.
433
- *
434
- * @example
435
- *```
436
- * client.signInSilently()
437
- *```
438
- */
439
- async signInSilently(additionalParams, tokenRequestConfig) {
440
- return this.client.signInSilently(additionalParams, tokenRequestConfig).then(async (response) => {
441
- if (!response) return false;
442
- return response;
443
- }).catch((error) => Promise.reject(error));
444
- }
445
- /**
446
- * This method clears the session for the specified session ID.
447
- *
448
- * @param sessionId - Optional session ID to clear the session for.
449
- *
450
- * @return void
451
- */
452
- clearSession(sessionId) {
453
- this.client.clearSession(sessionId);
454
- }
455
- };
456
- AuthAPI.DEFAULT_STATE = {
457
- displayName: "",
458
- email: "",
459
- isLoading: true,
460
- isSignedIn: false,
461
- username: ""
462
- };
463
- var api_default = AuthAPI;
464
-
465
110
  //#endregion
466
111
  //#region src/api/getAllOrganizations.ts
467
112
  /**
@@ -509,8 +154,7 @@ var api_default = AuthAPI;
509
154
  */
510
155
  const getAllOrganizations = async ({ fetcher, instanceId = 0,...requestConfig }) => {
511
156
  const defaultFetcher = async (url, config) => {
512
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
513
- const response = await client.httpRequest.bind(client)({
157
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
514
158
  headers: config.headers,
515
159
  method: config.method || "GET",
516
160
  url
@@ -581,8 +225,7 @@ var getAllOrganizations_default = getAllOrganizations;
581
225
  */
582
226
  const getMeOrganizations = async ({ fetcher, instanceId = 0,...requestConfig }) => {
583
227
  const defaultFetcher = async (url, config) => {
584
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
585
- const response = await client.httpRequest.bind(client)({
228
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
586
229
  headers: config.headers,
587
230
  method: config.method || "GET",
588
231
  url
@@ -602,171 +245,17 @@ const getMeOrganizations = async ({ fetcher, instanceId = 0,...requestConfig })
602
245
  };
603
246
  var getMeOrganizations_default = getMeOrganizations;
604
247
 
605
- //#endregion
606
- //#region src/api/getSchemas.ts
607
- /**
608
- * Retrieves the SCIM2 schemas from the specified endpoint.
609
- * This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
610
- *
611
- * @param config - Request configuration object.
612
- * @returns A promise that resolves with the SCIM2 schemas information.
613
- * @example
614
- * ```typescript
615
- * // Using default ThunderID SPA client httpClient
616
- * try {
617
- * const schemas = await getSchemas({
618
- * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
619
- * });
620
- * console.log(schemas);
621
- * } catch (error) {
622
- * if (error instanceof ThunderIDAPIError) {
623
- * console.error('Failed to get schemas:', error.message);
624
- * }
625
- * }
626
- * ```
627
- *
628
- * @example
629
- * ```typescript
630
- * // Using custom fetcher
631
- * try {
632
- * const schemas = await getSchemas({
633
- * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
634
- * fetcher: customFetchFunction
635
- * });
636
- * console.log(schemas);
637
- * } catch (error) {
638
- * if (error instanceof ThunderIDAPIError) {
639
- * console.error('Failed to get schemas:', error.message);
640
- * }
641
- * }
642
- * ```
643
- */
644
- const getSchemas = async ({ fetcher, instanceId = 0,...requestConfig }) => {
645
- const defaultFetcher = async (url, config) => {
646
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
647
- const response = await client.httpRequest.bind(client)({
648
- headers: config.headers,
649
- method: config.method || "GET",
650
- url
651
- });
652
- return {
653
- json: () => Promise.resolve(response.data),
654
- ok: response.status >= 200 && response.status < 300,
655
- status: response.status,
656
- statusText: response.statusText || "",
657
- text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
658
- };
659
- };
660
- return (0, __thunderid_browser.getSchemas)({
661
- ...requestConfig,
662
- fetcher: fetcher || defaultFetcher
663
- });
664
- };
665
- var getSchemas_default = getSchemas;
666
-
667
- //#endregion
668
- //#region src/api/getScim2Me.ts
669
- /**
670
- * Retrieves the user profile information from the specified SCIM2 /Me endpoint.
671
- * This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
672
- *
673
- * @param requestConfig - Request configuration object.
674
- * @returns A promise that resolves with the user profile information.
675
- * @example
676
- * ```typescript
677
- * // Using default ThunderID SPA client httpClient
678
- * try {
679
- * const userProfile = await getScim2Me({
680
- * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
681
- * });
682
- * console.log(userProfile);
683
- * } catch (error) {
684
- * if (error instanceof ThunderIDAPIError) {
685
- * console.error('Failed to get user profile:', error.message);
686
- * }
687
- * }
688
- * ```
689
- *
690
- * @example
691
- * ```typescript
692
- * // Using custom fetcher
693
- * try {
694
- * const userProfile = await getScim2Me({
695
- * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
696
- * fetcher: customFetchFunction
697
- * });
698
- * console.log(userProfile);
699
- * } catch (error) {
700
- * if (error instanceof ThunderIDAPIError) {
701
- * console.error('Failed to get user profile:', error.message);
702
- * }
703
- * }
704
- * ```
705
- */
706
- const getScim2Me = async ({ fetcher, instanceId = 0,...requestConfig }) => {
707
- const defaultFetcher = async (url, config) => {
708
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
709
- const response = await client.httpRequest.bind(client)({
710
- headers: config.headers,
711
- method: config.method || "GET",
712
- url
713
- });
714
- return {
715
- json: () => Promise.resolve(response.data),
716
- ok: response.status >= 200 && response.status < 300,
717
- status: response.status,
718
- statusText: response.statusText || "",
719
- text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
720
- };
721
- };
722
- return (0, __thunderid_browser.getScim2Me)({
723
- ...requestConfig,
724
- fetcher: fetcher || defaultFetcher
725
- });
726
- };
727
- var getScim2Me_default = getScim2Me;
728
-
729
248
  //#endregion
730
249
  //#region src/ThunderIDReactClient.ts
731
- /**
732
- * Client for mplementing ThunderID in React applications.
733
- * This class provides the core functionality for managing user authentication and sessions.
734
- *
735
- * @typeParam T - Configuration type that extends ThunderIDReactConfig.
736
- */
737
250
  var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserClient {
738
- authApi;
739
251
  loadingState = false;
740
- clientInstanceId;
741
- initializeConfig;
742
- /**
743
- * Creates a new ThunderIDReactClient instance.
744
- * @param instanceId - Optional instance ID for multi-auth context support. Defaults to 0 for backward compatibility.
745
- */
252
+ _initializeConfig;
746
253
  constructor(instanceId = 0) {
747
- super();
748
- this.clientInstanceId = instanceId;
749
- this.authApi = new api_default(void 0, instanceId);
254
+ super(instanceId);
750
255
  }
751
- /**
752
- * Get the instance ID for this client.
753
- * @returns The instance ID used for multi-auth context support.
754
- */
755
- getInstanceId() {
756
- return this.clientInstanceId;
757
- }
758
- /**
759
- * Set the loading state of the client
760
- * @param loading - Boolean indicating if the client is in a loading state
761
- */
762
256
  setLoading(loading) {
763
257
  this.loadingState = loading;
764
258
  }
765
- /**
766
- * Wrap async operations with loading state management
767
- * @param operation - The async operation to execute
768
- * @returns Promise with the result of the operation
769
- */
770
259
  async withLoading(operation) {
771
260
  this.setLoading(true);
772
261
  try {
@@ -779,19 +268,19 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
779
268
  let resolvedOrganizationHandle = config?.organizationHandle;
780
269
  if (!resolvedOrganizationHandle) resolvedOrganizationHandle = (0, __thunderid_browser.deriveOrganizationHandleFromBaseUrl)(config?.baseUrl);
781
270
  return this.withLoading(async () => {
782
- this.initializeConfig = {
271
+ this._initializeConfig = {
783
272
  ...config,
784
273
  organizationHandle: resolvedOrganizationHandle,
785
274
  periodicTokenRefresh: config?.tokenLifecycle?.refreshToken?.autoRefresh ?? config?.periodicTokenRefresh
786
275
  };
787
- return this.authApi.init(this.initializeConfig);
276
+ return super.initialize(this._initializeConfig);
788
277
  });
789
278
  }
790
279
  reInitialize(config) {
791
280
  return this.withLoading(async () => {
792
281
  let isInitialized;
793
282
  try {
794
- await this.authApi.reInitialize(config);
283
+ await super.reInitialize(config);
795
284
  isInitialized = true;
796
285
  } catch (error) {
797
286
  throw new __thunderid_browser.ThunderIDRuntimeError(`Failed to check if the client is initialized: ${error instanceof Error ? error.message : String(error)}`, "ThunderIDReactClient-reInitialize-RuntimeError-001", "react", "An error occurred while checking the initialization status of the client.");
@@ -802,52 +291,29 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
802
291
  async updateUserProfile() {
803
292
  throw new Error("Not implemented");
804
293
  }
805
- async getUser(options) {
806
- try {
807
- let baseUrl = options?.baseUrl;
808
- if (!baseUrl) baseUrl = (await this.authApi.getConfigData())?.baseUrl;
809
- return (0, __thunderid_browser.generateUserProfile)(await getScim2Me_default({ baseUrl }), (0, __thunderid_browser.flattenUserSchema)(await getSchemas_default({ baseUrl })));
810
- } catch (error) {
811
- return (0, __thunderid_browser.extractUserClaimsFromIdToken)(await this.getDecodedIdToken());
812
- }
294
+ async getUser() {
295
+ return (0, __thunderid_browser.extractUserClaimsFromIdToken)(await this.getDecodedIdToken());
813
296
  }
814
297
  async getDecodedIdToken(sessionId) {
815
- return this.authApi.getDecodedIdToken(sessionId);
298
+ return super.getDecodedIdToken(sessionId);
816
299
  }
817
300
  async getIdToken() {
818
- return this.withLoading(async () => this.authApi.getIdToken());
301
+ return this.withLoading(async () => super.getIdToken());
819
302
  }
820
- async getUserProfile(options) {
303
+ async getUserProfile() {
821
304
  return this.withLoading(async () => {
822
- try {
823
- let baseUrl = options?.baseUrl;
824
- if (!baseUrl) baseUrl = (await this.authApi.getConfigData())?.baseUrl;
825
- const profile = await getScim2Me_default({
826
- baseUrl,
827
- instanceId: this.getInstanceId()
828
- });
829
- const processedSchemas = (0, __thunderid_browser.flattenUserSchema)(await getSchemas_default({
830
- baseUrl,
831
- instanceId: this.getInstanceId()
832
- }));
833
- return {
834
- flattenedProfile: (0, __thunderid_browser.generateFlattenedUserProfile)(profile, processedSchemas),
835
- profile,
836
- schemas: processedSchemas
837
- };
838
- } catch (error) {
839
- return {
840
- flattenedProfile: (0, __thunderid_browser.extractUserClaimsFromIdToken)(await this.getDecodedIdToken()),
841
- profile: (0, __thunderid_browser.extractUserClaimsFromIdToken)(await this.getDecodedIdToken()),
842
- schemas: []
843
- };
844
- }
305
+ const claims = (0, __thunderid_browser.extractUserClaimsFromIdToken)(await this.getDecodedIdToken());
306
+ return {
307
+ flattenedProfile: claims,
308
+ profile: claims,
309
+ schemas: []
310
+ };
845
311
  });
846
312
  }
847
313
  async getMyOrganizations(options) {
848
314
  try {
849
315
  let baseUrl = options?.baseUrl;
850
- if (!baseUrl) baseUrl = (await this.authApi.getConfigData())?.baseUrl;
316
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
851
317
  return await getMeOrganizations_default({
852
318
  baseUrl,
853
319
  instanceId: this.getInstanceId()
@@ -859,7 +325,7 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
859
325
  async getAllOrganizations(options) {
860
326
  try {
861
327
  let baseUrl = options?.baseUrl;
862
- if (!baseUrl) baseUrl = (await this.authApi.getConfigData())?.baseUrl;
328
+ if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
863
329
  return await getAllOrganizations_default({
864
330
  baseUrl,
865
331
  instanceId: this.getInstanceId()
@@ -885,7 +351,7 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
885
351
  async switchOrganization(organization) {
886
352
  return this.withLoading(async () => {
887
353
  try {
888
- const sourceInstanceId = (await this.authApi.getConfigData())?.organizationChain?.sourceInstanceId;
354
+ const sourceInstanceId = (await this.getStorageManager().getConfigData())?.organizationChain?.sourceInstanceId;
889
355
  if (!organization.id) throw new __thunderid_browser.ThunderIDRuntimeError("Organization ID is required for switching organizations", "react-ThunderIDReactClient-SwitchOrganizationError-001", "react", "The organization object must contain a valid ID to perform the organization switch.");
890
356
  const exchangeConfig = {
891
357
  attachToken: false,
@@ -900,39 +366,29 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
900
366
  returnsSession: true,
901
367
  signInRequired: sourceInstanceId === void 0
902
368
  };
903
- return await this.authApi.exchangeToken(exchangeConfig, () => {});
369
+ return await super.exchangeToken(exchangeConfig);
904
370
  } catch (error) {
905
371
  throw new __thunderid_browser.ThunderIDRuntimeError(`Failed to switch organization: ${error.message || error}`, "react-ThunderIDReactClient-SwitchOrganizationError-003", "react", "An error occurred while switching to the specified organization. Please try again.");
906
372
  }
907
373
  });
908
374
  }
909
375
  isLoading() {
910
- return this.loadingState || this.authApi.isLoading();
911
- }
912
- async isInitialized() {
913
- return this.authApi.isInitialized();
376
+ return this.loadingState;
914
377
  }
915
378
  async isSignedIn() {
916
- return this.authApi.isSignedIn();
917
- }
918
- async startAutoRefreshToken() {
919
- return this.authApi.startAutoRefreshToken();
920
- }
921
- getConfiguration() {
922
- return this.authApi.getConfigData();
379
+ return super.isSignedIn();
923
380
  }
924
381
  async exchangeToken(config) {
925
- return this.withLoading(async () => this.authApi.exchangeToken(config, () => {}));
382
+ return this.withLoading(async () => super.exchangeToken(config));
926
383
  }
927
384
  async signIn(...args) {
928
385
  return this.withLoading(async () => {
929
386
  const arg1 = args[0];
930
387
  const arg2 = args[1];
931
- const config = await this.authApi.getConfigData();
932
- if (!config || Object.keys(config).length === 0) await this.initialize(this.initializeConfig);
933
- const isV2Platform = config?.platform === __thunderid_browser.Platform.ThunderIDV2;
934
- if (isV2Platform && typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) return;
935
- if (isV2Platform && typeof arg1 === "object" && arg1 !== null && !(0, __thunderid_browser.isEmpty)(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
388
+ const config = await this.getStorageManager().getConfigData();
389
+ if (!config || Object.keys(config).length === 0) await this.initialize(this._initializeConfig);
390
+ if (typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) return;
391
+ if (typeof arg1 === "object" && arg1 !== null && !(0, __thunderid_browser.isEmpty)(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
936
392
  const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
937
393
  const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
938
394
  const authId = authIdFromUrl || authIdFromStorage;
@@ -943,14 +399,7 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
943
399
  payload: arg1,
944
400
  url: arg2?.url
945
401
  });
946
- /**
947
- * NOTE: For ThunderID V2, if the embedded (App Native) sign-in flow returns a completed status along with an assertion (ID
948
- * token), we manually set the session using that assertion. This is a temporary workaround until the platform
949
- * fully supports session management for embedded flows.
950
- *
951
- * Tracker:
952
- */
953
- if (isV2Platform && response && typeof response === "object" && response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatusV2.Complete && response.assertion) {
402
+ if (response && typeof response === "object" && response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatusV2.Complete && response.assertion) {
954
403
  const decodedAssertion = await this.decodeJwtToken(response.assertion);
955
404
  const createdAt = decodedAssertion.iat ? decodedAssertion.iat * 1e3 : Date.now();
956
405
  const expiresIn = decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;
@@ -962,90 +411,50 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
962
411
  scope: decodedAssertion.scope,
963
412
  token_type: "Bearer"
964
413
  });
414
+ this.notifySignIn((0, __thunderid_browser.extractUserClaimsFromIdToken)(decodedAssertion));
965
415
  }
966
416
  return response;
967
417
  }
968
- if (typeof arg1 === "object" && "flowId" in arg1 && typeof arg2 === "object" && "url" in arg2) return (0, __thunderid_browser.executeEmbeddedSignInFlow)({
969
- payload: arg1,
970
- url: arg2.url
971
- });
972
- return await this.authApi.signIn(arg1);
418
+ return await super.signIn(arg1);
973
419
  });
974
420
  }
975
421
  async signInSilently(options) {
976
- return this.authApi.signInSilently(options);
977
- }
978
- async signOut(...args) {
979
- if (args[1] && typeof args[1] !== "function") throw new Error("The second argument must be a function.");
980
- const config = await this.authApi.getConfigData();
981
- if (config.platform === __thunderid_browser.Platform.ThunderIDV2) {
982
- this.authApi.clearSession();
983
- if (config.signInUrl) (0, __thunderid_browser.navigate)(config.signInUrl);
984
- else this.signIn(config.signInOptions);
985
- args[1]?.(config.afterSignOutUrl || "");
986
- return Promise.resolve(config.afterSignOutUrl || "");
987
- }
988
- const response = await this.authApi.signOut(args[1]);
989
- return Promise.resolve(String(response));
422
+ return super.signInSilently(options);
990
423
  }
991
424
  async signUp(...args) {
992
- const config = await this.authApi.getConfigData();
425
+ const config = await this.getStorageManager().getConfigData();
993
426
  const firstArg = args[0];
994
427
  const baseUrl = config?.baseUrl;
995
- if (config.platform === __thunderid_browser.Platform.ThunderIDV2) {
996
- const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
997
- const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
998
- const authId = authIdFromUrl || authIdFromStorage;
999
- if (authIdFromUrl && !authIdFromStorage) sessionStorage.setItem("thunderid_auth_id", authIdFromUrl);
1000
- return (0, __thunderid_browser.executeEmbeddedSignUpFlowV2)({
1001
- authId,
1002
- baseUrl,
1003
- payload: typeof firstArg === "object" && "flowType" in firstArg ? {
1004
- ...firstArg,
1005
- verbose: true
1006
- } : firstArg
1007
- });
1008
- }
1009
- if (typeof firstArg === "object" && "flowType" in firstArg) return (0, __thunderid_browser.executeEmbeddedSignUpFlow)({
428
+ const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
429
+ const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
430
+ const authId = authIdFromUrl || authIdFromStorage;
431
+ if (authIdFromUrl && !authIdFromStorage) sessionStorage.setItem("thunderid_auth_id", authIdFromUrl);
432
+ return (0, __thunderid_browser.executeEmbeddedSignUpFlowV2)({
433
+ authId,
1010
434
  baseUrl,
1011
- payload: firstArg
435
+ payload: typeof firstArg === "object" && "flowType" in firstArg ? {
436
+ ...firstArg,
437
+ verbose: true
438
+ } : firstArg
1012
439
  });
1013
- (0, __thunderid_browser.navigate)((0, __thunderid_browser.getRedirectBasedSignUpUrl)(config));
1014
440
  }
1015
441
  async recover(payload) {
1016
- const config = await this.authApi.getConfigData();
1017
- const baseUrl = config?.baseUrl;
1018
- if (config?.platform === __thunderid_browser.Platform.ThunderIDV2) return (0, __thunderid_browser.executeEmbeddedRecoveryFlowV2)({
1019
- baseUrl,
442
+ return (0, __thunderid_browser.executeEmbeddedRecoveryFlowV2)({
443
+ baseUrl: (await this.getStorageManager().getConfigData())?.baseUrl,
1020
444
  payload: {
1021
445
  ...payload,
1022
446
  verbose: true
1023
447
  }
1024
448
  });
1025
449
  }
1026
- async getDiscoveryResponse() {
1027
- return (await this.authApi.getStorageManager()).loadOpenIDProviderConfiguration();
450
+ getStorageManager() {
451
+ return super.getStorageManager();
1028
452
  }
1029
453
  async request(requestConfig) {
1030
- return this.authApi.httpRequest(requestConfig);
454
+ return super.httpRequest(requestConfig);
1031
455
  }
1032
456
  async requestAll(requestConfigs) {
1033
- return this.authApi.httpRequestAll(requestConfigs);
1034
- }
1035
- async getAccessToken(sessionId) {
1036
- return this.authApi.getAccessToken(sessionId);
1037
- }
1038
- clearSession(sessionId) {
1039
- this.authApi.clearSession(sessionId);
1040
- }
1041
- async setSession(sessionData, sessionId) {
1042
- return (await this.authApi.getStorageManager()).setSessionData(sessionData, sessionId);
1043
- }
1044
- async getStorageManager() {
1045
- return this.authApi.getStorageManager();
1046
- }
1047
- decodeJwtToken(token) {
1048
- return this.authApi.decodeJwtToken(token);
457
+ return super.httpRequestAll(requestConfigs);
1049
458
  }
1050
459
  };
1051
460
  var ThunderIDReactClient_default = ThunderIDReactClient;
@@ -1374,7 +783,7 @@ const FlowMetaProvider = ({ children, enabled = true }) => {
1374
783
  const [pendingLanguage, setPendingLanguage] = (0, react.useState)(null);
1375
784
  const lastFetchedRef = (0, react.useRef)(null);
1376
785
  const fetchFlowMeta = (0, react.useCallback)(async () => {
1377
- if (!enabled || platform !== __thunderid_browser.Platform.ThunderIDV2) {
786
+ if (!enabled || platform !== __thunderid_browser.Platform.ThunderID) {
1378
787
  setMeta(null);
1379
788
  setIsLoading(false);
1380
789
  return;
@@ -1405,7 +814,7 @@ const FlowMetaProvider = ({ children, enabled = true }) => {
1405
814
  i18nContext?.currentLanguage
1406
815
  ]);
1407
816
  const switchLanguage = (0, react.useCallback)(async (language) => {
1408
- if (!enabled || platform !== __thunderid_browser.Platform.ThunderIDV2) return;
817
+ if (!enabled || platform !== __thunderid_browser.Platform.ThunderID) return;
1409
818
  setIsLoading(true);
1410
819
  setError(null);
1411
820
  try {
@@ -2241,7 +1650,7 @@ var ThemeProvider_default$2 = ThemeProvider$1;
2241
1650
  */
2242
1651
  const ThemeProvider = ({ children, theme, detection, inheritFromBranding, mode }) => {
2243
1652
  const { platform } = useThunderID_default();
2244
- if (platform === __thunderid_browser.Platform.ThunderIDV2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeProvider_default$2, {
1653
+ if (platform === __thunderid_browser.Platform.ThunderID) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeProvider_default$2, {
2245
1654
  theme,
2246
1655
  children
2247
1656
  });
@@ -2325,7 +1734,7 @@ var UserProvider_default = UserProvider;
2325
1734
  //#endregion
2326
1735
  //#region src/contexts/ThunderID/ThunderIDProvider.tsx
2327
1736
  const logger$9 = (0, __thunderid_browser.createPackageComponentLogger)("@thunderid/react", "ThunderIDProvider");
2328
- const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignOutUrl = window.location.origin, baseUrl: initialBaseUrl, clientId, children, extensions, scopes, preferences, signInUrl, signUpUrl, organizationHandle, applicationId, signInOptions, syncSession, instanceId = 0, organizationChain, platform = __thunderid_browser.Platform.ThunderIDV2,...rest }) => {
1737
+ const ThunderIDProvider = ({ afterSignInUrl, afterSignOutUrl, baseUrl: initialBaseUrl, clientId, children, extensions, scopes, preferences, signInUrl, signUpUrl, organizationHandle, applicationId, signInOptions, syncSession, instanceId = 0, organizationChain,...rest }) => {
2329
1738
  const reRenderCheckRef = (0, react.useRef)(false);
2330
1739
  const client = (0, react.useMemo)(() => new ThunderIDReactClient_default(instanceId), [instanceId]);
2331
1740
  const storageManagerRef = (0, react.useRef)(null);
@@ -2339,8 +1748,8 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2339
1748
  const [userProfile, setUserProfile] = (0, react.useState)(null);
2340
1749
  const [baseUrl, setBaseUrl] = (0, react.useState)(initialBaseUrl);
2341
1750
  const [config, setConfig] = (0, react.useState)({
2342
- afterSignInUrl,
2343
- afterSignOutUrl,
1751
+ afterSignInUrl: afterSignInUrl ?? window.location.origin,
1752
+ afterSignOutUrl: afterSignOutUrl ?? window.location.origin,
2344
1753
  applicationId,
2345
1754
  baseUrl,
2346
1755
  clientId,
@@ -2351,7 +1760,6 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2351
1760
  signInUrl,
2352
1761
  signUpUrl,
2353
1762
  syncSession,
2354
- platform,
2355
1763
  ...rest
2356
1764
  });
2357
1765
  const [isUpdatingSession, setIsUpdatingSession] = (0, react.useState)(false);
@@ -2385,32 +1793,13 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2385
1793
  resolvedBaseUrl = `${(await client.getConfiguration()).baseUrl}/o`;
2386
1794
  setBaseUrl(resolvedBaseUrl);
2387
1795
  }
2388
- if (config.platform === __thunderid_browser.Platform.ThunderIDV2) {
2389
- const claims = (0, __thunderid_browser.extractUserClaimsFromIdToken)(decodedToken);
2390
- setUser(claims);
2391
- setUserProfile({
2392
- flattenedProfile: claims,
2393
- profile: claims,
2394
- schemas: []
2395
- });
2396
- } else {
2397
- if (preferences?.user?.fetchUserProfile !== false) {
2398
- try {
2399
- setUser(await client.getUser({ baseUrl: resolvedBaseUrl }));
2400
- } catch (error) {}
2401
- try {
2402
- setUserProfile(await client.getUserProfile({ baseUrl: resolvedBaseUrl }));
2403
- } catch (error) {}
2404
- }
2405
- if (preferences?.user?.fetchOrganizations !== false) {
2406
- try {
2407
- setCurrentOrganization(await client.getCurrentOrganization());
2408
- } catch (error) {}
2409
- try {
2410
- setMyOrganizations(await client.getMyOrganizations());
2411
- } catch (error) {}
2412
- }
2413
- }
1796
+ const claims = (0, __thunderid_browser.extractUserClaimsFromIdToken)(decodedToken);
1797
+ setUser(claims);
1798
+ setUserProfile({
1799
+ flattenedProfile: claims,
1800
+ profile: claims,
1801
+ schemas: []
1802
+ });
2414
1803
  setIsSignedInSync(await client.isSignedIn());
2415
1804
  } catch (error) {} finally {
2416
1805
  setIsUpdatingSession(false);
@@ -2419,16 +1808,13 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2419
1808
  }
2420
1809
  async function signIn(...args) {
2421
1810
  const arg1 = args[0];
2422
- const isV2FlowRequest = config.platform === __thunderid_browser.Platform.ThunderIDV2 && typeof arg1 === "object" && arg1 !== null && ("executionId" in arg1 || "applicationId" in arg1);
1811
+ const isV2FlowRequest = typeof arg1 === "object" && arg1 !== null && ("executionId" in arg1 || "applicationId" in arg1);
2423
1812
  try {
2424
1813
  if (!isV2FlowRequest) {
2425
1814
  setIsUpdatingSession(true);
2426
1815
  setIsLoadingSync(true);
2427
1816
  }
2428
- const response = await client.signIn(...args);
2429
- if (isV2FlowRequest || response && typeof response === "object" && "flowStatus" in response) return response;
2430
- if (await client.isSignedIn()) await updateSession();
2431
- return response;
1817
+ return await client.signIn(...args);
2432
1818
  } catch (error) {
2433
1819
  throw new __thunderid_browser.ThunderIDRuntimeError(`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`, "thunderid-signIn-Error", "react", "An error occurred while trying to sign in.");
2434
1820
  } finally {
@@ -2445,6 +1831,9 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2445
1831
  if (reRenderCheckRef.current) return;
2446
1832
  reRenderCheckRef.current = true;
2447
1833
  (async () => {
1834
+ await client.on("sign-in", async () => {
1835
+ await updateSession();
1836
+ });
2448
1837
  const isAlreadySignedIn = await client.isSignedIn();
2449
1838
  const scheduleAutoRefresh = async () => {
2450
1839
  try {
@@ -2464,16 +1853,12 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2464
1853
  return;
2465
1854
  }
2466
1855
  const currentUrl = new URL(window.location.href);
2467
- const hasAuthParamsResult = hasAuthParams(currentUrl, afterSignInUrl) && hasCalledForThisInstance(currentUrl, instanceId ?? 0);
2468
- const isV2Platform = config.platform === __thunderid_browser.Platform.ThunderIDV2;
2469
- if (hasAuthParamsResult) try {
2470
- if (isV2Platform) {
2471
- const urlParams = currentUrl.searchParams;
2472
- const code = urlParams.get("code");
2473
- const executionIdFromUrl = urlParams.get("executionId");
2474
- const storedExecutionId = sessionStorage.getItem("thunderid_execution_id");
2475
- if (code && !executionIdFromUrl && !storedExecutionId) await signIn();
2476
- } else await signIn({ callOnlyOnRedirect: true });
1856
+ if (hasAuthParams(currentUrl, config.afterSignInUrl) && hasCalledForThisInstance(currentUrl, instanceId ?? 0)) try {
1857
+ const urlParams = currentUrl.searchParams;
1858
+ const code = urlParams.get("code");
1859
+ const executionIdFromUrl = urlParams.get("executionId");
1860
+ const storedExecutionId = sessionStorage.getItem("thunderid_execution_id");
1861
+ if (code && !executionIdFromUrl && !storedExecutionId) await signIn();
2477
1862
  } catch (error) {
2478
1863
  throw new __thunderid_browser.ThunderIDRuntimeError(`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`, "thunderid-signIn-Error", "react", "An error occurred while trying to sign in.");
2479
1864
  }
@@ -2520,7 +1905,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2520
1905
  const checkLoadingState = () => {
2521
1906
  if (isUpdatingSession) return;
2522
1907
  const currentUrl = new URL(window.location.href);
2523
- if (!isSignedInSync && hasAuthParams(currentUrl, afterSignInUrl)) return;
1908
+ if (!isSignedInSync && hasAuthParams(currentUrl, config.afterSignInUrl)) return;
2524
1909
  setIsLoadingSync(client.isLoading());
2525
1910
  };
2526
1911
  checkLoadingState();
@@ -2557,10 +1942,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2557
1942
  setHasFetchedBranding(false);
2558
1943
  await fetchBranding();
2559
1944
  }, [fetchBranding]);
2560
- (0, react.useEffect)(() => {
2561
- if (config.platform === __thunderid_browser.Platform.ThunderIDV2) return;
2562
- if (preferences?.theme?.inheritFromBranding === true && isInitializedSync && baseUrl && !hasFetchedBranding && !isBrandingLoading) fetchBranding();
2563
- }, [
1945
+ (0, react.useEffect)(() => {}, [
2564
1946
  preferences?.theme?.inheritFromBranding,
2565
1947
  isInitializedSync,
2566
1948
  baseUrl,
@@ -2572,9 +1954,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2572
1954
  try {
2573
1955
  setIsUpdatingSession(true);
2574
1956
  setIsLoadingSync(true);
2575
- const response = await client.signInSilently(options);
2576
- if (await client.isSignedIn()) await updateSession();
2577
- return response;
1957
+ return await client.signInSilently(options);
2578
1958
  } catch (error) {
2579
1959
  throw new __thunderid_browser.ThunderIDRuntimeError(`Error while signing in silently: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`, "thunderid-signInSilently-Error", "react", "An error occurred while trying to sign in silently.");
2580
1960
  } finally {
@@ -2621,7 +2001,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2621
2001
  const clearSession = (0, react.useCallback)(async (...args) => client.clearSession(...args), [client]);
2622
2002
  const reInitialize = (0, react.useCallback)(async (reInitConfig) => client.reInitialize(reInitConfig), [client]);
2623
2003
  const value = (0, react.useMemo)(() => ({
2624
- afterSignInUrl,
2004
+ afterSignInUrl: config.afterSignInUrl,
2625
2005
  applicationId: config.applicationId,
2626
2006
  baseUrl,
2627
2007
  clearSession,
@@ -2643,7 +2023,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2643
2023
  organization: currentOrganization,
2644
2024
  organizationChain,
2645
2025
  organizationHandle: config?.organizationHandle,
2646
- platform: config?.platform,
2026
+ platform: __thunderid_browser.Platform.ThunderID,
2647
2027
  reInitialize,
2648
2028
  recover,
2649
2029
  signIn,
@@ -2659,9 +2039,9 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
2659
2039
  }), [
2660
2040
  applicationId,
2661
2041
  config?.organizationHandle,
2042
+ config.afterSignInUrl,
2662
2043
  signInUrl,
2663
2044
  signUpUrl,
2664
- afterSignInUrl,
2665
2045
  baseUrl,
2666
2046
  clientId,
2667
2047
  wellKnown,
@@ -8727,7 +8107,7 @@ const getConsentOptionalKey = (purposeId, attrName) => `__consent_opt__${purpose
8727
8107
  const ConsentCheckboxList = ({ variant, purpose, formValues, onInputChange, children }) => {
8728
8108
  const { theme, colorScheme } = useTheme_default();
8729
8109
  const styles = ConsentCheckboxList_styles_default(theme, colorScheme);
8730
- const attributes = variant === "ESSENTIAL" ? purpose.essential : purpose.optional;
8110
+ const attributes = (variant === "ESSENTIAL" ? purpose.essential : purpose.optional).map((e) => e.name);
8731
8111
  if (!attributes || attributes.length === 0) return null;
8732
8112
  const isEssential = variant === "ESSENTIAL";
8733
8113
  const isChecked = (attrName) => {
@@ -8820,7 +8200,7 @@ const Consent = ({ consentData, formValues, onInputChange, children }) => {
8820
8200
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Typography_default, {
8821
8201
  variant: "subtitle2",
8822
8202
  fontWeight: "bold",
8823
- children: "Optional Attributes"
8203
+ children: purpose.type === "permissions" ? "Permissions" : "Optional Attributes"
8824
8204
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConsentCheckboxList_default, {
8825
8205
  variant: "OPTIONAL",
8826
8206
  purpose,
@@ -9292,12 +8672,12 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
9292
8672
  const isDeny = componentVariant.toLowerCase() !== "primary";
9293
8673
  const decisions = { purposes: consentPrompt.purposes.map((p) => ({
9294
8674
  approved: !isDeny,
9295
- elements: [...p.essential.map((attr) => ({
8675
+ elements: [...p.essential.map((e) => ({
9296
8676
  approved: !isDeny,
9297
- name: attr
9298
- })), ...p.optional.map((attr) => ({
9299
- approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, attr)] !== "false",
9300
- name: attr
8677
+ name: e.name
8678
+ })), ...p.optional.map((e) => ({
8679
+ approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, e.name)] !== "false",
8680
+ name: e.name
9301
8681
  }))],
9302
8682
  purposeName: p.purposeName
9303
8683
  })) };
@@ -9852,7 +9232,7 @@ var BaseSignIn_default$1 = BaseSignIn$1;
9852
9232
  //#region src/components/presentation/auth/SignIn/BaseSignIn.tsx
9853
9233
  const BaseSignIn = (props) => {
9854
9234
  const { platform } = useThunderID_default();
9855
- if (platform === __thunderid_browser.Platform.ThunderIDV2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseSignIn_default$1, { ...props });
9235
+ if (platform === __thunderid_browser.Platform.ThunderID) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseSignIn_default$1, { ...props });
9856
9236
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseSignIn_default$2, { ...props });
9857
9237
  };
9858
9238
  var BaseSignIn_default = BaseSignIn;
@@ -10380,14 +9760,14 @@ const SignIn$1 = ({ className, preferences, size = "medium", onSuccess, onError,
10380
9760
  }
10381
9761
  const decisions = { purposes: purposes.map((p) => ({
10382
9762
  approved: !isDeny,
10383
- elements: [...(p.essential || []).map((attr) => ({
9763
+ elements: [...(p.essential || []).map((e) => ({
10384
9764
  approved: !isDeny,
10385
- name: attr
10386
- })), ...(p.optional || []).map((attr) => {
10387
- const key = `__consent_opt__${p.purposeId}__${attr}`;
9765
+ name: e.name
9766
+ })), ...(p.optional || []).map((e) => {
9767
+ const key = `__consent_opt__${p.purposeId}__${e.name}`;
10388
9768
  return {
10389
9769
  approved: isDeny ? false : processedInputs[key] !== "false",
10390
- name: attr
9770
+ name: e.name
10391
9771
  };
10392
9772
  })],
10393
9773
  purposeName: p.purposeName
@@ -10623,7 +10003,7 @@ const SignIn = ({ className, size = "medium", children, preferences,...rest }) =
10623
10003
  window.location.href = url.toString();
10624
10004
  }
10625
10005
  };
10626
- if (platform === __thunderid_browser.Platform.ThunderIDV2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SignIn_default$1, {
10006
+ if (platform === __thunderid_browser.Platform.ThunderID) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SignIn_default$1, {
10627
10007
  className,
10628
10008
  size,
10629
10009
  variant: rest.variant,
@@ -12420,7 +11800,7 @@ var BaseSignUp_default$1 = BaseSignUp$1;
12420
11800
  //#region src/components/presentation/auth/SignUp/BaseSignUp.tsx
12421
11801
  const BaseSignUp = (props) => {
12422
11802
  const { platform } = useThunderID_default();
12423
- if (platform === __thunderid_browser.Platform.ThunderIDV2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseSignUp_default$1, { ...props });
11803
+ if (platform === __thunderid_browser.Platform.ThunderID) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseSignUp_default$1, { ...props });
12424
11804
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseSignUp_default$2, { ...props });
12425
11805
  };
12426
11806
  var BaseSignUp_default = BaseSignUp;
@@ -12596,7 +11976,7 @@ var SignUp_default$2 = SignUp$1;
12596
11976
  */
12597
11977
  const SignUp = (props) => {
12598
11978
  const { platform } = useThunderID_default();
12599
- if (platform === __thunderid_browser.Platform.ThunderIDV2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SignUp_default$2, { ...props });
11979
+ if (platform === __thunderid_browser.Platform.ThunderID) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SignUp_default$2, { ...props });
12600
11980
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SignUp_default$1, { ...props });
12601
11981
  };
12602
11982
  var SignUp_default = SignUp;
@@ -13346,7 +12726,7 @@ var BaseRecovery_default$1 = BaseRecovery$1;
13346
12726
  //#region src/components/presentation/auth/Recovery/BaseRecovery.tsx
13347
12727
  const BaseRecovery = (props) => {
13348
12728
  const { platform } = useThunderID_default();
13349
- if (platform === __thunderid_browser.Platform.ThunderIDV2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseRecovery_default$1, { ...props });
12729
+ if (platform === __thunderid_browser.Platform.ThunderID) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseRecovery_default$1, { ...props });
13350
12730
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseRecovery_default$2, { ...props });
13351
12731
  };
13352
12732
  var BaseRecovery_default = BaseRecovery;
@@ -13484,7 +12864,7 @@ var Recovery_default$2 = Recovery$1;
13484
12864
  */
13485
12865
  const Recovery = (props) => {
13486
12866
  const { platform } = useThunderID_default();
13487
- if (platform === __thunderid_browser.Platform.ThunderIDV2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Recovery_default$2, { ...props });
12867
+ if (platform === __thunderid_browser.Platform.ThunderID) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Recovery_default$2, { ...props });
13488
12868
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Recovery_default$1, { ...props });
13489
12869
  };
13490
12870
  var Recovery_default = Recovery;
@@ -14651,7 +14031,7 @@ var AcceptInvite_default = AcceptInvite;
14651
14031
  */
14652
14032
  const Callback = ({ onNavigate, onError }) => {
14653
14033
  const processingRef = (0, react.useRef)(false);
14654
- const navigate$5 = (path) => {
14034
+ const navigate$4 = (path) => {
14655
14035
  if (onNavigate) onNavigate(path);
14656
14036
  else (0, __thunderid_browser.navigate)(path);
14657
14037
  };
@@ -14686,7 +14066,7 @@ const Callback = ({ onNavigate, onError }) => {
14686
14066
  const params$1 = new URLSearchParams();
14687
14067
  params$1.set("error", oauthError);
14688
14068
  if (errorDescription) params$1.set("error_description", errorDescription);
14689
- navigate$5(`/?${params$1.toString()}`);
14069
+ navigate$4(`/?${params$1.toString()}`);
14690
14070
  return;
14691
14071
  }
14692
14072
  throw new Error("Invalid OAuth state - possible CSRF attack");
@@ -14704,14 +14084,14 @@ const Callback = ({ onNavigate, onError }) => {
14704
14084
  const params$1 = new URLSearchParams();
14705
14085
  params$1.set("error", oauthError);
14706
14086
  if (errorDescription) params$1.set("error_description", errorDescription);
14707
- navigate$5(`${returnPath}?${params$1.toString()}`);
14087
+ navigate$4(`${returnPath}?${params$1.toString()}`);
14708
14088
  return;
14709
14089
  }
14710
14090
  if (!code) throw new Error("Missing OAuth authorization code");
14711
14091
  const params = new URLSearchParams();
14712
14092
  params.set("code", code);
14713
14093
  if (nonce) params.set("nonce", nonce);
14714
- navigate$5(`${returnPath}?${params.toString()}`);
14094
+ navigate$4(`${returnPath}?${params.toString()}`);
14715
14095
  } catch (err) {
14716
14096
  const errorMessage = err instanceof Error ? err.message : "OAuth callback processing failed";
14717
14097
  console.error("OAuth callback error:", err);
@@ -14719,7 +14099,7 @@ const Callback = ({ onNavigate, onError }) => {
14719
14099
  const params = new URLSearchParams();
14720
14100
  params.set("error", "callback_error");
14721
14101
  params.set("error_description", errorMessage);
14722
- navigate$5(`${returnPath}?${params.toString()}`);
14102
+ navigate$4(`${returnPath}?${params.toString()}`);
14723
14103
  }
14724
14104
  };
14725
14105
  processOAuthCallback();
@@ -16340,8 +15720,7 @@ var BaseUserProfile_default = BaseUserProfile;
16340
15720
  */
16341
15721
  const updateMeProfile = async ({ fetcher, instanceId = 0,...requestConfig }) => {
16342
15722
  const defaultFetcher = async (url, config) => {
16343
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
16344
- const response = await client.httpRequest.bind(client)({
15723
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
16345
15724
  data: config.body ? JSON.parse(config.body) : void 0,
16346
15725
  headers: config.headers,
16347
15726
  method: config.method || "PATCH",
@@ -17892,8 +17271,7 @@ const BaseCreateOrganization = ({ cardLayout = true, className = "", defaultPare
17892
17271
  */
17893
17272
  const createOrganization = async ({ fetcher, instanceId = 0,...requestConfig }) => {
17894
17273
  const defaultFetcher = async (url, config) => {
17895
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
17896
- const response = await client.httpRequest.bind(client)({
17274
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
17897
17275
  data: config.body ? JSON.parse(config.body) : void 0,
17898
17276
  headers: config.headers,
17899
17277
  method: config.method || "POST",
@@ -19471,8 +18849,7 @@ var BaseOrganizationProfile_default = BaseOrganizationProfile;
19471
18849
  */
19472
18850
  const getOrganization = async ({ fetcher, instanceId = 0,...requestConfig }) => {
19473
18851
  const defaultFetcher = async (url, config) => {
19474
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
19475
- const response = await client.httpRequest.bind(client)({
18852
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
19476
18853
  headers: config.headers,
19477
18854
  method: config.method || "GET",
19478
18855
  url
@@ -19541,8 +18918,7 @@ var getOrganization_default = getOrganization;
19541
18918
  */
19542
18919
  const updateOrganization = async ({ fetcher, instanceId = 0,...requestConfig }) => {
19543
18920
  const defaultFetcher = async (url, config) => {
19544
- const client = __thunderid_browser.ThunderIDSPAClient.getInstance(instanceId);
19545
- const response = await client.httpRequest.bind(client)({
18921
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
19546
18922
  data: config.body ? JSON.parse(config.body) : void 0,
19547
18923
  headers: config.headers,
19548
18924
  method: config.method || "PATCH",
@@ -20068,6 +19444,128 @@ const LanguageSwitcher = ({ children, className }) => {
20068
19444
  };
20069
19445
  var LanguageSwitcher_default = LanguageSwitcher;
20070
19446
 
19447
+ //#endregion
19448
+ //#region src/api/getSchemas.ts
19449
+ /**
19450
+ * Retrieves the SCIM2 schemas from the specified endpoint.
19451
+ * This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
19452
+ *
19453
+ * @param config - Request configuration object.
19454
+ * @returns A promise that resolves with the SCIM2 schemas information.
19455
+ * @example
19456
+ * ```typescript
19457
+ * // Using default ThunderID SPA client httpClient
19458
+ * try {
19459
+ * const schemas = await getSchemas({
19460
+ * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
19461
+ * });
19462
+ * console.log(schemas);
19463
+ * } catch (error) {
19464
+ * if (error instanceof ThunderIDAPIError) {
19465
+ * console.error('Failed to get schemas:', error.message);
19466
+ * }
19467
+ * }
19468
+ * ```
19469
+ *
19470
+ * @example
19471
+ * ```typescript
19472
+ * // Using custom fetcher
19473
+ * try {
19474
+ * const schemas = await getSchemas({
19475
+ * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
19476
+ * fetcher: customFetchFunction
19477
+ * });
19478
+ * console.log(schemas);
19479
+ * } catch (error) {
19480
+ * if (error instanceof ThunderIDAPIError) {
19481
+ * console.error('Failed to get schemas:', error.message);
19482
+ * }
19483
+ * }
19484
+ * ```
19485
+ */
19486
+ const getSchemas = async ({ fetcher, instanceId = 0,...requestConfig }) => {
19487
+ const defaultFetcher = async (url, config) => {
19488
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
19489
+ headers: config.headers,
19490
+ method: config.method || "GET",
19491
+ url
19492
+ });
19493
+ return {
19494
+ json: () => Promise.resolve(response.data),
19495
+ ok: response.status >= 200 && response.status < 300,
19496
+ status: response.status,
19497
+ statusText: response.statusText || "",
19498
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
19499
+ };
19500
+ };
19501
+ return (0, __thunderid_browser.getSchemas)({
19502
+ ...requestConfig,
19503
+ fetcher: fetcher || defaultFetcher
19504
+ });
19505
+ };
19506
+ var getSchemas_default = getSchemas;
19507
+
19508
+ //#endregion
19509
+ //#region src/api/getScim2Me.ts
19510
+ /**
19511
+ * Retrieves the user profile information from the specified SCIM2 /Me endpoint.
19512
+ * This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
19513
+ *
19514
+ * @param requestConfig - Request configuration object.
19515
+ * @returns A promise that resolves with the user profile information.
19516
+ * @example
19517
+ * ```typescript
19518
+ * // Using default ThunderID SPA client httpClient
19519
+ * try {
19520
+ * const userProfile = await getScim2Me({
19521
+ * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
19522
+ * });
19523
+ * console.log(userProfile);
19524
+ * } catch (error) {
19525
+ * if (error instanceof ThunderIDAPIError) {
19526
+ * console.error('Failed to get user profile:', error.message);
19527
+ * }
19528
+ * }
19529
+ * ```
19530
+ *
19531
+ * @example
19532
+ * ```typescript
19533
+ * // Using custom fetcher
19534
+ * try {
19535
+ * const userProfile = await getScim2Me({
19536
+ * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
19537
+ * fetcher: customFetchFunction
19538
+ * });
19539
+ * console.log(userProfile);
19540
+ * } catch (error) {
19541
+ * if (error instanceof ThunderIDAPIError) {
19542
+ * console.error('Failed to get user profile:', error.message);
19543
+ * }
19544
+ * }
19545
+ * ```
19546
+ */
19547
+ const getScim2Me = async ({ fetcher, instanceId = 0,...requestConfig }) => {
19548
+ const defaultFetcher = async (url, config) => {
19549
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
19550
+ headers: config.headers,
19551
+ method: config.method || "GET",
19552
+ url
19553
+ });
19554
+ return {
19555
+ json: () => Promise.resolve(response.data),
19556
+ ok: response.status >= 200 && response.status < 300,
19557
+ status: response.status,
19558
+ statusText: response.statusText || "",
19559
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
19560
+ };
19561
+ };
19562
+ return (0, __thunderid_browser.getScim2Me)({
19563
+ ...requestConfig,
19564
+ fetcher: fetcher || defaultFetcher
19565
+ });
19566
+ };
19567
+ var getScim2Me_default = getScim2Me;
19568
+
20071
19569
  //#endregion
20072
19570
  exports.AcceptInvite = AcceptInvite_default;
20073
19571
  exports.Alert = Alert_default;
@@ -20162,6 +19660,7 @@ exports.EyeOff = EyeOff_default;
20162
19660
  exports.FacebookButton = FacebookButton_default;
20163
19661
  exports.FieldFactory = FieldFactory;
20164
19662
  exports.FlowContext = FlowContext_default;
19663
+ exports.FlowMetaProvider = FlowMetaProvider_default;
20165
19664
  exports.FlowProvider = FlowProvider_default;
20166
19665
  exports.FlowTimer = FlowTimer_default;
20167
19666
  exports.FormControl = FormControl_default;