@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/README.md +1 -1
- package/dist/ThunderIDReactClient.d.ts +6 -43
- package/dist/ThunderIDReactClient.d.ts.map +1 -1
- package/dist/api/createOrganization.d.ts.map +1 -1
- package/dist/api/getAllOrganizations.d.ts.map +1 -1
- package/dist/api/getMeOrganizations.d.ts.map +1 -1
- package/dist/api/getOrganization.d.ts.map +1 -1
- package/dist/api/getSchemas.d.ts.map +1 -1
- package/dist/api/getScim2Me.d.ts.map +1 -1
- package/dist/api/updateMeProfile.d.ts.map +1 -1
- package/dist/api/updateOrganization.d.ts.map +1 -1
- package/dist/cjs/index.js +230 -731
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/adapters/ConsentCheckboxList.d.ts.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDContext.d.ts +3 -2
- package/dist/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +226 -728
- package/dist/index.js.map +1 -1
- package/package.json +16 -10
- package/dist/__temp__/api.d.ts +0 -258
- package/dist/__temp__/api.d.ts.map +0 -1
- package/dist/__temp__/models.d.ts +0 -98
- package/dist/__temp__/models.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationNativeAuthenticationConstants, DEFAULT_THEME, EMOJI_URI_SCHEME, EmbeddedFlowActionVariantV2 as EmbeddedFlowActionVariant, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowComponentTypeV2, EmbeddedFlowComponentTypeV2 as EmbeddedFlowComponentType, EmbeddedFlowEventTypeV2, EmbeddedFlowEventTypeV2 as EmbeddedFlowEventType, EmbeddedFlowResponseType, EmbeddedFlowStatus, EmbeddedFlowTextVariantV2 as EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedRecoveryFlowStatusV2 as EmbeddedRecoveryFlowStatus, EmbeddedRecoveryFlowTypeV2 as EmbeddedRecoveryFlowType, EmbeddedSignInFlowAuthenticatorKnownIdPType, EmbeddedSignInFlowAuthenticatorParamType, EmbeddedSignInFlowAuthenticatorPromptType, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowStatusV2, EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatus, EmbeddedSignInFlowStepType, EmbeddedSignInFlowTypeV2, EmbeddedSignInFlowTypeV2 as EmbeddedSignInFlowType, FieldType, FlowMetaType,
|
|
1
|
+
import { ApplicationNativeAuthenticationConstants, DEFAULT_THEME, EMOJI_URI_SCHEME, EmbeddedFlowActionVariantV2 as EmbeddedFlowActionVariant, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowComponentTypeV2, EmbeddedFlowComponentTypeV2 as EmbeddedFlowComponentType, EmbeddedFlowEventTypeV2, EmbeddedFlowEventTypeV2 as EmbeddedFlowEventType, EmbeddedFlowResponseType, EmbeddedFlowStatus, EmbeddedFlowTextVariantV2 as EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedRecoveryFlowStatusV2 as EmbeddedRecoveryFlowStatus, EmbeddedRecoveryFlowTypeV2 as EmbeddedRecoveryFlowType, EmbeddedSignInFlowAuthenticatorKnownIdPType, EmbeddedSignInFlowAuthenticatorParamType, EmbeddedSignInFlowAuthenticatorPromptType, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowStatusV2, EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatus, EmbeddedSignInFlowStepType, EmbeddedSignInFlowTypeV2, EmbeddedSignInFlowTypeV2 as EmbeddedSignInFlowType, FetchHttpClient, FieldType, FlowMetaType, Platform, ThunderIDAPIError, ThunderIDBrowserClient, ThunderIDError, ThunderIDRuntimeError, ThunderIDRuntimeError as ThunderIDRuntimeError$1, TranslationBundleConstants, WellKnownSchemaIds, arrayBufferToBase64url, base64urlToArrayBuffer, bem, countryCodeToFlagEmoji, createClassObserver, createMediaQueryListener, createOrganization, createPackageComponentLogger, createPatchOperations, createTheme, deepMerge, deriveOrganizationHandleFromBaseUrl, detectThemeMode, executeEmbeddedRecoveryFlowV2, executeEmbeddedSignInFlowV2, executeEmbeddedSignUpFlowV2, extractEmojiFromUri, extractEmojiFromUri as extractEmojiFromUri$1, extractUserClaimsFromIdToken, formatDate, generateFlattenedUserProfile, get, getActiveTheme, getActiveTheme as getActiveTheme$1, getAllOrganizations, getBrandingPreference, getDefaultI18nBundles, getFlowMetaV2, getMeOrganizations, getOrganization, getOrganizationUnitChildren, getSchemas, getScim2Me, handleWebAuthnAuthentication, hasAuthParamsInUrl, hasCalledForThisInstanceInUrl, http, isEmojiUri, isEmojiUri as isEmojiUri$1, isEmpty, logger, navigate, navigate as navigate$1, normalizeTranslations, resolveEmojiUrisInHtml, resolveEmojiUrisInHtml as resolveEmojiUrisInHtml$1, resolveFlowTemplateLiterals, resolveFlowTemplateLiterals as resolveFlowTemplateLiterals$1, resolveLocaleDisplayName, resolveLocaleDisplayName as resolveLocaleDisplayName$1, resolveLocaleEmoji, resolveLocaleEmoji as resolveLocaleEmoji$1, resolveMeta, transformBrandingPreferenceToTheme, updateMeProfile, updateOrganization, withVendorCSSClassPrefix } from "@thunderid/browser";
|
|
2
2
|
import React, { cloneElement, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { css, cx, keyframes } from "@emotion/css";
|
|
@@ -78,361 +78,6 @@ const useBrowserUrl = () => {
|
|
|
78
78
|
};
|
|
79
79
|
var useBrowserUrl_default = useBrowserUrl;
|
|
80
80
|
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/__temp__/api.ts
|
|
83
|
-
var AuthAPI = class AuthAPI {
|
|
84
|
-
static DEFAULT_STATE;
|
|
85
|
-
authState = AuthAPI.DEFAULT_STATE;
|
|
86
|
-
client;
|
|
87
|
-
apiInstanceId;
|
|
88
|
-
loadingState;
|
|
89
|
-
constructor(spaClient, instanceId = 0) {
|
|
90
|
-
this.apiInstanceId = instanceId;
|
|
91
|
-
this.client = spaClient ?? ThunderIDSPAClient.getInstance(instanceId);
|
|
92
|
-
this.getState = this.getState.bind(this);
|
|
93
|
-
this.init = this.init.bind(this);
|
|
94
|
-
this.signIn = this.signIn.bind(this);
|
|
95
|
-
this.signOut = this.signOut.bind(this);
|
|
96
|
-
this.updateState = this.updateState.bind(this);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get the instance ID for this AuthAPI instance.
|
|
100
|
-
* @returns The instance ID used for multi-auth context support.
|
|
101
|
-
*/
|
|
102
|
-
getInstanceId() {
|
|
103
|
-
return this.apiInstanceId;
|
|
104
|
-
}
|
|
105
|
-
setLoadingState(isLoading) {
|
|
106
|
-
this.loadingState = isLoading;
|
|
107
|
-
}
|
|
108
|
-
getLoadingState() {
|
|
109
|
-
return this.loadingState;
|
|
110
|
-
}
|
|
111
|
-
isLoading() {
|
|
112
|
-
return this.getLoadingState();
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Method to return Auth Client instance authentication state.
|
|
116
|
-
*
|
|
117
|
-
* @return {AuthStateInterface} Authentication State.
|
|
118
|
-
*/
|
|
119
|
-
getState() {
|
|
120
|
-
return this.authState;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Method to initialize the AuthClient instance.
|
|
124
|
-
*
|
|
125
|
-
* @param {Config} config - `dispatch` function from React Auth Context.
|
|
126
|
-
*/
|
|
127
|
-
async init(config) {
|
|
128
|
-
return this.client.initialize(config);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Method to get the configuration data.
|
|
132
|
-
*
|
|
133
|
-
* @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
|
|
134
|
-
*/
|
|
135
|
-
async getConfigData() {
|
|
136
|
-
return this.client.getConfigData();
|
|
137
|
-
}
|
|
138
|
-
async getStorageManager() {
|
|
139
|
-
return this.client.getStorageManager();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Method to get the configuration data.
|
|
143
|
-
*
|
|
144
|
-
* @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
|
|
145
|
-
*/
|
|
146
|
-
async isInitialized() {
|
|
147
|
-
return this.client.isInitialized();
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Method to handle user Sign In requests.
|
|
151
|
-
*
|
|
152
|
-
* @param {any} dispatch - `dispatch` function from React Auth Context.
|
|
153
|
-
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
154
|
-
* @param {any} callback - Action to trigger on successful sign in.
|
|
155
|
-
*/
|
|
156
|
-
async signIn(config, authorizationCode, sessionState, authState, callback, tokenRequestConfig) {
|
|
157
|
-
return this.client.signIn(config, authorizationCode, sessionState, authState, tokenRequestConfig).then(async (response) => {
|
|
158
|
-
if (!response) return null;
|
|
159
|
-
if (await this.client.isSignedIn()) {
|
|
160
|
-
const stateToUpdate = {
|
|
161
|
-
displayName: response.displayName,
|
|
162
|
-
email: response.email,
|
|
163
|
-
isLoading: false,
|
|
164
|
-
isSignedIn: true,
|
|
165
|
-
username: response.username
|
|
166
|
-
};
|
|
167
|
-
this.updateState(stateToUpdate);
|
|
168
|
-
this.setLoadingState(false);
|
|
169
|
-
if (callback) callback(response);
|
|
170
|
-
}
|
|
171
|
-
return response;
|
|
172
|
-
}).catch((error) => Promise.reject(error));
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Method to handle user Sign Out requests.
|
|
176
|
-
*
|
|
177
|
-
* @param {any} dispatch - `dispatch` function from React Auth Context.
|
|
178
|
-
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
179
|
-
* @param {any} callback - Action to trigger on successful sign out.
|
|
180
|
-
*/
|
|
181
|
-
signOut(callback) {
|
|
182
|
-
return this.client.signOut().then((response) => {
|
|
183
|
-
if (callback) callback(response);
|
|
184
|
-
return response;
|
|
185
|
-
}).catch((error) => Promise.reject(error));
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Method to update Auth Client instance authentication state.
|
|
189
|
-
*
|
|
190
|
-
* @param {AuthStateInterface} state - State values to update in authentication state.
|
|
191
|
-
*/
|
|
192
|
-
updateState(state) {
|
|
193
|
-
this.authState = {
|
|
194
|
-
...this.authState,
|
|
195
|
-
...state
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* This method returns a Promise that resolves with the basic user information obtained from the ID token.
|
|
200
|
-
*
|
|
201
|
-
* @return {Promise<User>} - A promise that resolves with the user information.
|
|
202
|
-
*/
|
|
203
|
-
async getUser() {
|
|
204
|
-
return this.client.getUser();
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* This method sends an API request to a protected endpoint.
|
|
208
|
-
* The access token is automatically attached to the header of the request.
|
|
209
|
-
* This is the only way by which protected endpoints can be accessed
|
|
210
|
-
* when the web worker is used to store session information.
|
|
211
|
-
*
|
|
212
|
-
* @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
|
|
213
|
-
*
|
|
214
|
-
* @return {Promise<Response>} - Returns a Promise that resolves with the response to the request.
|
|
215
|
-
*/
|
|
216
|
-
async httpRequest(config) {
|
|
217
|
-
return this.client.httpRequest(config);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* This method sends multiple API requests to a protected endpoint.
|
|
221
|
-
* The access token is automatically attached to the header of the request.
|
|
222
|
-
* This is the only way by which multiple requests can be sent to protected endpoints
|
|
223
|
-
* when the web worker is used to store session information.
|
|
224
|
-
*
|
|
225
|
-
* @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
|
|
226
|
-
*
|
|
227
|
-
* @return {Promise<Response>} - Returns a Promise that resolves with the responses to the requests.
|
|
228
|
-
*/
|
|
229
|
-
async httpRequestAll(configs) {
|
|
230
|
-
return this.client.httpRequestAll(configs);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* This method allows you to send a request with a custom grant.
|
|
234
|
-
*
|
|
235
|
-
* @param {CustomGrantRequestParams} config - The request parameters.
|
|
236
|
-
*
|
|
237
|
-
* @return {Promise<Response | SignInResponse>} - A Promise that resolves with
|
|
238
|
-
* the value returned by the custom grant request.
|
|
239
|
-
*/
|
|
240
|
-
exchangeToken(config, callback) {
|
|
241
|
-
return this.client.exchangeToken(config).then((response) => {
|
|
242
|
-
if (!response) return null;
|
|
243
|
-
if (config.returnsSession) this.updateState({
|
|
244
|
-
...this.getState(),
|
|
245
|
-
...response,
|
|
246
|
-
isLoading: false,
|
|
247
|
-
isSignedIn: true
|
|
248
|
-
});
|
|
249
|
-
if (callback) callback(response);
|
|
250
|
-
return response;
|
|
251
|
-
}).catch((error) => Promise.reject(error));
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* This method ends a user session. The access token is revoked and the session information is destroyed.
|
|
255
|
-
*
|
|
256
|
-
* @return {Promise<boolean>} - A promise that resolves with `true` if the process is successful.
|
|
257
|
-
*/
|
|
258
|
-
async revokeAccessToken(dispatch) {
|
|
259
|
-
return this.client.revokeAccessToken().then(() => {
|
|
260
|
-
this.updateState({
|
|
261
|
-
...AuthAPI.DEFAULT_STATE,
|
|
262
|
-
isLoading: false
|
|
263
|
-
});
|
|
264
|
-
dispatch(AuthAPI.DEFAULT_STATE);
|
|
265
|
-
return true;
|
|
266
|
-
}).catch((error) => Promise.reject(error));
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* This method returns a Promise that resolves with an object containing the service endpoints.
|
|
270
|
-
*
|
|
271
|
-
* @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
|
|
272
|
-
*/
|
|
273
|
-
async getOpenIDProviderEndpoints() {
|
|
274
|
-
return this.client.getOpenIDProviderEndpoints();
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* This methods returns the Axios http client.
|
|
278
|
-
*
|
|
279
|
-
* @return {HttpClient} - The Axios HTTP client.
|
|
280
|
-
*/
|
|
281
|
-
async getHttpClient() {
|
|
282
|
-
return this.client.getHttpClient();
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* This method decodes a JWT token payload and returns it.
|
|
286
|
-
*
|
|
287
|
-
* @param token - The token to decode.
|
|
288
|
-
* @returns The decoded token payload.
|
|
289
|
-
*/
|
|
290
|
-
async decodeJwtToken(token) {
|
|
291
|
-
return this.client.decodeJwtToken(token);
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* This method decodes the payload of the id token and returns it.
|
|
295
|
-
*
|
|
296
|
-
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
297
|
-
* the decoded payload of the id token.
|
|
298
|
-
*/
|
|
299
|
-
async getDecodedIdToken(sessionId) {
|
|
300
|
-
return this.client.getDecodedIdToken(sessionId);
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* This method decodes the payload of the idp id token and returns it.
|
|
304
|
-
*
|
|
305
|
-
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
306
|
-
* the decoded payload of the idp id token.
|
|
307
|
-
*/
|
|
308
|
-
async getDecodedIDPIDToken() {
|
|
309
|
-
return this.client.getDecodedIdToken();
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* This method returns the ID token.
|
|
313
|
-
*
|
|
314
|
-
* @return {Promise<string>} - A Promise that resolves with the id token.
|
|
315
|
-
*/
|
|
316
|
-
async getIdToken() {
|
|
317
|
-
return this.client.getIdToken();
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* This method return a Promise that resolves with the access token.
|
|
321
|
-
*
|
|
322
|
-
* **This method will not return the access token if the storage type is set to `webWorker`.**
|
|
323
|
-
*
|
|
324
|
-
* @return {Promise<string>} - A Promise that resolves with the access token.
|
|
325
|
-
*/
|
|
326
|
-
async getAccessToken(sessionId) {
|
|
327
|
-
return this.client.getAccessToken(sessionId);
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* This method return a Promise that resolves with the idp access token.
|
|
331
|
-
*
|
|
332
|
-
* **This method will not return the idp access token if the storage type is set to `webWorker`.**
|
|
333
|
-
* **This can be used to access the IDP access token when custom auth grant functionalities are used**
|
|
334
|
-
*
|
|
335
|
-
* @return {Promise<string>} - A Promise that resolves with the idp access token.
|
|
336
|
-
*/
|
|
337
|
-
async getIDPAccessToken() {
|
|
338
|
-
return this.client.getIDPAccessToken();
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* This method refreshes the access token.
|
|
342
|
-
*
|
|
343
|
-
* @return {TokenResponseInterface} - A Promise that resolves with an object containing
|
|
344
|
-
* information about the refreshed access token.
|
|
345
|
-
*/
|
|
346
|
-
async refreshAccessToken() {
|
|
347
|
-
return this.client.refreshAccessToken();
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* This method specifies if the user is authenticated or not.
|
|
351
|
-
*
|
|
352
|
-
* @return {Promise<boolean>} - A Promise that resolves with `true` if teh user is authenticated.
|
|
353
|
-
*/
|
|
354
|
-
async isSignedIn() {
|
|
355
|
-
return this.client.isSignedIn();
|
|
356
|
-
}
|
|
357
|
-
async startAutoRefreshToken() {
|
|
358
|
-
return this.client.startAutoRefreshToken();
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* This method specifies if the session is active or not.
|
|
362
|
-
*
|
|
363
|
-
* @return {Promise<boolean>} - A Promise that resolves with `true` if there is an active session.
|
|
364
|
-
*/
|
|
365
|
-
async isSessionActive() {
|
|
366
|
-
return this.client.isSessionActive();
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* This method enables callback functions attached to the http client.
|
|
370
|
-
*
|
|
371
|
-
* @return {Promise<boolean>} - A promise that resolves with True.
|
|
372
|
-
*
|
|
373
|
-
*/
|
|
374
|
-
async enableHttpHandler() {
|
|
375
|
-
return this.client.enableHttpHandler();
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* This method disables callback functions attached to the http client.
|
|
379
|
-
*
|
|
380
|
-
* @return {Promise<boolean>} - A promise that resolves with True.
|
|
381
|
-
*/
|
|
382
|
-
async disableHttpHandler() {
|
|
383
|
-
return this.client.disableHttpHandler();
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* This method updates the configuration that was passed into the constructor when instantiating this class.
|
|
387
|
-
*
|
|
388
|
-
* @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
|
|
389
|
-
*/
|
|
390
|
-
async reInitialize(config) {
|
|
391
|
-
return this.client.reInitialize(config);
|
|
392
|
-
}
|
|
393
|
-
on(hook, callback, id) {
|
|
394
|
-
if (hook === Hooks.CustomGrant) return this.client.on(hook, callback, id);
|
|
395
|
-
return this.client.on(hook, callback);
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* This method allows you to sign in silently.
|
|
399
|
-
* First, this method sends a prompt none request to see if there is an active user session in the identity server.
|
|
400
|
-
* If there is one, then it requests the access token and stores it. Else, it returns false.
|
|
401
|
-
*
|
|
402
|
-
* @return {Promise<User | boolean>} - A Promise that resolves with the user information after signing in
|
|
403
|
-
* or with `false` if the user is not signed in.
|
|
404
|
-
*
|
|
405
|
-
* @example
|
|
406
|
-
*```
|
|
407
|
-
* client.signInSilently()
|
|
408
|
-
*```
|
|
409
|
-
*/
|
|
410
|
-
async signInSilently(additionalParams, tokenRequestConfig) {
|
|
411
|
-
return this.client.signInSilently(additionalParams, tokenRequestConfig).then(async (response) => {
|
|
412
|
-
if (!response) return false;
|
|
413
|
-
return response;
|
|
414
|
-
}).catch((error) => Promise.reject(error));
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* This method clears the session for the specified session ID.
|
|
418
|
-
*
|
|
419
|
-
* @param sessionId - Optional session ID to clear the session for.
|
|
420
|
-
*
|
|
421
|
-
* @return void
|
|
422
|
-
*/
|
|
423
|
-
clearSession(sessionId) {
|
|
424
|
-
this.client.clearSession(sessionId);
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
AuthAPI.DEFAULT_STATE = {
|
|
428
|
-
displayName: "",
|
|
429
|
-
email: "",
|
|
430
|
-
isLoading: true,
|
|
431
|
-
isSignedIn: false,
|
|
432
|
-
username: ""
|
|
433
|
-
};
|
|
434
|
-
var api_default = AuthAPI;
|
|
435
|
-
|
|
436
81
|
//#endregion
|
|
437
82
|
//#region src/api/getAllOrganizations.ts
|
|
438
83
|
/**
|
|
@@ -480,8 +125,7 @@ var api_default = AuthAPI;
|
|
|
480
125
|
*/
|
|
481
126
|
const getAllOrganizations$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
482
127
|
const defaultFetcher = async (url, config) => {
|
|
483
|
-
const
|
|
484
|
-
const response = await client.httpRequest.bind(client)({
|
|
128
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
485
129
|
headers: config.headers,
|
|
486
130
|
method: config.method || "GET",
|
|
487
131
|
url
|
|
@@ -552,8 +196,7 @@ var getAllOrganizations_default = getAllOrganizations$1;
|
|
|
552
196
|
*/
|
|
553
197
|
const getMeOrganizations$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
554
198
|
const defaultFetcher = async (url, config) => {
|
|
555
|
-
const
|
|
556
|
-
const response = await client.httpRequest.bind(client)({
|
|
199
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
557
200
|
headers: config.headers,
|
|
558
201
|
method: config.method || "GET",
|
|
559
202
|
url
|
|
@@ -573,171 +216,17 @@ const getMeOrganizations$1 = async ({ fetcher, instanceId = 0,...requestConfig }
|
|
|
573
216
|
};
|
|
574
217
|
var getMeOrganizations_default = getMeOrganizations$1;
|
|
575
218
|
|
|
576
|
-
//#endregion
|
|
577
|
-
//#region src/api/getSchemas.ts
|
|
578
|
-
/**
|
|
579
|
-
* Retrieves the SCIM2 schemas from the specified endpoint.
|
|
580
|
-
* This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
|
|
581
|
-
*
|
|
582
|
-
* @param config - Request configuration object.
|
|
583
|
-
* @returns A promise that resolves with the SCIM2 schemas information.
|
|
584
|
-
* @example
|
|
585
|
-
* ```typescript
|
|
586
|
-
* // Using default ThunderID SPA client httpClient
|
|
587
|
-
* try {
|
|
588
|
-
* const schemas = await getSchemas({
|
|
589
|
-
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
|
|
590
|
-
* });
|
|
591
|
-
* console.log(schemas);
|
|
592
|
-
* } catch (error) {
|
|
593
|
-
* if (error instanceof ThunderIDAPIError) {
|
|
594
|
-
* console.error('Failed to get schemas:', error.message);
|
|
595
|
-
* }
|
|
596
|
-
* }
|
|
597
|
-
* ```
|
|
598
|
-
*
|
|
599
|
-
* @example
|
|
600
|
-
* ```typescript
|
|
601
|
-
* // Using custom fetcher
|
|
602
|
-
* try {
|
|
603
|
-
* const schemas = await getSchemas({
|
|
604
|
-
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
|
|
605
|
-
* fetcher: customFetchFunction
|
|
606
|
-
* });
|
|
607
|
-
* console.log(schemas);
|
|
608
|
-
* } catch (error) {
|
|
609
|
-
* if (error instanceof ThunderIDAPIError) {
|
|
610
|
-
* console.error('Failed to get schemas:', error.message);
|
|
611
|
-
* }
|
|
612
|
-
* }
|
|
613
|
-
* ```
|
|
614
|
-
*/
|
|
615
|
-
const getSchemas$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
616
|
-
const defaultFetcher = async (url, config) => {
|
|
617
|
-
const client = ThunderIDSPAClient.getInstance(instanceId);
|
|
618
|
-
const response = await client.httpRequest.bind(client)({
|
|
619
|
-
headers: config.headers,
|
|
620
|
-
method: config.method || "GET",
|
|
621
|
-
url
|
|
622
|
-
});
|
|
623
|
-
return {
|
|
624
|
-
json: () => Promise.resolve(response.data),
|
|
625
|
-
ok: response.status >= 200 && response.status < 300,
|
|
626
|
-
status: response.status,
|
|
627
|
-
statusText: response.statusText || "",
|
|
628
|
-
text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
|
|
629
|
-
};
|
|
630
|
-
};
|
|
631
|
-
return getSchemas({
|
|
632
|
-
...requestConfig,
|
|
633
|
-
fetcher: fetcher || defaultFetcher
|
|
634
|
-
});
|
|
635
|
-
};
|
|
636
|
-
var getSchemas_default = getSchemas$1;
|
|
637
|
-
|
|
638
|
-
//#endregion
|
|
639
|
-
//#region src/api/getScim2Me.ts
|
|
640
|
-
/**
|
|
641
|
-
* Retrieves the user profile information from the specified SCIM2 /Me endpoint.
|
|
642
|
-
* This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
|
|
643
|
-
*
|
|
644
|
-
* @param requestConfig - Request configuration object.
|
|
645
|
-
* @returns A promise that resolves with the user profile information.
|
|
646
|
-
* @example
|
|
647
|
-
* ```typescript
|
|
648
|
-
* // Using default ThunderID SPA client httpClient
|
|
649
|
-
* try {
|
|
650
|
-
* const userProfile = await getScim2Me({
|
|
651
|
-
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
|
|
652
|
-
* });
|
|
653
|
-
* console.log(userProfile);
|
|
654
|
-
* } catch (error) {
|
|
655
|
-
* if (error instanceof ThunderIDAPIError) {
|
|
656
|
-
* console.error('Failed to get user profile:', error.message);
|
|
657
|
-
* }
|
|
658
|
-
* }
|
|
659
|
-
* ```
|
|
660
|
-
*
|
|
661
|
-
* @example
|
|
662
|
-
* ```typescript
|
|
663
|
-
* // Using custom fetcher
|
|
664
|
-
* try {
|
|
665
|
-
* const userProfile = await getScim2Me({
|
|
666
|
-
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
|
|
667
|
-
* fetcher: customFetchFunction
|
|
668
|
-
* });
|
|
669
|
-
* console.log(userProfile);
|
|
670
|
-
* } catch (error) {
|
|
671
|
-
* if (error instanceof ThunderIDAPIError) {
|
|
672
|
-
* console.error('Failed to get user profile:', error.message);
|
|
673
|
-
* }
|
|
674
|
-
* }
|
|
675
|
-
* ```
|
|
676
|
-
*/
|
|
677
|
-
const getScim2Me$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
678
|
-
const defaultFetcher = async (url, config) => {
|
|
679
|
-
const client = ThunderIDSPAClient.getInstance(instanceId);
|
|
680
|
-
const response = await client.httpRequest.bind(client)({
|
|
681
|
-
headers: config.headers,
|
|
682
|
-
method: config.method || "GET",
|
|
683
|
-
url
|
|
684
|
-
});
|
|
685
|
-
return {
|
|
686
|
-
json: () => Promise.resolve(response.data),
|
|
687
|
-
ok: response.status >= 200 && response.status < 300,
|
|
688
|
-
status: response.status,
|
|
689
|
-
statusText: response.statusText || "",
|
|
690
|
-
text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
|
|
691
|
-
};
|
|
692
|
-
};
|
|
693
|
-
return getScim2Me({
|
|
694
|
-
...requestConfig,
|
|
695
|
-
fetcher: fetcher || defaultFetcher
|
|
696
|
-
});
|
|
697
|
-
};
|
|
698
|
-
var getScim2Me_default = getScim2Me$1;
|
|
699
|
-
|
|
700
219
|
//#endregion
|
|
701
220
|
//#region src/ThunderIDReactClient.ts
|
|
702
|
-
/**
|
|
703
|
-
* Client for mplementing ThunderID in React applications.
|
|
704
|
-
* This class provides the core functionality for managing user authentication and sessions.
|
|
705
|
-
*
|
|
706
|
-
* @typeParam T - Configuration type that extends ThunderIDReactConfig.
|
|
707
|
-
*/
|
|
708
221
|
var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
709
|
-
authApi;
|
|
710
222
|
loadingState = false;
|
|
711
|
-
|
|
712
|
-
initializeConfig;
|
|
713
|
-
/**
|
|
714
|
-
* Creates a new ThunderIDReactClient instance.
|
|
715
|
-
* @param instanceId - Optional instance ID for multi-auth context support. Defaults to 0 for backward compatibility.
|
|
716
|
-
*/
|
|
223
|
+
_initializeConfig;
|
|
717
224
|
constructor(instanceId = 0) {
|
|
718
|
-
super();
|
|
719
|
-
this.clientInstanceId = instanceId;
|
|
720
|
-
this.authApi = new api_default(void 0, instanceId);
|
|
225
|
+
super(instanceId);
|
|
721
226
|
}
|
|
722
|
-
/**
|
|
723
|
-
* Get the instance ID for this client.
|
|
724
|
-
* @returns The instance ID used for multi-auth context support.
|
|
725
|
-
*/
|
|
726
|
-
getInstanceId() {
|
|
727
|
-
return this.clientInstanceId;
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Set the loading state of the client
|
|
731
|
-
* @param loading - Boolean indicating if the client is in a loading state
|
|
732
|
-
*/
|
|
733
227
|
setLoading(loading) {
|
|
734
228
|
this.loadingState = loading;
|
|
735
229
|
}
|
|
736
|
-
/**
|
|
737
|
-
* Wrap async operations with loading state management
|
|
738
|
-
* @param operation - The async operation to execute
|
|
739
|
-
* @returns Promise with the result of the operation
|
|
740
|
-
*/
|
|
741
230
|
async withLoading(operation) {
|
|
742
231
|
this.setLoading(true);
|
|
743
232
|
try {
|
|
@@ -750,19 +239,19 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
|
750
239
|
let resolvedOrganizationHandle = config?.organizationHandle;
|
|
751
240
|
if (!resolvedOrganizationHandle) resolvedOrganizationHandle = deriveOrganizationHandleFromBaseUrl(config?.baseUrl);
|
|
752
241
|
return this.withLoading(async () => {
|
|
753
|
-
this.
|
|
242
|
+
this._initializeConfig = {
|
|
754
243
|
...config,
|
|
755
244
|
organizationHandle: resolvedOrganizationHandle,
|
|
756
245
|
periodicTokenRefresh: config?.tokenLifecycle?.refreshToken?.autoRefresh ?? config?.periodicTokenRefresh
|
|
757
246
|
};
|
|
758
|
-
return
|
|
247
|
+
return super.initialize(this._initializeConfig);
|
|
759
248
|
});
|
|
760
249
|
}
|
|
761
250
|
reInitialize(config) {
|
|
762
251
|
return this.withLoading(async () => {
|
|
763
252
|
let isInitialized;
|
|
764
253
|
try {
|
|
765
|
-
await
|
|
254
|
+
await super.reInitialize(config);
|
|
766
255
|
isInitialized = true;
|
|
767
256
|
} catch (error) {
|
|
768
257
|
throw new ThunderIDRuntimeError$1(`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.");
|
|
@@ -773,52 +262,29 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
|
773
262
|
async updateUserProfile() {
|
|
774
263
|
throw new Error("Not implemented");
|
|
775
264
|
}
|
|
776
|
-
async getUser(
|
|
777
|
-
|
|
778
|
-
let baseUrl = options?.baseUrl;
|
|
779
|
-
if (!baseUrl) baseUrl = (await this.authApi.getConfigData())?.baseUrl;
|
|
780
|
-
return generateUserProfile(await getScim2Me_default({ baseUrl }), flattenUserSchema(await getSchemas_default({ baseUrl })));
|
|
781
|
-
} catch (error) {
|
|
782
|
-
return extractUserClaimsFromIdToken(await this.getDecodedIdToken());
|
|
783
|
-
}
|
|
265
|
+
async getUser() {
|
|
266
|
+
return extractUserClaimsFromIdToken(await this.getDecodedIdToken());
|
|
784
267
|
}
|
|
785
268
|
async getDecodedIdToken(sessionId) {
|
|
786
|
-
return
|
|
269
|
+
return super.getDecodedIdToken(sessionId);
|
|
787
270
|
}
|
|
788
271
|
async getIdToken() {
|
|
789
|
-
return this.withLoading(async () =>
|
|
272
|
+
return this.withLoading(async () => super.getIdToken());
|
|
790
273
|
}
|
|
791
|
-
async getUserProfile(
|
|
274
|
+
async getUserProfile() {
|
|
792
275
|
return this.withLoading(async () => {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
});
|
|
800
|
-
const processedSchemas = flattenUserSchema(await getSchemas_default({
|
|
801
|
-
baseUrl,
|
|
802
|
-
instanceId: this.getInstanceId()
|
|
803
|
-
}));
|
|
804
|
-
return {
|
|
805
|
-
flattenedProfile: generateFlattenedUserProfile(profile, processedSchemas),
|
|
806
|
-
profile,
|
|
807
|
-
schemas: processedSchemas
|
|
808
|
-
};
|
|
809
|
-
} catch (error) {
|
|
810
|
-
return {
|
|
811
|
-
flattenedProfile: extractUserClaimsFromIdToken(await this.getDecodedIdToken()),
|
|
812
|
-
profile: extractUserClaimsFromIdToken(await this.getDecodedIdToken()),
|
|
813
|
-
schemas: []
|
|
814
|
-
};
|
|
815
|
-
}
|
|
276
|
+
const claims = extractUserClaimsFromIdToken(await this.getDecodedIdToken());
|
|
277
|
+
return {
|
|
278
|
+
flattenedProfile: claims,
|
|
279
|
+
profile: claims,
|
|
280
|
+
schemas: []
|
|
281
|
+
};
|
|
816
282
|
});
|
|
817
283
|
}
|
|
818
284
|
async getMyOrganizations(options) {
|
|
819
285
|
try {
|
|
820
286
|
let baseUrl = options?.baseUrl;
|
|
821
|
-
if (!baseUrl) baseUrl = (await this.
|
|
287
|
+
if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
|
|
822
288
|
return await getMeOrganizations_default({
|
|
823
289
|
baseUrl,
|
|
824
290
|
instanceId: this.getInstanceId()
|
|
@@ -830,7 +296,7 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
|
830
296
|
async getAllOrganizations(options) {
|
|
831
297
|
try {
|
|
832
298
|
let baseUrl = options?.baseUrl;
|
|
833
|
-
if (!baseUrl) baseUrl = (await this.
|
|
299
|
+
if (!baseUrl) baseUrl = (await this.getStorageManager().getConfigData())?.baseUrl;
|
|
834
300
|
return await getAllOrganizations_default({
|
|
835
301
|
baseUrl,
|
|
836
302
|
instanceId: this.getInstanceId()
|
|
@@ -856,7 +322,7 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
|
856
322
|
async switchOrganization(organization) {
|
|
857
323
|
return this.withLoading(async () => {
|
|
858
324
|
try {
|
|
859
|
-
const sourceInstanceId = (await this.
|
|
325
|
+
const sourceInstanceId = (await this.getStorageManager().getConfigData())?.organizationChain?.sourceInstanceId;
|
|
860
326
|
if (!organization.id) throw new ThunderIDRuntimeError$1("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.");
|
|
861
327
|
const exchangeConfig = {
|
|
862
328
|
attachToken: false,
|
|
@@ -871,39 +337,29 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
|
871
337
|
returnsSession: true,
|
|
872
338
|
signInRequired: sourceInstanceId === void 0
|
|
873
339
|
};
|
|
874
|
-
return await
|
|
340
|
+
return await super.exchangeToken(exchangeConfig);
|
|
875
341
|
} catch (error) {
|
|
876
342
|
throw new ThunderIDRuntimeError$1(`Failed to switch organization: ${error.message || error}`, "react-ThunderIDReactClient-SwitchOrganizationError-003", "react", "An error occurred while switching to the specified organization. Please try again.");
|
|
877
343
|
}
|
|
878
344
|
});
|
|
879
345
|
}
|
|
880
346
|
isLoading() {
|
|
881
|
-
return this.loadingState
|
|
882
|
-
}
|
|
883
|
-
async isInitialized() {
|
|
884
|
-
return this.authApi.isInitialized();
|
|
347
|
+
return this.loadingState;
|
|
885
348
|
}
|
|
886
349
|
async isSignedIn() {
|
|
887
|
-
return
|
|
888
|
-
}
|
|
889
|
-
async startAutoRefreshToken() {
|
|
890
|
-
return this.authApi.startAutoRefreshToken();
|
|
891
|
-
}
|
|
892
|
-
getConfiguration() {
|
|
893
|
-
return this.authApi.getConfigData();
|
|
350
|
+
return super.isSignedIn();
|
|
894
351
|
}
|
|
895
352
|
async exchangeToken(config) {
|
|
896
|
-
return this.withLoading(async () =>
|
|
353
|
+
return this.withLoading(async () => super.exchangeToken(config));
|
|
897
354
|
}
|
|
898
355
|
async signIn(...args) {
|
|
899
356
|
return this.withLoading(async () => {
|
|
900
357
|
const arg1 = args[0];
|
|
901
358
|
const arg2 = args[1];
|
|
902
|
-
const config = await this.
|
|
903
|
-
if (!config || Object.keys(config).length === 0) await this.initialize(this.
|
|
904
|
-
|
|
905
|
-
if (
|
|
906
|
-
if (isV2Platform && typeof arg1 === "object" && arg1 !== null && !isEmpty(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
|
|
359
|
+
const config = await this.getStorageManager().getConfigData();
|
|
360
|
+
if (!config || Object.keys(config).length === 0) await this.initialize(this._initializeConfig);
|
|
361
|
+
if (typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) return;
|
|
362
|
+
if (typeof arg1 === "object" && arg1 !== null && !isEmpty(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
|
|
907
363
|
const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
|
|
908
364
|
const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
|
|
909
365
|
const authId = authIdFromUrl || authIdFromStorage;
|
|
@@ -914,14 +370,7 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
|
914
370
|
payload: arg1,
|
|
915
371
|
url: arg2?.url
|
|
916
372
|
});
|
|
917
|
-
|
|
918
|
-
* NOTE: For ThunderID V2, if the embedded (App Native) sign-in flow returns a completed status along with an assertion (ID
|
|
919
|
-
* token), we manually set the session using that assertion. This is a temporary workaround until the platform
|
|
920
|
-
* fully supports session management for embedded flows.
|
|
921
|
-
*
|
|
922
|
-
* Tracker:
|
|
923
|
-
*/
|
|
924
|
-
if (isV2Platform && response && typeof response === "object" && response.flowStatus === EmbeddedSignInFlowStatusV2.Complete && response.assertion) {
|
|
373
|
+
if (response && typeof response === "object" && response.flowStatus === EmbeddedSignInFlowStatusV2.Complete && response.assertion) {
|
|
925
374
|
const decodedAssertion = await this.decodeJwtToken(response.assertion);
|
|
926
375
|
const createdAt = decodedAssertion.iat ? decodedAssertion.iat * 1e3 : Date.now();
|
|
927
376
|
const expiresIn = decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;
|
|
@@ -933,90 +382,50 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
|
|
|
933
382
|
scope: decodedAssertion.scope,
|
|
934
383
|
token_type: "Bearer"
|
|
935
384
|
});
|
|
385
|
+
this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion));
|
|
936
386
|
}
|
|
937
387
|
return response;
|
|
938
388
|
}
|
|
939
|
-
|
|
940
|
-
payload: arg1,
|
|
941
|
-
url: arg2.url
|
|
942
|
-
});
|
|
943
|
-
return await this.authApi.signIn(arg1);
|
|
389
|
+
return await super.signIn(arg1);
|
|
944
390
|
});
|
|
945
391
|
}
|
|
946
392
|
async signInSilently(options) {
|
|
947
|
-
return
|
|
948
|
-
}
|
|
949
|
-
async signOut(...args) {
|
|
950
|
-
if (args[1] && typeof args[1] !== "function") throw new Error("The second argument must be a function.");
|
|
951
|
-
const config = await this.authApi.getConfigData();
|
|
952
|
-
if (config.platform === Platform.ThunderIDV2) {
|
|
953
|
-
this.authApi.clearSession();
|
|
954
|
-
if (config.signInUrl) navigate$1(config.signInUrl);
|
|
955
|
-
else this.signIn(config.signInOptions);
|
|
956
|
-
args[1]?.(config.afterSignOutUrl || "");
|
|
957
|
-
return Promise.resolve(config.afterSignOutUrl || "");
|
|
958
|
-
}
|
|
959
|
-
const response = await this.authApi.signOut(args[1]);
|
|
960
|
-
return Promise.resolve(String(response));
|
|
393
|
+
return super.signInSilently(options);
|
|
961
394
|
}
|
|
962
395
|
async signUp(...args) {
|
|
963
|
-
const config = await this.
|
|
396
|
+
const config = await this.getStorageManager().getConfigData();
|
|
964
397
|
const firstArg = args[0];
|
|
965
398
|
const baseUrl = config?.baseUrl;
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
authId,
|
|
973
|
-
baseUrl,
|
|
974
|
-
payload: typeof firstArg === "object" && "flowType" in firstArg ? {
|
|
975
|
-
...firstArg,
|
|
976
|
-
verbose: true
|
|
977
|
-
} : firstArg
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
if (typeof firstArg === "object" && "flowType" in firstArg) return executeEmbeddedSignUpFlow({
|
|
399
|
+
const authIdFromUrl = new URL(window.location.href).searchParams.get("authId");
|
|
400
|
+
const authIdFromStorage = sessionStorage.getItem("thunderid_auth_id");
|
|
401
|
+
const authId = authIdFromUrl || authIdFromStorage;
|
|
402
|
+
if (authIdFromUrl && !authIdFromStorage) sessionStorage.setItem("thunderid_auth_id", authIdFromUrl);
|
|
403
|
+
return executeEmbeddedSignUpFlowV2({
|
|
404
|
+
authId,
|
|
981
405
|
baseUrl,
|
|
982
|
-
payload: firstArg
|
|
406
|
+
payload: typeof firstArg === "object" && "flowType" in firstArg ? {
|
|
407
|
+
...firstArg,
|
|
408
|
+
verbose: true
|
|
409
|
+
} : firstArg
|
|
983
410
|
});
|
|
984
|
-
navigate$1(getRedirectBasedSignUpUrl(config));
|
|
985
411
|
}
|
|
986
412
|
async recover(payload) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if (config?.platform === Platform.ThunderIDV2) return executeEmbeddedRecoveryFlowV2({
|
|
990
|
-
baseUrl,
|
|
413
|
+
return executeEmbeddedRecoveryFlowV2({
|
|
414
|
+
baseUrl: (await this.getStorageManager().getConfigData())?.baseUrl,
|
|
991
415
|
payload: {
|
|
992
416
|
...payload,
|
|
993
417
|
verbose: true
|
|
994
418
|
}
|
|
995
419
|
});
|
|
996
420
|
}
|
|
997
|
-
|
|
998
|
-
return
|
|
421
|
+
getStorageManager() {
|
|
422
|
+
return super.getStorageManager();
|
|
999
423
|
}
|
|
1000
424
|
async request(requestConfig) {
|
|
1001
|
-
return
|
|
425
|
+
return super.httpRequest(requestConfig);
|
|
1002
426
|
}
|
|
1003
427
|
async requestAll(requestConfigs) {
|
|
1004
|
-
return
|
|
1005
|
-
}
|
|
1006
|
-
async getAccessToken(sessionId) {
|
|
1007
|
-
return this.authApi.getAccessToken(sessionId);
|
|
1008
|
-
}
|
|
1009
|
-
clearSession(sessionId) {
|
|
1010
|
-
this.authApi.clearSession(sessionId);
|
|
1011
|
-
}
|
|
1012
|
-
async setSession(sessionData, sessionId) {
|
|
1013
|
-
return (await this.authApi.getStorageManager()).setSessionData(sessionData, sessionId);
|
|
1014
|
-
}
|
|
1015
|
-
async getStorageManager() {
|
|
1016
|
-
return this.authApi.getStorageManager();
|
|
1017
|
-
}
|
|
1018
|
-
decodeJwtToken(token) {
|
|
1019
|
-
return this.authApi.decodeJwtToken(token);
|
|
428
|
+
return super.httpRequestAll(requestConfigs);
|
|
1020
429
|
}
|
|
1021
430
|
};
|
|
1022
431
|
var ThunderIDReactClient_default = ThunderIDReactClient;
|
|
@@ -1345,7 +754,7 @@ const FlowMetaProvider = ({ children, enabled = true }) => {
|
|
|
1345
754
|
const [pendingLanguage, setPendingLanguage] = useState(null);
|
|
1346
755
|
const lastFetchedRef = useRef(null);
|
|
1347
756
|
const fetchFlowMeta = useCallback(async () => {
|
|
1348
|
-
if (!enabled || platform !== Platform.
|
|
757
|
+
if (!enabled || platform !== Platform.ThunderID) {
|
|
1349
758
|
setMeta(null);
|
|
1350
759
|
setIsLoading(false);
|
|
1351
760
|
return;
|
|
@@ -1376,7 +785,7 @@ const FlowMetaProvider = ({ children, enabled = true }) => {
|
|
|
1376
785
|
i18nContext?.currentLanguage
|
|
1377
786
|
]);
|
|
1378
787
|
const switchLanguage = useCallback(async (language) => {
|
|
1379
|
-
if (!enabled || platform !== Platform.
|
|
788
|
+
if (!enabled || platform !== Platform.ThunderID) return;
|
|
1380
789
|
setIsLoading(true);
|
|
1381
790
|
setError(null);
|
|
1382
791
|
try {
|
|
@@ -2212,7 +1621,7 @@ var ThemeProvider_default$2 = ThemeProvider$1;
|
|
|
2212
1621
|
*/
|
|
2213
1622
|
const ThemeProvider = ({ children, theme, detection, inheritFromBranding, mode }) => {
|
|
2214
1623
|
const { platform } = useThunderID_default();
|
|
2215
|
-
if (platform === Platform.
|
|
1624
|
+
if (platform === Platform.ThunderID) return /* @__PURE__ */ jsx(ThemeProvider_default$2, {
|
|
2216
1625
|
theme,
|
|
2217
1626
|
children
|
|
2218
1627
|
});
|
|
@@ -2296,7 +1705,7 @@ var UserProvider_default = UserProvider;
|
|
|
2296
1705
|
//#endregion
|
|
2297
1706
|
//#region src/contexts/ThunderID/ThunderIDProvider.tsx
|
|
2298
1707
|
const logger$8 = createPackageComponentLogger("@thunderid/react", "ThunderIDProvider");
|
|
2299
|
-
const ThunderIDProvider = ({ afterSignInUrl
|
|
1708
|
+
const ThunderIDProvider = ({ afterSignInUrl, afterSignOutUrl, baseUrl: initialBaseUrl, clientId, children, extensions, scopes, preferences, signInUrl, signUpUrl, organizationHandle, applicationId, signInOptions, syncSession, instanceId = 0, organizationChain,...rest }) => {
|
|
2300
1709
|
const reRenderCheckRef = useRef(false);
|
|
2301
1710
|
const client = useMemo(() => new ThunderIDReactClient_default(instanceId), [instanceId]);
|
|
2302
1711
|
const storageManagerRef = useRef(null);
|
|
@@ -2310,8 +1719,8 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2310
1719
|
const [userProfile, setUserProfile] = useState(null);
|
|
2311
1720
|
const [baseUrl, setBaseUrl] = useState(initialBaseUrl);
|
|
2312
1721
|
const [config, setConfig] = useState({
|
|
2313
|
-
afterSignInUrl,
|
|
2314
|
-
afterSignOutUrl,
|
|
1722
|
+
afterSignInUrl: afterSignInUrl ?? window.location.origin,
|
|
1723
|
+
afterSignOutUrl: afterSignOutUrl ?? window.location.origin,
|
|
2315
1724
|
applicationId,
|
|
2316
1725
|
baseUrl,
|
|
2317
1726
|
clientId,
|
|
@@ -2322,7 +1731,6 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2322
1731
|
signInUrl,
|
|
2323
1732
|
signUpUrl,
|
|
2324
1733
|
syncSession,
|
|
2325
|
-
platform,
|
|
2326
1734
|
...rest
|
|
2327
1735
|
});
|
|
2328
1736
|
const [isUpdatingSession, setIsUpdatingSession] = useState(false);
|
|
@@ -2356,32 +1764,13 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2356
1764
|
resolvedBaseUrl = `${(await client.getConfiguration()).baseUrl}/o`;
|
|
2357
1765
|
setBaseUrl(resolvedBaseUrl);
|
|
2358
1766
|
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
});
|
|
2367
|
-
} else {
|
|
2368
|
-
if (preferences?.user?.fetchUserProfile !== false) {
|
|
2369
|
-
try {
|
|
2370
|
-
setUser(await client.getUser({ baseUrl: resolvedBaseUrl }));
|
|
2371
|
-
} catch (error) {}
|
|
2372
|
-
try {
|
|
2373
|
-
setUserProfile(await client.getUserProfile({ baseUrl: resolvedBaseUrl }));
|
|
2374
|
-
} catch (error) {}
|
|
2375
|
-
}
|
|
2376
|
-
if (preferences?.user?.fetchOrganizations !== false) {
|
|
2377
|
-
try {
|
|
2378
|
-
setCurrentOrganization(await client.getCurrentOrganization());
|
|
2379
|
-
} catch (error) {}
|
|
2380
|
-
try {
|
|
2381
|
-
setMyOrganizations(await client.getMyOrganizations());
|
|
2382
|
-
} catch (error) {}
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
1767
|
+
const claims = extractUserClaimsFromIdToken(decodedToken);
|
|
1768
|
+
setUser(claims);
|
|
1769
|
+
setUserProfile({
|
|
1770
|
+
flattenedProfile: claims,
|
|
1771
|
+
profile: claims,
|
|
1772
|
+
schemas: []
|
|
1773
|
+
});
|
|
2385
1774
|
setIsSignedInSync(await client.isSignedIn());
|
|
2386
1775
|
} catch (error) {} finally {
|
|
2387
1776
|
setIsUpdatingSession(false);
|
|
@@ -2390,16 +1779,13 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2390
1779
|
}
|
|
2391
1780
|
async function signIn(...args) {
|
|
2392
1781
|
const arg1 = args[0];
|
|
2393
|
-
const isV2FlowRequest =
|
|
1782
|
+
const isV2FlowRequest = typeof arg1 === "object" && arg1 !== null && ("executionId" in arg1 || "applicationId" in arg1);
|
|
2394
1783
|
try {
|
|
2395
1784
|
if (!isV2FlowRequest) {
|
|
2396
1785
|
setIsUpdatingSession(true);
|
|
2397
1786
|
setIsLoadingSync(true);
|
|
2398
1787
|
}
|
|
2399
|
-
|
|
2400
|
-
if (isV2FlowRequest || response && typeof response === "object" && "flowStatus" in response) return response;
|
|
2401
|
-
if (await client.isSignedIn()) await updateSession();
|
|
2402
|
-
return response;
|
|
1788
|
+
return await client.signIn(...args);
|
|
2403
1789
|
} catch (error) {
|
|
2404
1790
|
throw new ThunderIDRuntimeError$1(`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`, "thunderid-signIn-Error", "react", "An error occurred while trying to sign in.");
|
|
2405
1791
|
} finally {
|
|
@@ -2416,6 +1802,9 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2416
1802
|
if (reRenderCheckRef.current) return;
|
|
2417
1803
|
reRenderCheckRef.current = true;
|
|
2418
1804
|
(async () => {
|
|
1805
|
+
await client.on("sign-in", async () => {
|
|
1806
|
+
await updateSession();
|
|
1807
|
+
});
|
|
2419
1808
|
const isAlreadySignedIn = await client.isSignedIn();
|
|
2420
1809
|
const scheduleAutoRefresh = async () => {
|
|
2421
1810
|
try {
|
|
@@ -2435,16 +1824,12 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2435
1824
|
return;
|
|
2436
1825
|
}
|
|
2437
1826
|
const currentUrl = new URL(window.location.href);
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
const executionIdFromUrl = urlParams.get("executionId");
|
|
2445
|
-
const storedExecutionId = sessionStorage.getItem("thunderid_execution_id");
|
|
2446
|
-
if (code && !executionIdFromUrl && !storedExecutionId) await signIn();
|
|
2447
|
-
} else await signIn({ callOnlyOnRedirect: true });
|
|
1827
|
+
if (hasAuthParams(currentUrl, config.afterSignInUrl) && hasCalledForThisInstance(currentUrl, instanceId ?? 0)) try {
|
|
1828
|
+
const urlParams = currentUrl.searchParams;
|
|
1829
|
+
const code = urlParams.get("code");
|
|
1830
|
+
const executionIdFromUrl = urlParams.get("executionId");
|
|
1831
|
+
const storedExecutionId = sessionStorage.getItem("thunderid_execution_id");
|
|
1832
|
+
if (code && !executionIdFromUrl && !storedExecutionId) await signIn();
|
|
2448
1833
|
} catch (error) {
|
|
2449
1834
|
throw new ThunderIDRuntimeError$1(`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`, "thunderid-signIn-Error", "react", "An error occurred while trying to sign in.");
|
|
2450
1835
|
}
|
|
@@ -2491,7 +1876,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2491
1876
|
const checkLoadingState = () => {
|
|
2492
1877
|
if (isUpdatingSession) return;
|
|
2493
1878
|
const currentUrl = new URL(window.location.href);
|
|
2494
|
-
if (!isSignedInSync && hasAuthParams(currentUrl, afterSignInUrl)) return;
|
|
1879
|
+
if (!isSignedInSync && hasAuthParams(currentUrl, config.afterSignInUrl)) return;
|
|
2495
1880
|
setIsLoadingSync(client.isLoading());
|
|
2496
1881
|
};
|
|
2497
1882
|
checkLoadingState();
|
|
@@ -2528,10 +1913,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2528
1913
|
setHasFetchedBranding(false);
|
|
2529
1914
|
await fetchBranding();
|
|
2530
1915
|
}, [fetchBranding]);
|
|
2531
|
-
useEffect(() => {
|
|
2532
|
-
if (config.platform === Platform.ThunderIDV2) return;
|
|
2533
|
-
if (preferences?.theme?.inheritFromBranding === true && isInitializedSync && baseUrl && !hasFetchedBranding && !isBrandingLoading) fetchBranding();
|
|
2534
|
-
}, [
|
|
1916
|
+
useEffect(() => {}, [
|
|
2535
1917
|
preferences?.theme?.inheritFromBranding,
|
|
2536
1918
|
isInitializedSync,
|
|
2537
1919
|
baseUrl,
|
|
@@ -2543,9 +1925,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2543
1925
|
try {
|
|
2544
1926
|
setIsUpdatingSession(true);
|
|
2545
1927
|
setIsLoadingSync(true);
|
|
2546
|
-
|
|
2547
|
-
if (await client.isSignedIn()) await updateSession();
|
|
2548
|
-
return response;
|
|
1928
|
+
return await client.signInSilently(options);
|
|
2549
1929
|
} catch (error) {
|
|
2550
1930
|
throw new ThunderIDRuntimeError$1(`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.");
|
|
2551
1931
|
} finally {
|
|
@@ -2592,7 +1972,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2592
1972
|
const clearSession = useCallback(async (...args) => client.clearSession(...args), [client]);
|
|
2593
1973
|
const reInitialize = useCallback(async (reInitConfig) => client.reInitialize(reInitConfig), [client]);
|
|
2594
1974
|
const value = useMemo(() => ({
|
|
2595
|
-
afterSignInUrl,
|
|
1975
|
+
afterSignInUrl: config.afterSignInUrl,
|
|
2596
1976
|
applicationId: config.applicationId,
|
|
2597
1977
|
baseUrl,
|
|
2598
1978
|
clearSession,
|
|
@@ -2614,7 +1994,7 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2614
1994
|
organization: currentOrganization,
|
|
2615
1995
|
organizationChain,
|
|
2616
1996
|
organizationHandle: config?.organizationHandle,
|
|
2617
|
-
platform:
|
|
1997
|
+
platform: Platform.ThunderID,
|
|
2618
1998
|
reInitialize,
|
|
2619
1999
|
recover,
|
|
2620
2000
|
signIn,
|
|
@@ -2630,9 +2010,9 @@ const ThunderIDProvider = ({ afterSignInUrl = window.location.origin, afterSignO
|
|
|
2630
2010
|
}), [
|
|
2631
2011
|
applicationId,
|
|
2632
2012
|
config?.organizationHandle,
|
|
2013
|
+
config.afterSignInUrl,
|
|
2633
2014
|
signInUrl,
|
|
2634
2015
|
signUpUrl,
|
|
2635
|
-
afterSignInUrl,
|
|
2636
2016
|
baseUrl,
|
|
2637
2017
|
clientId,
|
|
2638
2018
|
wellKnown,
|
|
@@ -8698,7 +8078,7 @@ const getConsentOptionalKey = (purposeId, attrName) => `__consent_opt__${purpose
|
|
|
8698
8078
|
const ConsentCheckboxList = ({ variant, purpose, formValues, onInputChange, children }) => {
|
|
8699
8079
|
const { theme, colorScheme } = useTheme_default();
|
|
8700
8080
|
const styles = ConsentCheckboxList_styles_default(theme, colorScheme);
|
|
8701
|
-
const attributes = variant === "ESSENTIAL" ? purpose.essential : purpose.optional;
|
|
8081
|
+
const attributes = (variant === "ESSENTIAL" ? purpose.essential : purpose.optional).map((e) => e.name);
|
|
8702
8082
|
if (!attributes || attributes.length === 0) return null;
|
|
8703
8083
|
const isEssential = variant === "ESSENTIAL";
|
|
8704
8084
|
const isChecked = (attrName) => {
|
|
@@ -8791,7 +8171,7 @@ const Consent = ({ consentData, formValues, onInputChange, children }) => {
|
|
|
8791
8171
|
children: [/* @__PURE__ */ jsx(Typography_default, {
|
|
8792
8172
|
variant: "subtitle2",
|
|
8793
8173
|
fontWeight: "bold",
|
|
8794
|
-
children: "Optional Attributes"
|
|
8174
|
+
children: purpose.type === "permissions" ? "Permissions" : "Optional Attributes"
|
|
8795
8175
|
}), /* @__PURE__ */ jsx(ConsentCheckboxList_default, {
|
|
8796
8176
|
variant: "OPTIONAL",
|
|
8797
8177
|
purpose,
|
|
@@ -9263,12 +8643,12 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
|
|
|
9263
8643
|
const isDeny = componentVariant.toLowerCase() !== "primary";
|
|
9264
8644
|
const decisions = { purposes: consentPrompt.purposes.map((p) => ({
|
|
9265
8645
|
approved: !isDeny,
|
|
9266
|
-
elements: [...p.essential.map((
|
|
8646
|
+
elements: [...p.essential.map((e) => ({
|
|
9267
8647
|
approved: !isDeny,
|
|
9268
|
-
name:
|
|
9269
|
-
})), ...p.optional.map((
|
|
9270
|
-
approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId,
|
|
9271
|
-
name:
|
|
8648
|
+
name: e.name
|
|
8649
|
+
})), ...p.optional.map((e) => ({
|
|
8650
|
+
approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, e.name)] !== "false",
|
|
8651
|
+
name: e.name
|
|
9272
8652
|
}))],
|
|
9273
8653
|
purposeName: p.purposeName
|
|
9274
8654
|
})) };
|
|
@@ -9823,7 +9203,7 @@ var BaseSignIn_default$1 = BaseSignIn$1;
|
|
|
9823
9203
|
//#region src/components/presentation/auth/SignIn/BaseSignIn.tsx
|
|
9824
9204
|
const BaseSignIn = (props) => {
|
|
9825
9205
|
const { platform } = useThunderID_default();
|
|
9826
|
-
if (platform === Platform.
|
|
9206
|
+
if (platform === Platform.ThunderID) return /* @__PURE__ */ jsx(BaseSignIn_default$1, { ...props });
|
|
9827
9207
|
return /* @__PURE__ */ jsx(BaseSignIn_default$2, { ...props });
|
|
9828
9208
|
};
|
|
9829
9209
|
var BaseSignIn_default = BaseSignIn;
|
|
@@ -10351,14 +9731,14 @@ const SignIn$1 = ({ className, preferences, size = "medium", onSuccess, onError,
|
|
|
10351
9731
|
}
|
|
10352
9732
|
const decisions = { purposes: purposes.map((p) => ({
|
|
10353
9733
|
approved: !isDeny,
|
|
10354
|
-
elements: [...(p.essential || []).map((
|
|
9734
|
+
elements: [...(p.essential || []).map((e) => ({
|
|
10355
9735
|
approved: !isDeny,
|
|
10356
|
-
name:
|
|
10357
|
-
})), ...(p.optional || []).map((
|
|
10358
|
-
const key = `__consent_opt__${p.purposeId}__${
|
|
9736
|
+
name: e.name
|
|
9737
|
+
})), ...(p.optional || []).map((e) => {
|
|
9738
|
+
const key = `__consent_opt__${p.purposeId}__${e.name}`;
|
|
10359
9739
|
return {
|
|
10360
9740
|
approved: isDeny ? false : processedInputs[key] !== "false",
|
|
10361
|
-
name:
|
|
9741
|
+
name: e.name
|
|
10362
9742
|
};
|
|
10363
9743
|
})],
|
|
10364
9744
|
purposeName: p.purposeName
|
|
@@ -10594,7 +9974,7 @@ const SignIn = ({ className, size = "medium", children, preferences,...rest }) =
|
|
|
10594
9974
|
window.location.href = url.toString();
|
|
10595
9975
|
}
|
|
10596
9976
|
};
|
|
10597
|
-
if (platform === Platform.
|
|
9977
|
+
if (platform === Platform.ThunderID) return /* @__PURE__ */ jsx(SignIn_default$1, {
|
|
10598
9978
|
className,
|
|
10599
9979
|
size,
|
|
10600
9980
|
variant: rest.variant,
|
|
@@ -12391,7 +11771,7 @@ var BaseSignUp_default$1 = BaseSignUp$1;
|
|
|
12391
11771
|
//#region src/components/presentation/auth/SignUp/BaseSignUp.tsx
|
|
12392
11772
|
const BaseSignUp = (props) => {
|
|
12393
11773
|
const { platform } = useThunderID_default();
|
|
12394
|
-
if (platform === Platform.
|
|
11774
|
+
if (platform === Platform.ThunderID) return /* @__PURE__ */ jsx(BaseSignUp_default$1, { ...props });
|
|
12395
11775
|
return /* @__PURE__ */ jsx(BaseSignUp_default$2, { ...props });
|
|
12396
11776
|
};
|
|
12397
11777
|
var BaseSignUp_default = BaseSignUp;
|
|
@@ -12567,7 +11947,7 @@ var SignUp_default$2 = SignUp$1;
|
|
|
12567
11947
|
*/
|
|
12568
11948
|
const SignUp = (props) => {
|
|
12569
11949
|
const { platform } = useThunderID_default();
|
|
12570
|
-
if (platform === Platform.
|
|
11950
|
+
if (platform === Platform.ThunderID) return /* @__PURE__ */ jsx(SignUp_default$2, { ...props });
|
|
12571
11951
|
return /* @__PURE__ */ jsx(SignUp_default$1, { ...props });
|
|
12572
11952
|
};
|
|
12573
11953
|
var SignUp_default = SignUp;
|
|
@@ -13317,7 +12697,7 @@ var BaseRecovery_default$1 = BaseRecovery$1;
|
|
|
13317
12697
|
//#region src/components/presentation/auth/Recovery/BaseRecovery.tsx
|
|
13318
12698
|
const BaseRecovery = (props) => {
|
|
13319
12699
|
const { platform } = useThunderID_default();
|
|
13320
|
-
if (platform === Platform.
|
|
12700
|
+
if (platform === Platform.ThunderID) return /* @__PURE__ */ jsx(BaseRecovery_default$1, { ...props });
|
|
13321
12701
|
return /* @__PURE__ */ jsx(BaseRecovery_default$2, { ...props });
|
|
13322
12702
|
};
|
|
13323
12703
|
var BaseRecovery_default = BaseRecovery;
|
|
@@ -13455,7 +12835,7 @@ var Recovery_default$2 = Recovery$1;
|
|
|
13455
12835
|
*/
|
|
13456
12836
|
const Recovery = (props) => {
|
|
13457
12837
|
const { platform } = useThunderID_default();
|
|
13458
|
-
if (platform === Platform.
|
|
12838
|
+
if (platform === Platform.ThunderID) return /* @__PURE__ */ jsx(Recovery_default$2, { ...props });
|
|
13459
12839
|
return /* @__PURE__ */ jsx(Recovery_default$1, { ...props });
|
|
13460
12840
|
};
|
|
13461
12841
|
var Recovery_default = Recovery;
|
|
@@ -16311,8 +15691,7 @@ var BaseUserProfile_default = BaseUserProfile;
|
|
|
16311
15691
|
*/
|
|
16312
15692
|
const updateMeProfile$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
16313
15693
|
const defaultFetcher = async (url, config) => {
|
|
16314
|
-
const
|
|
16315
|
-
const response = await client.httpRequest.bind(client)({
|
|
15694
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
16316
15695
|
data: config.body ? JSON.parse(config.body) : void 0,
|
|
16317
15696
|
headers: config.headers,
|
|
16318
15697
|
method: config.method || "PATCH",
|
|
@@ -17863,8 +17242,7 @@ const BaseCreateOrganization = ({ cardLayout = true, className = "", defaultPare
|
|
|
17863
17242
|
*/
|
|
17864
17243
|
const createOrganization$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
17865
17244
|
const defaultFetcher = async (url, config) => {
|
|
17866
|
-
const
|
|
17867
|
-
const response = await client.httpRequest.bind(client)({
|
|
17245
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
17868
17246
|
data: config.body ? JSON.parse(config.body) : void 0,
|
|
17869
17247
|
headers: config.headers,
|
|
17870
17248
|
method: config.method || "POST",
|
|
@@ -19442,8 +18820,7 @@ var BaseOrganizationProfile_default = BaseOrganizationProfile;
|
|
|
19442
18820
|
*/
|
|
19443
18821
|
const getOrganization$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
19444
18822
|
const defaultFetcher = async (url, config) => {
|
|
19445
|
-
const
|
|
19446
|
-
const response = await client.httpRequest.bind(client)({
|
|
18823
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
19447
18824
|
headers: config.headers,
|
|
19448
18825
|
method: config.method || "GET",
|
|
19449
18826
|
url
|
|
@@ -19512,8 +18889,7 @@ var getOrganization_default = getOrganization$1;
|
|
|
19512
18889
|
*/
|
|
19513
18890
|
const updateOrganization$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
19514
18891
|
const defaultFetcher = async (url, config) => {
|
|
19515
|
-
const
|
|
19516
|
-
const response = await client.httpRequest.bind(client)({
|
|
18892
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
19517
18893
|
data: config.body ? JSON.parse(config.body) : void 0,
|
|
19518
18894
|
headers: config.headers,
|
|
19519
18895
|
method: config.method || "PATCH",
|
|
@@ -20040,5 +19416,127 @@ const LanguageSwitcher = ({ children, className }) => {
|
|
|
20040
19416
|
var LanguageSwitcher_default = LanguageSwitcher;
|
|
20041
19417
|
|
|
20042
19418
|
//#endregion
|
|
20043
|
-
|
|
19419
|
+
//#region src/api/getSchemas.ts
|
|
19420
|
+
/**
|
|
19421
|
+
* Retrieves the SCIM2 schemas from the specified endpoint.
|
|
19422
|
+
* This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
|
|
19423
|
+
*
|
|
19424
|
+
* @param config - Request configuration object.
|
|
19425
|
+
* @returns A promise that resolves with the SCIM2 schemas information.
|
|
19426
|
+
* @example
|
|
19427
|
+
* ```typescript
|
|
19428
|
+
* // Using default ThunderID SPA client httpClient
|
|
19429
|
+
* try {
|
|
19430
|
+
* const schemas = await getSchemas({
|
|
19431
|
+
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
|
|
19432
|
+
* });
|
|
19433
|
+
* console.log(schemas);
|
|
19434
|
+
* } catch (error) {
|
|
19435
|
+
* if (error instanceof ThunderIDAPIError) {
|
|
19436
|
+
* console.error('Failed to get schemas:', error.message);
|
|
19437
|
+
* }
|
|
19438
|
+
* }
|
|
19439
|
+
* ```
|
|
19440
|
+
*
|
|
19441
|
+
* @example
|
|
19442
|
+
* ```typescript
|
|
19443
|
+
* // Using custom fetcher
|
|
19444
|
+
* try {
|
|
19445
|
+
* const schemas = await getSchemas({
|
|
19446
|
+
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
|
|
19447
|
+
* fetcher: customFetchFunction
|
|
19448
|
+
* });
|
|
19449
|
+
* console.log(schemas);
|
|
19450
|
+
* } catch (error) {
|
|
19451
|
+
* if (error instanceof ThunderIDAPIError) {
|
|
19452
|
+
* console.error('Failed to get schemas:', error.message);
|
|
19453
|
+
* }
|
|
19454
|
+
* }
|
|
19455
|
+
* ```
|
|
19456
|
+
*/
|
|
19457
|
+
const getSchemas$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
19458
|
+
const defaultFetcher = async (url, config) => {
|
|
19459
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
19460
|
+
headers: config.headers,
|
|
19461
|
+
method: config.method || "GET",
|
|
19462
|
+
url
|
|
19463
|
+
});
|
|
19464
|
+
return {
|
|
19465
|
+
json: () => Promise.resolve(response.data),
|
|
19466
|
+
ok: response.status >= 200 && response.status < 300,
|
|
19467
|
+
status: response.status,
|
|
19468
|
+
statusText: response.statusText || "",
|
|
19469
|
+
text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
|
|
19470
|
+
};
|
|
19471
|
+
};
|
|
19472
|
+
return getSchemas({
|
|
19473
|
+
...requestConfig,
|
|
19474
|
+
fetcher: fetcher || defaultFetcher
|
|
19475
|
+
});
|
|
19476
|
+
};
|
|
19477
|
+
var getSchemas_default = getSchemas$1;
|
|
19478
|
+
|
|
19479
|
+
//#endregion
|
|
19480
|
+
//#region src/api/getScim2Me.ts
|
|
19481
|
+
/**
|
|
19482
|
+
* Retrieves the user profile information from the specified SCIM2 /Me endpoint.
|
|
19483
|
+
* This function uses the ThunderID SPA client's httpClient by default, but allows for custom fetchers.
|
|
19484
|
+
*
|
|
19485
|
+
* @param requestConfig - Request configuration object.
|
|
19486
|
+
* @returns A promise that resolves with the user profile information.
|
|
19487
|
+
* @example
|
|
19488
|
+
* ```typescript
|
|
19489
|
+
* // Using default ThunderID SPA client httpClient
|
|
19490
|
+
* try {
|
|
19491
|
+
* const userProfile = await getScim2Me({
|
|
19492
|
+
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
|
|
19493
|
+
* });
|
|
19494
|
+
* console.log(userProfile);
|
|
19495
|
+
* } catch (error) {
|
|
19496
|
+
* if (error instanceof ThunderIDAPIError) {
|
|
19497
|
+
* console.error('Failed to get user profile:', error.message);
|
|
19498
|
+
* }
|
|
19499
|
+
* }
|
|
19500
|
+
* ```
|
|
19501
|
+
*
|
|
19502
|
+
* @example
|
|
19503
|
+
* ```typescript
|
|
19504
|
+
* // Using custom fetcher
|
|
19505
|
+
* try {
|
|
19506
|
+
* const userProfile = await getScim2Me({
|
|
19507
|
+
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
|
|
19508
|
+
* fetcher: customFetchFunction
|
|
19509
|
+
* });
|
|
19510
|
+
* console.log(userProfile);
|
|
19511
|
+
* } catch (error) {
|
|
19512
|
+
* if (error instanceof ThunderIDAPIError) {
|
|
19513
|
+
* console.error('Failed to get user profile:', error.message);
|
|
19514
|
+
* }
|
|
19515
|
+
* }
|
|
19516
|
+
* ```
|
|
19517
|
+
*/
|
|
19518
|
+
const getScim2Me$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
|
|
19519
|
+
const defaultFetcher = async (url, config) => {
|
|
19520
|
+
const response = await FetchHttpClient.getInstance(instanceId).request({
|
|
19521
|
+
headers: config.headers,
|
|
19522
|
+
method: config.method || "GET",
|
|
19523
|
+
url
|
|
19524
|
+
});
|
|
19525
|
+
return {
|
|
19526
|
+
json: () => Promise.resolve(response.data),
|
|
19527
|
+
ok: response.status >= 200 && response.status < 300,
|
|
19528
|
+
status: response.status,
|
|
19529
|
+
statusText: response.statusText || "",
|
|
19530
|
+
text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
|
|
19531
|
+
};
|
|
19532
|
+
};
|
|
19533
|
+
return getScim2Me({
|
|
19534
|
+
...requestConfig,
|
|
19535
|
+
fetcher: fetcher || defaultFetcher
|
|
19536
|
+
});
|
|
19537
|
+
};
|
|
19538
|
+
var getScim2Me_default = getScim2Me$1;
|
|
19539
|
+
|
|
19540
|
+
//#endregion
|
|
19541
|
+
export { AcceptInvite_default as AcceptInvite, Alert_default as Alert, BaseAcceptInvite_default as BaseAcceptInvite, BaseCreateOrganization, BaseInviteUser_default as BaseInviteUser, BaseLanguageSwitcher_default as BaseLanguageSwitcher, BaseOrganization_default as BaseOrganization, BaseOrganizationList_default as BaseOrganizationList, BaseOrganizationProfile_default as BaseOrganizationProfile, BaseOrganizationSwitcher_default as BaseOrganizationSwitcher, BaseRecovery_default as BaseRecovery, BaseSignIn_default as BaseSignIn, BaseSignInButton_default as BaseSignInButton, BaseSignOutButton_default as BaseSignOutButton, BaseSignUp_default as BaseSignUp, BaseSignUpButton_default as BaseSignUpButton, BaseUser_default as BaseUser, BaseUserDropdown_default as BaseUserDropdown, BaseUserProfile_default as BaseUserProfile, BrandingContext_default as BrandingContext, BrandingProvider_default as BrandingProvider, BuildingAlt_default as BuildingAlt, Button_default as Button, Callback, Card_default as Card, Checkbox_default as Checkbox, CircleAlert_default as CircleAlert, CircleCheck_default as CircleCheck, Consent_default as Consent, ConsentCheckboxList_default as ConsentCheckboxList, CreateOrganization, DatePicker_default as DatePicker, Divider_default as Divider, EMOJI_URI_SCHEME, EmailOtp_default as EmailOtp, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowEventType, EmbeddedFlowTextVariant, EmbeddedRecoveryFlowStatus, EmbeddedRecoveryFlowType, EmbeddedSignInFlowStatus, EmbeddedSignInFlowType, Eye_default as Eye, EyeOff_default as EyeOff, FacebookButton_default as FacebookButton, FieldFactory, FlowContext_default as FlowContext, FlowMetaProvider_default as FlowMetaProvider, FlowProvider_default as FlowProvider, FlowTimer_default as FlowTimer, FormControl_default as FormControl, GitHubButton_default as GitHubButton, GoogleButton_default as GoogleButton, I18nContext_default as I18nContext, I18nProvider_default as I18nProvider, IdentifierFirst_default as IdentifierFirst, Info_default as Info, InputLabel_default as InputLabel, InviteUser_default as InviteUser, KeyValueInput_default as KeyValueInput, LanguageSwitcher_default as LanguageSwitcher, LinkedInButton_default as LinkedInButton, Loading_default as Loading, LogOut_default as LogOut, Logo_default as Logo, MicrosoftButton_default as MicrosoftButton, MultiInput_default as MultiInput, MultiOptionButton_default as MultiOptionButton, Organization_default as Organization, OrganizationContext_default as OrganizationContext, OrganizationList_default as OrganizationList, OrganizationProfile_default as OrganizationProfile, OrganizationProvider_default as OrganizationProvider, OrganizationSwitcher_default as OrganizationSwitcher, OrganizationUnitPicker_default as OrganizationUnitPicker, OtpField_default as OtpField, PasswordField_default as PasswordField, Recovery_default as Recovery, Select_default as Select, SignIn_default as SignIn, SignInButton_default as SignInButton, SignInWithEthereumButton_default as SignInWithEthereumButton, SignOutButton_default as SignOutButton, SignUp_default as SignUp, SignUpButton_default as SignUpButton, SignedIn_default as SignedIn, SignedOut_default as SignedOut, SmsOtp_default as SmsOtp, SocialButton_default as SocialButton, Spinner_default as Spinner, TextField_default as TextField, ThemeContext_default as ThemeContext, ThemeProvider_default as ThemeProvider, ThunderIDContext_default as ThunderIDContext, ThunderIDProvider_default as ThunderIDProvider, ThunderIDRuntimeError, Toggle_default as Toggle, Totp_default as Totp, TriangleAlert_default as TriangleAlert, Typography_default as Typography, User_default as User, UserContext_default as UserContext, UserDropdown_default as UserDropdown, User_default$1 as UserIcon, UserProfile_default as UserProfile, UserProvider_default as UserProvider, UsernamePassword_default as UsernamePassword, countryCodeToFlagEmoji, createField, createOrganization_default as createOrganization, createPatchOperations, createSignInOption, createSignInOptionFromAuthenticator, extractEmojiFromUri, getActiveTheme, getAllOrganizations_default as getAllOrganizations, getConsentOptionalKey, getMeOrganizations_default as getMeOrganizations, getScim2Me_default as getMeProfile, getOrganization_default as getOrganization, getSchemas_default as getSchemas, http, isEmojiUri, navigate, resolveEmojiUrisInHtml, resolveFlowTemplateLiterals, resolveLocaleDisplayName, resolveLocaleEmoji, resolveMeta, updateMeProfile_default as updateMeProfile, updateOrganization_default as updateOrganization, useBranding_default as useBranding, useBrandingContext_default as useBrandingContext, useBrowserUrl_default as useBrowserUrl, useFlow_default as useFlow, useForm_default as useForm, useI18n_default as useI18n, useOrganization_default as useOrganization, useTheme_default as useTheme, useThunderID_default as useThunderID, useTranslation_default as useTranslation, useUser_default as useUser, validateFieldValue };
|
|
20044
19542
|
//# sourceMappingURL=index.js.map
|