@nibssplc/cams-sdk-react 0.0.1-beta.43 → 0.0.1-beta.45
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 +3 -3
- package/dist/index.cjs.js +12 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -14
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,8 +14,8 @@ export interface UseCAMSMSALAuthReturn {
|
|
|
14
14
|
isAuthenticated: boolean;
|
|
15
15
|
isLoading: boolean;
|
|
16
16
|
error: CAMSError | null;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
idToken: string;
|
|
18
|
+
accessToken: string;
|
|
19
|
+
appCode: string;
|
|
20
20
|
}
|
|
21
21
|
export declare function useCAMSMSALAuth(options?: UseCAMSMSALAuthOptions): UseCAMSMSALAuthReturn;
|
package/dist/index.cjs.js
CHANGED
|
@@ -16716,9 +16716,10 @@ function useCAMSMSALAuth(options) {
|
|
|
16716
16716
|
var account = useAccount(accounts[0] || {});
|
|
16717
16717
|
var storageKey = "CAMS-MSAL-AUTH-SDK";
|
|
16718
16718
|
var _b = React__default.useState(null), error = _b[0], setError = _b[1];
|
|
16719
|
-
var _c = React__default.useState(
|
|
16720
|
-
var _d = React__default.useState(
|
|
16721
|
-
var _e = React__default.useState(
|
|
16719
|
+
var _c = React__default.useState(""), token = _c[0], setToken = _c[1];
|
|
16720
|
+
var _d = React__default.useState(""), idToken = _d[0], setIdToken = _d[1];
|
|
16721
|
+
var _e = React__default.useState(""), appCode = _e[0], setAppCode = _e[1];
|
|
16722
|
+
var _f = React__default.useState(""), accessToken = _f[0], setAccessToken = _f[1];
|
|
16722
16723
|
var isLoading = inProgress !== InteractionStatus.None;
|
|
16723
16724
|
var isAuthenticated = !!account && !!token;
|
|
16724
16725
|
var scopes = options.scopes || ["openid", "profile", "email"];
|
|
@@ -16736,11 +16737,12 @@ function useCAMSMSALAuth(options) {
|
|
|
16736
16737
|
var stored = localStorage.getItem(storageKey);
|
|
16737
16738
|
if (stored) {
|
|
16738
16739
|
try {
|
|
16739
|
-
var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken;
|
|
16740
|
+
var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken, appCode_1 = _a.appCode;
|
|
16740
16741
|
if (accessToken_1 && isTokenValid(accessToken_1)) {
|
|
16741
16742
|
setToken(accessToken_1);
|
|
16742
16743
|
setAccessToken(accessToken_1);
|
|
16743
16744
|
setIdToken(idToken_1);
|
|
16745
|
+
setAppCode(appCode_1);
|
|
16744
16746
|
}
|
|
16745
16747
|
else {
|
|
16746
16748
|
localStorage.removeItem(storageKey);
|
|
@@ -16865,9 +16867,9 @@ function useCAMSMSALAuth(options) {
|
|
|
16865
16867
|
return [4 /*yield*/, instance.logoutRedirect()];
|
|
16866
16868
|
case 1:
|
|
16867
16869
|
_a.sent();
|
|
16868
|
-
setToken(
|
|
16869
|
-
setAccessToken(
|
|
16870
|
-
setIdToken(
|
|
16870
|
+
setToken("");
|
|
16871
|
+
setAccessToken("");
|
|
16872
|
+
setIdToken("");
|
|
16871
16873
|
setError(null);
|
|
16872
16874
|
if (typeof window !== "undefined") {
|
|
16873
16875
|
localStorage.removeItem(storageKey);
|
|
@@ -16889,9 +16891,9 @@ function useCAMSMSALAuth(options) {
|
|
|
16889
16891
|
isAuthenticated: isAuthenticated,
|
|
16890
16892
|
isLoading: isLoading,
|
|
16891
16893
|
error: error,
|
|
16892
|
-
token: token,
|
|
16893
16894
|
idToken: idToken,
|
|
16894
16895
|
accessToken: accessToken,
|
|
16896
|
+
appCode: appCode,
|
|
16895
16897
|
};
|
|
16896
16898
|
}
|
|
16897
16899
|
|
|
@@ -17413,17 +17415,13 @@ function CAMSMSALProviderInner(_a) {
|
|
|
17413
17415
|
localStorage.setItem(auth.storageKey, JSON.stringify({
|
|
17414
17416
|
accessToken: auth.accessToken,
|
|
17415
17417
|
idToken: auth.idToken,
|
|
17418
|
+
appCode: auth.appCode
|
|
17416
17419
|
}));
|
|
17417
17420
|
}
|
|
17418
|
-
}, [auth.accessToken, auth.idToken, auth.storageKey]);
|
|
17421
|
+
}, [auth.accessToken, auth.idToken, auth.appCode, auth.storageKey]);
|
|
17419
17422
|
// Persist profile separately
|
|
17420
17423
|
React__default.useEffect(function () {
|
|
17421
17424
|
if (typeof window !== "undefined") {
|
|
17422
|
-
// if (userProfile) {
|
|
17423
|
-
// localStorage.setItem(profileStorageKey, JSO N.stringify(userProfile));
|
|
17424
|
-
// } else {
|
|
17425
|
-
// localStorage.removeItem(profileStorageKey);
|
|
17426
|
-
// }
|
|
17427
17425
|
if (userProfile) {
|
|
17428
17426
|
setCookie(profileStorageKey, JSON.stringify(userProfile), 1); // Store for 1 day
|
|
17429
17427
|
}
|