@nibssplc/cams-sdk-react 1.0.0-rc.21 → 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 +13 -36
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +13 -36
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -361,12 +361,13 @@ function useCAMSAuth(options) {
|
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
var setCookie
|
|
364
|
+
var setCookie = function (name, value, days) {
|
|
365
365
|
if (days === void 0) { days = 1; }
|
|
366
366
|
var expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
|
|
367
|
+
console.log("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
|
|
367
368
|
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
|
|
368
369
|
};
|
|
369
|
-
var getCookie
|
|
370
|
+
var getCookie = function (name) {
|
|
370
371
|
var _a;
|
|
371
372
|
return ((_a = document.cookie
|
|
372
373
|
.split("; ")
|
|
@@ -377,7 +378,7 @@ var getCookie$1 = function (name) {
|
|
|
377
378
|
.split("=")[1])
|
|
378
379
|
: null;
|
|
379
380
|
};
|
|
380
|
-
var deleteCookie
|
|
381
|
+
var deleteCookie = function (name) {
|
|
381
382
|
document.cookie = name + "=; Max-Age=-99999999; path=/";
|
|
382
383
|
};
|
|
383
384
|
|
|
@@ -558,7 +559,7 @@ function useCAMSMSALAuth(options) {
|
|
|
558
559
|
accessToken: accessToken,
|
|
559
560
|
idToken: idToken,
|
|
560
561
|
}));
|
|
561
|
-
setCookie
|
|
562
|
+
setCookie("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }), activeCookiePeriod);
|
|
562
563
|
setRequiresMFA(false);
|
|
563
564
|
// Set requiresMFA to false after storage update
|
|
564
565
|
Logger.debug("MFA completed successfully, storage updated", {
|
|
@@ -1227,26 +1228,6 @@ function ProtectedRoute(_a) {
|
|
|
1227
1228
|
}
|
|
1228
1229
|
|
|
1229
1230
|
var CAMSMSALContext = createContext(null);
|
|
1230
|
-
var setCookie = function (name, value, days) {
|
|
1231
|
-
if (days === void 0) { days = 1; }
|
|
1232
|
-
var expires = new Date(Date.now() + days * 864e5).toUTCString();
|
|
1233
|
-
Logger.debug("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
|
|
1234
|
-
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
|
|
1235
|
-
};
|
|
1236
|
-
var getCookie = function (name) {
|
|
1237
|
-
var _a;
|
|
1238
|
-
return ((_a = document.cookie
|
|
1239
|
-
.split("; ")
|
|
1240
|
-
.find(function (row) { return row.startsWith(name + "="); })) === null || _a === void 0 ? void 0 : _a.split("=")[1])
|
|
1241
|
-
? decodeURIComponent(document.cookie
|
|
1242
|
-
.split("; ")
|
|
1243
|
-
.find(function (row) { return row.startsWith(name + "="); })
|
|
1244
|
-
.split("=")[1])
|
|
1245
|
-
: null;
|
|
1246
|
-
};
|
|
1247
|
-
var deleteCookie = function (name) {
|
|
1248
|
-
document.cookie = name + "=; Max-Age=-99999999; path=/";
|
|
1249
|
-
};
|
|
1250
1231
|
var isTokenValid = function (token) {
|
|
1251
1232
|
try {
|
|
1252
1233
|
var payload = JSON.parse(atob(token.split(".")[1]));
|
|
@@ -1303,7 +1284,7 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1303
1284
|
useEffect(function () {
|
|
1304
1285
|
if (typeof window !== "undefined") {
|
|
1305
1286
|
if (userProfile) {
|
|
1306
|
-
setCookie(profileStorageKey, JSON.stringify(userProfile),
|
|
1287
|
+
setCookie(profileStorageKey, JSON.stringify(userProfile), 1); // Store for 1 day
|
|
1307
1288
|
}
|
|
1308
1289
|
else {
|
|
1309
1290
|
deleteCookie(profileStorageKey);
|
|
@@ -1330,9 +1311,7 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1330
1311
|
}
|
|
1331
1312
|
function CAMSMSALProvider(props) {
|
|
1332
1313
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1333
|
-
var instance =
|
|
1334
|
-
? msalInstance || new PublicClientApplication(msalConfig)
|
|
1335
|
-
: null;
|
|
1314
|
+
var instance = msalInstance || new PublicClientApplication(msalConfig);
|
|
1336
1315
|
return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSMSALProviderInner, __assign({}, props)) }));
|
|
1337
1316
|
}
|
|
1338
1317
|
function useCAMSMSALContext() {
|
|
@@ -1381,7 +1360,7 @@ function CAMSProviderCore(props) {
|
|
|
1381
1360
|
if (typeof window === "undefined")
|
|
1382
1361
|
return null;
|
|
1383
1362
|
try {
|
|
1384
|
-
var storedProfile = getCookie
|
|
1363
|
+
var storedProfile = getCookie(profileStorageKey);
|
|
1385
1364
|
return storedProfile ? JSON.parse(storedProfile) : null;
|
|
1386
1365
|
}
|
|
1387
1366
|
catch (_a) {
|
|
@@ -1391,7 +1370,7 @@ function CAMSProviderCore(props) {
|
|
|
1391
1370
|
var _a = useState(getInitialProfile), userProfile = _a[0], setUserProfile = _a[1];
|
|
1392
1371
|
useEffect(function () {
|
|
1393
1372
|
if (typeof window !== "undefined") {
|
|
1394
|
-
var storedProfile = getCookie
|
|
1373
|
+
var storedProfile = getCookie(profileStorageKey);
|
|
1395
1374
|
if (storedProfile) {
|
|
1396
1375
|
try {
|
|
1397
1376
|
setUserProfile(JSON.parse(storedProfile));
|
|
@@ -1403,10 +1382,10 @@ function CAMSProviderCore(props) {
|
|
|
1403
1382
|
useEffect(function () {
|
|
1404
1383
|
if (typeof window !== "undefined") {
|
|
1405
1384
|
if (userProfile) {
|
|
1406
|
-
setCookie
|
|
1385
|
+
setCookie(profileStorageKey, JSON.stringify(userProfile), 1);
|
|
1407
1386
|
}
|
|
1408
1387
|
else {
|
|
1409
|
-
deleteCookie
|
|
1388
|
+
deleteCookie(profileStorageKey);
|
|
1410
1389
|
}
|
|
1411
1390
|
}
|
|
1412
1391
|
}, [userProfile, profileStorageKey]);
|
|
@@ -1418,7 +1397,7 @@ function CAMSProviderCore(props) {
|
|
|
1418
1397
|
_a.sent();
|
|
1419
1398
|
setUserProfile(null);
|
|
1420
1399
|
if (typeof window !== "undefined") {
|
|
1421
|
-
deleteCookie
|
|
1400
|
+
deleteCookie(profileStorageKey);
|
|
1422
1401
|
}
|
|
1423
1402
|
return [2 /*return*/];
|
|
1424
1403
|
}
|
|
@@ -1467,9 +1446,7 @@ function UnifiedCAMSProvider(props) {
|
|
|
1467
1446
|
}
|
|
1468
1447
|
if (props.mode === "MSAL") {
|
|
1469
1448
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1470
|
-
var instance =
|
|
1471
|
-
? msalInstance || new PublicClientApplication(msalConfig)
|
|
1472
|
-
: null;
|
|
1449
|
+
var instance = msalInstance || new PublicClientApplication(msalConfig);
|
|
1473
1450
|
return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
|
|
1474
1451
|
}
|
|
1475
1452
|
return (jsxRuntimeExports.jsx(ClientOnly, { fallback: jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
|