@nibssplc/cams-sdk-react 1.0.0-rc.16 → 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.
@@ -11,6 +11,7 @@ export interface CAMSMSALProviderProps extends UseCAMSMSALAuthOptions {
11
11
  children: React.ReactNode;
12
12
  msalConfig: Configuration;
13
13
  msalInstance?: PublicClientApplication;
14
+ activeCookiePeriod?: number;
14
15
  }
15
16
  export declare function CAMSMSALProvider(props: Readonly<CAMSMSALProviderProps>): import("react/jsx-runtime").JSX.Element;
16
17
  export declare function useCAMSMSALContext(): CAMSMSALContextValue;
@@ -11,6 +11,7 @@ export interface UseCAMSMSALAuthOptions {
11
11
  appCode: string;
12
12
  allowedOrigins?: string[];
13
13
  MFAEndpoint?: string;
14
+ activeCookiePeriod?: number;
14
15
  }
15
16
  export interface UseCAMSMSALAuthReturn {
16
17
  login: () => Promise<void>;
package/dist/index.cjs.js CHANGED
@@ -383,6 +383,7 @@ function useCAMSAuth(options) {
383
383
  }
384
384
 
385
385
  var setCookie$1 = function (name, value, days) {
386
+ if (days === void 0) { days = 1; }
386
387
  var expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
387
388
  document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
388
389
  };
@@ -577,7 +578,7 @@ function useCAMSMSALAuth(options) {
577
578
  accessToken: accessToken,
578
579
  idToken: idToken,
579
580
  }));
580
- setCookie$1("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }), 1);
581
+ setCookie$1("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }), options.activeCookiePeriod);
581
582
  setRequiresMFA(false);
582
583
  // Set requiresMFA to false after storage update
583
584
  camsSdk.Logger.debug("MFA completed successfully, storage updated", {
@@ -1246,7 +1247,9 @@ function ProtectedRoute(_a) {
1246
1247
 
1247
1248
  var CAMSMSALContext = React.createContext(null);
1248
1249
  var setCookie = function (name, value, days) {
1250
+ if (days === void 0) { days = 1; }
1249
1251
  var expires = new Date(Date.now() + days * 864e5).toUTCString();
1252
+ camsSdk.Logger.debug("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
1250
1253
  document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
1251
1254
  };
1252
1255
  var getCookie = function (name) {
@@ -1319,7 +1322,7 @@ function CAMSMSALProviderInner(_a) {
1319
1322
  React.useEffect(function () {
1320
1323
  if (typeof window !== "undefined") {
1321
1324
  if (userProfile) {
1322
- setCookie(profileStorageKey, JSON.stringify(userProfile), 1); // Store for 1 day
1325
+ setCookie(profileStorageKey, JSON.stringify(userProfile), authOptions.activeCookiePeriod); // Store for 1 day
1323
1326
  }
1324
1327
  else {
1325
1328
  deleteCookie(profileStorageKey);
@@ -1470,7 +1473,8 @@ function CAMSProviderCore(props) {
1470
1473
  userProfile,
1471
1474
  ]);
1472
1475
  var value = React.useMemo(function () {
1473
- return (__assign(__assign({}, auth), { logout: enhancedLogout, userProfile: userProfile, setUserProfile: setUserProfile, authMode: mode }));
1476
+ auth.logout; var authRest = __rest(auth, ["logout"]);
1477
+ return __assign(__assign({}, authRest), { logout: enhancedLogout, userProfile: userProfile, setUserProfile: setUserProfile, authMode: mode });
1474
1478
  }, [auth, userProfile, mode]);
1475
1479
  return jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children });
1476
1480
  }