@functionalcms/svelte-components 3.4.0 → 3.5.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/auth/getMachineAccessToken.d.ts +1 -0
- package/dist/auth/getMachineAccessToken.js +22 -0
- package/dist/auth/types.d.ts +12 -1
- package/dist/components/agnostic/Disclose/Disclose.svelte +106 -103
- package/dist/components/agnostic/Disclose/Disclose.svelte.d.ts +2 -9
- package/dist/server-side/getServices.d.ts +6 -6
- package/dist/server-side/getServices.js +12 -12
- package/dist/server-side/types.d.ts +5 -0
- package/dist/server-side/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getMachineAccessToken: (scope?: string) => Promise<string>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AUTH_KEYCLOAK_ID, AUTH_KEYCLOAK_SECRET, AUTH_KEYCLOAK_ISSUER } from '$env/static/private';
|
|
2
|
+
export const getMachineAccessToken = async (scope = '') => {
|
|
3
|
+
const response = await fetch(`${AUTH_KEYCLOAK_ISSUER}/protocol/openid-connect/token`, {
|
|
4
|
+
method: "POST",
|
|
5
|
+
body: new URLSearchParams({
|
|
6
|
+
grant_type: "client_credentials",
|
|
7
|
+
client_id: AUTH_KEYCLOAK_ID,
|
|
8
|
+
client_secret: AUTH_KEYCLOAK_SECRET,
|
|
9
|
+
scope,
|
|
10
|
+
}),
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
13
|
+
Accept: "application/json"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
console.log('Response was NOT okay');
|
|
18
|
+
throw new Error('Token not validated.');
|
|
19
|
+
}
|
|
20
|
+
const token = await response.json();
|
|
21
|
+
return token.access_token;
|
|
22
|
+
};
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -8,8 +8,19 @@ export declare class Token {
|
|
|
8
8
|
session_state?: string;
|
|
9
9
|
token_type?: string;
|
|
10
10
|
}
|
|
11
|
+
export interface Session {
|
|
12
|
+
client_id: string;
|
|
13
|
+
email_verified: string;
|
|
14
|
+
preferred_username: string;
|
|
15
|
+
sub: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Locals {
|
|
19
|
+
session: Session;
|
|
20
|
+
auth_token: string;
|
|
21
|
+
}
|
|
11
22
|
export type ISession = {
|
|
12
|
-
session:
|
|
23
|
+
session: Session;
|
|
13
24
|
token: Token;
|
|
14
25
|
};
|
|
15
26
|
export type SessionInfoCache = {
|
|
@@ -1,108 +1,111 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
.disclose {
|
|
3
|
-
margin-block-end: var(--fluid-4);
|
|
4
|
-
|
|
5
|
-
/* When this element is a direct child of a flex container with
|
|
6
|
-
flex-direction: column it collapses similar to an inline element even though
|
|
7
|
-
it's block. This helps prevent that. */
|
|
8
|
-
width: 100%;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.disclose-title {
|
|
12
|
-
display: block;
|
|
13
|
-
cursor: pointer;
|
|
14
|
-
font-weight: 600;
|
|
15
|
-
padding: var(--fluid-8) var(--fluid-12);
|
|
16
|
-
|
|
17
|
-
/* Required to position the icon absolutely */
|
|
18
|
-
position: relative;
|
|
19
|
-
color: inherit;
|
|
20
|
-
transition: color var(--functional-timing-slow);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.disclose-panel {
|
|
24
|
-
font-weight: 400;
|
|
25
|
-
padding: var(--fluid-16);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.disclose-title,
|
|
29
|
-
.disclose-panel {
|
|
30
|
-
margin: 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */
|
|
34
|
-
.disclose-title::webkit-details-marker {
|
|
35
|
-
display: none;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.disclose-bordered .disclose-title {
|
|
39
|
-
border: 1px solid var(--functional-gray-light);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.disclose-bg .disclose-title {
|
|
43
|
-
background-color: var(--functional-gray-light);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.disclose-title:focus {
|
|
47
|
-
box-shadow: 0 0 0 var(--functional-focus-ring-outline-width) var(--functional-focus-ring-color);
|
|
48
|
-
|
|
49
|
-
/* Needed for High Contrast mode */
|
|
50
|
-
outline:
|
|
51
|
-
var(--functional-focus-ring-outline-width) var(--functional-focus-ring-outline-style)
|
|
52
|
-
var(--functional-focus-ring-outline-color);
|
|
53
|
-
transition: box-shadow var(--functional-timing-fast) ease-out;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.disclose-title::after {
|
|
57
|
-
color: var(--functional-gray-dark);
|
|
58
|
-
content: "\203A";
|
|
59
|
-
position: absolute;
|
|
60
|
-
right: var(--fluid-12);
|
|
61
|
-
top: 0;
|
|
62
|
-
bottom: 0;
|
|
63
|
-
|
|
64
|
-
/* Chevron thinning :) */
|
|
65
|
-
font-size: var(--fluid-32);
|
|
66
|
-
line-height: 1;
|
|
67
|
-
font-weight: 100;
|
|
68
|
-
transition: transform var(--functional-timing-slow);
|
|
69
|
-
transform: rotate(0);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@media (prefers-reduced-motion), (update: slow) {
|
|
73
|
-
.disclose-title,
|
|
74
|
-
.disclose-title:focus,
|
|
75
|
-
.disclose-title::after {
|
|
76
|
-
transition: none;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.disclose[open] > .disclose-title::after {
|
|
81
|
-
transform: rotate(90deg);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
</style>
|
|
85
|
-
|
|
86
1
|
<script lang="ts">
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: Snippet,
|
|
6
|
+
title?: string;
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
isBackground?: boolean;
|
|
9
|
+
isBordered?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { children, title = '', isOpen = false, isBackground = false, isBordered = false }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const discloseClasses = [
|
|
15
|
+
'disclose',
|
|
16
|
+
isBackground ? 'disclose-bg' : '',
|
|
17
|
+
isBordered ? 'disclose-bordered' : ''
|
|
18
|
+
]
|
|
19
|
+
.filter((c) => c)
|
|
20
|
+
.join(' ');
|
|
101
21
|
</script>
|
|
102
22
|
|
|
103
23
|
<details class={discloseClasses} bind:open={isOpen}>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
24
|
+
<summary class="disclose-title">{title}</summary>
|
|
25
|
+
<div class="disclose-panel">
|
|
26
|
+
{@render children()}
|
|
27
|
+
</div>
|
|
108
28
|
</details>
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
.disclose {
|
|
32
|
+
margin-block-end: var(--fluid-4);
|
|
33
|
+
|
|
34
|
+
/* When this element is a direct child of a flex container with
|
|
35
|
+
flex-direction: column it collapses similar to an inline element even though
|
|
36
|
+
it's block. This helps prevent that. */
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.disclose-title {
|
|
41
|
+
display: block;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
padding: var(--fluid-8) var(--fluid-12);
|
|
45
|
+
|
|
46
|
+
/* Required to position the icon absolutely */
|
|
47
|
+
position: relative;
|
|
48
|
+
color: inherit;
|
|
49
|
+
transition: color var(--functional-timing-slow);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.disclose-panel {
|
|
53
|
+
font-weight: 400;
|
|
54
|
+
padding: var(--fluid-16);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.disclose-title,
|
|
58
|
+
.disclose-panel {
|
|
59
|
+
margin: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */
|
|
63
|
+
.disclose-title::webkit-details-marker {
|
|
64
|
+
display: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.disclose-bordered .disclose-title {
|
|
68
|
+
border: 1px solid var(--functional-gray-light);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.disclose-bg .disclose-title {
|
|
72
|
+
background-color: var(--functional-gray-light);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.disclose-title:focus {
|
|
76
|
+
box-shadow: 0 0 0 var(--functional-focus-ring-outline-width) var(--functional-focus-ring-color);
|
|
77
|
+
|
|
78
|
+
/* Needed for High Contrast mode */
|
|
79
|
+
outline: var(--functional-focus-ring-outline-width) var(--functional-focus-ring-outline-style)
|
|
80
|
+
var(--functional-focus-ring-outline-color);
|
|
81
|
+
transition: box-shadow var(--functional-timing-fast) ease-out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.disclose-title::after {
|
|
85
|
+
color: var(--functional-gray-dark);
|
|
86
|
+
content: '\203A';
|
|
87
|
+
position: absolute;
|
|
88
|
+
right: var(--fluid-12);
|
|
89
|
+
top: 0;
|
|
90
|
+
bottom: 0;
|
|
91
|
+
|
|
92
|
+
/* Chevron thinning :) */
|
|
93
|
+
font-size: var(--fluid-32);
|
|
94
|
+
line-height: 1;
|
|
95
|
+
font-weight: 100;
|
|
96
|
+
transition: transform var(--functional-timing-slow);
|
|
97
|
+
transform: rotate(0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@media (prefers-reduced-motion), (update: slow) {
|
|
101
|
+
.disclose-title,
|
|
102
|
+
.disclose-title:focus,
|
|
103
|
+
.disclose-title::after {
|
|
104
|
+
transition: none;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.disclose[open] > .disclose-title::after {
|
|
109
|
+
transform: rotate(90deg);
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
|
-
props:
|
|
4
|
-
title?: string;
|
|
5
|
-
isOpen?: boolean;
|
|
6
|
-
isBackground?: boolean;
|
|
7
|
-
isBordered?: boolean;
|
|
8
|
-
};
|
|
3
|
+
props: Record<string, never>;
|
|
9
4
|
events: {
|
|
10
5
|
[evt: string]: CustomEvent<any>;
|
|
11
6
|
};
|
|
12
|
-
slots: {
|
|
13
|
-
default: {};
|
|
14
|
-
};
|
|
7
|
+
slots: {};
|
|
15
8
|
};
|
|
16
9
|
export type DiscloseProps = typeof __propDef.props;
|
|
17
10
|
export type DiscloseEvents = typeof __propDef.events;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommunicationService, DataService, TemplateService, WebsitesService, BlobService, AiService } from "@functionalcms/services";
|
|
2
|
-
export declare const getDataService: (locals: any) => DataService;
|
|
3
|
-
export declare const getCommunicationService: (locals: any) => CommunicationService;
|
|
4
|
-
export declare const getWebsiteService: (locals: any) => WebsitesService;
|
|
5
|
-
export declare const getTemplateService: (locals: any) => TemplateService;
|
|
6
|
-
export declare const getBlobService: (locals: any) => BlobService;
|
|
7
|
-
export declare const getAIService: (locals: any) => AiService;
|
|
2
|
+
export declare const getDataService: (locals: any, getToken?: (locals: any) => string) => DataService;
|
|
3
|
+
export declare const getCommunicationService: (locals: any, getToken?: (locals: any) => string) => CommunicationService;
|
|
4
|
+
export declare const getWebsiteService: (locals: any, getToken?: (locals: any) => string) => WebsitesService;
|
|
5
|
+
export declare const getTemplateService: (locals: any, getToken?: (locals: any) => string) => TemplateService;
|
|
6
|
+
export declare const getBlobService: (locals: any, getToken?: (locals: any) => string) => BlobService;
|
|
7
|
+
export declare const getAIService: (locals: any, getToken?: (locals: any) => string) => AiService;
|
|
@@ -3,33 +3,33 @@ import { CommunicationService, DataService, TemplateService, WebsitesService, Bl
|
|
|
3
3
|
const getAccessToken = (locals) => {
|
|
4
4
|
return locals.token.access_token;
|
|
5
5
|
};
|
|
6
|
-
export const getDataService = (locals) => {
|
|
7
|
-
const accessToken =
|
|
6
|
+
export const getDataService = (locals, getToken = getAccessToken) => {
|
|
7
|
+
const accessToken = getToken(locals);
|
|
8
8
|
const service = new DataService(accessToken, DOMAIN, ENDPOINT);
|
|
9
9
|
return service;
|
|
10
10
|
};
|
|
11
|
-
export const getCommunicationService = (locals) => {
|
|
12
|
-
const accessToken =
|
|
11
|
+
export const getCommunicationService = (locals, getToken = getAccessToken) => {
|
|
12
|
+
const accessToken = getToken(locals);
|
|
13
13
|
const service = new CommunicationService(accessToken, DOMAIN, ENDPOINT);
|
|
14
14
|
return service;
|
|
15
15
|
};
|
|
16
|
-
export const getWebsiteService = (locals) => {
|
|
17
|
-
const accessToken =
|
|
16
|
+
export const getWebsiteService = (locals, getToken = getAccessToken) => {
|
|
17
|
+
const accessToken = getToken(locals);
|
|
18
18
|
const service = new WebsitesService(accessToken, DOMAIN, ENDPOINT);
|
|
19
19
|
return service;
|
|
20
20
|
};
|
|
21
|
-
export const getTemplateService = (locals) => {
|
|
22
|
-
const accessToken =
|
|
21
|
+
export const getTemplateService = (locals, getToken = getAccessToken) => {
|
|
22
|
+
const accessToken = getToken(locals);
|
|
23
23
|
const service = new TemplateService(accessToken, DOMAIN, ENDPOINT);
|
|
24
24
|
return service;
|
|
25
25
|
};
|
|
26
|
-
export const getBlobService = (locals) => {
|
|
27
|
-
const accessToken =
|
|
26
|
+
export const getBlobService = (locals, getToken = getAccessToken) => {
|
|
27
|
+
const accessToken = getToken(locals);
|
|
28
28
|
const service = new BlobService(accessToken, DOMAIN, ENDPOINT);
|
|
29
29
|
return service;
|
|
30
30
|
};
|
|
31
|
-
export const getAIService = (locals) => {
|
|
32
|
-
const accessToken =
|
|
31
|
+
export const getAIService = (locals, getToken = getAccessToken) => {
|
|
32
|
+
const accessToken = getToken(locals);
|
|
33
33
|
const service = new AiService(accessToken, DOMAIN, ENDPOINT);
|
|
34
34
|
return service;
|
|
35
35
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|