@asgardeo/react 0.22.4 → 0.22.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsgardeoReactClient.d.ts +1 -0
- package/dist/cjs/index.js +184 -32
- package/dist/cjs/index.js.map +2 -2
- package/dist/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.d.ts +1 -0
- package/dist/components/presentation/auth/InviteUser/v2/BaseInviteUser.d.ts +1 -0
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +4 -0
- package/dist/index.js +190 -34
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
|
@@ -22,6 +22,7 @@ import { CardProps } from '../../../../primitives/Card/Card';
|
|
|
22
22
|
* Flow response structure from the backend.
|
|
23
23
|
*/
|
|
24
24
|
export interface AcceptInviteFlowResponse {
|
|
25
|
+
challengeToken?: string;
|
|
25
26
|
data?: {
|
|
26
27
|
additionalData?: Record<string, string>;
|
|
27
28
|
components?: any[];
|
|
@@ -22,6 +22,7 @@ import { CardProps } from '../../../../primitives/Card/Card';
|
|
|
22
22
|
* Flow response structure from the backend.
|
|
23
23
|
*/
|
|
24
24
|
export interface InviteUserFlowResponse {
|
|
25
|
+
challengeToken?: string;
|
|
25
26
|
data?: {
|
|
26
27
|
additionalData?: Record<string, any>;
|
|
27
28
|
components?: any[];
|
|
@@ -66,6 +66,10 @@ export type AsgardeoContextProps = {
|
|
|
66
66
|
* @returns A promise that resolves to the ID token.
|
|
67
67
|
*/
|
|
68
68
|
getIdToken: () => Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the underlying StorageManager instance for reading and writing SDK-managed storage.
|
|
71
|
+
*/
|
|
72
|
+
getStorageManager: () => Promise<any>;
|
|
69
73
|
/**
|
|
70
74
|
* HTTP request function to make API calls.
|
|
71
75
|
* @param requestConfig - Configuration for the HTTP request.
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var AsgardeoContext = createContext({
|
|
|
30
30
|
getAccessToken: null,
|
|
31
31
|
getDecodedIdToken: null,
|
|
32
32
|
getIdToken: null,
|
|
33
|
+
getStorageManager: () => Promise.resolve(null),
|
|
33
34
|
http: {
|
|
34
35
|
request: () => null,
|
|
35
36
|
requestAll: () => null
|
|
@@ -921,6 +922,9 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
921
922
|
async setSession(sessionData, sessionId) {
|
|
922
923
|
return (await this.asgardeo.getStorageManager()).setSessionData(sessionData, sessionId);
|
|
923
924
|
}
|
|
925
|
+
async getStorageManager() {
|
|
926
|
+
return this.asgardeo.getStorageManager();
|
|
927
|
+
}
|
|
924
928
|
decodeJwtToken(token) {
|
|
925
929
|
return this.asgardeo.decodeJwtToken(token);
|
|
926
930
|
}
|
|
@@ -2038,6 +2042,7 @@ var AsgardeoProvider = ({
|
|
|
2038
2042
|
}) => {
|
|
2039
2043
|
const reRenderCheckRef = useRef2(false);
|
|
2040
2044
|
const asgardeo = useMemo7(() => new AsgardeoReactClient_default(instanceId), [instanceId]);
|
|
2045
|
+
const storageManagerRef = useRef2(null);
|
|
2041
2046
|
const { hasAuthParams, hasCalledForThisInstance } = useBrowserUrl_default();
|
|
2042
2047
|
const [user, setUser] = useState8(null);
|
|
2043
2048
|
const [currentOrganization, setCurrentOrganization] = useState8(null);
|
|
@@ -2386,6 +2391,13 @@ var AsgardeoProvider = ({
|
|
|
2386
2391
|
async () => asgardeo.getAccessToken(),
|
|
2387
2392
|
[asgardeo]
|
|
2388
2393
|
);
|
|
2394
|
+
const getStorageManager = useCallback8(async () => {
|
|
2395
|
+
const storageManager = storageManagerRef.current ?? await asgardeo.getStorageManager();
|
|
2396
|
+
if (storageManager) {
|
|
2397
|
+
storageManagerRef.current = storageManager;
|
|
2398
|
+
}
|
|
2399
|
+
return storageManager;
|
|
2400
|
+
}, [asgardeo]);
|
|
2389
2401
|
const request = useCallback8(
|
|
2390
2402
|
async (...args) => asgardeo.request(...args),
|
|
2391
2403
|
[asgardeo]
|
|
@@ -2428,6 +2440,7 @@ var AsgardeoProvider = ({
|
|
|
2428
2440
|
getAccessToken,
|
|
2429
2441
|
getDecodedIdToken,
|
|
2430
2442
|
getIdToken,
|
|
2443
|
+
getStorageManager,
|
|
2431
2444
|
http: {
|
|
2432
2445
|
request,
|
|
2433
2446
|
requestAll
|
|
@@ -2474,6 +2487,7 @@ var AsgardeoProvider = ({
|
|
|
2474
2487
|
switchOrganization,
|
|
2475
2488
|
getDecodedIdToken,
|
|
2476
2489
|
getAccessToken,
|
|
2490
|
+
getStorageManager,
|
|
2477
2491
|
request,
|
|
2478
2492
|
requestAll,
|
|
2479
2493
|
exchangeToken,
|
|
@@ -9498,7 +9512,8 @@ import {
|
|
|
9498
9512
|
AsgardeoRuntimeError as AsgardeoRuntimeError8,
|
|
9499
9513
|
EmbeddedFlowType,
|
|
9500
9514
|
EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatusV22,
|
|
9501
|
-
EmbeddedSignInFlowTypeV2
|
|
9515
|
+
EmbeddedSignInFlowTypeV2,
|
|
9516
|
+
logger as logger7
|
|
9502
9517
|
} from "@asgardeo/browser";
|
|
9503
9518
|
import { useState as useState20, useEffect as useEffect18, useRef as useRef7 } from "react";
|
|
9504
9519
|
|
|
@@ -9786,11 +9801,13 @@ var SignIn = ({
|
|
|
9786
9801
|
variant,
|
|
9787
9802
|
children
|
|
9788
9803
|
}) => {
|
|
9789
|
-
const { applicationId, afterSignInUrl, signIn, isInitialized, isLoading, meta } = useAsgardeo_default();
|
|
9804
|
+
const { applicationId, afterSignInUrl, signIn, isInitialized, isLoading, meta, getStorageManager } = useAsgardeo_default();
|
|
9790
9805
|
const { t } = useTranslation_default(preferences?.i18n);
|
|
9791
9806
|
const [components, setComponents] = useState20([]);
|
|
9792
9807
|
const [additionalData, setAdditionalData] = useState20({});
|
|
9793
9808
|
const [currentExecutionId, setCurrentExecutionId] = useState20(null);
|
|
9809
|
+
const challengeTokenRef = useRef7(null);
|
|
9810
|
+
const [isStorageReady, setIsStorageReady] = useState20(false);
|
|
9794
9811
|
const [isFlowInitialized, setIsFlowInitialized] = useState20(false);
|
|
9795
9812
|
const [flowError, setFlowError] = useState20(null);
|
|
9796
9813
|
const [isSubmitting, setIsSubmitting] = useState20(false);
|
|
@@ -9814,8 +9831,38 @@ var SignIn = ({
|
|
|
9814
9831
|
sessionStorage.removeItem("asgardeo_execution_id");
|
|
9815
9832
|
}
|
|
9816
9833
|
};
|
|
9817
|
-
|
|
9834
|
+
useEffect18(() => {
|
|
9835
|
+
if (!isInitialized) return;
|
|
9836
|
+
(async () => {
|
|
9837
|
+
try {
|
|
9838
|
+
const storageManager = await getStorageManager();
|
|
9839
|
+
const tempData = await storageManager?.getTemporaryData();
|
|
9840
|
+
if (tempData?.challengeToken) {
|
|
9841
|
+
challengeTokenRef.current = tempData.challengeToken;
|
|
9842
|
+
}
|
|
9843
|
+
} finally {
|
|
9844
|
+
setIsStorageReady(true);
|
|
9845
|
+
}
|
|
9846
|
+
})();
|
|
9847
|
+
}, [isInitialized]);
|
|
9848
|
+
const setChallengeToken = async (challengeToken) => {
|
|
9849
|
+
challengeTokenRef.current = challengeToken;
|
|
9850
|
+
try {
|
|
9851
|
+
const storageManager = await getStorageManager();
|
|
9852
|
+
if (storageManager) {
|
|
9853
|
+
if (challengeToken) {
|
|
9854
|
+
await storageManager.setTemporaryDataParameter("challengeToken", challengeToken);
|
|
9855
|
+
} else {
|
|
9856
|
+
await storageManager.removeTemporaryDataParameter("challengeToken");
|
|
9857
|
+
}
|
|
9858
|
+
}
|
|
9859
|
+
} catch {
|
|
9860
|
+
logger7.warn("Failed to persist challenge token in storage.");
|
|
9861
|
+
}
|
|
9862
|
+
};
|
|
9863
|
+
const clearFlowState = async () => {
|
|
9818
9864
|
setExecutionId(null);
|
|
9865
|
+
await setChallengeToken(null);
|
|
9819
9866
|
setIsFlowInitialized(false);
|
|
9820
9867
|
sessionStorage.removeItem("asgardeo_auth_id");
|
|
9821
9868
|
setIsTimeoutDisabled(false);
|
|
@@ -9871,13 +9918,14 @@ var SignIn = ({
|
|
|
9871
9918
|
setError(err);
|
|
9872
9919
|
cleanupOAuthUrlParams(true);
|
|
9873
9920
|
};
|
|
9874
|
-
const handleRedirection = (response) => {
|
|
9921
|
+
const handleRedirection = async (response) => {
|
|
9875
9922
|
if (response.type === EmbeddedSignInFlowTypeV2.Redirection) {
|
|
9876
9923
|
const redirectURL = response.data?.redirectURL || response?.redirectURL;
|
|
9877
9924
|
if (redirectURL && window?.location) {
|
|
9878
9925
|
if (response.executionId) {
|
|
9879
9926
|
setExecutionId(response.executionId);
|
|
9880
9927
|
}
|
|
9928
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
9881
9929
|
const urlParams = getUrlParams2();
|
|
9882
9930
|
handleAuthId(urlParams.authId);
|
|
9883
9931
|
initiateOAuthRedirect(redirectURL);
|
|
@@ -9913,7 +9961,7 @@ var SignIn = ({
|
|
|
9913
9961
|
flowType: EmbeddedFlowType.Authentication
|
|
9914
9962
|
});
|
|
9915
9963
|
}
|
|
9916
|
-
if (handleRedirection(response)) {
|
|
9964
|
+
if (await handleRedirection(response)) {
|
|
9917
9965
|
return;
|
|
9918
9966
|
}
|
|
9919
9967
|
const {
|
|
@@ -9928,6 +9976,7 @@ var SignIn = ({
|
|
|
9928
9976
|
},
|
|
9929
9977
|
meta
|
|
9930
9978
|
);
|
|
9979
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
9931
9980
|
if (normalizedExecutionId && normalizedComponents) {
|
|
9932
9981
|
setExecutionId(normalizedExecutionId);
|
|
9933
9982
|
setComponents(normalizedComponents);
|
|
@@ -9938,7 +9987,7 @@ var SignIn = ({
|
|
|
9938
9987
|
}
|
|
9939
9988
|
} catch (error) {
|
|
9940
9989
|
const err = error;
|
|
9941
|
-
clearFlowState();
|
|
9990
|
+
await clearFlowState();
|
|
9942
9991
|
const errorMessage = err?.failureReason || (err instanceof Error ? err.message : String(err));
|
|
9943
9992
|
setError(new Error(errorMessage));
|
|
9944
9993
|
initializationAttemptedRef.current = false;
|
|
@@ -10041,15 +10090,17 @@ var SignIn = ({
|
|
|
10041
10090
|
const response = await signIn({
|
|
10042
10091
|
executionId: effectiveExecutionId,
|
|
10043
10092
|
...payload,
|
|
10044
|
-
inputs: processedInputs
|
|
10093
|
+
inputs: processedInputs,
|
|
10094
|
+
...challengeTokenRef.current ? { challengeToken: challengeTokenRef.current } : {}
|
|
10045
10095
|
});
|
|
10046
|
-
if (handleRedirection(response)) {
|
|
10096
|
+
if (await handleRedirection(response)) {
|
|
10047
10097
|
return;
|
|
10048
10098
|
}
|
|
10049
10099
|
if (response.data?.additionalData?.["passkeyChallenge"] || response.data?.additionalData?.["passkeyCreationOptions"]) {
|
|
10050
10100
|
const { passkeyChallenge, passkeyCreationOptions } = response.data.additionalData;
|
|
10051
10101
|
const effectiveExecutionIdForPasskey = response.executionId || effectiveExecutionId;
|
|
10052
10102
|
passkeyProcessedRef.current = false;
|
|
10103
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
10053
10104
|
setPasskeyState({
|
|
10054
10105
|
actionId: "submit",
|
|
10055
10106
|
challenge: passkeyChallenge,
|
|
@@ -10074,7 +10125,7 @@ var SignIn = ({
|
|
|
10074
10125
|
meta
|
|
10075
10126
|
);
|
|
10076
10127
|
if (response.flowStatus === EmbeddedSignInFlowStatusV22.Error) {
|
|
10077
|
-
clearFlowState();
|
|
10128
|
+
await clearFlowState();
|
|
10078
10129
|
const failureReason = response?.failureReason;
|
|
10079
10130
|
const errorMessage = failureReason || "Authentication flow failed. Please try again.";
|
|
10080
10131
|
const err = new Error(errorMessage);
|
|
@@ -10087,6 +10138,7 @@ var SignIn = ({
|
|
|
10087
10138
|
const finalRedirectUrl = redirectUrl || afterSignInUrl;
|
|
10088
10139
|
setIsSubmitting(false);
|
|
10089
10140
|
setExecutionId(null);
|
|
10141
|
+
await setChallengeToken(null);
|
|
10090
10142
|
setIsFlowInitialized(false);
|
|
10091
10143
|
sessionStorage.removeItem("asgardeo_execution_id");
|
|
10092
10144
|
sessionStorage.removeItem("asgardeo_auth_id");
|
|
@@ -10102,6 +10154,7 @@ var SignIn = ({
|
|
|
10102
10154
|
}
|
|
10103
10155
|
return;
|
|
10104
10156
|
}
|
|
10157
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
10105
10158
|
if (normalizedExecutionId && normalizedComponents) {
|
|
10106
10159
|
setExecutionId(normalizedExecutionId);
|
|
10107
10160
|
setComponents(normalizedComponents);
|
|
@@ -10115,7 +10168,7 @@ var SignIn = ({
|
|
|
10115
10168
|
}
|
|
10116
10169
|
} catch (error) {
|
|
10117
10170
|
const err = error;
|
|
10118
|
-
clearFlowState();
|
|
10171
|
+
await clearFlowState();
|
|
10119
10172
|
const errorMessage = err?.failureReason || (err instanceof Error ? err.message : String(err));
|
|
10120
10173
|
setError(new Error(errorMessage));
|
|
10121
10174
|
return;
|
|
@@ -10128,7 +10181,7 @@ var SignIn = ({
|
|
|
10128
10181
|
};
|
|
10129
10182
|
useOAuthCallback({
|
|
10130
10183
|
currentExecutionId,
|
|
10131
|
-
isInitialized: isInitialized && !isLoading,
|
|
10184
|
+
isInitialized: isInitialized && !isLoading && isStorageReady,
|
|
10132
10185
|
isSubmitting,
|
|
10133
10186
|
onError: (err) => {
|
|
10134
10187
|
clearFlowState();
|
|
@@ -10940,7 +10993,7 @@ var BaseSignUp_styles_default = useStyles21;
|
|
|
10940
10993
|
|
|
10941
10994
|
// src/components/presentation/auth/SignUp/v1/BaseSignUp.tsx
|
|
10942
10995
|
import { jsx as jsx80, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
10943
|
-
var
|
|
10996
|
+
var logger8 = createPackageComponentLogger7(
|
|
10944
10997
|
"@asgardeo/react",
|
|
10945
10998
|
"BaseSignUp"
|
|
10946
10999
|
);
|
|
@@ -11081,7 +11134,7 @@ var BaseSignUpContent = ({
|
|
|
11081
11134
|
const redirectUrl = response.data.redirectURL;
|
|
11082
11135
|
const popup = window.open(redirectUrl, "oauth_popup", "width=500,height=600,scrollbars=yes,resizable=yes");
|
|
11083
11136
|
if (!popup) {
|
|
11084
|
-
|
|
11137
|
+
logger8.error("Failed to open popup window");
|
|
11085
11138
|
return false;
|
|
11086
11139
|
}
|
|
11087
11140
|
let hasProcessedCallback = false;
|
|
@@ -11150,7 +11203,7 @@ var BaseSignUpContent = ({
|
|
|
11150
11203
|
const state = url.searchParams.get("state");
|
|
11151
11204
|
const error = url.searchParams.get("error");
|
|
11152
11205
|
if (error) {
|
|
11153
|
-
|
|
11206
|
+
logger8.error("OAuth error:");
|
|
11154
11207
|
popup.close();
|
|
11155
11208
|
cleanup();
|
|
11156
11209
|
return;
|
|
@@ -11185,7 +11238,7 @@ var BaseSignUpContent = ({
|
|
|
11185
11238
|
} catch (e) {
|
|
11186
11239
|
}
|
|
11187
11240
|
} catch (e) {
|
|
11188
|
-
|
|
11241
|
+
logger8.error("Error monitoring popup:");
|
|
11189
11242
|
}
|
|
11190
11243
|
}, 1e3);
|
|
11191
11244
|
return true;
|
|
@@ -11455,7 +11508,7 @@ var getAuthComponentHeadings_default = getAuthComponentHeadings;
|
|
|
11455
11508
|
|
|
11456
11509
|
// src/components/presentation/auth/SignUp/v2/BaseSignUp.tsx
|
|
11457
11510
|
import { jsx as jsx81, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
11458
|
-
var
|
|
11511
|
+
var logger9 = createPackageComponentLogger8(
|
|
11459
11512
|
"@asgardeo/react",
|
|
11460
11513
|
"BaseSignUp"
|
|
11461
11514
|
);
|
|
@@ -11482,7 +11535,7 @@ var BaseSignUpContent2 = ({
|
|
|
11482
11535
|
const { theme, colorScheme } = useTheme_default();
|
|
11483
11536
|
const { t } = useTranslation_default();
|
|
11484
11537
|
const { subtitle: flowSubtitle, title: flowTitle, messages: flowMessages, addMessage, clearMessages } = useFlow_default();
|
|
11485
|
-
const { meta } = useAsgardeo_default();
|
|
11538
|
+
const { meta, isInitialized: isSdkInitialized, getStorageManager } = useAsgardeo_default();
|
|
11486
11539
|
const styles = BaseSignUp_styles_default(theme, colorScheme);
|
|
11487
11540
|
const [isLoading, setIsLoading] = useState22(false);
|
|
11488
11541
|
const [isFlowInitialized, setIsFlowInitialized] = useState22(false);
|
|
@@ -11495,8 +11548,37 @@ var BaseSignUpContent2 = ({
|
|
|
11495
11548
|
executionId: null,
|
|
11496
11549
|
isActive: false
|
|
11497
11550
|
});
|
|
11551
|
+
const challengeTokenRef = useRef9(null);
|
|
11498
11552
|
const initializationAttemptedRef = useRef9(false);
|
|
11499
11553
|
const passkeyProcessedRef = useRef9(false);
|
|
11554
|
+
useEffect20(() => {
|
|
11555
|
+
if (!isSdkInitialized) return;
|
|
11556
|
+
(async () => {
|
|
11557
|
+
try {
|
|
11558
|
+
const storageManager = await getStorageManager();
|
|
11559
|
+
const tempData = await storageManager?.getTemporaryData();
|
|
11560
|
+
if (tempData?.challengeToken) {
|
|
11561
|
+
challengeTokenRef.current = tempData.challengeToken;
|
|
11562
|
+
}
|
|
11563
|
+
} catch {
|
|
11564
|
+
}
|
|
11565
|
+
})();
|
|
11566
|
+
}, [isSdkInitialized]);
|
|
11567
|
+
const setChallengeToken = async (challengeToken) => {
|
|
11568
|
+
challengeTokenRef.current = challengeToken;
|
|
11569
|
+
try {
|
|
11570
|
+
const storageManager = await getStorageManager();
|
|
11571
|
+
if (storageManager) {
|
|
11572
|
+
if (challengeToken) {
|
|
11573
|
+
await storageManager.setTemporaryDataParameter("challengeToken", challengeToken);
|
|
11574
|
+
} else {
|
|
11575
|
+
await storageManager.removeTemporaryDataParameter("challengeToken");
|
|
11576
|
+
}
|
|
11577
|
+
}
|
|
11578
|
+
} catch {
|
|
11579
|
+
logger9.warn("Failed to persist challenge token in storage.");
|
|
11580
|
+
}
|
|
11581
|
+
};
|
|
11500
11582
|
const handleError = useCallback15(
|
|
11501
11583
|
(error) => {
|
|
11502
11584
|
const errorMessage = error?.failureReason || extractErrorMessage(error, t);
|
|
@@ -11612,7 +11694,7 @@ var BaseSignUpContent2 = ({
|
|
|
11612
11694
|
const redirectUrl = response.data.redirectURL;
|
|
11613
11695
|
const popup = window.open(redirectUrl, "oauth_popup", "width=500,height=600,scrollbars=yes,resizable=yes");
|
|
11614
11696
|
if (!popup) {
|
|
11615
|
-
|
|
11697
|
+
logger9.error("Failed to open popup window");
|
|
11616
11698
|
return false;
|
|
11617
11699
|
}
|
|
11618
11700
|
let hasProcessedCallback = false;
|
|
@@ -11643,7 +11725,8 @@ var BaseSignUpContent2 = ({
|
|
|
11643
11725
|
inputs: {
|
|
11644
11726
|
code,
|
|
11645
11727
|
state
|
|
11646
|
-
}
|
|
11728
|
+
},
|
|
11729
|
+
...challengeTokenRef.current ? { challengeToken: challengeTokenRef.current } : {}
|
|
11647
11730
|
};
|
|
11648
11731
|
try {
|
|
11649
11732
|
const continueResponse = await onSubmit(payload);
|
|
@@ -11683,7 +11766,7 @@ var BaseSignUpContent2 = ({
|
|
|
11683
11766
|
const state = url.searchParams.get("state");
|
|
11684
11767
|
const error = url.searchParams.get("error");
|
|
11685
11768
|
if (error) {
|
|
11686
|
-
|
|
11769
|
+
logger9.error("OAuth error:");
|
|
11687
11770
|
popup.close();
|
|
11688
11771
|
cleanup();
|
|
11689
11772
|
return;
|
|
@@ -11696,7 +11779,8 @@ var BaseSignUpContent2 = ({
|
|
|
11696
11779
|
inputs: {
|
|
11697
11780
|
code,
|
|
11698
11781
|
state
|
|
11699
|
-
}
|
|
11782
|
+
},
|
|
11783
|
+
...challengeTokenRef.current ? { challengeToken: challengeTokenRef.current } : {}
|
|
11700
11784
|
};
|
|
11701
11785
|
try {
|
|
11702
11786
|
const continueResponse = await onSubmit(payload);
|
|
@@ -11718,7 +11802,7 @@ var BaseSignUpContent2 = ({
|
|
|
11718
11802
|
} catch (e) {
|
|
11719
11803
|
}
|
|
11720
11804
|
} catch (e) {
|
|
11721
|
-
|
|
11805
|
+
logger9.error("Error monitoring popup:");
|
|
11722
11806
|
}
|
|
11723
11807
|
}, 1e3);
|
|
11724
11808
|
return true;
|
|
@@ -11752,11 +11836,13 @@ var BaseSignUpContent2 = ({
|
|
|
11752
11836
|
...currentFlow.executionId && { executionId: currentFlow.executionId },
|
|
11753
11837
|
flowType: currentFlow.flowType || "REGISTRATION",
|
|
11754
11838
|
...component.id && { action: component.id },
|
|
11839
|
+
...challengeTokenRef.current ? { challengeToken: challengeTokenRef.current } : {},
|
|
11755
11840
|
inputs: filteredInputs
|
|
11756
11841
|
};
|
|
11757
11842
|
const rawResponse = await onSubmit(payload);
|
|
11758
11843
|
const response = normalizeFlowResponseLocal(rawResponse);
|
|
11759
11844
|
onFlowChange?.(response);
|
|
11845
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
11760
11846
|
if (response.flowStatus === EmbeddedFlowStatus2.Complete) {
|
|
11761
11847
|
onComplete?.(response);
|
|
11762
11848
|
return;
|
|
@@ -11909,6 +11995,7 @@ var BaseSignUpContent2 = ({
|
|
|
11909
11995
|
try {
|
|
11910
11996
|
const rawResponse = await onInitialize();
|
|
11911
11997
|
const response = normalizeFlowResponseLocal(rawResponse);
|
|
11998
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
11912
11999
|
setCurrentFlow(response);
|
|
11913
12000
|
setIsFlowInitialized(true);
|
|
11914
12001
|
onFlowChange?.(response);
|
|
@@ -12157,7 +12244,10 @@ import { EmbeddedFlowType as EmbeddedFlowType5, getOrganizationUnitChildren } fr
|
|
|
12157
12244
|
import { useCallback as useCallback17 } from "react";
|
|
12158
12245
|
|
|
12159
12246
|
// src/components/presentation/auth/InviteUser/v2/BaseInviteUser.tsx
|
|
12160
|
-
import {
|
|
12247
|
+
import {
|
|
12248
|
+
EmbeddedFlowType as EmbeddedFlowType4,
|
|
12249
|
+
logger as logger10
|
|
12250
|
+
} from "@asgardeo/browser";
|
|
12161
12251
|
import { cx as cx26 } from "@emotion/css";
|
|
12162
12252
|
import { useCallback as useCallback16, useEffect as useEffect21, useRef as useRef10, useState as useState23 } from "react";
|
|
12163
12253
|
|
|
@@ -12218,7 +12308,7 @@ var BaseInviteUser = ({
|
|
|
12218
12308
|
showTitle = true,
|
|
12219
12309
|
showSubtitle = true
|
|
12220
12310
|
}) => {
|
|
12221
|
-
const { meta } = useAsgardeo_default();
|
|
12311
|
+
const { meta, isInitialized: isSdkInitialized, getStorageManager } = useAsgardeo_default();
|
|
12222
12312
|
const { t } = useTranslation_default(preferences?.i18n);
|
|
12223
12313
|
const { theme } = useTheme_default();
|
|
12224
12314
|
const styles = BaseInviteUser_styles_default(theme, theme.vars.colors.text.primary);
|
|
@@ -12230,7 +12320,36 @@ var BaseInviteUser = ({
|
|
|
12230
12320
|
const [formErrors, setFormErrors] = useState23({});
|
|
12231
12321
|
const [touchedFields, setTouchedFields] = useState23({});
|
|
12232
12322
|
const [isFormValid, setIsFormValid] = useState23(true);
|
|
12323
|
+
const challengeTokenRef = useRef10(null);
|
|
12233
12324
|
const initializationAttemptedRef = useRef10(false);
|
|
12325
|
+
useEffect21(() => {
|
|
12326
|
+
if (!isSdkInitialized) return;
|
|
12327
|
+
(async () => {
|
|
12328
|
+
try {
|
|
12329
|
+
const storageManager = await getStorageManager();
|
|
12330
|
+
const tempData = await storageManager?.getTemporaryData();
|
|
12331
|
+
if (tempData?.challengeToken) {
|
|
12332
|
+
challengeTokenRef.current = tempData.challengeToken;
|
|
12333
|
+
}
|
|
12334
|
+
} catch {
|
|
12335
|
+
}
|
|
12336
|
+
})();
|
|
12337
|
+
}, [isSdkInitialized]);
|
|
12338
|
+
const setChallengeToken = async (challengeToken) => {
|
|
12339
|
+
challengeTokenRef.current = challengeToken;
|
|
12340
|
+
try {
|
|
12341
|
+
const storageManager = await getStorageManager();
|
|
12342
|
+
if (storageManager) {
|
|
12343
|
+
if (challengeToken) {
|
|
12344
|
+
await storageManager.setTemporaryDataParameter("challengeToken", challengeToken);
|
|
12345
|
+
} else {
|
|
12346
|
+
await storageManager.removeTemporaryDataParameter("challengeToken");
|
|
12347
|
+
}
|
|
12348
|
+
}
|
|
12349
|
+
} catch {
|
|
12350
|
+
logger10.warn("Failed to persist challenge token in storage.");
|
|
12351
|
+
}
|
|
12352
|
+
};
|
|
12234
12353
|
const handleError = useCallback16(
|
|
12235
12354
|
(error) => {
|
|
12236
12355
|
const errorMessage = error?.failureReason || extractErrorMessage(error, t, "components.inviteUser.errors.generic");
|
|
@@ -12327,7 +12446,8 @@ var BaseInviteUser = ({
|
|
|
12327
12446
|
const payload = {
|
|
12328
12447
|
executionId: currentFlow.executionId,
|
|
12329
12448
|
inputs,
|
|
12330
|
-
verbose: true
|
|
12449
|
+
verbose: true,
|
|
12450
|
+
...challengeTokenRef.current ? { challengeToken: challengeTokenRef.current } : {}
|
|
12331
12451
|
};
|
|
12332
12452
|
if (component?.id) {
|
|
12333
12453
|
payload["action"] = component.id;
|
|
@@ -12335,6 +12455,7 @@ var BaseInviteUser = ({
|
|
|
12335
12455
|
const rawResponse = await onSubmit(payload);
|
|
12336
12456
|
const response = normalizeFlowResponseLocal(rawResponse);
|
|
12337
12457
|
onFlowChange?.(response);
|
|
12458
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
12338
12459
|
if (response.flowStatus === "ERROR") {
|
|
12339
12460
|
handleError(response);
|
|
12340
12461
|
return;
|
|
@@ -12373,6 +12494,7 @@ var BaseInviteUser = ({
|
|
|
12373
12494
|
};
|
|
12374
12495
|
const rawResponse = await onInitialize(payload);
|
|
12375
12496
|
const response = normalizeFlowResponseLocal(rawResponse);
|
|
12497
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
12376
12498
|
setCurrentFlow(response);
|
|
12377
12499
|
setIsFlowInitialized(true);
|
|
12378
12500
|
onFlowChange?.(response);
|
|
@@ -12643,7 +12765,7 @@ var BaseAcceptInvite = ({
|
|
|
12643
12765
|
showTitle = true,
|
|
12644
12766
|
showSubtitle = true
|
|
12645
12767
|
}) => {
|
|
12646
|
-
const { meta } = useAsgardeo_default();
|
|
12768
|
+
const { meta, isInitialized, getStorageManager } = useAsgardeo_default();
|
|
12647
12769
|
const { t } = useTranslation_default(preferences?.i18n);
|
|
12648
12770
|
const { theme } = useTheme_default();
|
|
12649
12771
|
const styles = BaseAcceptInvite_styles_default(theme, theme.vars.colors.text.primary);
|
|
@@ -12657,7 +12779,34 @@ var BaseAcceptInvite = ({
|
|
|
12657
12779
|
const [formErrors, setFormErrors] = useState24({});
|
|
12658
12780
|
const [touchedFields, setTouchedFields] = useState24({});
|
|
12659
12781
|
const [isFormValid, setIsFormValid] = useState24(true);
|
|
12782
|
+
const [isStorageReady, setIsStorageReady] = useState24(false);
|
|
12783
|
+
const challengeTokenRef = useRef11(null);
|
|
12660
12784
|
const tokenValidationAttemptedRef = useRef11(false);
|
|
12785
|
+
useEffect22(() => {
|
|
12786
|
+
if (!isInitialized) return;
|
|
12787
|
+
(async () => {
|
|
12788
|
+
try {
|
|
12789
|
+
const storageManager = await getStorageManager();
|
|
12790
|
+
const tempData = await storageManager?.getTemporaryData();
|
|
12791
|
+
if (tempData?.challengeToken) {
|
|
12792
|
+
challengeTokenRef.current = tempData.challengeToken;
|
|
12793
|
+
}
|
|
12794
|
+
} finally {
|
|
12795
|
+
setIsStorageReady(true);
|
|
12796
|
+
}
|
|
12797
|
+
})();
|
|
12798
|
+
}, [isInitialized]);
|
|
12799
|
+
const setChallengeToken = async (challengeToken) => {
|
|
12800
|
+
challengeTokenRef.current = challengeToken;
|
|
12801
|
+
const storageManager = await getStorageManager();
|
|
12802
|
+
if (storageManager) {
|
|
12803
|
+
if (challengeToken) {
|
|
12804
|
+
await storageManager.setTemporaryDataParameter("challengeToken", challengeToken);
|
|
12805
|
+
} else {
|
|
12806
|
+
await storageManager.removeTemporaryDataParameter("challengeToken");
|
|
12807
|
+
}
|
|
12808
|
+
}
|
|
12809
|
+
};
|
|
12661
12810
|
const handleError = useCallback18(
|
|
12662
12811
|
(error) => {
|
|
12663
12812
|
const errorMessage = error?.failureReason || extractErrorMessage(error, t, "components.acceptInvite.errors.generic");
|
|
@@ -12696,7 +12845,7 @@ var BaseAcceptInvite = ({
|
|
|
12696
12845
|
);
|
|
12697
12846
|
useOAuthCallback({
|
|
12698
12847
|
currentExecutionId: executionId ?? null,
|
|
12699
|
-
isInitialized:
|
|
12848
|
+
isInitialized: isStorageReady,
|
|
12700
12849
|
onComplete: () => {
|
|
12701
12850
|
setIsValidatingToken(false);
|
|
12702
12851
|
onComplete?.();
|
|
@@ -12719,8 +12868,12 @@ var BaseAcceptInvite = ({
|
|
|
12719
12868
|
setIsValidatingToken(true);
|
|
12720
12869
|
},
|
|
12721
12870
|
onSubmit: async (payload) => {
|
|
12722
|
-
const rawResponse = await onSubmit(
|
|
12871
|
+
const rawResponse = await onSubmit({
|
|
12872
|
+
...payload,
|
|
12873
|
+
...challengeTokenRef.current ? { challengeToken: challengeTokenRef.current } : {}
|
|
12874
|
+
});
|
|
12723
12875
|
const response = normalizeFlowResponseLocal(rawResponse);
|
|
12876
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
12724
12877
|
return response;
|
|
12725
12878
|
},
|
|
12726
12879
|
tokenValidationAttemptedRef
|
|
@@ -12782,7 +12935,8 @@ var BaseAcceptInvite = ({
|
|
|
12782
12935
|
const payload = {
|
|
12783
12936
|
executionId: currentFlow.executionId,
|
|
12784
12937
|
inputs,
|
|
12785
|
-
verbose: true
|
|
12938
|
+
verbose: true,
|
|
12939
|
+
...challengeTokenRef.current ? { challengeToken: challengeTokenRef.current } : {}
|
|
12786
12940
|
};
|
|
12787
12941
|
if (component?.id) {
|
|
12788
12942
|
payload["action"] = component.id;
|
|
@@ -12790,6 +12944,7 @@ var BaseAcceptInvite = ({
|
|
|
12790
12944
|
const rawResponse = await onSubmit(payload);
|
|
12791
12945
|
const response = normalizeFlowResponseLocal(rawResponse);
|
|
12792
12946
|
onFlowChange?.(response);
|
|
12947
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
12793
12948
|
if (response.type === "REDIRECTION") {
|
|
12794
12949
|
const redirectURL = response.data?.redirectURL || response?.redirectURL;
|
|
12795
12950
|
if (redirectURL && typeof window !== "undefined") {
|
|
@@ -12859,6 +13014,7 @@ var BaseAcceptInvite = ({
|
|
|
12859
13014
|
const rawResponse = await onSubmit(payload);
|
|
12860
13015
|
const response = normalizeFlowResponseLocal(rawResponse);
|
|
12861
13016
|
onFlowChange?.(response);
|
|
13017
|
+
await setChallengeToken(response.challengeToken ?? null);
|
|
12862
13018
|
if (response.flowStatus === "ERROR") {
|
|
12863
13019
|
setIsTokenInvalid(true);
|
|
12864
13020
|
handleError(response);
|
|
@@ -16010,7 +16166,7 @@ var BaseCreateOrganization_styles_default = useStyles30;
|
|
|
16010
16166
|
|
|
16011
16167
|
// src/components/presentation/CreateOrganization/BaseCreateOrganization.tsx
|
|
16012
16168
|
import { jsx as jsx110, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
16013
|
-
var
|
|
16169
|
+
var logger11 = createPackageComponentLogger9(
|
|
16014
16170
|
"@asgardeo/react",
|
|
16015
16171
|
"BaseCreateOrganization"
|
|
16016
16172
|
);
|
|
@@ -16096,7 +16252,7 @@ var BaseCreateOrganization = ({
|
|
|
16096
16252
|
onSuccess(payload);
|
|
16097
16253
|
}
|
|
16098
16254
|
} catch (submitError) {
|
|
16099
|
-
|
|
16255
|
+
logger11.error("Form submission error:");
|
|
16100
16256
|
}
|
|
16101
16257
|
};
|
|
16102
16258
|
const createOrganizationContent = /* @__PURE__ */ jsx110("div", { className: cx34(styles["root"], cardLayout && styles["card"], className), style, children: /* @__PURE__ */ jsxs51("div", { className: cx34(styles["content"]), children: [
|
|
@@ -17633,7 +17789,7 @@ var updateOrganization_default = updateOrganization;
|
|
|
17633
17789
|
|
|
17634
17790
|
// src/components/presentation/OrganizationProfile/OrganizationProfile.tsx
|
|
17635
17791
|
import { jsx as jsx116 } from "react/jsx-runtime";
|
|
17636
|
-
var
|
|
17792
|
+
var logger12 = createPackageComponentLogger10(
|
|
17637
17793
|
"@asgardeo/react",
|
|
17638
17794
|
"OrganizationProfile"
|
|
17639
17795
|
);
|
|
@@ -17664,7 +17820,7 @@ var OrganizationProfile = ({
|
|
|
17664
17820
|
});
|
|
17665
17821
|
setOrganization(orgData);
|
|
17666
17822
|
} catch (err) {
|
|
17667
|
-
|
|
17823
|
+
logger12.error("Failed to fetch organization:");
|
|
17668
17824
|
setOrganization(null);
|
|
17669
17825
|
}
|
|
17670
17826
|
};
|
|
@@ -17686,7 +17842,7 @@ var OrganizationProfile = ({
|
|
|
17686
17842
|
await onUpdate(payload);
|
|
17687
17843
|
}
|
|
17688
17844
|
} catch (err) {
|
|
17689
|
-
|
|
17845
|
+
logger12.error("Failed to update organization:");
|
|
17690
17846
|
throw err;
|
|
17691
17847
|
}
|
|
17692
17848
|
};
|