@nibssplc/cams-sdk-react 1.0.0-rc.103 → 1.0.0-rc.105
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 +43 -51
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +43 -51
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -643,32 +643,26 @@ function useCAMSMSALAuth(options) {
|
|
|
643
643
|
});
|
|
644
644
|
}); }, []);
|
|
645
645
|
var logout = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
646
|
-
var
|
|
646
|
+
var camsError;
|
|
647
647
|
return __generator$1(this, function (_a) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
return [3 /*break*/, 3];
|
|
665
|
-
case 2:
|
|
666
|
-
err_2 = _a.sent();
|
|
667
|
-
camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Logout failed: " + err_2);
|
|
668
|
-
setError(camsError);
|
|
669
|
-
return [3 /*break*/, 3];
|
|
670
|
-
case 3: return [2 /*return*/];
|
|
648
|
+
try {
|
|
649
|
+
camsSdk.Logger.info("Logging User Out");
|
|
650
|
+
setAccessToken("");
|
|
651
|
+
setIdToken("");
|
|
652
|
+
setError(null);
|
|
653
|
+
setRequiresMFA(false);
|
|
654
|
+
setIsAuthenticated(false);
|
|
655
|
+
if (typeof window !== "undefined") {
|
|
656
|
+
localStorage.removeItem(storageKey);
|
|
657
|
+
deleteCookie(storageKey + "-PROFILE");
|
|
658
|
+
}
|
|
659
|
+
// await instance.logoutRedirect();
|
|
660
|
+
}
|
|
661
|
+
catch (err) {
|
|
662
|
+
camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Logout failed: " + err);
|
|
663
|
+
setError(camsError);
|
|
671
664
|
}
|
|
665
|
+
return [2 /*return*/];
|
|
672
666
|
});
|
|
673
667
|
}); }, [instance, storageKey]);
|
|
674
668
|
return {
|
|
@@ -1512,15 +1506,20 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1512
1506
|
var _a = React.useState(false), loading = _a[0], setLoading = _a[1];
|
|
1513
1507
|
var _b = React.useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
|
|
1514
1508
|
var _c = React.useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
|
|
1515
|
-
var handleSubmitCredentials = React.
|
|
1516
|
-
var
|
|
1509
|
+
var handleSubmitCredentials = React.useCallback(function (CredentialsAuthEndpoint, credentials) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1510
|
+
var authenticator, response, error_2;
|
|
1517
1511
|
return __generator$1(this, function (_a) {
|
|
1518
1512
|
switch (_a.label) {
|
|
1519
1513
|
case 0:
|
|
1520
1514
|
_a.trys.push([0, 2, 3, 4]);
|
|
1521
1515
|
setLoading(true);
|
|
1522
|
-
|
|
1523
|
-
|
|
1516
|
+
setAttemptCount(function (prev) {
|
|
1517
|
+
var currentAttempt = prev + 1;
|
|
1518
|
+
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
1519
|
+
setIsMaxAttemptsReached(true);
|
|
1520
|
+
}
|
|
1521
|
+
return currentAttempt;
|
|
1522
|
+
});
|
|
1524
1523
|
authenticator = new camsSdk.CAMSMFAAuthenticator();
|
|
1525
1524
|
return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
|
|
1526
1525
|
case 1:
|
|
@@ -1530,24 +1529,12 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1530
1529
|
return [2 /*return*/, true];
|
|
1531
1530
|
}
|
|
1532
1531
|
else {
|
|
1533
|
-
|
|
1534
|
-
setIsMaxAttemptsReached(true);
|
|
1535
|
-
onAuthComplete(false, {
|
|
1536
|
-
message: "Maximum attempts reached",
|
|
1537
|
-
});
|
|
1538
|
-
}
|
|
1539
|
-
else {
|
|
1540
|
-
onAuthComplete(false, response.response.data);
|
|
1541
|
-
}
|
|
1532
|
+
onAuthComplete(false, response.response.data);
|
|
1542
1533
|
return [2 /*return*/, false];
|
|
1543
1534
|
}
|
|
1544
1535
|
case 2:
|
|
1545
1536
|
error_2 = _a.sent();
|
|
1546
1537
|
console.error(error_2);
|
|
1547
|
-
currentAttempt = attemptCount + 1;
|
|
1548
|
-
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
1549
|
-
setIsMaxAttemptsReached(true);
|
|
1550
|
-
}
|
|
1551
1538
|
onAuthComplete(false, error_2.response.data);
|
|
1552
1539
|
return [2 /*return*/, false];
|
|
1553
1540
|
case 3:
|
|
@@ -1556,7 +1543,7 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1556
1543
|
case 4: return [2 /*return*/];
|
|
1557
1544
|
}
|
|
1558
1545
|
});
|
|
1559
|
-
}); }
|
|
1546
|
+
}); }, [onAuthComplete]);
|
|
1560
1547
|
return {
|
|
1561
1548
|
handleSubmitCredentials: handleSubmitCredentials,
|
|
1562
1549
|
loading: loading,
|
|
@@ -1827,15 +1814,20 @@ var DefaultLoginPage = function (_a) {
|
|
|
1827
1814
|
}, disabled: isLoading, children: [jsxRuntime.jsx(lucideReact.KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsxRuntime.jsx("span", { children: "Create a Passkey" })] }))] }), jsxRuntime.jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsxRuntime.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsxRuntime.jsx("span", { children: "Powered By NIBSS" })] })] }) }) }, "landing"), jsxRuntime.jsx(ADLoginModal, { open: showADModal, onOpenChange: setShowADModal, isLoading: context.isLoading || isCredAuthLoading, setIsLoading: setIsCredAuthLoading, onLogin: function (_a) { return __awaiter$1(void 0, [_a], void 0, function (_b) {
|
|
1828
1815
|
var username = _b.username, password = _b.password, MFACode = _b.MFACode;
|
|
1829
1816
|
return __generator$1(this, function (_c) {
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1817
|
+
switch (_c.label) {
|
|
1818
|
+
case 0:
|
|
1819
|
+
// Implement your AD login logic here
|
|
1820
|
+
console.log("AD Login:", { username: username, MFACode: MFACode });
|
|
1821
|
+
return [4 /*yield*/, handleSubmitCredentials(CredentialsAuthEndpoint, {
|
|
1822
|
+
username: username,
|
|
1823
|
+
password: password,
|
|
1824
|
+
MFACode: MFACode,
|
|
1825
|
+
appCode: context.appCode,
|
|
1826
|
+
})];
|
|
1827
|
+
case 1:
|
|
1828
|
+
_c.sent();
|
|
1829
|
+
return [2 /*return*/];
|
|
1830
|
+
}
|
|
1839
1831
|
});
|
|
1840
1832
|
}); } })] }));
|
|
1841
1833
|
};
|