@hellocoop/svelte 2.1.6 → 2.1.8-canary.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/README.md +1 -2
- package/dist/Provider.svelte +25 -21
- package/dist/Provider.svelte.d.ts +28 -19
- package/dist/auth.js +5 -5
- package/dist/buttons/BaseButton.svelte +83 -60
- package/dist/buttons/BaseButton.svelte.d.ts +33 -31
- package/dist/buttons/ContinueButton.svelte +3 -2
- package/dist/buttons/ContinueButton.svelte.d.ts +18 -16
- package/dist/buttons/LoginButton.svelte +3 -2
- package/dist/buttons/LoginButton.svelte.d.ts +18 -16
- package/dist/buttons/UpdateProfileButton.svelte +7 -2
- package/dist/buttons/UpdateProfileButton.svelte.d.ts +18 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/login-status/LoggedIn.svelte +8 -4
- package/dist/login-status/LoggedIn.svelte.d.ts +18 -16
- package/dist/login-status/LoggedOut.svelte +10 -6
- package/dist/login-status/LoggedOut.svelte.d.ts +18 -16
- package/dist/types.d.ts +16 -16
- package/dist/types.js +13 -27
- package/package.json +64 -63
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
[Hellō](https://hello.dev) is an identity network that provides login and registration using the standard OpenID Connect protocol. Hellō offers your users choice between all popular social login providers.
|
|
4
4
|
|
|
5
5
|
This [Svelte](https://svelte.dev/) package provides:
|
|
6
|
+
|
|
6
7
|
- Svelte components for buttons and logged in context
|
|
7
8
|
|
|
8
9
|
See the [Svelte SDK documentation](https://www.hello.dev/docs/sdks/svelte) for details.
|
|
9
|
-
|
|
10
|
-
|
package/dist/Provider.svelte
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
<script context="module"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
import type { Auth } from './auth.js'
|
|
3
|
+
import { setContext, getContext } from 'svelte'
|
|
4
|
+
|
|
5
|
+
export const routeConfig = {
|
|
6
|
+
login: '/api/hellocoop?login=true',
|
|
7
|
+
auth: '/api/hellocoop?auth=true',
|
|
8
|
+
logout: '/api/hellocoop?logout=true',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getHelloProviderContext = (): Auth | undefined => {
|
|
12
|
+
return getContext('HelloProviderContext')
|
|
13
|
+
}
|
|
10
14
|
</script>
|
|
11
|
-
|
|
12
|
-
<script
|
|
13
|
-
export let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (config?.
|
|
20
|
-
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
export let auth: any = {} //tbd: any
|
|
18
|
+
export let config: any = {} //tbd: any
|
|
19
|
+
|
|
20
|
+
setContext('HelloProviderContext', auth)
|
|
21
|
+
|
|
22
|
+
if (config?.login) routeConfig.login = config.login
|
|
23
|
+
if (config?.auth) routeConfig.auth = config.auth
|
|
24
|
+
if (config?.logout) routeConfig.logout = config.logout
|
|
21
25
|
</script>
|
|
22
|
-
|
|
23
|
-
<slot/>
|
|
26
|
+
|
|
27
|
+
<slot />
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { Auth } from './auth.js';
|
|
3
2
|
export declare const routeConfig: {
|
|
4
3
|
login: string;
|
|
@@ -6,23 +5,33 @@ export declare const routeConfig: {
|
|
|
6
5
|
logout: string;
|
|
7
6
|
};
|
|
8
7
|
export declare const getHelloProviderContext: () => Auth | undefined;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
9
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
10
|
+
$$bindings?: Bindings;
|
|
11
|
+
} & Exports;
|
|
12
|
+
(internal: unknown, props: Props & {
|
|
13
|
+
$$events?: Events;
|
|
14
|
+
$$slots?: Slots;
|
|
15
|
+
}): Exports & {
|
|
16
|
+
$set?: any;
|
|
17
|
+
$on?: any;
|
|
13
18
|
};
|
|
14
|
-
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
};
|
|
17
|
-
slots: {
|
|
18
|
-
default: {};
|
|
19
|
-
};
|
|
20
|
-
exports?: {} | undefined;
|
|
21
|
-
bindings?: string | undefined;
|
|
22
|
-
};
|
|
23
|
-
export type ProviderProps = typeof __propDef.props;
|
|
24
|
-
export type ProviderEvents = typeof __propDef.events;
|
|
25
|
-
export type ProviderSlots = typeof __propDef.slots;
|
|
26
|
-
export default class Provider extends SvelteComponent<ProviderProps, ProviderEvents, ProviderSlots> {
|
|
19
|
+
z_$$bindings?: Bindings;
|
|
27
20
|
}
|
|
28
|
-
|
|
21
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
22
|
+
default: any;
|
|
23
|
+
} ? Props extends Record<string, never> ? any : {
|
|
24
|
+
children?: any;
|
|
25
|
+
} : {});
|
|
26
|
+
declare const Provider: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
27
|
+
auth?: any;
|
|
28
|
+
config?: any;
|
|
29
|
+
}, {
|
|
30
|
+
default: {};
|
|
31
|
+
}>, {
|
|
32
|
+
[evt: string]: CustomEvent<any>;
|
|
33
|
+
}, {
|
|
34
|
+
default: {};
|
|
35
|
+
}, {}, string>;
|
|
36
|
+
type Provider = InstanceType<typeof Provider>;
|
|
37
|
+
export default Provider;
|
package/dist/auth.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
2
|
// @ts-ignore tbd
|
|
3
|
-
import { useSWR } from
|
|
3
|
+
import { useSWR } from 'sswr';
|
|
4
4
|
// @ts-ignore tbd - has no exported member?
|
|
5
|
-
import { getHelloProviderContext, routeConfig } from
|
|
5
|
+
import { getHelloProviderContext, routeConfig } from './Provider.svelte';
|
|
6
6
|
const fetcher = async (url) => {
|
|
7
7
|
try {
|
|
8
8
|
const response = await fetch(url);
|
|
@@ -16,13 +16,13 @@ const fetcher = async (url) => {
|
|
|
16
16
|
};
|
|
17
17
|
export const useAuth = () => {
|
|
18
18
|
const defaultAuth = getHelloProviderContext();
|
|
19
|
-
const { data: auth, isLoading } = useSWR(routeConfig.auth, {
|
|
19
|
+
const { data: auth, isLoading, } = useSWR(routeConfig.auth, {
|
|
20
20
|
fetcher,
|
|
21
|
-
initialData: defaultAuth
|
|
21
|
+
initialData: defaultAuth,
|
|
22
22
|
});
|
|
23
23
|
return {
|
|
24
24
|
auth: auth || {},
|
|
25
25
|
isLoading,
|
|
26
|
-
isLoggedIn: auth?.isLoggedIn
|
|
26
|
+
isLoggedIn: auth?.isLoggedIn,
|
|
27
27
|
};
|
|
28
28
|
};
|
|
@@ -1,64 +1,87 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
export let
|
|
17
|
-
export let
|
|
18
|
-
export let
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { routeConfig } from '../Provider.svelte'
|
|
3
|
+
import type { ProviderHint, Scope } from '@hellocoop/definitions'
|
|
4
|
+
import { onMount } from 'svelte'
|
|
5
|
+
import { Button } from '../types.js' // tbd use @hellocoop/definitions (currently, some esm import errors)
|
|
6
|
+
|
|
7
|
+
export let label: string = 'ō Continue with Hellō'
|
|
8
|
+
export let style: any = {} //TBD any
|
|
9
|
+
export let color: Button.Color = 'black'
|
|
10
|
+
export let theme: Button.Theme = 'ignore-light'
|
|
11
|
+
export let hover: Button.Hover = 'pop'
|
|
12
|
+
export let scope: Scope[] = []
|
|
13
|
+
// @ts-ignore tbd
|
|
14
|
+
export let update: Button.update = false
|
|
15
|
+
export let targetURI: string = ''
|
|
16
|
+
export let providerHint: ProviderHint[] = []
|
|
17
|
+
export let showLoader: boolean = false
|
|
18
|
+
export let disabled: boolean = false
|
|
19
|
+
export let promptLogin: boolean = false
|
|
20
|
+
export let promptConsent: boolean = false
|
|
21
|
+
export let loginHint: string = ''
|
|
22
|
+
export let domainHint: string = ''
|
|
23
|
+
|
|
24
|
+
let checkedForStylesheet: boolean = false
|
|
25
|
+
|
|
26
|
+
onMount(() => {
|
|
27
|
+
//check if dev has added Hellō stylesheet to pages with Hellō buttons
|
|
28
|
+
if (typeof window != 'undefined' && !checkedForStylesheet) {
|
|
29
|
+
const hasStylesheet = Array.from(
|
|
30
|
+
document.head.getElementsByTagName('link'),
|
|
31
|
+
).find(
|
|
32
|
+
(element) =>
|
|
33
|
+
element.getAttribute('rel') === 'stylesheet' &&
|
|
34
|
+
element.getAttribute('href')?.startsWith(Button.STYLES_URL),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
if (!hasStylesheet)
|
|
38
|
+
console.warn(
|
|
39
|
+
'Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info.',
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
checkedForStylesheet = true
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
let clicked: boolean = false
|
|
47
|
+
const loginRoute = new URL(routeConfig.login, window.location.origin)
|
|
48
|
+
if (scope) loginRoute.searchParams.set('scope', scope.join(' '))
|
|
49
|
+
|
|
50
|
+
loginRoute.searchParams.set(
|
|
51
|
+
'target_uri',
|
|
52
|
+
targetURI || window.location.pathname,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
if (update) loginRoute.searchParams.set('prompt', 'consent')
|
|
56
|
+
|
|
57
|
+
if (promptLogin && promptConsent) {
|
|
58
|
+
loginRoute.searchParams.set('prompt', 'login consent')
|
|
59
|
+
} else if (promptLogin) {
|
|
60
|
+
loginRoute.searchParams.set('prompt', 'login')
|
|
61
|
+
} else if (promptConsent) {
|
|
62
|
+
loginRoute.searchParams.set('prompt', 'consent')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (loginHint) loginRoute.searchParams.set('login_hint', loginHint)
|
|
66
|
+
|
|
67
|
+
if (domainHint) loginRoute.searchParams.set('login_hint', domainHint)
|
|
68
|
+
|
|
69
|
+
if (providerHint)
|
|
70
|
+
loginRoute.searchParams.set('provider_hint', providerHint.join(' '))
|
|
71
|
+
|
|
72
|
+
const onClickHandler = (): void => {
|
|
73
|
+
clicked = true
|
|
74
|
+
window.location.href = loginRoute.href
|
|
75
|
+
}
|
|
54
76
|
</script>
|
|
55
77
|
|
|
56
78
|
<button
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
79
|
+
on:click={onClickHandler}
|
|
80
|
+
class="hello-btn {Button.CLASS_MAPPING[color]?.[theme]} {Button
|
|
81
|
+
.HOVER_MAPPING[hover]}"
|
|
82
|
+
class:hello-btn-loader={showLoader || clicked}
|
|
83
|
+
disabled={disabled || clicked}
|
|
84
|
+
{style}
|
|
62
85
|
>
|
|
63
|
-
|
|
64
|
-
</button>
|
|
86
|
+
{@html label}
|
|
87
|
+
</button>
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { ProviderHint, Scope } from '@hellocoop/definitions';
|
|
3
|
-
import { Button } from '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
providerHint?: ProviderHint[];
|
|
15
|
-
showLoader?: boolean;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
promptLogin?: boolean;
|
|
18
|
-
promptConsent?: boolean;
|
|
19
|
-
loginHint?: string;
|
|
20
|
-
domainHint?: string;
|
|
2
|
+
import { Button } from '../types.js';
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
21
13
|
};
|
|
22
|
-
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {};
|
|
26
|
-
exports?: {} | undefined;
|
|
27
|
-
bindings?: string | undefined;
|
|
28
|
-
};
|
|
29
|
-
export type BaseButtonProps = typeof __propDef.props;
|
|
30
|
-
export type BaseButtonEvents = typeof __propDef.events;
|
|
31
|
-
export type BaseButtonSlots = typeof __propDef.slots;
|
|
32
|
-
export default class BaseButton extends SvelteComponent<BaseButtonProps, BaseButtonEvents, BaseButtonSlots> {
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
33
15
|
}
|
|
34
|
-
|
|
16
|
+
declare const BaseButton: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
label?: string;
|
|
18
|
+
style?: any;
|
|
19
|
+
color?: Button.Color;
|
|
20
|
+
theme?: Button.Theme;
|
|
21
|
+
hover?: Button.Hover;
|
|
22
|
+
scope?: Scope[];
|
|
23
|
+
update?: Button.update;
|
|
24
|
+
targetURI?: string;
|
|
25
|
+
providerHint?: ProviderHint[];
|
|
26
|
+
showLoader?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
promptLogin?: boolean;
|
|
29
|
+
promptConsent?: boolean;
|
|
30
|
+
loginHint?: string;
|
|
31
|
+
domainHint?: string;
|
|
32
|
+
}, {
|
|
33
|
+
[evt: string]: CustomEvent<any>;
|
|
34
|
+
}, {}, {}, string>;
|
|
35
|
+
type BaseButton = InstanceType<typeof BaseButton>;
|
|
36
|
+
export default BaseButton;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
5
11
|
};
|
|
6
|
-
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
exports?: undefined;
|
|
11
|
-
bindings?: undefined;
|
|
12
|
-
};
|
|
13
|
-
export type ContinueButtonProps = typeof __propDef.props;
|
|
14
|
-
export type ContinueButtonEvents = typeof __propDef.events;
|
|
15
|
-
export type ContinueButtonSlots = typeof __propDef.slots;
|
|
16
|
-
export default class ContinueButton extends SvelteComponent<ContinueButtonProps, ContinueButtonEvents, ContinueButtonSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
declare const ContinueButton: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
}, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type ContinueButton = InstanceType<typeof ContinueButton>;
|
|
20
|
+
export default ContinueButton;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import BaseButton from './BaseButton.svelte'
|
|
2
3
|
</script>
|
|
3
4
|
|
|
4
|
-
<BaseButton {...$$props} label="ō Login with Hellō" />
|
|
5
|
+
<BaseButton {...$$props} label="ō Login with Hellō" />
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
5
11
|
};
|
|
6
|
-
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
exports?: undefined;
|
|
11
|
-
bindings?: undefined;
|
|
12
|
-
};
|
|
13
|
-
export type LoginButtonProps = typeof __propDef.props;
|
|
14
|
-
export type LoginButtonEvents = typeof __propDef.events;
|
|
15
|
-
export type LoginButtonSlots = typeof __propDef.slots;
|
|
16
|
-
export default class LoginButton extends SvelteComponent<LoginButtonProps, LoginButtonEvents, LoginButtonSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
declare const LoginButton: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
}, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type LoginButton = InstanceType<typeof LoginButton>;
|
|
20
|
+
export default LoginButton;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import BaseButton from './BaseButton.svelte'
|
|
2
3
|
</script>
|
|
3
4
|
|
|
4
|
-
<BaseButton
|
|
5
|
+
<BaseButton
|
|
6
|
+
{...$$props}
|
|
7
|
+
label="ō Update Profile with Hellō"
|
|
8
|
+
update={true}
|
|
9
|
+
/>
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
5
11
|
};
|
|
6
|
-
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
exports?: undefined;
|
|
11
|
-
bindings?: undefined;
|
|
12
|
-
};
|
|
13
|
-
export type UpdateProfileButtonProps = typeof __propDef.props;
|
|
14
|
-
export type UpdateProfileButtonEvents = typeof __propDef.events;
|
|
15
|
-
export type UpdateProfileButtonSlots = typeof __propDef.slots;
|
|
16
|
-
export default class UpdateProfileButton extends SvelteComponent<UpdateProfileButtonProps, UpdateProfileButtonEvents, UpdateProfileButtonSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
declare const UpdateProfileButton: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
}, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type UpdateProfileButton = InstanceType<typeof UpdateProfileButton>;
|
|
20
|
+
export default UpdateProfileButton;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { default as LoggedIn } from './login-status/LoggedIn.svelte';
|
|
|
5
5
|
export { default as LoggedOut } from './login-status/LoggedOut.svelte';
|
|
6
6
|
export * from './auth.js';
|
|
7
7
|
export * from './logout.js';
|
|
8
|
-
export { default as HelloProvider, routeConfig, getHelloProviderContext } from './Provider.svelte';
|
|
8
|
+
export { default as HelloProvider, routeConfig, getHelloProviderContext, } from './Provider.svelte';
|
package/dist/index.js
CHANGED
|
@@ -12,4 +12,4 @@ export * from './auth.js';
|
|
|
12
12
|
export * from './logout.js';
|
|
13
13
|
//Provider
|
|
14
14
|
// @ts-ignore tbd - has no exported member?
|
|
15
|
-
export { default as HelloProvider, routeConfig, getHelloProviderContext } from './Provider.svelte';
|
|
15
|
+
export { default as HelloProvider, routeConfig, getHelloProviderContext, } from './Provider.svelte';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useAuth } from '../auth.js'
|
|
3
|
+
import type { Readable } from 'svelte/store'
|
|
4
|
+
|
|
5
|
+
const isLoggedIn = (): Readable<boolean> | boolean =>
|
|
6
|
+
useAuth()?.isLoggedIn || false
|
|
3
7
|
</script>
|
|
4
8
|
|
|
5
9
|
{#if isLoggedIn()}
|
|
6
|
-
|
|
7
|
-
{/if}
|
|
10
|
+
<slot />
|
|
11
|
+
{/if}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
6
11
|
};
|
|
7
|
-
|
|
8
|
-
default: {};
|
|
9
|
-
};
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type LoggedInProps = typeof __propDef.props;
|
|
14
|
-
export type LoggedInEvents = typeof __propDef.events;
|
|
15
|
-
export type LoggedInSlots = typeof __propDef.slots;
|
|
16
|
-
export default class LoggedIn extends SvelteComponent<LoggedInProps, LoggedInEvents, LoggedInSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
declare const LoggedIn: $$__sveltets_2_IsomorphicComponent<any, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {
|
|
17
|
+
default: {};
|
|
18
|
+
}, {}, string>;
|
|
19
|
+
type LoggedIn = InstanceType<typeof LoggedIn>;
|
|
20
|
+
export default LoggedIn;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useAuth } from '../auth.js'
|
|
3
|
+
import type { Readable } from 'svelte/store'
|
|
4
|
+
|
|
5
|
+
const isLoggedIn = (): Readable<boolean> | boolean =>
|
|
6
|
+
useAuth()?.isLoggedIn || false
|
|
3
7
|
</script>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<slot/>
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
{#if !isLoggedIn()}
|
|
10
|
+
<slot />
|
|
11
|
+
{/if}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
6
11
|
};
|
|
7
|
-
|
|
8
|
-
default: {};
|
|
9
|
-
};
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type LoggedOutProps = typeof __propDef.props;
|
|
14
|
-
export type LoggedOutEvents = typeof __propDef.events;
|
|
15
|
-
export type LoggedOutSlots = typeof __propDef.slots;
|
|
16
|
-
export default class LoggedOut extends SvelteComponent<LoggedOutProps, LoggedOutEvents, LoggedOutSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
declare const LoggedOut: $$__sveltets_2_IsomorphicComponent<any, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {
|
|
17
|
+
default: {};
|
|
18
|
+
}, {}, string>;
|
|
19
|
+
type LoggedOut = InstanceType<typeof LoggedOut>;
|
|
20
|
+
export default LoggedOut;
|
package/dist/types.d.ts
CHANGED
|
@@ -8,11 +8,11 @@ export declare const VALID_SCOPES: readonly ["name", "nickname", "preferred_user
|
|
|
8
8
|
export declare const VALID_RESPONSE_TYPE: readonly ["id_token", "code"];
|
|
9
9
|
export declare const VALID_RESPONSE_MODE: string[];
|
|
10
10
|
export declare const VALID_PROVIDER_HINT: readonly ["apple", "discord", "facebook", "github", "gitlab", "google", "twitch", "twitter", "tumblr", "mastodon", "microsoft", "line", "wordpress", "yahoo", "phone", "ethereum", "qrcode", "apple--", "microsoft--", "google--", "email--", "passkey--"];
|
|
11
|
-
export type Scope = typeof VALID_SCOPES[number];
|
|
12
|
-
export type AuthResponseType = typeof VALID_RESPONSE_TYPE[number];
|
|
13
|
-
export type AuthResponseMode = typeof VALID_RESPONSE_MODE[number];
|
|
14
|
-
export type ProviderHint = typeof VALID_PROVIDER_HINT[number];
|
|
15
|
-
type IdentityClaims = typeof VALID_IDENTITY_CLAIMS[number];
|
|
11
|
+
export type Scope = (typeof VALID_SCOPES)[number];
|
|
12
|
+
export type AuthResponseType = (typeof VALID_RESPONSE_TYPE)[number];
|
|
13
|
+
export type AuthResponseMode = (typeof VALID_RESPONSE_MODE)[number];
|
|
14
|
+
export type ProviderHint = (typeof VALID_PROVIDER_HINT)[number];
|
|
15
|
+
type IdentityClaims = (typeof VALID_IDENTITY_CLAIMS)[number];
|
|
16
16
|
type OptionalClaims = {
|
|
17
17
|
[K in IdentityClaims]?: unknown;
|
|
18
18
|
};
|
|
@@ -34,9 +34,9 @@ export type TokenHeader = {
|
|
|
34
34
|
alg: string;
|
|
35
35
|
};
|
|
36
36
|
export declare namespace Button {
|
|
37
|
-
type Color =
|
|
38
|
-
type Theme =
|
|
39
|
-
type Hover =
|
|
37
|
+
type Color = 'black' | 'white';
|
|
38
|
+
type Theme = 'ignore-light' | 'ignore-dark' | 'aware-invert' | 'aware-static';
|
|
39
|
+
type Hover = 'pop' | 'glow' | 'flare' | 'none';
|
|
40
40
|
type Update = boolean;
|
|
41
41
|
const STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css";
|
|
42
42
|
const HOVER_MAPPING: {
|
|
@@ -47,16 +47,16 @@ export declare namespace Button {
|
|
|
47
47
|
};
|
|
48
48
|
const CLASS_MAPPING: {
|
|
49
49
|
black: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
'ignore-light': string;
|
|
51
|
+
'ignore-dark': string;
|
|
52
|
+
'aware-invert': string;
|
|
53
|
+
'aware-static': string;
|
|
54
54
|
};
|
|
55
55
|
white: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
'ignore-light': string;
|
|
57
|
+
'ignore-dark': string;
|
|
58
|
+
'aware-invert': string;
|
|
59
|
+
'aware-static': string;
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
}
|
package/dist/types.js
CHANGED
|
@@ -17,7 +17,7 @@ export const VALID_IDENTITY_CLAIMS = [
|
|
|
17
17
|
'discord',
|
|
18
18
|
'twitter',
|
|
19
19
|
'github',
|
|
20
|
-
'gitlab'
|
|
20
|
+
'gitlab',
|
|
21
21
|
];
|
|
22
22
|
export const VALID_SCOPES = [
|
|
23
23
|
...VALID_IDENTITY_CLAIMS,
|
|
@@ -55,41 +55,27 @@ export const VALID_PROVIDER_HINT = [
|
|
|
55
55
|
'email--',
|
|
56
56
|
'passkey--',
|
|
57
57
|
];
|
|
58
|
-
const CLASS_MAPPING = {
|
|
59
|
-
black: {
|
|
60
|
-
"ignore-light": "",
|
|
61
|
-
"ignore-dark": "hello-btn-black-on-dark",
|
|
62
|
-
"aware-invert": "hello-btn-black-and-invert",
|
|
63
|
-
"aware-static": "hello-btn-black-and-static"
|
|
64
|
-
},
|
|
65
|
-
white: {
|
|
66
|
-
"ignore-light": "hello-btn-white-on-light",
|
|
67
|
-
"ignore-dark": "hello-btn-white-on-dark",
|
|
68
|
-
"aware-invert": "hello-btn-white-and-invert",
|
|
69
|
-
"aware-static": "hello-btn-white-and-static"
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
58
|
export var Button;
|
|
73
59
|
(function (Button) {
|
|
74
60
|
Button.STYLES_URL = 'https://cdn.hello.coop/css/hello-btn.css';
|
|
75
61
|
Button.HOVER_MAPPING = {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
pop: '',
|
|
63
|
+
glow: 'hello-btn-hover-glow',
|
|
64
|
+
flare: 'hello-btn-hover-flare',
|
|
65
|
+
none: 'hello-btn-hover-none',
|
|
80
66
|
};
|
|
81
67
|
Button.CLASS_MAPPING = {
|
|
82
68
|
black: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
'ignore-light': '',
|
|
70
|
+
'ignore-dark': 'hello-btn-black-on-dark',
|
|
71
|
+
'aware-invert': 'hello-btn-black-and-invert',
|
|
72
|
+
'aware-static': 'hello-btn-black-and-static',
|
|
87
73
|
},
|
|
88
74
|
white: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
75
|
+
'ignore-light': 'hello-btn-white-on-light',
|
|
76
|
+
'ignore-dark': 'hello-btn-white-on-dark',
|
|
77
|
+
'aware-invert': 'hello-btn-white-and-invert',
|
|
78
|
+
'aware-static': 'hello-btn-white-and-static',
|
|
93
79
|
},
|
|
94
80
|
};
|
|
95
81
|
})(Button || (Button = {}));
|
package/package.json
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
2
|
+
"name": "@hellocoop/svelte",
|
|
3
|
+
"version": "2.1.8-canary.0",
|
|
4
|
+
"description": "Svelte SDK for Hellō https://hello.dev",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/hellocoop/packages.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://www.hello.dev/docs/sdks/svelte",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "svelte-kit sync && svelte-package && publint",
|
|
12
|
+
"prebuild": "rimraf dist node_modules"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"svelte": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"reactjs",
|
|
22
|
+
"react",
|
|
23
|
+
"react.js",
|
|
24
|
+
"hello",
|
|
25
|
+
"openid",
|
|
26
|
+
"oidc",
|
|
27
|
+
"sso"
|
|
28
|
+
],
|
|
29
|
+
"author": {
|
|
30
|
+
"name": "Hello Identity Co-op",
|
|
31
|
+
"email": "contact@hello.coop",
|
|
32
|
+
"url": "https://hello.coop"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/hellocoop/packages/issues"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"!dist/**/*.test.*",
|
|
41
|
+
"!dist/**/*.spec.*"
|
|
42
|
+
],
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"svelte": ">=4.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@sveltejs/adapter-auto": "^3.3.1",
|
|
48
|
+
"@sveltejs/kit": "^2.9.1",
|
|
49
|
+
"@sveltejs/package": "^2.3.7",
|
|
50
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.1",
|
|
51
|
+
"publint": "^0.2.12",
|
|
52
|
+
"svelte": "^5.10.0",
|
|
53
|
+
"svelte-check": "^4.1.1",
|
|
54
|
+
"tslib": "^2.8.1",
|
|
55
|
+
"typescript": "^5.7.2",
|
|
56
|
+
"vite": "^6.0.3"
|
|
57
|
+
},
|
|
58
|
+
"svelte": "./dist/index.js",
|
|
59
|
+
"types": "./dist/index.d.ts",
|
|
60
|
+
"type": "module",
|
|
61
|
+
"gitHead": "96cc2f3fa1a3724a4a96b19cc7c5d97f04cc49f8",
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@hellocoop/definitions": "^1.0.9",
|
|
64
|
+
"sswr": "^2.1.0"
|
|
65
|
+
}
|
|
65
66
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Hellō
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|