@nibssplc/cams-sdk-react 1.0.0-rc.96 → 1.0.0-rc.98

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.esm.js CHANGED
@@ -1561,33 +1561,41 @@ var MFAOptions = function (_a) {
1561
1561
  email: ((_c = (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.email) || context.email,
1562
1562
  appCode: context.appCode || "",
1563
1563
  MFAEndpoint: MFAEndpoints.ValidateUserMFA,
1564
- onAuthComplete: function (state, data) {
1565
- console.log("Completed Auth. Handling MFA", state, data);
1566
- if (state) {
1567
- // Call completeMFA to update context state
1568
- if (completeMFA && data) {
1569
- console.log("IN Complete MFA Block. Handling MFA", data);
1570
- completeMFA(data).catch(function (error) {
1571
- console.error("Failed to complete MFA:", error);
1572
- });
1573
- }
1574
- setShowSuccessAnimation(true);
1575
- toast.success(jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsx(ShieldCheck, { className: "w-4 h-4" }), jsxs("span", { children: ["Multi-Factor Authentication Successful. ", data === null || data === void 0 ? void 0 : data.message] })] }));
1576
- setTimeout(function () { return onComplete === null || onComplete === void 0 ? void 0 : onComplete(true); }, 2000);
1577
- }
1578
- else {
1579
- toast.error(jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsx(ShieldClose, { className: "w-4 h-4" }), jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "Unable to Validate User. Please try again." })] }));
1580
- if (isMaxAttemptsReached) {
1581
- setTimeout(function () {
1582
- logout().then(function () {
1583
- onAuthFailed === null || onAuthFailed === void 0 ? void 0 : onAuthFailed();
1584
- onComplete === null || onComplete === void 0 ? void 0 : onComplete(false);
1585
- });
1586
- }, 3000);
1564
+ onAuthComplete: function (state, data) { return __awaiter$1(void 0, void 0, void 0, function () {
1565
+ return __generator$1(this, function (_a) {
1566
+ switch (_a.label) {
1567
+ case 0:
1568
+ console.log("Completed Auth. Handling MFA", state, data);
1569
+ if (!(state && (data === null || data === void 0 ? void 0 : data.isValid))) return [3 /*break*/, 2];
1570
+ // Call completeMFA to update context state
1571
+ console.log("IN Complete MFA Block. Handling MFA", data);
1572
+ return [4 /*yield*/, (completeMFA === null || completeMFA === void 0 ? void 0 : completeMFA(data).catch(function (error) {
1573
+ console.error("Failed to complete MFA:", error);
1574
+ }))];
1575
+ case 1:
1576
+ _a.sent();
1577
+ onComplete(true);
1578
+ toast.success(jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsx(ShieldCheck, { className: "w-4 h-4" }), jsxs("span", { children: ["Multi-Factor Authentication Successful. ", data === null || data === void 0 ? void 0 : data.message] })] }));
1579
+ setTimeout(function () { return setShowSuccessAnimation(true); }, 2000);
1580
+ return [3 /*break*/, 3];
1581
+ case 2:
1582
+ toast.error(jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsx(ShieldClose, { className: "w-4 h-4" }), jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "Unable to Validate User. Please try again." })] }));
1583
+ if (isMaxAttemptsReached) {
1584
+ setTimeout(function () {
1585
+ logout().then(function () {
1586
+ onAuthFailed === null || onAuthFailed === void 0 ? void 0 : onAuthFailed();
1587
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete(false);
1588
+ });
1589
+ }, 3000);
1590
+ }
1591
+ _a.label = 3;
1592
+ case 3: return [2 /*return*/];
1587
1593
  }
1588
- }
1589
- },
1590
- }), handleSubmitOTP = _j.handleSubmitOTP, loading = _j.loading, attemptCount = _j.attemptCount, remainingAttempts = _j.remainingAttempts, isMaxAttemptsReached = _j.isMaxAttemptsReached, resetAttempts = _j.resetAttempts;
1594
+ });
1595
+ }); },
1596
+ }), handleSubmitOTP = _j.handleSubmitOTP, loading = _j.loading,
1597
+ // setLoading,
1598
+ attemptCount = _j.attemptCount, remainingAttempts = _j.remainingAttempts, isMaxAttemptsReached = _j.isMaxAttemptsReached, resetAttempts = _j.resetAttempts;
1591
1599
  var handleGoBack = function () {
1592
1600
  setAuthType(null);
1593
1601
  setOtpVisible(false);
@@ -1834,14 +1842,15 @@ var MFAGate = function (_a) {
1834
1842
  var contextAccessToken = "accessToken" in context ? context.accessToken : "";
1835
1843
  var handleComplete = useCallback(function (success) {
1836
1844
  var _a;
1837
- if (success && context.authMode === "MSAL") {
1845
+ if (success) {
1838
1846
  var accessToken = "accessToken" in context ? context.accessToken : "";
1839
1847
  var idToken = "idToken" in context ? context.idToken : "";
1840
- if (accessToken && idToken) {
1848
+ Logger.info("MFA Authentication Successful", { context: context || null });
1849
+ context.isAuthenticated = true;
1850
+ if (context.authMode === "MSAL") {
1841
1851
  var tokens = { accessToken: accessToken, idToken: idToken };
1842
1852
  onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(tokens);
1843
1853
  if ("onAuthSuccess" in context) {
1844
- context.isAuthenticated = true;
1845
1854
  (_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens);
1846
1855
  }
1847
1856
  }