@nibssplc/cams-sdk-react 0.0.1-beta.38 → 0.0.1-beta.39
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 +36 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +36 -9
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -16737,15 +16737,15 @@ function useCAMSMSALAuth(options) {
|
|
|
16737
16737
|
// const response = await instance.handleRedirectPromise();
|
|
16738
16738
|
// if (response) {
|
|
16739
16739
|
// const account = response.account;
|
|
16740
|
-
// instance.
|
|
16741
|
-
// const tokenResponse = await instance.
|
|
16740
|
+
// instance.setActiveA ccount(account);
|
|
16741
|
+
// const tokenResponse = await instance.acq uireTokenSilent({
|
|
16742
16742
|
// scopes,
|
|
16743
16743
|
// account,
|
|
16744
16744
|
// });
|
|
16745
16745
|
// setToken(tokenResponse.accessToken);
|
|
16746
16746
|
// setAccessToken(tokenResponse.accessToken);
|
|
16747
|
-
// setIdToken(tokenResponse.
|
|
16748
|
-
// options.onAuthSuccess?.(
|
|
16747
|
+
// setIdToken(tokenResponse.idTo ken);
|
|
16748
|
+
// options.onAuthSuccess?.(tokenR esponse.accessToken);
|
|
16749
16749
|
// if (
|
|
16750
16750
|
// typeof window !== "undefined" &&
|
|
16751
16751
|
// process.env.NODE_ENV !== "test"
|
|
@@ -16769,7 +16769,7 @@ function useCAMSMSALAuth(options) {
|
|
|
16769
16769
|
_d.label = 1;
|
|
16770
16770
|
case 1:
|
|
16771
16771
|
_d.trys.push([1, 3, , 4]);
|
|
16772
|
-
// await instance.
|
|
16772
|
+
// await instance.loginR edirect({
|
|
16773
16773
|
// scopes,
|
|
16774
16774
|
// prompt: options.prompt || "login",
|
|
16775
16775
|
// });
|
|
@@ -16802,7 +16802,7 @@ function useCAMSMSALAuth(options) {
|
|
|
16802
16802
|
}
|
|
16803
16803
|
})];
|
|
16804
16804
|
case 2:
|
|
16805
|
-
// await instance.
|
|
16805
|
+
// await instance.loginR edirect({
|
|
16806
16806
|
// scopes,
|
|
16807
16807
|
// prompt: options.prompt || "login",
|
|
16808
16808
|
// });
|
|
@@ -17317,6 +17317,24 @@ function ProtectedRoute(_a) {
|
|
|
17317
17317
|
}
|
|
17318
17318
|
|
|
17319
17319
|
var CAMSMSALContext = createContext(null);
|
|
17320
|
+
var setCookie = function (name, value, days) {
|
|
17321
|
+
var expires = new Date(Date.now() + days * 864e5).toUTCString();
|
|
17322
|
+
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=strict");
|
|
17323
|
+
};
|
|
17324
|
+
var getCookie = function (name) {
|
|
17325
|
+
var _a;
|
|
17326
|
+
return ((_a = document.cookie
|
|
17327
|
+
.split("; ")
|
|
17328
|
+
.find(function (row) { return row.startsWith(name + "="); })) === null || _a === void 0 ? void 0 : _a.split("=")[1])
|
|
17329
|
+
? decodeURIComponent(document.cookie
|
|
17330
|
+
.split("; ")
|
|
17331
|
+
.find(function (row) { return row.startsWith(name + "="); })
|
|
17332
|
+
.split("=")[1])
|
|
17333
|
+
: null;
|
|
17334
|
+
};
|
|
17335
|
+
var deleteCookie = function (name) {
|
|
17336
|
+
document.cookie = name + "=; Max-Age=-99999999; path=/";
|
|
17337
|
+
};
|
|
17320
17338
|
var isTokenValid = function (token) {
|
|
17321
17339
|
try {
|
|
17322
17340
|
var payload = JSON.parse(atob(token.split(".")[1]));
|
|
@@ -17347,7 +17365,8 @@ function CAMSMSALProviderInner(_a) {
|
|
|
17347
17365
|
// Load profile from storage on mount
|
|
17348
17366
|
useEffect(function () {
|
|
17349
17367
|
if (typeof window !== "undefined") {
|
|
17350
|
-
|
|
17368
|
+
// const storedProfile = localStorage.get Item(profileStorageKey);
|
|
17369
|
+
var storedProfile = getCookie(profileStorageKey);
|
|
17351
17370
|
if (storedProfile) {
|
|
17352
17371
|
try {
|
|
17353
17372
|
setUserProfile(JSON.parse(storedProfile));
|
|
@@ -17370,11 +17389,16 @@ function CAMSMSALProviderInner(_a) {
|
|
|
17370
17389
|
// Persist profile separately
|
|
17371
17390
|
useEffect(function () {
|
|
17372
17391
|
if (typeof window !== "undefined") {
|
|
17392
|
+
// if (userProfile) {
|
|
17393
|
+
// localStorage.setItem(profileStorageKey, JSO N.stringify(userProfile));
|
|
17394
|
+
// } else {
|
|
17395
|
+
// localStorage.removeItem(profileStorageKey);
|
|
17396
|
+
// }
|
|
17373
17397
|
if (userProfile) {
|
|
17374
|
-
|
|
17398
|
+
setCookie(profileStorageKey, JSON.stringify(userProfile), 1); // Store for 1 day
|
|
17375
17399
|
}
|
|
17376
17400
|
else {
|
|
17377
|
-
|
|
17401
|
+
deleteCookie(profileStorageKey);
|
|
17378
17402
|
}
|
|
17379
17403
|
}
|
|
17380
17404
|
}, [userProfile, profileStorageKey]);
|
|
@@ -17386,6 +17410,9 @@ function CAMSMSALProviderInner(_a) {
|
|
|
17386
17410
|
case 1:
|
|
17387
17411
|
_a.sent();
|
|
17388
17412
|
setUserProfile(null);
|
|
17413
|
+
if (typeof window !== "undefined") {
|
|
17414
|
+
deleteCookie(profileStorageKey);
|
|
17415
|
+
}
|
|
17389
17416
|
return [2 /*return*/];
|
|
17390
17417
|
}
|
|
17391
17418
|
});
|