@functionalcms/svelte-components 0.8.11 → 0.9.1
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.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const authStore: {
|
|
|
11
11
|
isAuthenticated: import("svelte/store").Readable<boolean>;
|
|
12
12
|
userId: import("svelte/store").Readable<string>;
|
|
13
13
|
accessToken: import("svelte/store").Readable<string>;
|
|
14
|
+
username: import("svelte/store").Readable<string>;
|
|
14
15
|
initialise: (config: AuthConfig) => Promise<void>;
|
|
15
16
|
signIn: () => Promise<void>;
|
|
16
17
|
signOut: () => Promise<void>;
|
package/dist/authStore.js
CHANGED
|
@@ -3,6 +3,7 @@ import { PublicClientApplication } from "@azure/msal-browser";
|
|
|
3
3
|
const isAuthenticated = writable(false);
|
|
4
4
|
const accessToken = writable('');
|
|
5
5
|
const userId = writable('');
|
|
6
|
+
const username = writable('');
|
|
6
7
|
let msal;
|
|
7
8
|
let authConfig;
|
|
8
9
|
const getMSALConfig = (config) => {
|
|
@@ -35,7 +36,8 @@ const handleToken = (token) => {
|
|
|
35
36
|
if (token !== null) {
|
|
36
37
|
isAuthenticated.set(true);
|
|
37
38
|
accessToken.set(token.accessToken);
|
|
38
|
-
userId.set(token.
|
|
39
|
+
userId.set(token.account.idTokenClaims.sub);
|
|
40
|
+
username.set(token.account.idTokenClaims.name);
|
|
39
41
|
}
|
|
40
42
|
else {
|
|
41
43
|
isAuthenticated.set(false);
|
|
@@ -52,6 +54,7 @@ export const authStore = {
|
|
|
52
54
|
isAuthenticated: readonly(isAuthenticated),
|
|
53
55
|
userId: readonly(userId),
|
|
54
56
|
accessToken: readonly(accessToken),
|
|
57
|
+
username: readonly(username),
|
|
55
58
|
initialise: async (config) => {
|
|
56
59
|
msal = new PublicClientApplication(getMSALConfig(config));
|
|
57
60
|
await msal.initialize();
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
<script>import { Header, HeaderNav, HeaderNavItem, MenuItem } from "agnostic-svelte";
|
|
2
|
-
import { Visiblity } from "
|
|
2
|
+
import { Visiblity } from "../HeaderNavigationItem";
|
|
3
|
+
import { get } from "svelte/store";
|
|
3
4
|
export let companyName;
|
|
4
5
|
export let logoUrl;
|
|
5
6
|
export let pages;
|
|
6
7
|
export let authentication;
|
|
7
|
-
const selectVisible = (pages2, visiblity) =>
|
|
8
|
-
|
|
8
|
+
const selectVisible = (pages2, visiblity) => {
|
|
9
|
+
console.log(visiblity);
|
|
10
|
+
return pages2.filter((page) => page.visiblity === Visiblity.Always || page.visiblity === visiblity);
|
|
11
|
+
};
|
|
9
12
|
$:
|
|
10
|
-
|
|
13
|
+
visibility = authentication ? Visiblity.Authenticated : Visiblity.NotAuthenticated;
|
|
14
|
+
$:
|
|
15
|
+
visibleNavItems = selectVisible(pages, visibility);
|
|
11
16
|
</script>
|
|
12
|
-
|
|
13
17
|
<div class="header">
|
|
14
18
|
<Header>
|
|
15
19
|
<div slot="logoleft">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { HeaderNavigationItem } from '
|
|
2
|
+
import type { HeaderNavigationItem } from '../HeaderNavigationItem';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
/**
|
|
@@ -13,7 +13,7 @@ declare const __propDef: {
|
|
|
13
13
|
*/ pages: HeaderNavigationItem[];
|
|
14
14
|
/**
|
|
15
15
|
* @type {Readonly<bool>}
|
|
16
|
-
*/ authentication:
|
|
16
|
+
*/ authentication: boolean;
|
|
17
17
|
};
|
|
18
18
|
events: {
|
|
19
19
|
[evt: string]: CustomEvent<any>;
|