@functionalcms/svelte-components 0.8.5 → 0.8.6
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/authStore.js +9 -16
- package/package.json +1 -1
package/dist/authStore.js
CHANGED
|
@@ -3,8 +3,8 @@ import { PublicClientApplication } from "@azure/msal-browser";
|
|
|
3
3
|
const isAuthenticated = writable(false);
|
|
4
4
|
const accessToken = writable('');
|
|
5
5
|
const userId = writable('');
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
let msal;
|
|
7
|
+
let authConfig;
|
|
8
8
|
const getMSALConfig = (config) => {
|
|
9
9
|
return {
|
|
10
10
|
auth: {
|
|
@@ -39,10 +39,9 @@ const handleToken = (token) => {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const logUsingCookies = async (config) => {
|
|
42
|
-
const
|
|
43
|
-
const accounts = msalInstance.getAllAccounts();
|
|
42
|
+
const accounts = msal.getAllAccounts();
|
|
44
43
|
if (accounts.length > 0) {
|
|
45
|
-
const token = await
|
|
44
|
+
const token = await msal.acquireTokenSilent(getTokenRequest(config, accounts[0]));
|
|
46
45
|
handleToken(token);
|
|
47
46
|
}
|
|
48
47
|
};
|
|
@@ -50,23 +49,17 @@ export const authStore = {
|
|
|
50
49
|
isAuthenticated: readonly(isAuthenticated),
|
|
51
50
|
userId: readonly(userId),
|
|
52
51
|
accessToken: readonly(accessToken),
|
|
53
|
-
// msal: readonly(msal),
|
|
54
|
-
// authConfig: readonly(authConfig),
|
|
55
52
|
initialise: async (config) => {
|
|
56
|
-
|
|
57
|
-
await
|
|
53
|
+
msal = new PublicClientApplication(getMSALConfig(config));
|
|
54
|
+
await msal.initialize();
|
|
58
55
|
await logUsingCookies(config);
|
|
59
|
-
|
|
60
|
-
authConfig.set(config);
|
|
56
|
+
authConfig = config;
|
|
61
57
|
},
|
|
62
58
|
signIn: async () => {
|
|
63
|
-
const
|
|
64
|
-
const msalInstance = get(msal);
|
|
65
|
-
const loginResponse = await msalInstance.loginPopup(getLoginRequest(config));
|
|
59
|
+
const loginResponse = await msal.loginPopup(getLoginRequest(authConfig));
|
|
66
60
|
handleToken(loginResponse);
|
|
67
61
|
},
|
|
68
62
|
signOut: async () => {
|
|
69
|
-
|
|
70
|
-
await msalInstance.logoutPopup({});
|
|
63
|
+
await msal.logoutPopup({});
|
|
71
64
|
},
|
|
72
65
|
};
|