@nibssplc/cams-sdk-react 1.0.0-rc.104 → 1.0.0-rc.106
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 +26 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +26 -28
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1506,15 +1506,20 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1506
1506
|
var _a = React.useState(false), loading = _a[0], setLoading = _a[1];
|
|
1507
1507
|
var _b = React.useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
|
|
1508
1508
|
var _c = React.useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
|
|
1509
|
-
var handleSubmitCredentials = React.
|
|
1510
|
-
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;
|
|
1511
1511
|
return __generator$1(this, function (_a) {
|
|
1512
1512
|
switch (_a.label) {
|
|
1513
1513
|
case 0:
|
|
1514
1514
|
_a.trys.push([0, 2, 3, 4]);
|
|
1515
1515
|
setLoading(true);
|
|
1516
|
-
|
|
1517
|
-
|
|
1516
|
+
setAttemptCount(function (prev) {
|
|
1517
|
+
var currentAttempt = prev + 1;
|
|
1518
|
+
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
1519
|
+
setIsMaxAttemptsReached(true);
|
|
1520
|
+
}
|
|
1521
|
+
return currentAttempt;
|
|
1522
|
+
});
|
|
1518
1523
|
authenticator = new camsSdk.CAMSMFAAuthenticator();
|
|
1519
1524
|
return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
|
|
1520
1525
|
case 1:
|
|
@@ -1524,25 +1529,13 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1524
1529
|
return [2 /*return*/, true];
|
|
1525
1530
|
}
|
|
1526
1531
|
else {
|
|
1527
|
-
|
|
1528
|
-
setIsMaxAttemptsReached(true);
|
|
1529
|
-
onAuthComplete(false, {
|
|
1530
|
-
message: "Maximum attempts reached",
|
|
1531
|
-
});
|
|
1532
|
-
}
|
|
1533
|
-
else {
|
|
1534
|
-
onAuthComplete(false, response.response.data);
|
|
1535
|
-
}
|
|
1532
|
+
onAuthComplete(false, response);
|
|
1536
1533
|
return [2 /*return*/, false];
|
|
1537
1534
|
}
|
|
1538
1535
|
case 2:
|
|
1539
1536
|
error_2 = _a.sent();
|
|
1540
1537
|
console.error(error_2);
|
|
1541
|
-
|
|
1542
|
-
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
1543
|
-
setIsMaxAttemptsReached(true);
|
|
1544
|
-
}
|
|
1545
|
-
onAuthComplete(false, error_2.response.data);
|
|
1538
|
+
onAuthComplete(false, error_2);
|
|
1546
1539
|
return [2 /*return*/, false];
|
|
1547
1540
|
case 3:
|
|
1548
1541
|
setLoading(false);
|
|
@@ -1550,7 +1543,7 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1550
1543
|
case 4: return [2 /*return*/];
|
|
1551
1544
|
}
|
|
1552
1545
|
});
|
|
1553
|
-
}); }
|
|
1546
|
+
}); }, [onAuthComplete]);
|
|
1554
1547
|
return {
|
|
1555
1548
|
handleSubmitCredentials: handleSubmitCredentials,
|
|
1556
1549
|
loading: loading,
|
|
@@ -1821,15 +1814,20 @@ var DefaultLoginPage = function (_a) {
|
|
|
1821
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) {
|
|
1822
1815
|
var username = _b.username, password = _b.password, MFACode = _b.MFACode;
|
|
1823
1816
|
return __generator$1(this, function (_c) {
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
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
|
+
}
|
|
1833
1831
|
});
|
|
1834
1832
|
}); } })] }));
|
|
1835
1833
|
};
|