@nibssplc/cams-sdk-react 1.0.0-rc.77 → 1.0.0-rc.79
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 +11 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -4,6 +4,7 @@ import { CAMSSessionManager, isPopupWindow, Logger, CAMSError, CAMSErrorType, CA
|
|
|
4
4
|
export * from '@nibssplc/cams-sdk';
|
|
5
5
|
import { useMsal, useAccount, MsalProvider } from '@azure/msal-react';
|
|
6
6
|
import { InteractionStatus, PublicClientApplication } from '@azure/msal-browser';
|
|
7
|
+
import { toast } from 'sonner';
|
|
7
8
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
8
9
|
import z$1, { z } from 'zod';
|
|
9
10
|
import { OTPInput, OTPInputContext, REGEXP_ONLY_DIGITS } from 'input-otp';
|
|
@@ -16,7 +17,6 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
16
17
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
17
18
|
import { cva } from 'class-variance-authority';
|
|
18
19
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
19
|
-
import { toast } from 'sonner';
|
|
20
20
|
import { motion } from 'framer-motion';
|
|
21
21
|
|
|
22
22
|
/******************************************************************************
|
|
@@ -466,7 +466,7 @@ function useCAMSMSALAuth(options) {
|
|
|
466
466
|
}
|
|
467
467
|
}, [accessToken, account, instance, options.storageKey]);
|
|
468
468
|
var login = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
469
|
-
var response, mfaConfig, authenticator, userConfig, err_1, camsError_1, camsError;
|
|
469
|
+
var response, mfaConfig, authenticator, userConfig, camsError, err_1, camsError_1, camsError;
|
|
470
470
|
var _a;
|
|
471
471
|
return __generator$1(this, function (_b) {
|
|
472
472
|
switch (_b.label) {
|
|
@@ -495,12 +495,12 @@ function useCAMSMSALAuth(options) {
|
|
|
495
495
|
return [4 /*yield*/, authenticator.GetUserMFAConfig(mfaConfig)];
|
|
496
496
|
case 3:
|
|
497
497
|
userConfig = _b.sent();
|
|
498
|
-
|
|
498
|
+
console.log("CAMS MFA Authenticator initialized:", {
|
|
499
499
|
mfaConfig: mfaConfig,
|
|
500
500
|
userConfig: userConfig,
|
|
501
501
|
});
|
|
502
502
|
// Don't persist as authenticated until MFA is complete
|
|
503
|
-
if (typeof window !== "undefined" && userConfig.isValid) {
|
|
503
|
+
if (typeof window !== "undefined" && userConfig.isValid && userConfig.userInfo.email) {
|
|
504
504
|
setAccessToken(response.accessToken);
|
|
505
505
|
setIdToken(response.idToken);
|
|
506
506
|
localStorage.setItem(storageKey, JSON.stringify({
|
|
@@ -512,6 +512,11 @@ function useCAMSMSALAuth(options) {
|
|
|
512
512
|
setEmail(userConfig.userInfo.email);
|
|
513
513
|
setRequiresMFA(userConfig.userInfo.isMFAEnabled);
|
|
514
514
|
}
|
|
515
|
+
else {
|
|
516
|
+
camsError = new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "Login failed: " + userConfig.message);
|
|
517
|
+
toast.error("Login failed");
|
|
518
|
+
setError(camsError);
|
|
519
|
+
}
|
|
515
520
|
return [3 /*break*/, 5];
|
|
516
521
|
case 4:
|
|
517
522
|
err_1 = _b.sent();
|
|
@@ -1864,9 +1869,10 @@ var MFAGate = function (_a) {
|
|
|
1864
1869
|
}, 50);
|
|
1865
1870
|
return function () { return clearTimeout(timer); };
|
|
1866
1871
|
}, [
|
|
1872
|
+
context.accessToken,
|
|
1867
1873
|
context.isLoading,
|
|
1868
1874
|
context.isAuthenticated,
|
|
1869
|
-
|
|
1875
|
+
context.requiresMFA,
|
|
1870
1876
|
requiresMFA,
|
|
1871
1877
|
context,
|
|
1872
1878
|
]);
|