@nibssplc/cams-sdk-react 1.0.0-rc.16 → 1.0.0-rc.18
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/hooks/useCAMSMSALAuth.d.ts +2 -0
- package/dist/index.cjs.js +10 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +10 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
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
|
};
|
|
@@ -540,7 +541,7 @@ function useCAMSMSALAuth(options) {
|
|
|
540
541
|
case 4: return [2 /*return*/];
|
|
541
542
|
}
|
|
542
543
|
});
|
|
543
|
-
}); }, [instance, scopes, options, inProgress]);
|
|
544
|
+
}); }, [instance, scopes, options.prompt, options.appCode, options.MFAEndpoint, options.onAuthSuccess, options.onAuthError, storageKey, inProgress]);
|
|
544
545
|
var completeMFA = useCallback(function (data) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
545
546
|
return __generator$1(this, function (_a) {
|
|
546
547
|
if (!mfaAuthenticator) {
|
|
@@ -556,7 +557,7 @@ function useCAMSMSALAuth(options) {
|
|
|
556
557
|
accessToken: accessToken,
|
|
557
558
|
idToken: idToken,
|
|
558
559
|
}));
|
|
559
|
-
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);
|
|
560
561
|
setRequiresMFA(false);
|
|
561
562
|
// Set requiresMFA to false after storage update
|
|
562
563
|
Logger.debug("MFA completed successfully, storage updated", {
|
|
@@ -575,7 +576,7 @@ function useCAMSMSALAuth(options) {
|
|
|
575
576
|
}
|
|
576
577
|
return [2 /*return*/];
|
|
577
578
|
});
|
|
578
|
-
}); }, [mfaAuthenticator, accessToken, idToken, storageKey]);
|
|
579
|
+
}); }, [mfaAuthenticator, accessToken, idToken, storageKey, options.activeCookiePeriod]);
|
|
579
580
|
var sendEmailOTP = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
580
581
|
return __generator$1(this, function (_a) {
|
|
581
582
|
switch (_a.label) {
|
|
@@ -632,6 +633,7 @@ function useCAMSMSALAuth(options) {
|
|
|
632
633
|
completeMFA: completeMFA,
|
|
633
634
|
sendEmailOTP: sendEmailOTP,
|
|
634
635
|
setRequiresMFA: setRequiresMFA,
|
|
636
|
+
activeCookiePeriod: options.activeCookiePeriod || 1,
|
|
635
637
|
};
|
|
636
638
|
}
|
|
637
639
|
|
|
@@ -1225,7 +1227,9 @@ function ProtectedRoute(_a) {
|
|
|
1225
1227
|
|
|
1226
1228
|
var CAMSMSALContext = createContext(null);
|
|
1227
1229
|
var setCookie = function (name, value, days) {
|
|
1230
|
+
if (days === void 0) { days = 1; }
|
|
1228
1231
|
var expires = new Date(Date.now() + days * 864e5).toUTCString();
|
|
1232
|
+
Logger.debug("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
|
|
1229
1233
|
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
|
|
1230
1234
|
};
|
|
1231
1235
|
var getCookie = function (name) {
|
|
@@ -1298,7 +1302,7 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1298
1302
|
useEffect(function () {
|
|
1299
1303
|
if (typeof window !== "undefined") {
|
|
1300
1304
|
if (userProfile) {
|
|
1301
|
-
setCookie(profileStorageKey, JSON.stringify(userProfile),
|
|
1305
|
+
setCookie(profileStorageKey, JSON.stringify(userProfile), auth.activeCookiePeriod); // Store for 1 day
|
|
1302
1306
|
}
|
|
1303
1307
|
else {
|
|
1304
1308
|
deleteCookie(profileStorageKey);
|
|
@@ -1449,7 +1453,8 @@ function CAMSProviderCore(props) {
|
|
|
1449
1453
|
userProfile,
|
|
1450
1454
|
]);
|
|
1451
1455
|
var value = useMemo(function () {
|
|
1452
|
-
|
|
1456
|
+
auth.logout; var authRest = __rest(auth, ["logout"]);
|
|
1457
|
+
return __assign(__assign({}, authRest), { logout: enhancedLogout, userProfile: userProfile, setUserProfile: setUserProfile, authMode: mode });
|
|
1453
1458
|
}, [auth, userProfile, mode]);
|
|
1454
1459
|
return jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children });
|
|
1455
1460
|
}
|