@nibssplc/cams-sdk-react 1.0.0-rc.15 → 1.0.0-rc.17
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.esm.js
CHANGED
|
@@ -362,6 +362,7 @@ function useCAMSAuth(options) {
|
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
var setCookie$1 = function (name, value, days) {
|
|
365
|
+
if (days === void 0) { days = 1; }
|
|
365
366
|
var expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
|
|
366
367
|
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
|
|
367
368
|
};
|
|
@@ -471,6 +472,10 @@ function useCAMSMSALAuth(options) {
|
|
|
471
472
|
return __generator$1(this, function (_e) {
|
|
472
473
|
switch (_e.label) {
|
|
473
474
|
case 0:
|
|
475
|
+
if (inProgress !== InteractionStatus.None) {
|
|
476
|
+
Logger.warn("Authentication already in progress, ignoring duplicate call");
|
|
477
|
+
return [2 /*return*/];
|
|
478
|
+
}
|
|
474
479
|
setError(null);
|
|
475
480
|
_e.label = 1;
|
|
476
481
|
case 1:
|
|
@@ -510,6 +515,11 @@ function useCAMSMSALAuth(options) {
|
|
|
510
515
|
return [3 /*break*/, 4];
|
|
511
516
|
case 3:
|
|
512
517
|
err_1 = _e.sent();
|
|
518
|
+
// Handle interaction_in_progress error
|
|
519
|
+
if (err_1.errorCode === "interaction_in_progress") {
|
|
520
|
+
Logger.warn("Interaction already in progress, please wait");
|
|
521
|
+
return [2 /*return*/];
|
|
522
|
+
}
|
|
513
523
|
// Handle user cancellation gracefully
|
|
514
524
|
if (err_1.errorCode === "user_cancelled") {
|
|
515
525
|
Logger.error("User cancelled login");
|
|
@@ -531,7 +541,7 @@ function useCAMSMSALAuth(options) {
|
|
|
531
541
|
case 4: return [2 /*return*/];
|
|
532
542
|
}
|
|
533
543
|
});
|
|
534
|
-
}); }, [instance, scopes, options]);
|
|
544
|
+
}); }, [instance, scopes, options, inProgress]);
|
|
535
545
|
var completeMFA = useCallback(function (data) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
536
546
|
return __generator$1(this, function (_a) {
|
|
537
547
|
if (!mfaAuthenticator) {
|
|
@@ -547,7 +557,7 @@ function useCAMSMSALAuth(options) {
|
|
|
547
557
|
accessToken: accessToken,
|
|
548
558
|
idToken: idToken,
|
|
549
559
|
}));
|
|
550
|
-
setCookie$1("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }),
|
|
560
|
+
setCookie$1("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }), options.activeCookiePeriod);
|
|
551
561
|
setRequiresMFA(false);
|
|
552
562
|
// Set requiresMFA to false after storage update
|
|
553
563
|
Logger.debug("MFA completed successfully, storage updated", {
|
|
@@ -1216,7 +1226,9 @@ function ProtectedRoute(_a) {
|
|
|
1216
1226
|
|
|
1217
1227
|
var CAMSMSALContext = createContext(null);
|
|
1218
1228
|
var setCookie = function (name, value, days) {
|
|
1229
|
+
if (days === void 0) { days = 1; }
|
|
1219
1230
|
var expires = new Date(Date.now() + days * 864e5).toUTCString();
|
|
1231
|
+
Logger.debug("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
|
|
1220
1232
|
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
|
|
1221
1233
|
};
|
|
1222
1234
|
var getCookie = function (name) {
|
|
@@ -1289,7 +1301,7 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1289
1301
|
useEffect(function () {
|
|
1290
1302
|
if (typeof window !== "undefined") {
|
|
1291
1303
|
if (userProfile) {
|
|
1292
|
-
setCookie(profileStorageKey, JSON.stringify(userProfile),
|
|
1304
|
+
setCookie(profileStorageKey, JSON.stringify(userProfile), authOptions.activeCookiePeriod); // Store for 1 day
|
|
1293
1305
|
}
|
|
1294
1306
|
else {
|
|
1295
1307
|
deleteCookie(profileStorageKey);
|
|
@@ -1440,7 +1452,8 @@ function CAMSProviderCore(props) {
|
|
|
1440
1452
|
userProfile,
|
|
1441
1453
|
]);
|
|
1442
1454
|
var value = useMemo(function () {
|
|
1443
|
-
|
|
1455
|
+
auth.logout; var authRest = __rest(auth, ["logout"]);
|
|
1456
|
+
return __assign(__assign({}, authRest), { logout: enhancedLogout, userProfile: userProfile, setUserProfile: setUserProfile, authMode: mode });
|
|
1444
1457
|
}, [auth, userProfile, mode]);
|
|
1445
1458
|
return jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children });
|
|
1446
1459
|
}
|