@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 CHANGED
@@ -4,6 +4,7 @@ var React = require('react');
4
4
  var camsSdk = require('@nibssplc/cams-sdk');
5
5
  var msalReact = require('@azure/msal-react');
6
6
  var msalBrowser = require('@azure/msal-browser');
7
+ var sonner = require('sonner');
7
8
  var jsxRuntime = require('react/jsx-runtime');
8
9
  var z = require('zod');
9
10
  var inputOtp = require('input-otp');
@@ -16,7 +17,6 @@ var reactSlot = require('@radix-ui/react-slot');
16
17
  var LabelPrimitive = require('@radix-ui/react-label');
17
18
  var classVarianceAuthority = require('class-variance-authority');
18
19
  var DialogPrimitive = require('@radix-ui/react-dialog');
19
- var sonner = require('sonner');
20
20
  var framerMotion = require('framer-motion');
21
21
 
22
22
  function _interopNamespaceDefault(e) {
@@ -487,7 +487,7 @@ function useCAMSMSALAuth(options) {
487
487
  }
488
488
  }, [accessToken, account, instance, options.storageKey]);
489
489
  var login = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
490
- var response, mfaConfig, authenticator, userConfig, err_1, camsError_1, camsError;
490
+ var response, mfaConfig, authenticator, userConfig, camsError, err_1, camsError_1, camsError;
491
491
  var _a;
492
492
  return __generator$1(this, function (_b) {
493
493
  switch (_b.label) {
@@ -516,12 +516,12 @@ function useCAMSMSALAuth(options) {
516
516
  return [4 /*yield*/, authenticator.GetUserMFAConfig(mfaConfig)];
517
517
  case 3:
518
518
  userConfig = _b.sent();
519
- camsSdk.Logger.debug("CAMS MFA Authenticator initialized:", {
519
+ console.log("CAMS MFA Authenticator initialized:", {
520
520
  mfaConfig: mfaConfig,
521
521
  userConfig: userConfig,
522
522
  });
523
523
  // Don't persist as authenticated until MFA is complete
524
- if (typeof window !== "undefined" && userConfig.isValid) {
524
+ if (typeof window !== "undefined" && userConfig.isValid && userConfig.userInfo.email) {
525
525
  setAccessToken(response.accessToken);
526
526
  setIdToken(response.idToken);
527
527
  localStorage.setItem(storageKey, JSON.stringify({
@@ -533,6 +533,11 @@ function useCAMSMSALAuth(options) {
533
533
  setEmail(userConfig.userInfo.email);
534
534
  setRequiresMFA(userConfig.userInfo.isMFAEnabled);
535
535
  }
536
+ else {
537
+ camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Login failed: " + userConfig.message);
538
+ sonner.toast.error("Login failed");
539
+ setError(camsError);
540
+ }
536
541
  return [3 /*break*/, 5];
537
542
  case 4:
538
543
  err_1 = _b.sent();
@@ -1885,9 +1890,10 @@ var MFAGate = function (_a) {
1885
1890
  }, 50);
1886
1891
  return function () { return clearTimeout(timer); };
1887
1892
  }, [
1893
+ context.accessToken,
1888
1894
  context.isLoading,
1889
1895
  context.isAuthenticated,
1890
- // context["requiresMFA"],
1896
+ context.requiresMFA,
1891
1897
  requiresMFA,
1892
1898
  context,
1893
1899
  ]);