@nibssplc/cams-sdk-react 1.0.0-rc.107 → 1.0.0-rc.109
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/components/Loading.d.ts +2 -3
- package/dist/index.cjs.js +38 -32
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +38 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -17,6 +17,7 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
17
17
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
18
18
|
import { cva } from 'class-variance-authority';
|
|
19
19
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
20
|
+
import { newtonsCradle } from 'ldrs';
|
|
20
21
|
import { motion } from 'framer-motion';
|
|
21
22
|
|
|
22
23
|
/******************************************************************************
|
|
@@ -1195,7 +1196,7 @@ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
1195
1196
|
};
|
|
1196
1197
|
const parseAsync = /* @__PURE__*/ _parseAsync($ZodRealError);
|
|
1197
1198
|
|
|
1198
|
-
function t(r,e){try{var o=r();}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function i
|
|
1199
|
+
function t(r,e){try{var o=r();}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("invalid_union"===t.code&&t.errors.length>0){var u=t.errors[0][0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("invalid_union"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function a(o,a,u){if(void 0===u&&(u={}),function(r){return "_def"in r&&"object"==typeof r._def&&"typeName"in r._def}(o))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o["sync"===u.mode?"parse":"parseAsync"](n,a)).then(function(e){return c.shouldUseNativeValidation&&validateFieldsNatively({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return {values:{},errors:toNestErrors(s(r.errors,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return "_zod"in r&&"object"==typeof r._zod}(o))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve(("sync"===u.mode?parse:parseAsync)(o,s,a)).then(function(e){return f.shouldUseNativeValidation&&validateFieldsNatively({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof $ZodError}(r))return {values:{},errors:toNestErrors(i(r.issues,!f.shouldUseNativeValidation&&"all"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error("Invalid input: not a Zod schema")}
|
|
1199
1200
|
|
|
1200
1201
|
function cn() {
|
|
1201
1202
|
var inputs = [];
|
|
@@ -1311,7 +1312,7 @@ var GenericOTPVerifier = function (_a) {
|
|
|
1311
1312
|
}),
|
|
1312
1313
|
_b));
|
|
1313
1314
|
var form = useForm({
|
|
1314
|
-
resolver: a
|
|
1315
|
+
resolver: a(Schema),
|
|
1315
1316
|
defaultValues: (_c = {}, _c[fieldName] = "", _c),
|
|
1316
1317
|
});
|
|
1317
1318
|
return (jsxs(Card, { className: "relative rounded space-y-4 p-0 m-0 py-8 space-x-6", children: [jsxs(CardHeader, { className: "flex items-center justify-center flex-col gap-2 mt-2 text-center mb-8", children: [jsx("div", { className: "w-16 h-16 bg-gradient-to-br from-lime-400 via-green-500 to-emerald-600 rounded-xl flex items-center justify-center text-white text-2xl mb-6 group-hover:scale-110 transition-transform duration-300", children: jsx(RectangleEllipsis, {}) }), jsx(CardTitle, { className: "font-bold text-emerald-700 text-2xl", children: "One-Time-Password (OTP)" }), attemptCount > 0 && (jsx("div", { className: "text-sm mt-2 ".concat(isMaxAttemptsReached ? "text-red-600" : "text-orange-600"), children: isMaxAttemptsReached
|
|
@@ -1385,11 +1386,12 @@ function DialogTitle(_a) {
|
|
|
1385
1386
|
return (jsx(DialogPrimitive.Title, __assign({ "data-slot": "dialog-title", className: cn("text-lg leading-none font-semibold", className) }, props)));
|
|
1386
1387
|
}
|
|
1387
1388
|
|
|
1388
|
-
var
|
|
1389
|
-
|
|
1390
|
-
var LoadingSpinner = function (_a) {
|
|
1389
|
+
var LoadingScreen = function (_a) {
|
|
1391
1390
|
var loadingText = _a.loadingText;
|
|
1392
|
-
|
|
1391
|
+
useEffect(function () {
|
|
1392
|
+
newtonsCradle.register();
|
|
1393
|
+
}, []);
|
|
1394
|
+
return (jsxs("div", { className: "flex flex-col justify-center items-center h-full w-full py-10", children: [jsx("l-newtons-cradle", { size: 124, speed: 1.5, color: "green" }), loadingText ? (jsx("p", { className: "text-center font-semibold mt-3", children: loadingText })) : (jsx("p", { className: "text-center font-semibold mt-3", children: "Loading..." }))] }));
|
|
1393
1395
|
};
|
|
1394
1396
|
|
|
1395
1397
|
var AuthSuccessAnimation = function (_a) {
|
|
@@ -1403,8 +1405,8 @@ var useOTPHandler = function (_a) {
|
|
|
1403
1405
|
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
1404
1406
|
var _c = useState(0), attemptCount = _c[0], setAttemptCount = _c[1];
|
|
1405
1407
|
var _d = useState(false), isMaxAttemptsReached = _d[0], setIsMaxAttemptsReached = _d[1];
|
|
1406
|
-
var handleSubmitOTP =
|
|
1407
|
-
var currentAttempt, authentication, response, error_1
|
|
1408
|
+
var handleSubmitOTP = useCallback(function (authenticationValue) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1409
|
+
var currentAttempt, authentication, response, error_1;
|
|
1408
1410
|
return __generator$1(this, function (_a) {
|
|
1409
1411
|
switch (_a.label) {
|
|
1410
1412
|
case 0:
|
|
@@ -1416,10 +1418,15 @@ var useOTPHandler = function (_a) {
|
|
|
1416
1418
|
_a.sent();
|
|
1417
1419
|
return [2 /*return*/, false];
|
|
1418
1420
|
case 2:
|
|
1419
|
-
|
|
1421
|
+
currentAttempt = 0;
|
|
1422
|
+
_a.label = 3;
|
|
1423
|
+
case 3:
|
|
1424
|
+
_a.trys.push([3, 12, 14, 15]);
|
|
1420
1425
|
setLoading(true);
|
|
1421
|
-
|
|
1422
|
-
|
|
1426
|
+
setAttemptCount(function (prev) {
|
|
1427
|
+
currentAttempt = prev + 1;
|
|
1428
|
+
return currentAttempt;
|
|
1429
|
+
});
|
|
1423
1430
|
authentication = new CAMSMFAAuthenticator();
|
|
1424
1431
|
return [4 /*yield*/, authentication.VerifyMFAOTP({
|
|
1425
1432
|
appCode: appCode,
|
|
@@ -1427,46 +1434,45 @@ var useOTPHandler = function (_a) {
|
|
|
1427
1434
|
email: email,
|
|
1428
1435
|
MFACode: authenticationValue,
|
|
1429
1436
|
}, MFAEndpoint || "")];
|
|
1430
|
-
case
|
|
1437
|
+
case 4:
|
|
1431
1438
|
response = _a.sent();
|
|
1432
|
-
if (!response) return [3 /*break*/,
|
|
1439
|
+
if (!response) return [3 /*break*/, 6];
|
|
1433
1440
|
return [4 /*yield*/, onAuthComplete(true, response)];
|
|
1434
|
-
case
|
|
1441
|
+
case 5:
|
|
1435
1442
|
_a.sent();
|
|
1436
1443
|
return [2 /*return*/, true];
|
|
1437
|
-
case
|
|
1438
|
-
if (!(currentAttempt >= MAX_ATTEMPTS)) return [3 /*break*/,
|
|
1444
|
+
case 6:
|
|
1445
|
+
if (!(currentAttempt >= MAX_ATTEMPTS)) return [3 /*break*/, 8];
|
|
1439
1446
|
setIsMaxAttemptsReached(true);
|
|
1440
1447
|
return [4 /*yield*/, onAuthComplete(false, {
|
|
1441
1448
|
message: "Maximum Attempts Reached",
|
|
1442
1449
|
})];
|
|
1443
|
-
case
|
|
1450
|
+
case 7:
|
|
1444
1451
|
_a.sent();
|
|
1445
|
-
return [3 /*break*/,
|
|
1446
|
-
case
|
|
1447
|
-
case
|
|
1452
|
+
return [3 /*break*/, 10];
|
|
1453
|
+
case 8: return [4 /*yield*/, onAuthComplete(false, response)];
|
|
1454
|
+
case 9:
|
|
1448
1455
|
_a.sent();
|
|
1449
|
-
_a.label =
|
|
1450
|
-
case
|
|
1451
|
-
case
|
|
1452
|
-
case
|
|
1456
|
+
_a.label = 10;
|
|
1457
|
+
case 10: return [2 /*return*/, false];
|
|
1458
|
+
case 11: return [3 /*break*/, 15];
|
|
1459
|
+
case 12:
|
|
1453
1460
|
error_1 = _a.sent();
|
|
1454
1461
|
console.error(error_1);
|
|
1455
|
-
currentAttempt = attemptCount + 1;
|
|
1456
1462
|
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
1457
1463
|
setIsMaxAttemptsReached(true);
|
|
1458
1464
|
}
|
|
1459
1465
|
return [4 /*yield*/, onAuthComplete(false, error_1)];
|
|
1460
|
-
case
|
|
1466
|
+
case 13:
|
|
1461
1467
|
_a.sent();
|
|
1462
1468
|
return [2 /*return*/, false];
|
|
1463
|
-
case
|
|
1469
|
+
case 14:
|
|
1464
1470
|
setLoading(false);
|
|
1465
1471
|
return [7 /*endfinally*/];
|
|
1466
|
-
case
|
|
1472
|
+
case 15: return [2 /*return*/];
|
|
1467
1473
|
}
|
|
1468
1474
|
});
|
|
1469
|
-
}); }
|
|
1475
|
+
}); }, [onAuthComplete, MFAEndpoint, isMaxAttemptsReached, appCode, instCode, email]);
|
|
1470
1476
|
var resetAttempts = useCallback(function () {
|
|
1471
1477
|
setAttemptCount(0);
|
|
1472
1478
|
setIsMaxAttemptsReached(false);
|
|
@@ -1630,7 +1636,7 @@ var MFAOptions = function (_a) {
|
|
|
1630
1636
|
}, children: jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsx(DialogHeader, { className: "w-full", children: jsx(DialogTitle, { className: "text-center", children: "Email OTP" }) }), jsxs("div", { className: "space-y-6", children: [jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) { return handleSubmitOTP(code); }, fieldName: "EmailOTP", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] })] }) }));
|
|
1631
1637
|
}
|
|
1632
1638
|
else if (authType === "AuthenticatorCode") {
|
|
1633
|
-
content = (jsx(Dialog, { open: otpVisible, onOpenChange: handleGoBack, children: jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsx(DialogHeader, { className: "w-full", children: jsx(DialogTitle, { className: "text-center", children: "Authenticator App" }) }), loading ? (jsx("div", { className: "p-3 h-full flex justify-center items-center", children: jsx(
|
|
1639
|
+
content = (jsx(Dialog, { open: otpVisible, onOpenChange: handleGoBack, children: jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsx(DialogHeader, { className: "w-full", children: jsx(DialogTitle, { className: "text-center", children: "Authenticator App" }) }), loading ? (jsx("div", { className: "p-3 h-full flex justify-center items-center", children: jsx(LoadingScreen, {}) })) : (jsxs("div", { className: "space-y-6", children: [jsx(CardDescription, { className: "text-sm text-gray-600 text-center", children: "Enter the 6-digit Code from your Authenticator app" }), jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) { return handleSubmitOTP(code); }, fieldName: "AuthenticatorCode", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] }))] }) }));
|
|
1634
1640
|
}
|
|
1635
1641
|
return (jsx("div", { className: "cams-sdk flex justify-center items-center h-dvh", children: jsxs(Card, { className: "space-y-6 p-6 rounded-lg shadow-md", children: [jsxs(CardHeader, { children: [jsx("div", { className: "flex justify-center items", children: jsx("img", { src: OTPAuthenticationImg, alt: "NIBSS Logo", width: 265, height: 265 }) }), jsx(CardTitle, { className: "text-3xl font-bold mb-6 text-center", children: "Two-Factor Authentication" }), jsx(CardTitle, { className: "text-gray-300 text-base -tracking-wide text-center", children: "Your Microsoft account has been validated. Please complete two-factor authentication to continue." })] }), jsx(CardContent, { children: content }), jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsx(ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsx("span", { children: "Powered By NIBSS" })] })] }) }));
|
|
1636
1642
|
};
|
|
@@ -1661,7 +1667,7 @@ var ADLoginModal = function (_a) {
|
|
|
1661
1667
|
}), credentials = _d[0], setCredentials = _d[1];
|
|
1662
1668
|
var _e = useState(""), MFACode = _e[0], setMFACode = _e[1];
|
|
1663
1669
|
var form = useForm({
|
|
1664
|
-
resolver: a
|
|
1670
|
+
resolver: a(credentialsSchema),
|
|
1665
1671
|
defaultValues: { username: "", password: "" },
|
|
1666
1672
|
});
|
|
1667
1673
|
var handleCredentialsSubmit = function (values) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
@@ -1824,7 +1830,7 @@ var MFAEndpointsSchema = z$1.object({
|
|
|
1824
1830
|
AuthChallengeVerify: z$1.url("MFA AuthChallengeVerify must be a valid URL"),
|
|
1825
1831
|
});
|
|
1826
1832
|
var MFAGate = function (_a) {
|
|
1827
|
-
var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsx("div", { className: "h-screen flex items-center justify-center", children: jsx(
|
|
1833
|
+
var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsx("div", { className: "h-screen flex items-center justify-center", children: jsx(LoadingScreen, {}) })) : _b, _c = _a.usePassKey, usePassKey = _c === void 0 ? false : _c, _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError;
|
|
1828
1834
|
var context = useCAMSContext();
|
|
1829
1835
|
var _e = useState("Loading"), authState = _e[0], setAuthState = _e[1];
|
|
1830
1836
|
var ValidatedMFAEndpoints = useMemo(function () {
|