@nibssplc/cams-sdk-react 1.0.0-rc.20 → 1.0.0-rc.22

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.cjs.js CHANGED
@@ -382,12 +382,13 @@ function useCAMSAuth(options) {
382
382
  };
383
383
  }
384
384
 
385
- var setCookie$1 = function (name, value, days) {
385
+ var setCookie = function (name, value, days) {
386
386
  if (days === void 0) { days = 1; }
387
387
  var expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
388
+ console.log("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
388
389
  document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
389
390
  };
390
- var getCookie$1 = function (name) {
391
+ var getCookie = function (name) {
391
392
  var _a;
392
393
  return ((_a = document.cookie
393
394
  .split("; ")
@@ -398,7 +399,7 @@ var getCookie$1 = function (name) {
398
399
  .split("=")[1])
399
400
  : null;
400
401
  };
401
- var deleteCookie$1 = function (name) {
402
+ var deleteCookie = function (name) {
402
403
  document.cookie = name + "=; Max-Age=-99999999; path=/";
403
404
  };
404
405
 
@@ -579,7 +580,7 @@ function useCAMSMSALAuth(options) {
579
580
  accessToken: accessToken,
580
581
  idToken: idToken,
581
582
  }));
582
- setCookie$1("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }), activeCookiePeriod);
583
+ setCookie("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }), activeCookiePeriod);
583
584
  setRequiresMFA(false);
584
585
  // Set requiresMFA to false after storage update
585
586
  camsSdk.Logger.debug("MFA completed successfully, storage updated", {
@@ -1248,26 +1249,6 @@ function ProtectedRoute(_a) {
1248
1249
  }
1249
1250
 
1250
1251
  var CAMSMSALContext = React.createContext(null);
1251
- var setCookie = function (name, value, days) {
1252
- if (days === void 0) { days = 1; }
1253
- var expires = new Date(Date.now() + days * 864e5).toUTCString();
1254
- camsSdk.Logger.debug("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
1255
- document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
1256
- };
1257
- var getCookie = function (name) {
1258
- var _a;
1259
- return ((_a = document.cookie
1260
- .split("; ")
1261
- .find(function (row) { return row.startsWith(name + "="); })) === null || _a === void 0 ? void 0 : _a.split("=")[1])
1262
- ? decodeURIComponent(document.cookie
1263
- .split("; ")
1264
- .find(function (row) { return row.startsWith(name + "="); })
1265
- .split("=")[1])
1266
- : null;
1267
- };
1268
- var deleteCookie = function (name) {
1269
- document.cookie = name + "=; Max-Age=-99999999; path=/";
1270
- };
1271
1252
  var isTokenValid = function (token) {
1272
1253
  try {
1273
1254
  var payload = JSON.parse(atob(token.split(".")[1]));
@@ -1324,7 +1305,7 @@ function CAMSMSALProviderInner(_a) {
1324
1305
  React.useEffect(function () {
1325
1306
  if (typeof window !== "undefined") {
1326
1307
  if (userProfile) {
1327
- setCookie(profileStorageKey, JSON.stringify(userProfile), auth.activeCookiePeriod); // Store for 1 day
1308
+ setCookie(profileStorageKey, JSON.stringify(userProfile), 1); // Store for 1 day
1328
1309
  }
1329
1310
  else {
1330
1311
  deleteCookie(profileStorageKey);
@@ -1351,9 +1332,7 @@ function CAMSMSALProviderInner(_a) {
1351
1332
  }
1352
1333
  function CAMSMSALProvider(props) {
1353
1334
  var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
1354
- var instance = typeof window !== "undefined"
1355
- ? msalInstance || new msalBrowser.PublicClientApplication(msalConfig)
1356
- : null;
1335
+ var instance = msalInstance || new msalBrowser.PublicClientApplication(msalConfig);
1357
1336
  return (jsxRuntimeExports.jsx(msalReact.MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSMSALProviderInner, __assign({}, props)) }));
1358
1337
  }
1359
1338
  function useCAMSMSALContext() {
@@ -1402,7 +1381,7 @@ function CAMSProviderCore(props) {
1402
1381
  if (typeof window === "undefined")
1403
1382
  return null;
1404
1383
  try {
1405
- var storedProfile = getCookie$1(profileStorageKey);
1384
+ var storedProfile = getCookie(profileStorageKey);
1406
1385
  return storedProfile ? JSON.parse(storedProfile) : null;
1407
1386
  }
1408
1387
  catch (_a) {
@@ -1412,7 +1391,7 @@ function CAMSProviderCore(props) {
1412
1391
  var _a = React.useState(getInitialProfile), userProfile = _a[0], setUserProfile = _a[1];
1413
1392
  React.useEffect(function () {
1414
1393
  if (typeof window !== "undefined") {
1415
- var storedProfile = getCookie$1(profileStorageKey);
1394
+ var storedProfile = getCookie(profileStorageKey);
1416
1395
  if (storedProfile) {
1417
1396
  try {
1418
1397
  setUserProfile(JSON.parse(storedProfile));
@@ -1424,10 +1403,10 @@ function CAMSProviderCore(props) {
1424
1403
  React.useEffect(function () {
1425
1404
  if (typeof window !== "undefined") {
1426
1405
  if (userProfile) {
1427
- setCookie$1(profileStorageKey, JSON.stringify(userProfile), 1);
1406
+ setCookie(profileStorageKey, JSON.stringify(userProfile), 1);
1428
1407
  }
1429
1408
  else {
1430
- deleteCookie$1(profileStorageKey);
1409
+ deleteCookie(profileStorageKey);
1431
1410
  }
1432
1411
  }
1433
1412
  }, [userProfile, profileStorageKey]);
@@ -1439,7 +1418,7 @@ function CAMSProviderCore(props) {
1439
1418
  _a.sent();
1440
1419
  setUserProfile(null);
1441
1420
  if (typeof window !== "undefined") {
1442
- deleteCookie$1(profileStorageKey);
1421
+ deleteCookie(profileStorageKey);
1443
1422
  }
1444
1423
  return [2 /*return*/];
1445
1424
  }
@@ -1488,9 +1467,7 @@ function UnifiedCAMSProvider(props) {
1488
1467
  }
1489
1468
  if (props.mode === "MSAL") {
1490
1469
  var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
1491
- var instance = typeof window !== "undefined"
1492
- ? msalInstance || new msalBrowser.PublicClientApplication(msalConfig)
1493
- : null;
1470
+ var instance = msalInstance || new msalBrowser.PublicClientApplication(msalConfig);
1494
1471
  return (jsxRuntimeExports.jsx(msalReact.MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
1495
1472
  }
1496
1473
  return (jsxRuntimeExports.jsx(ClientOnly, { fallback: jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));