@nibssplc/cams-sdk-react 1.0.0-rc.88 → 1.0.0-rc.89
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/index.cjs.js +14 -59
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +14 -59
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -482,7 +482,7 @@ function useCAMSMSALAuth(options) {
|
|
|
482
482
|
}
|
|
483
483
|
}, [accessToken, account, instance, options.storageKey]);
|
|
484
484
|
var login = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
485
|
-
var response,
|
|
485
|
+
var response, authenticator, userConfig, camsError, err_1, camsError_1, camsError;
|
|
486
486
|
var _a;
|
|
487
487
|
return __generator$1(this, function (_b) {
|
|
488
488
|
switch (_b.label) {
|
|
@@ -497,33 +497,28 @@ function useCAMSMSALAuth(options) {
|
|
|
497
497
|
_b.trys.push([1, 4, , 5]);
|
|
498
498
|
return [4 /*yield*/, instance.loginPopup({
|
|
499
499
|
scopes: scopes,
|
|
500
|
-
prompt: prompt || "
|
|
500
|
+
prompt: prompt || "login",
|
|
501
501
|
})];
|
|
502
502
|
case 2:
|
|
503
503
|
response = _b.sent();
|
|
504
|
-
mfaConfig = {
|
|
505
|
-
accessToken: response.accessToken,
|
|
506
|
-
idToken: response.idToken,
|
|
507
|
-
provider: "MSAL",
|
|
508
|
-
APIAuthEndpoint: ValidateUserEndpoint,
|
|
509
|
-
};
|
|
510
504
|
authenticator = new camsSdk.CAMSMFAAuthenticator();
|
|
511
505
|
setIsFetchingMFAConfig(true);
|
|
512
|
-
return [4 /*yield*/, authenticator.GetUserMFAConfig(
|
|
506
|
+
return [4 /*yield*/, authenticator.GetUserMFAConfig({
|
|
507
|
+
accessToken: response.accessToken,
|
|
508
|
+
idToken: response.idToken,
|
|
509
|
+
provider: "MSAL",
|
|
510
|
+
APIAuthEndpoint: ValidateUserEndpoint,
|
|
511
|
+
})];
|
|
513
512
|
case 3:
|
|
514
513
|
userConfig = _b.sent();
|
|
515
514
|
setIsFetchingMFAConfig(false);
|
|
516
|
-
|
|
517
|
-
mfaConfig: mfaConfig,
|
|
515
|
+
camsSdk.Logger.info("CAMS MFA Authenticator initialized. MSAL User Auth is Completed...", {
|
|
518
516
|
userConfig: userConfig,
|
|
517
|
+
storageKey: storageKey,
|
|
518
|
+
email: userConfig.userInfo.email,
|
|
519
519
|
});
|
|
520
|
-
camsSdk.Logger.info("MSAL User Auth is Completed");
|
|
521
520
|
// Don't persist as authenticated until MFA is complete
|
|
522
521
|
if (userConfig.isValid && userConfig.userInfo.email) {
|
|
523
|
-
camsSdk.Logger.info("MSAL User Auth is Completed...", {
|
|
524
|
-
storageKey: storageKey,
|
|
525
|
-
email: userConfig.userInfo.email,
|
|
526
|
-
});
|
|
527
522
|
setAccessToken(response.accessToken);
|
|
528
523
|
setIdToken(response.idToken);
|
|
529
524
|
localStorage.setItem(storageKey, JSON.stringify({
|
|
@@ -638,7 +633,7 @@ function useCAMSMSALAuth(options) {
|
|
|
638
633
|
setRequiresMFA(false);
|
|
639
634
|
if (typeof window !== "undefined") {
|
|
640
635
|
localStorage.removeItem(storageKey);
|
|
641
|
-
|
|
636
|
+
deleteCookie(storageKey + "-PROFILE");
|
|
642
637
|
}
|
|
643
638
|
return [4 /*yield*/, instance.logoutRedirect()];
|
|
644
639
|
case 1:
|
|
@@ -1858,8 +1853,6 @@ var MFAGate = function (_a) {
|
|
|
1858
1853
|
(_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens);
|
|
1859
1854
|
}
|
|
1860
1855
|
}
|
|
1861
|
-
// Force state update after MFA completion
|
|
1862
|
-
setAuthState("Authenticated");
|
|
1863
1856
|
}
|
|
1864
1857
|
else if (!success) {
|
|
1865
1858
|
camsSdk.Logger.error("MFA authentication failed", { context: context || null });
|
|
@@ -1884,59 +1877,21 @@ var MFAGate = function (_a) {
|
|
|
1884
1877
|
});
|
|
1885
1878
|
}); }, [context, onAuthError]);
|
|
1886
1879
|
React.useEffect(function () {
|
|
1887
|
-
console.log("Auth evaluation triggered:", {
|
|
1888
|
-
isLoading: context.isLoading,
|
|
1889
|
-
isAuthenticated: context.isAuthenticated,
|
|
1890
|
-
contextRequiresMFA: contextRequiresMFA,
|
|
1891
|
-
contextAccessToken: !!contextAccessToken,
|
|
1892
|
-
requiresMFA: requiresMFA,
|
|
1893
|
-
});
|
|
1894
1880
|
if (context.isLoading) {
|
|
1895
1881
|
setAuthState("Loading");
|
|
1896
1882
|
return;
|
|
1897
1883
|
}
|
|
1898
|
-
// Check if user has accessToken (MSAL authenticated)
|
|
1899
1884
|
if (!contextAccessToken) {
|
|
1900
1885
|
setAuthState("Unauthenticated");
|
|
1901
1886
|
return;
|
|
1902
1887
|
}
|
|
1903
|
-
// User has accessToken, determine if MFA is required
|
|
1904
1888
|
var shouldRequireMFA = requiresMFA !== null && requiresMFA !== void 0 ? requiresMFA : contextRequiresMFA;
|
|
1905
|
-
|
|
1906
|
-
shouldRequireMFA: shouldRequireMFA,
|
|
1907
|
-
hasAccessToken: !!contextAccessToken,
|
|
1908
|
-
finalState: shouldRequireMFA ? "MFA_Required" : "Authenticated",
|
|
1909
|
-
});
|
|
1910
|
-
if (shouldRequireMFA) {
|
|
1911
|
-
setAuthState("MFA_Required");
|
|
1912
|
-
}
|
|
1913
|
-
else {
|
|
1914
|
-
setAuthState("Authenticated");
|
|
1915
|
-
}
|
|
1916
|
-
}, [
|
|
1917
|
-
context.isLoading,
|
|
1918
|
-
context.isAuthenticated,
|
|
1919
|
-
contextRequiresMFA, // Now this will trigger re-evaluation when requiresMFA changes
|
|
1920
|
-
contextAccessToken, // And this when accessToken changes
|
|
1921
|
-
requiresMFA,
|
|
1922
|
-
context.authMode,
|
|
1923
|
-
]);
|
|
1924
|
-
// Debug useEffect
|
|
1925
|
-
React.useEffect(function () {
|
|
1926
|
-
console.log("Current authState:", authState);
|
|
1927
|
-
console.log("Context state:", {
|
|
1928
|
-
isLoading: context.isLoading,
|
|
1929
|
-
isAuthenticated: context.isAuthenticated,
|
|
1930
|
-
authMode: context.authMode,
|
|
1931
|
-
requiresMFA: contextRequiresMFA,
|
|
1932
|
-
hasAccessToken: !!contextAccessToken,
|
|
1933
|
-
});
|
|
1889
|
+
setAuthState(shouldRequireMFA ? "MFA_Required" : "Authenticated");
|
|
1934
1890
|
}, [
|
|
1935
|
-
authState,
|
|
1936
1891
|
context.isLoading,
|
|
1937
|
-
context.isAuthenticated,
|
|
1938
1892
|
contextRequiresMFA,
|
|
1939
1893
|
contextAccessToken,
|
|
1894
|
+
requiresMFA,
|
|
1940
1895
|
]);
|
|
1941
1896
|
if (useADLogin && !CredentialsAuthEndpoint)
|
|
1942
1897
|
return jsxRuntime.jsx(ErrorFallback, { message: "Invalid AD Login Configuration." });
|