@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.
Files changed (2) hide show
  1. package/dist/authStore.js +9 -16
  2. 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
- const msal = writable(null);
7
- const authConfig = writable({});
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 msalInstance = get(msal);
43
- const accounts = msalInstance.getAllAccounts();
42
+ const accounts = msal.getAllAccounts();
44
43
  if (accounts.length > 0) {
45
- const token = await msalInstance.acquireTokenSilent(getTokenRequest(config, accounts[0]));
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
- const msalInstance = new PublicClientApplication(getMSALConfig(config));
57
- await msalInstance.initialize();
53
+ msal = new PublicClientApplication(getMSALConfig(config));
54
+ await msal.initialize();
58
55
  await logUsingCookies(config);
59
- msal.set(msalInstance);
60
- authConfig.set(config);
56
+ authConfig = config;
61
57
  },
62
58
  signIn: async () => {
63
- const config = get(authConfig);
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
- const msalInstance = get(msal);
70
- await msalInstance.logoutPopup({});
63
+ await msal.logoutPopup({});
71
64
  },
72
65
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },