@functionalcms/svelte-components 2.16.4 → 2.17.0
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/auth.d.ts +6 -0
- package/dist/auth/auth.js +65 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SvelteKitAuth } from '@auth/sveltekit';
|
|
2
|
+
import Zitadel from "@auth/sveltekit/providers/zitadel";
|
|
3
|
+
function decodeBase64Value(base64) {
|
|
4
|
+
return Buffer.from(base64, 'base64').toString('utf-8');
|
|
5
|
+
}
|
|
6
|
+
function decodeMetadatas(metadata) {
|
|
7
|
+
const decodedMetadata = {};
|
|
8
|
+
for (const key in metadata) {
|
|
9
|
+
if (metadata.hasOwnProperty(key)) {
|
|
10
|
+
decodedMetadata[key] = decodeBase64Value(metadata[key]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return decodedMetadata;
|
|
14
|
+
}
|
|
15
|
+
function getRoles(roles) {
|
|
16
|
+
const mappedRoles = Object.keys(roles ?? []);
|
|
17
|
+
return mappedRoles;
|
|
18
|
+
}
|
|
19
|
+
const rolesScope = (projectId) => `urn:zitadel:iam:org:project:${projectId}:roles`;
|
|
20
|
+
const metadataScope = `urn:zitadel:iam:user:metadata`;
|
|
21
|
+
export const configureAuthentication = (projectId) => {
|
|
22
|
+
return SvelteKitAuth({
|
|
23
|
+
issuer: "https://login.functional-auth.com",
|
|
24
|
+
trustHost: true,
|
|
25
|
+
providers: [Zitadel({
|
|
26
|
+
async profile(profile) {
|
|
27
|
+
return {
|
|
28
|
+
id: profile.sub,
|
|
29
|
+
name: profile.name,
|
|
30
|
+
firstName: profile.given_name,
|
|
31
|
+
lastName: profile.family_name,
|
|
32
|
+
email: profile.email,
|
|
33
|
+
loginName: profile.preferred_username,
|
|
34
|
+
image: profile.picture,
|
|
35
|
+
accessToken: profile.access_token,
|
|
36
|
+
roles: getRoles(profile[rolesScope(projectId)]),
|
|
37
|
+
metadata: decodeMetadatas(profile[metadataScope])
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
})],
|
|
41
|
+
callbacks: {
|
|
42
|
+
async jwt({ token, user, account }) {
|
|
43
|
+
// Your JWT callback logic here
|
|
44
|
+
if (account) {
|
|
45
|
+
token.id = account.providerAccountId;
|
|
46
|
+
token.accessToken = account.access_token;
|
|
47
|
+
}
|
|
48
|
+
if (user) {
|
|
49
|
+
token.roles = user.roles;
|
|
50
|
+
token.metadata = user.metadata;
|
|
51
|
+
}
|
|
52
|
+
return token;
|
|
53
|
+
},
|
|
54
|
+
async session({ session, token, user }) {
|
|
55
|
+
session.accessToken = token.accessToken;
|
|
56
|
+
if (session.user) {
|
|
57
|
+
session.user.roles = token.roles;
|
|
58
|
+
session.user.metadata = token.metadata;
|
|
59
|
+
session.userId = token.id;
|
|
60
|
+
}
|
|
61
|
+
return session;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { title, suffix } from './stores/title.js';
|
|
|
24
24
|
import { pages } from './stores/pages.js';
|
|
25
25
|
import { metaDescription, metaKeywords } from './stores/meta.js';
|
|
26
26
|
import { Justify, Placement, Orientation, Position, Sizes, AlignItmes } from './components/Styling.js';
|
|
27
|
+
import type { configureAuthentication } from './auth/auth.js';
|
|
27
28
|
import { Alert, Avatar, AvatarGroup, Breadcrumb, Button, ButtonGroup, Card, ChoiceInput, Close, Dialog, Disclose, Divider, Drawer, EmptyState, Header, HeaderNav, HeaderNavItem, Icon, IconSvg, Input, InputAddonItem, Loader, Pagination, Progress, Select, Spinner, Switch, Table, Tabs, Tag, Toast, Toasts } from 'agnostic-svelte';
|
|
28
|
-
export { Visiblity, HeaderNavigationItem, DynamicMenu, FlatMenu, ColumnMenu, HamburgerMenu, BlogTitle, BlogDescription, listAllPosts, importPost, DefaultLayout, TwoColumnsLayout, Banner, Link, Logo, SimpleFooter, Gallery, Carusel, CaruseleItem, Spacer, Well, Justify, Placement, Orientation, AlignItmes, Position, Sizes, ShowItem, convertShowItemsToNavigationItems, title, suffix, pages, metaDescription, metaKeywords, Alert, Avatar, AvatarGroup, Breadcrumb, Button, ButtonGroup, Card, ChoiceInput, Close, Dialog, Disclose, Divider, Drawer, EmptyState, Header, HeaderNav, HeaderNavItem, Icon, IconSvg, Input, InputAddonItem, Loader, Pagination, Progress, Select, Spinner, Switch, Table, Tabs, Tag, Toast, Toasts };
|
|
29
|
+
export { Visiblity, HeaderNavigationItem, DynamicMenu, FlatMenu, ColumnMenu, HamburgerMenu, BlogTitle, BlogDescription, listAllPosts, importPost, DefaultLayout, TwoColumnsLayout, Banner, Link, Logo, SimpleFooter, Gallery, Carusel, CaruseleItem, Spacer, Well, Justify, Placement, Orientation, AlignItmes, Position, Sizes, ShowItem, convertShowItemsToNavigationItems, title, suffix, pages, metaDescription, metaKeywords, Alert, Avatar, AvatarGroup, Breadcrumb, Button, ButtonGroup, Card, ChoiceInput, Close, Dialog, Disclose, Divider, Drawer, EmptyState, Header, HeaderNav, HeaderNavItem, Icon, IconSvg, Input, InputAddonItem, Loader, Pagination, Progress, Select, Spinner, Switch, Table, Tabs, Tag, Toast, Toasts, configureAuthentication };
|
|
29
30
|
export type { BlogPost };
|
package/dist/index.js
CHANGED
|
@@ -24,4 +24,4 @@ import { pages } from './stores/pages.js';
|
|
|
24
24
|
import { metaDescription, metaKeywords } from './stores/meta.js';
|
|
25
25
|
import { Justify, Placement, Orientation, Position, Sizes, AlignItmes } from './components/Styling.js';
|
|
26
26
|
import { Alert, Avatar, AvatarGroup, Breadcrumb, Button, ButtonGroup, Card, ChoiceInput, Close, Dialog, Disclose, Divider, Drawer, EmptyState, Header, HeaderNav, HeaderNavItem, Icon, IconSvg, Input, InputAddonItem, Loader, Pagination, Progress, Select, Spinner, Switch, Table, Tabs, Tag, Toast, Toasts } from 'agnostic-svelte';
|
|
27
|
-
export { Visiblity, HeaderNavigationItem, DynamicMenu, FlatMenu, ColumnMenu, HamburgerMenu, BlogTitle, BlogDescription, listAllPosts, importPost, DefaultLayout, TwoColumnsLayout, Banner, Link, Logo, SimpleFooter, Gallery, Carusel, CaruseleItem, Spacer, Well, Justify, Placement, Orientation, AlignItmes, Position, Sizes, ShowItem, convertShowItemsToNavigationItems, title, suffix, pages, metaDescription, metaKeywords, Alert, Avatar, AvatarGroup, Breadcrumb, Button, ButtonGroup, Card, ChoiceInput, Close, Dialog, Disclose, Divider, Drawer, EmptyState, Header, HeaderNav, HeaderNavItem, Icon, IconSvg, Input, InputAddonItem, Loader, Pagination, Progress, Select, Spinner, Switch, Table, Tabs, Tag, Toast, Toasts };
|
|
27
|
+
export { Visiblity, HeaderNavigationItem, DynamicMenu, FlatMenu, ColumnMenu, HamburgerMenu, BlogTitle, BlogDescription, listAllPosts, importPost, DefaultLayout, TwoColumnsLayout, Banner, Link, Logo, SimpleFooter, Gallery, Carusel, CaruseleItem, Spacer, Well, Justify, Placement, Orientation, AlignItmes, Position, Sizes, ShowItem, convertShowItemsToNavigationItems, title, suffix, pages, metaDescription, metaKeywords, Alert, Avatar, AvatarGroup, Breadcrumb, Button, ButtonGroup, Card, ChoiceInput, Close, Dialog, Disclose, Divider, Drawer, EmptyState, Header, HeaderNav, HeaderNavItem, Icon, IconSvg, Input, InputAddonItem, Loader, Pagination, Progress, Select, Spinner, Switch, Table, Tabs, Tag, Toast, Toasts, configureAuthentication };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionalcms/svelte-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"watch": {
|
|
5
5
|
"build": {
|
|
6
6
|
"patterns": [
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"vite": "^5.0.10"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@splidejs/svelte-splide": "^0.2.9"
|
|
60
|
+
"@splidejs/svelte-splide": "^0.2.9",
|
|
61
|
+
"@auth/sveltekit": "latest"
|
|
61
62
|
},
|
|
62
63
|
"svelte": "./dist/index.js",
|
|
63
64
|
"types": "./dist/index.d.ts",
|