@nibssplc/cams-sdk-react 0.0.1-beta.77 → 0.0.1-beta.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/README.md +295 -0
- package/dist/components/ADLoginModal.d.ts +7 -0
- package/dist/components/MFAOptions.d.ts +1 -1
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/hooks/useCAMSAuth.d.ts +2 -0
- package/dist/index.cjs.js +149 -48
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +149 -49
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -12,7 +12,7 @@ var resolvers = require('@hookform/resolvers');
|
|
|
12
12
|
var clsx = require('clsx');
|
|
13
13
|
var tailwindMerge = require('tailwind-merge');
|
|
14
14
|
var reactSlot = require('@radix-ui/react-slot');
|
|
15
|
-
require('@radix-ui/react-label');
|
|
15
|
+
var LabelPrimitive = require('@radix-ui/react-label');
|
|
16
16
|
var classVarianceAuthority = require('class-variance-authority');
|
|
17
17
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
18
18
|
var sonner = require('sonner');
|
|
@@ -37,6 +37,7 @@ function _interopNamespaceDefault(e) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
40
|
+
var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
|
|
40
41
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
|
|
41
42
|
|
|
42
43
|
/******************************************************************************
|
|
@@ -134,15 +135,17 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
134
135
|
|
|
135
136
|
function useCAMSAuth(options) {
|
|
136
137
|
var _this = this;
|
|
138
|
+
var _a;
|
|
137
139
|
if (options === void 0) { options = {
|
|
138
140
|
appCode: "",
|
|
141
|
+
loginExpiry: 1,
|
|
139
142
|
storageKey: "CAMS-AUTH-SDK",
|
|
140
143
|
}; }
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
var
|
|
144
|
+
var _b = React.useState(false), isAuthenticated = _b[0], setIsAuthenticated = _b[1];
|
|
145
|
+
var _c = React.useState(false), isLoading = _c[0], setIsLoading = _c[1];
|
|
146
|
+
var _d = React.useState(null), error = _d[0], setError = _d[1];
|
|
147
|
+
var _e = React.useState(""), token = _e[0], setToken = _e[1];
|
|
148
|
+
var _f = React.useState(null), profile = _f[0], setProfile = _f[1];
|
|
146
149
|
var sessionManagerRef = React.useRef(null);
|
|
147
150
|
React.useEffect(function () {
|
|
148
151
|
var _a, _b;
|
|
@@ -153,7 +156,7 @@ function useCAMSAuth(options) {
|
|
|
153
156
|
if (camsSdk.isPopupWindow()) {
|
|
154
157
|
camsSdk.initializePopupAuth();
|
|
155
158
|
}
|
|
156
|
-
(_a = sessionManagerRef.current) !== null && _a !== void 0 ? _a : (sessionManagerRef.current = new camsSdk.CAMSSessionManager(localStorage, options.storageKey || "CAMS-SDK", {
|
|
159
|
+
(_a = sessionManagerRef.current) !== null && _a !== void 0 ? _a : (sessionManagerRef.current = new camsSdk.CAMSSessionManager(localStorage, options.storageKey || "CAMS-AUTH-SDK", {
|
|
157
160
|
onAuthSuccess: function (res) {
|
|
158
161
|
var _a;
|
|
159
162
|
setToken(res.userProfile.tokens.Bearer);
|
|
@@ -189,40 +192,53 @@ function useCAMSAuth(options) {
|
|
|
189
192
|
}
|
|
190
193
|
}, [options.storageKey]);
|
|
191
194
|
var login = React.useCallback(function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
192
|
-
var loginConfig, userProfile, err_1;
|
|
193
|
-
var _a;
|
|
194
|
-
return __generator(this, function (
|
|
195
|
-
switch (
|
|
195
|
+
var loginConfig, userProfile, err_1, e, isPopupClosedError, restoredToken, userProfile;
|
|
196
|
+
var _a, _b, _c;
|
|
197
|
+
return __generator(this, function (_d) {
|
|
198
|
+
switch (_d.label) {
|
|
196
199
|
case 0:
|
|
197
200
|
if (!sessionManagerRef.current)
|
|
198
201
|
return [2 /*return*/];
|
|
199
202
|
setIsLoading(true);
|
|
200
203
|
setError(null);
|
|
201
|
-
|
|
204
|
+
_d.label = 1;
|
|
202
205
|
case 1:
|
|
203
|
-
|
|
204
|
-
loginConfig = __assign(__assign({}, config), {
|
|
205
|
-
// autoClose: options.autoClose ?? config.autoClose,
|
|
206
|
-
idleTimeout: (_a = options.idleTimeout) !== null && _a !== void 0 ? _a : config.idleTimeout });
|
|
206
|
+
_d.trys.push([1, 4, 8, 9]);
|
|
207
|
+
loginConfig = __assign(__assign({}, config), { idleTimeout: options.idleTimeout });
|
|
207
208
|
return [4 /*yield*/, sessionManagerRef.current.login(loginConfig)];
|
|
208
209
|
case 2:
|
|
209
|
-
|
|
210
|
+
_d.sent();
|
|
210
211
|
return [4 /*yield*/, sessionManagerRef.current.getProfile()];
|
|
211
212
|
case 3:
|
|
212
|
-
userProfile =
|
|
213
|
+
userProfile = _d.sent();
|
|
213
214
|
setProfile(userProfile);
|
|
214
|
-
return [3 /*break*/,
|
|
215
|
+
return [3 /*break*/, 9];
|
|
215
216
|
case 4:
|
|
216
|
-
err_1 =
|
|
217
|
+
err_1 = _d.sent();
|
|
218
|
+
e = err_1;
|
|
219
|
+
isPopupClosedError = ((_a = e === null || e === void 0 ? void 0 : e.message) === null || _a === void 0 ? void 0 : _a.includes("Authentication window was closed")) ||
|
|
220
|
+
(e === null || e === void 0 ? void 0 : e.error) === "Authentication window was closed";
|
|
221
|
+
if (!(isPopupClosedError && sessionManagerRef.current.isAuthenticated())) return [3 /*break*/, 6];
|
|
222
|
+
restoredToken = (_b = sessionManagerRef.current.getAccessToken()) !== null && _b !== void 0 ? _b : "";
|
|
223
|
+
setToken(restoredToken);
|
|
224
|
+
setIsAuthenticated(true);
|
|
225
|
+
return [4 /*yield*/, sessionManagerRef.current.getProfile()];
|
|
226
|
+
case 5:
|
|
227
|
+
userProfile = _d.sent();
|
|
228
|
+
setProfile(userProfile);
|
|
229
|
+
(_c = options.onAuthSuccess) === null || _c === void 0 ? void 0 : _c.call(options, restoredToken);
|
|
230
|
+
return [3 /*break*/, 7];
|
|
231
|
+
case 6:
|
|
217
232
|
setError(err_1);
|
|
218
233
|
setIsAuthenticated(false);
|
|
219
234
|
setToken("");
|
|
220
235
|
setProfile(null);
|
|
221
|
-
|
|
222
|
-
case
|
|
236
|
+
_d.label = 7;
|
|
237
|
+
case 7: return [3 /*break*/, 9];
|
|
238
|
+
case 8:
|
|
223
239
|
setIsLoading(false);
|
|
224
240
|
return [7 /*endfinally*/];
|
|
225
|
-
case
|
|
241
|
+
case 9: return [2 /*return*/];
|
|
226
242
|
}
|
|
227
243
|
});
|
|
228
244
|
}); }, [options.idleTimeout]);
|
|
@@ -251,8 +267,9 @@ function useCAMSAuth(options) {
|
|
|
251
267
|
error: error,
|
|
252
268
|
token: token,
|
|
253
269
|
profile: profile,
|
|
270
|
+
loginExpiry: (_a = options.loginExpiry) !== null && _a !== void 0 ? _a : 1,
|
|
254
271
|
appCode: options.appCode,
|
|
255
|
-
storageKey: options.storageKey || "CAMS-SDK",
|
|
272
|
+
storageKey: options.storageKey || "CAMS-AUTH-SDK",
|
|
256
273
|
};
|
|
257
274
|
}
|
|
258
275
|
|
|
@@ -1418,6 +1435,11 @@ function InputOTPSlot(_a) {
|
|
|
1418
1435
|
return (jsxRuntimeExports.jsxs("div", __assign({ "data-slot": "input-otp-slot", "data-active": isActive, className: cn("data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-12 w-12 items-center justify-center border-y border-r text-lg font-semibold shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]", className) }, props, { children: [char, hasFakeCaret && (jsxRuntimeExports.jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: jsxRuntimeExports.jsx("div", { className: "animate-caret-blink bg-foreground h-4 w-px duration-1000" }) }))] })));
|
|
1419
1436
|
}
|
|
1420
1437
|
|
|
1438
|
+
function Label(_a) {
|
|
1439
|
+
var className = _a.className, props = __rest(_a, ["className"]);
|
|
1440
|
+
return (jsxRuntimeExports.jsx(LabelPrimitive__namespace.Root, __assign({ "data-slot": "label", className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className) }, props)));
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1421
1443
|
var Form = reactHookForm.FormProvider;
|
|
1422
1444
|
var FormFieldContext = React__namespace.createContext({});
|
|
1423
1445
|
var FormField = function (_a) {
|
|
@@ -1442,6 +1464,11 @@ function FormItem(_a) {
|
|
|
1442
1464
|
var id = React__namespace.useId();
|
|
1443
1465
|
return (jsxRuntimeExports.jsx(FormItemContext.Provider, { value: { id: id }, children: jsxRuntimeExports.jsx("div", __assign({ "data-slot": "form-item", className: cn("grid gap-2", className) }, props)) }));
|
|
1444
1466
|
}
|
|
1467
|
+
function FormLabel(_a) {
|
|
1468
|
+
var className = _a.className, props = __rest(_a, ["className"]);
|
|
1469
|
+
var _b = useFormField(), error = _b.error, formItemId = _b.formItemId;
|
|
1470
|
+
return (jsxRuntimeExports.jsx(Label, __assign({ "data-slot": "form-label", "data-error": !!error, className: cn("data-[error=true]:text-destructive", className), htmlFor: formItemId }, props)));
|
|
1471
|
+
}
|
|
1445
1472
|
function FormControl(_a) {
|
|
1446
1473
|
var props = __rest(_a, []);
|
|
1447
1474
|
var _b = useFormField(), error = _b.error, formItemId = _b.formItemId, formDescriptionId = _b.formDescriptionId, formMessageId = _b.formMessageId;
|
|
@@ -1706,7 +1733,7 @@ var useOTPHandler = function (_a) {
|
|
|
1706
1733
|
});
|
|
1707
1734
|
}
|
|
1708
1735
|
else {
|
|
1709
|
-
onAuthComplete(false, response);
|
|
1736
|
+
onAuthComplete(false, response.response.data);
|
|
1710
1737
|
}
|
|
1711
1738
|
return [2 /*return*/, false];
|
|
1712
1739
|
}
|
|
@@ -1716,12 +1743,12 @@ var useOTPHandler = function (_a) {
|
|
|
1716
1743
|
currentAttempt = attemptCount + 1;
|
|
1717
1744
|
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
1718
1745
|
setIsMaxAttemptsReached(true);
|
|
1719
|
-
onAuthComplete(false, error_1);
|
|
1746
|
+
onAuthComplete(false, error_1.response.data);
|
|
1720
1747
|
}
|
|
1721
1748
|
else {
|
|
1722
|
-
onAuthComplete(false, error_1);
|
|
1749
|
+
onAuthComplete(false, error_1.response.data);
|
|
1723
1750
|
}
|
|
1724
|
-
onAuthComplete(false, error_1);
|
|
1751
|
+
onAuthComplete(false, error_1.response.data);
|
|
1725
1752
|
return [2 /*return*/, false];
|
|
1726
1753
|
case 4:
|
|
1727
1754
|
setLoading(false);
|
|
@@ -1759,16 +1786,15 @@ var MFAOptions = function (_a) {
|
|
|
1759
1786
|
var _d = React.useState(false), otpVisible = _d[0], setOtpVisible = _d[1];
|
|
1760
1787
|
var _e = React.useState(false), showSuccessAnimation = _e[0], setShowSuccessAnimation = _e[1];
|
|
1761
1788
|
var _f = React.useState(null), authType = _f[0], setAuthType = _f[1];
|
|
1762
|
-
var _g = React.useState(""); _g[0]; var setLastOTPCode = _g[1];
|
|
1763
1789
|
var context = useCAMSContext$1();
|
|
1764
|
-
var
|
|
1790
|
+
var _g = context.authMode === "MSAL" && "sendEmailOTP" in context
|
|
1765
1791
|
? context
|
|
1766
1792
|
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
1767
1793
|
return [2 /*return*/];
|
|
1768
|
-
}); }); } }, sendEmailOTP =
|
|
1794
|
+
}); }); } }, sendEmailOTP = _g.sendEmailOTP, completeMFA = _g.completeMFA, logout = _g.logout;
|
|
1769
1795
|
var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
|
|
1770
1796
|
var idToken = context.authMode === "MSAL" ? context.idToken : "";
|
|
1771
|
-
var
|
|
1797
|
+
var _h = useOTPHandler({
|
|
1772
1798
|
accessToken: accessToken || "",
|
|
1773
1799
|
idToken: idToken || "",
|
|
1774
1800
|
provider: "MSAL",
|
|
@@ -1786,11 +1812,11 @@ var MFAOptions = function (_a) {
|
|
|
1786
1812
|
});
|
|
1787
1813
|
}
|
|
1788
1814
|
setShowSuccessAnimation(true);
|
|
1789
|
-
sonner.toast.success(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4" }), jsxRuntimeExports.
|
|
1815
|
+
sonner.toast.success(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4" }), jsxRuntimeExports.jsxs("span", { children: ["Multi-Factor Authentication Successful. ", data === null || data === void 0 ? void 0 : data.message] })] }));
|
|
1790
1816
|
setTimeout(function () { return onComplete === null || onComplete === void 0 ? void 0 : onComplete(true); }, 2000);
|
|
1791
1817
|
}
|
|
1792
1818
|
else {
|
|
1793
|
-
sonner.toast.error(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldClose, { className: "w-4 h-4" }), jsxRuntimeExports.jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "
|
|
1819
|
+
sonner.toast.error(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldClose, { className: "w-4 h-4" }), jsxRuntimeExports.jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "Unable to Validate User. Please try again." })] }));
|
|
1794
1820
|
if (isMaxAttemptsReached) {
|
|
1795
1821
|
setTimeout(function () {
|
|
1796
1822
|
logout().then(function () {
|
|
@@ -1801,7 +1827,7 @@ var MFAOptions = function (_a) {
|
|
|
1801
1827
|
}
|
|
1802
1828
|
}
|
|
1803
1829
|
},
|
|
1804
|
-
}), handleSubmitOTP =
|
|
1830
|
+
}), handleSubmitOTP = _h.handleSubmitOTP, loading = _h.loading, setLoading = _h.setLoading, attemptCount = _h.attemptCount, remainingAttempts = _h.remainingAttempts, isMaxAttemptsReached = _h.isMaxAttemptsReached, resetAttempts = _h.resetAttempts;
|
|
1805
1831
|
var handleGoBack = function () {
|
|
1806
1832
|
setAuthType(null);
|
|
1807
1833
|
setOtpVisible(false);
|
|
@@ -1848,16 +1874,10 @@ var MFAOptions = function (_a) {
|
|
|
1848
1874
|
setAuthType(null);
|
|
1849
1875
|
setOtpVisible(false);
|
|
1850
1876
|
setValue("");
|
|
1851
|
-
}, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Email OTP" }) }), jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) {
|
|
1852
|
-
setLastOTPCode(code);
|
|
1853
|
-
return handleSubmitOTP(code);
|
|
1854
|
-
}, fieldName: "EmailOTP", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] })] }) }));
|
|
1877
|
+
}, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Email OTP" }) }), jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) { return handleSubmitOTP(code); }, fieldName: "EmailOTP", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] })] }) }));
|
|
1855
1878
|
}
|
|
1856
1879
|
else if (authType === "AuthenticatorCode") {
|
|
1857
|
-
content = (jsxRuntimeExports.jsx(Dialog, { open: otpVisible, onOpenChange: handleGoBack, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Authenticator App" }) }), loading ? (jsxRuntimeExports.jsx("div", { className: "p-3 h-full flex justify-center items-center", children: jsxRuntimeExports.jsx(LoadingSpinner, {}) })) : (jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(CardDescription, { className: "text-sm text-gray-600 text-center", children: "Enter the 6-digit Code from your Authenticator app" }), jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) {
|
|
1858
|
-
setLastOTPCode(code);
|
|
1859
|
-
return handleSubmitOTP(code);
|
|
1860
|
-
}, fieldName: "AuthenticatorCode", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] }))] }) }));
|
|
1880
|
+
content = (jsxRuntimeExports.jsx(Dialog, { open: otpVisible, onOpenChange: handleGoBack, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Authenticator App" }) }), loading ? (jsxRuntimeExports.jsx("div", { className: "p-3 h-full flex justify-center items-center", children: jsxRuntimeExports.jsx(LoadingSpinner, {}) })) : (jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(CardDescription, { className: "text-sm text-gray-600 text-center", children: "Enter the 6-digit Code from your Authenticator app" }), jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) { return handleSubmitOTP(code); }, fieldName: "AuthenticatorCode", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] }))] }) }));
|
|
1861
1881
|
}
|
|
1862
1882
|
return (jsxRuntimeExports.jsx("div", { className: "flex justify-center items-center h-dvh", children: jsxRuntimeExports.jsxs(Card, { className: "space-y-6 p-6 rounded-lg shadow-md", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx("div", { className: "flex justify-center items", children: jsxRuntimeExports.jsx("img", { src: OTPAuthenticationImg, alt: "NIBSS Logo", width: 365, height: 365 }) }), jsxRuntimeExports.jsx(CardTitle, { className: "text-3xl font-bold mb-6 text-center", children: "Two-Factor Authentication" }), jsxRuntimeExports.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." })] }), jsxRuntimeExports.jsx(CardContent, { children: content }), jsxRuntimeExports.jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsxRuntimeExports.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsxRuntimeExports.jsx("span", { children: "Powered By NIBSS" })] })] }) }));
|
|
1863
1883
|
};
|
|
@@ -1868,9 +1888,80 @@ var AuthLogo = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2
|
|
|
1868
1888
|
|
|
1869
1889
|
var MicrosoftLogo = "data:image/svg+xml,%3Csvg%20width%3D%2225%22%20height%3D%2225%22%20viewBox%3D%220%200%2025%2025%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20id%3D%22microsoft_svgrepo.com%22%3E%3Cpath%20id%3D%22Vector%22%20d%3D%22M20.75%2013.25H13.25V20.75H20.75V13.25Z%22%20fill%3D%22%23FEBA08%22%2F%3E%3Cpath%20id%3D%22Vector_2%22%20d%3D%22M11.75%2013.25H4.25V20.75H11.75V13.25Z%22%20fill%3D%22%2305A6F0%22%2F%3E%3Cpath%20id%3D%22Vector_3%22%20d%3D%22M20.75%204.25H13.25V11.75H20.75V4.25Z%22%20fill%3D%22%2380BC06%22%2F%3E%3Cpath%20id%3D%22Vector_4%22%20d%3D%22M11.75%204.25H4.25V11.75H11.75V4.25Z%22%20fill%3D%22%23F25325%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E";
|
|
1870
1890
|
|
|
1891
|
+
var Input = React__namespace.forwardRef(function (_a, ref) {
|
|
1892
|
+
var className = _a.className, type = _a.type, props = __rest(_a, ["className", "type"]);
|
|
1893
|
+
return (jsxRuntimeExports.jsx("input", __assign({ type: type, className: cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className), ref: ref }, props)));
|
|
1894
|
+
});
|
|
1895
|
+
Input.displayName = "Input";
|
|
1896
|
+
|
|
1897
|
+
var credentialsSchema = z.z.object({
|
|
1898
|
+
username: z.z.string().min(1, "Username is required"),
|
|
1899
|
+
password: z.z.string().min(1, "Password is required"),
|
|
1900
|
+
});
|
|
1901
|
+
var ADLoginModal = function (_a) {
|
|
1902
|
+
var open = _a.open, onOpenChange = _a.onOpenChange, onLogin = _a.onLogin;
|
|
1903
|
+
var _b = React.useState("credentials"), step = _b[0], setStep = _b[1];
|
|
1904
|
+
var _c = React.useState({ username: "", password: "" }), credentials = _c[0], setCredentials = _c[1];
|
|
1905
|
+
var _d = React.useState(""), mfaCode = _d[0], setMfaCode = _d[1];
|
|
1906
|
+
var _e = React.useState(false), isLoading = _e[0], setIsLoading = _e[1];
|
|
1907
|
+
var form = reactHookForm.useForm({
|
|
1908
|
+
resolver: a$1(credentialsSchema),
|
|
1909
|
+
defaultValues: { username: "", password: "" },
|
|
1910
|
+
});
|
|
1911
|
+
var handleCredentialsSubmit = function (values) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1912
|
+
return __generator(this, function (_a) {
|
|
1913
|
+
setCredentials(values);
|
|
1914
|
+
setStep("mfa");
|
|
1915
|
+
return [2 /*return*/];
|
|
1916
|
+
});
|
|
1917
|
+
}); };
|
|
1918
|
+
var handleMFASubmit = function (code) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1919
|
+
var error_1;
|
|
1920
|
+
return __generator(this, function (_a) {
|
|
1921
|
+
switch (_a.label) {
|
|
1922
|
+
case 0:
|
|
1923
|
+
setIsLoading(true);
|
|
1924
|
+
_a.label = 1;
|
|
1925
|
+
case 1:
|
|
1926
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
1927
|
+
return [4 /*yield*/, onLogin(credentials.username, credentials.password, code)];
|
|
1928
|
+
case 2:
|
|
1929
|
+
_a.sent();
|
|
1930
|
+
onOpenChange(false);
|
|
1931
|
+
setStep("credentials");
|
|
1932
|
+
form.reset();
|
|
1933
|
+
setMfaCode("");
|
|
1934
|
+
return [3 /*break*/, 5];
|
|
1935
|
+
case 3:
|
|
1936
|
+
error_1 = _a.sent();
|
|
1937
|
+
console.error("AD login failed:", error_1);
|
|
1938
|
+
return [3 /*break*/, 5];
|
|
1939
|
+
case 4:
|
|
1940
|
+
setIsLoading(false);
|
|
1941
|
+
return [7 /*endfinally*/];
|
|
1942
|
+
case 5: return [2 /*return*/];
|
|
1943
|
+
}
|
|
1944
|
+
});
|
|
1945
|
+
}); };
|
|
1946
|
+
var handleClose = function () {
|
|
1947
|
+
onOpenChange(false);
|
|
1948
|
+
setStep("credentials");
|
|
1949
|
+
form.reset();
|
|
1950
|
+
setMfaCode("");
|
|
1951
|
+
};
|
|
1952
|
+
return (jsxRuntimeExports.jsx(Dialog, { open: open, onOpenChange: handleClose, children: jsxRuntimeExports.jsxs(DialogContent, { className: "sm:max-w-md", children: [jsxRuntimeExports.jsx(DialogHeader, { children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(lucideReact.KeyIcon, { className: "w-5 h-5 text-[#506f4a]" }), jsxRuntimeExports.jsx(DialogTitle, { children: "Sign in with AD" })] }) }), step === "credentials" ? (jsxRuntimeExports.jsx(Form, __assign({}, form, { children: jsxRuntimeExports.jsxs("form", { onSubmit: form.handleSubmit(handleCredentialsSubmit), className: "space-y-4", children: [jsxRuntimeExports.jsx(FormField, { control: form.control, name: "username", render: function (_a) {
|
|
1953
|
+
var field = _a.field;
|
|
1954
|
+
return (jsxRuntimeExports.jsxs(FormItem, { children: [jsxRuntimeExports.jsx(FormLabel, { children: "Username" }), jsxRuntimeExports.jsx(FormControl, { children: jsxRuntimeExports.jsx(Input, __assign({ placeholder: "Enter your username" }, field)) }), jsxRuntimeExports.jsx(FormMessage, {})] }));
|
|
1955
|
+
} }), jsxRuntimeExports.jsx(FormField, { control: form.control, name: "password", render: function (_a) {
|
|
1956
|
+
var field = _a.field;
|
|
1957
|
+
return (jsxRuntimeExports.jsxs(FormItem, { children: [jsxRuntimeExports.jsx(FormLabel, { children: "Password" }), jsxRuntimeExports.jsx(FormControl, { children: jsxRuntimeExports.jsx(Input, __assign({ type: "password", placeholder: "Enter your password" }, field)) }), jsxRuntimeExports.jsx(FormMessage, {})] }));
|
|
1958
|
+
} }), jsxRuntimeExports.jsx(Button, { type: "submit", className: "w-full bg-[#506f4a] hover:bg-[#506f4a]/90", children: "Continue" })] }) }))) : (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsx(GenericOTPVerifier, { value: mfaCode, setValue: setMfaCode, setLoading: setIsLoading, isDisabled: isLoading, onChangeOTP: handleMFASubmit, fieldName: "AuthenticatorCode" }), isLoading && (jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(lucideReact.Loader2, { className: "w-4 h-4 animate-spin" }), jsxRuntimeExports.jsx("span", { children: "Verifying..." })] }))] }))] }) }));
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1871
1961
|
var DefaultLoginPage = function () {
|
|
1872
1962
|
var context = useCAMSContext$1();
|
|
1873
1963
|
var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
|
|
1964
|
+
var _a = React.useState(false), showADModal = _a[0], setShowADModal = _a[1];
|
|
1874
1965
|
var handleLogin = function () {
|
|
1875
1966
|
if (authMode === "MSAL") {
|
|
1876
1967
|
login();
|
|
@@ -1890,11 +1981,21 @@ var DefaultLoginPage = function () {
|
|
|
1890
1981
|
},
|
|
1891
1982
|
exit: { opacity: 0, scale: 0.8, y: -50, transition: { duration: 0.3 } },
|
|
1892
1983
|
};
|
|
1893
|
-
return (jsxRuntimeExports.
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1984
|
+
return (jsxRuntimeExports.jsxs("main", { className: "min-h-screen bg-gray-50", children: [jsxRuntimeExports.jsx(framerMotion.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.5 }, children: jsxRuntimeExports.jsx("div", { className: "flex h-screen items-center justify-center", children: jsxRuntimeExports.jsxs(framerMotion.motion.div, { variants: cardVariants, initial: "hidden", animate: "visible", exit: "exit", className: "w-full max-w-md p-6 space-y-4 bg-gray-50 rounded-2xl shadow-2xl --dark:bg-gray-800", children: [jsxRuntimeExports.jsxs(CardHeader, { className: "text-center space-y-3", children: [jsxRuntimeExports.jsx("div", { className: "w-full flex items-center justify-center", children: jsxRuntimeExports.jsx("img", { src: NIBSSLogo, alt: "NIBSS Logo", width: 265, height: 265 }) }), jsxRuntimeExports.jsx(CardTitle, { className: "text-3xl font-bold --text-gray-900 --dark:text-white", children: "NIBSS CAMS" }), jsxRuntimeExports.jsx(CardTitle, { className: "text-gray-500 dark:text-gray-400 font-bold text-lg", children: "Centralized Authentication" })] }), jsxRuntimeExports.jsxs(CardAction, { className: "w-full flex flex-col items-center justify-center text-center text-gray-500 dark:text-gray-400 mb-4", children: [jsxRuntimeExports.jsx("img", { src: AuthLogo, alt: "Auth Logo", width: 365, height: 365 }), "Kindly use the below identity providers to authenticate"] }), jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs(Button
|
|
1985
|
+
// variant="outline"
|
|
1986
|
+
, {
|
|
1987
|
+
// variant="outline"
|
|
1988
|
+
className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: handleLogin, disabled: isLoading, children: [jsxRuntimeExports.jsx("img", { src: MicrosoftLogo, alt: "Microsoft Logo", width: 35, height: 35 }), jsxRuntimeExports.jsx("span", { children: isLoading ? "Logging in..." : "Sign in with Microsoft" })] }), jsxRuntimeExports.jsxs(Button
|
|
1989
|
+
// variant="outline"
|
|
1990
|
+
, {
|
|
1991
|
+
// variant="outline"
|
|
1992
|
+
className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: function () { return setShowADModal(true); }, disabled: isLoading, children: [jsxRuntimeExports.jsx(lucideReact.KeyIcon, {}), jsxRuntimeExports.jsx("span", { children: isLoading ? "Logging in..." : "Sign in with AD" })] })] }), jsxRuntimeExports.jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsxRuntimeExports.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsxRuntimeExports.jsx("span", { children: "Powered By NIBSS" })] })] }) }) }, "landing"), jsxRuntimeExports.jsx(ADLoginModal, { open: showADModal, onOpenChange: setShowADModal, onLogin: function (username, password, mfaCode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1993
|
+
return __generator(this, function (_a) {
|
|
1994
|
+
// Implement your AD login logic here
|
|
1995
|
+
console.log("AD Login:", { username: username, password: password, mfaCode: mfaCode });
|
|
1996
|
+
return [2 /*return*/];
|
|
1997
|
+
});
|
|
1998
|
+
}); } })] }));
|
|
1898
1999
|
};
|
|
1899
2000
|
|
|
1900
2001
|
var ErrorFallback = function (_a) {
|