@nibssplc/cams-sdk-react 1.0.0-rc.46 → 1.0.0-rc.48
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 +18 -4
- package/dist/components/MFAGate.d.ts +2 -1
- package/dist/components/UnifiedCAMSProvider.d.ts +5 -0
- package/dist/context/CAMSContext.d.ts +5 -0
- package/dist/hooks/useCAMSMSALAuth.d.ts +0 -5
- package/dist/index.cjs.js +26 -50
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +26 -50
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +3 -0
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -413,7 +413,7 @@ var deleteCookie = function (name) {
|
|
|
413
413
|
|
|
414
414
|
function useCAMSMSALAuth(options) {
|
|
415
415
|
var _this = this;
|
|
416
|
-
var optStorageKey = options.storageKey, optScopes = options.scopes, prompt = options.prompt, appCode = options.appCode, MFAEndpoint = options.MFAEndpoint,
|
|
416
|
+
var optStorageKey = options.storageKey, optScopes = options.scopes, prompt = options.prompt, appCode = options.appCode, MFAEndpoint = options.MFAEndpoint, _a = options.activeCookiePeriod, activeCookiePeriod = _a === void 0 ? 1 : _a;
|
|
417
417
|
var storageKey = optStorageKey || "CAMS-MSAL-AUTH-SDK";
|
|
418
418
|
var _b = useMsal(), instance = _b.instance, inProgress = _b.inProgress, accounts = _b.accounts;
|
|
419
419
|
var account = useAccount(accounts[0] || {});
|
|
@@ -542,10 +542,6 @@ function useCAMSMSALAuth(options) {
|
|
|
542
542
|
idToken: response.idToken,
|
|
543
543
|
}));
|
|
544
544
|
}
|
|
545
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess({
|
|
546
|
-
accessToken: response.accessToken,
|
|
547
|
-
idToken: response.idToken,
|
|
548
|
-
});
|
|
549
545
|
return [3 /*break*/, 4];
|
|
550
546
|
case 3:
|
|
551
547
|
err_1 = _b.sent();
|
|
@@ -565,12 +561,10 @@ function useCAMSMSALAuth(options) {
|
|
|
565
561
|
((_a = err_1.message) === null || _a === void 0 ? void 0 : _a.includes("popup"))) {
|
|
566
562
|
camsError_1 = new CAMSError(CAMSErrorType.POPUP_BLOCKED, "Popup blocked by browser. Please allow popups and try again.");
|
|
567
563
|
setError(camsError_1);
|
|
568
|
-
onAuthError === null || onAuthError === void 0 ? void 0 : onAuthError(camsError_1);
|
|
569
564
|
return [2 /*return*/];
|
|
570
565
|
}
|
|
571
566
|
camsError = new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "Login failed: " + err_1.message || err_1);
|
|
572
567
|
setError(camsError);
|
|
573
|
-
onAuthError === null || onAuthError === void 0 ? void 0 : onAuthError(camsError);
|
|
574
568
|
return [3 /*break*/, 4];
|
|
575
569
|
case 4: return [2 /*return*/];
|
|
576
570
|
}
|
|
@@ -581,8 +575,6 @@ function useCAMSMSALAuth(options) {
|
|
|
581
575
|
prompt,
|
|
582
576
|
appCode,
|
|
583
577
|
MFAEndpoint,
|
|
584
|
-
onAuthSuccess,
|
|
585
|
-
onAuthError,
|
|
586
578
|
storageKey,
|
|
587
579
|
inProgress,
|
|
588
580
|
]);
|
|
@@ -1475,8 +1467,8 @@ function CAMSProviderCore(props) {
|
|
|
1475
1467
|
]);
|
|
1476
1468
|
var value = useMemo(function () {
|
|
1477
1469
|
auth.logout; var authRest = __rest(auth, ["logout"]);
|
|
1478
|
-
return __assign(__assign({}, authRest), { logout: enhancedLogout, userProfile: userProfile, setUserProfile: setUserProfile, authMode: mode });
|
|
1479
|
-
}, [auth, userProfile, mode]);
|
|
1470
|
+
return __assign(__assign({}, authRest), { logout: enhancedLogout, userProfile: userProfile, setUserProfile: setUserProfile, authMode: mode, onAuthSuccess: mode === "MSAL" ? props.onAuthSuccess : undefined, onAuthError: mode === "MSAL" ? props.onAuthError : undefined });
|
|
1471
|
+
}, [auth, userProfile, mode, props]);
|
|
1480
1472
|
return jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children });
|
|
1481
1473
|
}
|
|
1482
1474
|
function UnifiedCAMSProvider(props) {
|
|
@@ -1823,36 +1815,6 @@ function DialogTitle(_a) {
|
|
|
1823
1815
|
|
|
1824
1816
|
var a="container_f782f4",i="inner_37f4c9",c="bar_409d0f";const r=({size:r=35,color:l="black",speed:d=1,stroke:o=3.5})=>jsxRuntimeExports.jsx("div",{className:a,style:{"--uib-size":r+"px","--uib-color":l,"--uib-speed":d+"s","--uib-stroke":o+"px"},children:jsxRuntimeExports.jsxs("div",{className:i,children:[jsxRuntimeExports.jsx("div",{className:c}),jsxRuntimeExports.jsx("div",{className:c}),jsxRuntimeExports.jsx("div",{className:c}),jsxRuntimeExports.jsx("div",{className:c})]})});
|
|
1825
1817
|
|
|
1826
|
-
function styleInject(css, ref) {
|
|
1827
|
-
if ( ref === void 0 ) ref = {};
|
|
1828
|
-
var insertAt = ref.insertAt;
|
|
1829
|
-
|
|
1830
|
-
if (typeof document === 'undefined') { return; }
|
|
1831
|
-
|
|
1832
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
1833
|
-
var style = document.createElement('style');
|
|
1834
|
-
style.type = 'text/css';
|
|
1835
|
-
|
|
1836
|
-
if (insertAt === 'top') {
|
|
1837
|
-
if (head.firstChild) {
|
|
1838
|
-
head.insertBefore(style, head.firstChild);
|
|
1839
|
-
} else {
|
|
1840
|
-
head.appendChild(style);
|
|
1841
|
-
}
|
|
1842
|
-
} else {
|
|
1843
|
-
head.appendChild(style);
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
if (style.styleSheet) {
|
|
1847
|
-
style.styleSheet.cssText = css;
|
|
1848
|
-
} else {
|
|
1849
|
-
style.appendChild(document.createTextNode(css));
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
var css_248z = ".container_f782f4 {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n height: calc(var(--uib-size) * 0.9);\n width: var(--uib-size);\n}\n\n.inner_37f4c9 {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: var(--uib-size);\n height: calc(var(--uib-size) * 0.9);\n}\n\n.bar_409d0f {\n width: var(--uib-stroke);\n height: 100%;\n background-color: var(--uib-color);\n transition: background-color 0.3s ease;\n}\n\n.bar_409d0f:nth-child(1) {\n animation: grow_ca6a4e var(--uib-speed) ease-in-out calc(var(--uib-speed) * -0.45) infinite;\n}\n\n.bar_409d0f:nth-child(2) {\n animation: grow_ca6a4e var(--uib-speed) ease-in-out calc(var(--uib-speed) * -0.3) infinite;\n}\n\n.bar_409d0f:nth-child(3) {\n animation: grow_ca6a4e var(--uib-speed) ease-in-out calc(var(--uib-speed) * -0.15) infinite;\n}\n\n.bar_409d0f:nth-child(4) {\n animation: grow_ca6a4e var(--uib-speed) ease-in-out infinite;\n}\n\n@keyframes grow_ca6a4e {\n 0%, 100% {\n transform: scaleY(0.3);\n }\n 50% {\n transform: scaleY(1);\n }\n}";
|
|
1854
|
-
styleInject(css_248z);
|
|
1855
|
-
|
|
1856
1818
|
var LoadingSpinner = function (_a) {
|
|
1857
1819
|
var loadingText = _a.loadingText;
|
|
1858
1820
|
return (jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-center items-center h-full w-full py-10", children: [jsxRuntimeExports.jsx("script", { type: "module", defer: true, src: "https://cdn.jsdelivr.net/npm/ldrs/dist/auto/waveform.js" }), jsxRuntimeExports.jsx(r, { size: "35", stroke: "3.5", speed: "1", color: "green" }), loadingText && (jsxRuntimeExports.jsx("p", { className: "text-center font-semibold mt-3", children: "Loading..." }))] }));
|
|
@@ -2427,7 +2389,7 @@ var MFAGate = function (_a) {
|
|
|
2427
2389
|
// loginComponent: LoginComponent = DefaultLoginPage,
|
|
2428
2390
|
_c = _a.usePassKey,
|
|
2429
2391
|
// loginComponent: LoginComponent = DefaultLoginPage,
|
|
2430
|
-
usePassKey = _c === void 0 ? false : _c, _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints;
|
|
2392
|
+
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;
|
|
2431
2393
|
var context = useCAMSContext();
|
|
2432
2394
|
var validatedMFAEndpoints = useMemo(function () {
|
|
2433
2395
|
var parsed = MFAEndpointsSchema.safeParse(MFAEndpoints);
|
|
@@ -2438,19 +2400,32 @@ var MFAGate = function (_a) {
|
|
|
2438
2400
|
return parsed.data;
|
|
2439
2401
|
}, [MFAEndpoints]);
|
|
2440
2402
|
var handleComplete = useCallback(function (success) {
|
|
2441
|
-
|
|
2403
|
+
var _a;
|
|
2404
|
+
if (success && context.authMode === "MSAL") {
|
|
2405
|
+
(_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, {
|
|
2406
|
+
accessToken: context.accessToken,
|
|
2407
|
+
idToken: context.idToken,
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
else if (!success) {
|
|
2442
2411
|
Logger.error("MFA authentication failed");
|
|
2443
|
-
|
|
2412
|
+
}
|
|
2413
|
+
}, [context]);
|
|
2444
2414
|
var handleAuthFailed = useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2415
|
+
var _a;
|
|
2416
|
+
return __generator$1(this, function (_b) {
|
|
2417
|
+
switch (_b.label) {
|
|
2418
|
+
case 0:
|
|
2419
|
+
if (context.authMode === "MSAL" && context.error) {
|
|
2420
|
+
(_a = context.onAuthError) === null || _a === void 0 ? void 0 : _a.call(context, context.error);
|
|
2421
|
+
}
|
|
2422
|
+
return [4 /*yield*/, context.logout()];
|
|
2448
2423
|
case 1:
|
|
2449
|
-
|
|
2424
|
+
_b.sent();
|
|
2450
2425
|
return [2 /*return*/];
|
|
2451
2426
|
}
|
|
2452
2427
|
});
|
|
2453
|
-
}); }, [context
|
|
2428
|
+
}); }, [context]);
|
|
2454
2429
|
if (useADLogin && !CredentialsAuthEndpoint)
|
|
2455
2430
|
return jsxRuntimeExports.jsx(ErrorFallback, { message: "Invalid AD Login Configuration." });
|
|
2456
2431
|
if (!validatedMFAEndpoints)
|
|
@@ -2459,7 +2434,8 @@ var MFAGate = function (_a) {
|
|
|
2459
2434
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
2460
2435
|
if (context.isLoading)
|
|
2461
2436
|
return fallback;
|
|
2462
|
-
|
|
2437
|
+
var shouldRequireMFA = requiresMFA !== null && requiresMFA !== void 0 ? requiresMFA : context.requiresMFA;
|
|
2438
|
+
if (shouldRequireMFA) {
|
|
2463
2439
|
return (jsxRuntimeExports.jsx(MFAOptions, { MFAEndpoints: validatedMFAEndpoints, usePassKey: usePassKey, onComplete: handleComplete, onAuthFailed: handleAuthFailed }));
|
|
2464
2440
|
}
|
|
2465
2441
|
if (!context.isAuthenticated) {
|