@hellocoop/svelte 1.0.1 → 1.0.2
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 +5 -53
- package/dist/Provider.svelte +9 -9
- package/dist/Provider.svelte.d.ts +2 -2
- package/dist/buttons/BaseButton.svelte +16 -4
- package/dist/buttons/BaseButton.svelte.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +63 -0
- package/dist/types.js +95 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1,58 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Svelte package for Hellō
|
|
2
2
|
|
|
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
|
+
- Svelte components for buttons and logged in context
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
See the [Svelte SDK documentation](https://www.hello.dev/docs/sdks/svelte) for details.
|
|
8
9
|
|
|
9
|
-
If you're seeing this, you've probably already done this step. Congrats!
|
|
10
10
|
|
|
11
|
-
```bash
|
|
12
|
-
# create a new project in the current directory
|
|
13
|
-
npm create svelte@latest
|
|
14
|
-
|
|
15
|
-
# create a new project in my-app
|
|
16
|
-
npm create svelte@latest my-app
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Developing
|
|
20
|
-
|
|
21
|
-
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm run dev
|
|
25
|
-
|
|
26
|
-
# or start the server and open the app in a new browser tab
|
|
27
|
-
npm run dev -- --open
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
|
|
31
|
-
|
|
32
|
-
## Building
|
|
33
|
-
|
|
34
|
-
To build your library:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npm run package
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
To create a production version of your showcase app:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npm run build
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
You can preview the production build with `npm run preview`.
|
|
47
|
-
|
|
48
|
-
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
|
49
|
-
|
|
50
|
-
## Publishing
|
|
51
|
-
|
|
52
|
-
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
|
|
53
|
-
|
|
54
|
-
To publish your library to [npm](https://www.npmjs.com):
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npm publish
|
|
58
|
-
```
|
package/dist/Provider.svelte
CHANGED
|
@@ -10,15 +10,15 @@ export const getHelloProviderContext = () => {
|
|
|
10
10
|
};
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<script>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
<script>export let auth = {};
|
|
14
|
+
export let config = {};
|
|
15
|
+
setContext("HelloProviderContext", auth);
|
|
16
|
+
if (config?.login)
|
|
17
|
+
routeConfig.login = config.login;
|
|
18
|
+
if (config?.auth)
|
|
19
|
+
routeConfig.auth = config.auth;
|
|
20
|
+
if (config?.logout)
|
|
21
|
+
routeConfig.logout = config.logout;
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<slot/>
|
|
@@ -8,8 +8,8 @@ export declare const routeConfig: {
|
|
|
8
8
|
export declare const getHelloProviderContext: () => Auth | undefined;
|
|
9
9
|
declare const __propDef: {
|
|
10
10
|
props: {
|
|
11
|
-
auth?:
|
|
12
|
-
config?:
|
|
11
|
+
auth?: any;
|
|
12
|
+
config?: any;
|
|
13
13
|
};
|
|
14
14
|
events: {
|
|
15
15
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
<script>import { routeConfig } from "../Provider.svelte";
|
|
2
|
-
import {
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import { Button } from "../types";
|
|
3
4
|
export let label = "\u014D Continue with Hell\u014D";
|
|
4
5
|
export let style = {};
|
|
5
6
|
export let color = "black";
|
|
6
7
|
export let theme = "ignore-light";
|
|
7
8
|
export let hover = "pop";
|
|
8
|
-
export let scope;
|
|
9
|
-
export let updateScope;
|
|
9
|
+
export let scope = [];
|
|
10
|
+
export let updateScope = "";
|
|
10
11
|
export let targetURI = "";
|
|
11
|
-
export let providerHint;
|
|
12
|
+
export let providerHint = [];
|
|
12
13
|
export let showLoader = false;
|
|
13
14
|
export let disabled = false;
|
|
15
|
+
let checkedForStylesheet = false;
|
|
16
|
+
onMount(() => {
|
|
17
|
+
if (typeof window != "undefined" && !checkedForStylesheet) {
|
|
18
|
+
const hasStylesheet = Array.from(document.head.getElementsByTagName("link")).find(
|
|
19
|
+
(element) => element.getAttribute("rel") === "stylesheet" && element.getAttribute("href")?.startsWith(Button.STYLES_URL)
|
|
20
|
+
);
|
|
21
|
+
if (!hasStylesheet)
|
|
22
|
+
console.warn("Could not find Hell\u014D stylesheet. Please add to pages with Hell\u014D buttons. See http://hello.dev/docs/buttons/#stylesheet for more info.");
|
|
23
|
+
checkedForStylesheet = true;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
14
26
|
let clicked = false;
|
|
15
27
|
const loginRoute = new URL(routeConfig.login, window.location.origin);
|
|
16
28
|
if (scope)
|
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export { default as LoggedIn } from './login-status/LoggedIn.svelte';
|
|
|
10
10
|
export { default as LoggedOut } from './login-status/LoggedOut.svelte';
|
|
11
11
|
export * from './auth.js';
|
|
12
12
|
export * from './logout.js';
|
|
13
|
-
export { default as
|
|
13
|
+
export { default as HelloProvider, routeConfig, getHelloProviderContext } from './Provider.svelte';
|
package/dist/index.js
CHANGED
|
@@ -16,4 +16,4 @@ export * from './auth.js';
|
|
|
16
16
|
//Logout
|
|
17
17
|
export * from './logout.js';
|
|
18
18
|
//Provider
|
|
19
|
-
export { default as
|
|
19
|
+
export { default as HelloProvider, routeConfig, getHelloProviderContext } from './Provider.svelte';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export declare const PRODUCTION_WALLET: string;
|
|
2
|
+
export declare const DEFAULT_SCOPE: Scope[];
|
|
3
|
+
export declare const DEFAULT_RESPONSE_TYPE: AuthResponseType;
|
|
4
|
+
export declare const DEFAULT_RESPONSE_MODE: AuthResponseMode;
|
|
5
|
+
export declare const DEFAULT_PATH: string;
|
|
6
|
+
export declare const VALID_IDENTITY_CLAIMS: readonly ["name", "nickname", "preferred_username", "given_name", "family_name", "email", "phone", "picture", "ethereum", "discord", "twitter", "github", "gitlab"];
|
|
7
|
+
export declare const VALID_SCOPES: readonly ["name", "nickname", "preferred_username", "given_name", "family_name", "email", "phone", "picture", "ethereum", "discord", "twitter", "github", "gitlab", "openid", "profile_update"];
|
|
8
|
+
export declare const VALID_RESPONSE_TYPE: readonly ["id_token", "code"];
|
|
9
|
+
export declare const VALID_RESPONSE_MODE: string[];
|
|
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];
|
|
16
|
+
type OptionalClaims = {
|
|
17
|
+
[K in IdentityClaims]?: unknown;
|
|
18
|
+
};
|
|
19
|
+
export type Claims = OptionalClaims & {
|
|
20
|
+
sub: string;
|
|
21
|
+
};
|
|
22
|
+
export type TokenPayload = OptionalClaims & {
|
|
23
|
+
iss: string;
|
|
24
|
+
aud: string;
|
|
25
|
+
nonce: string;
|
|
26
|
+
jti: string;
|
|
27
|
+
sub: string;
|
|
28
|
+
scope: string[];
|
|
29
|
+
iat: number;
|
|
30
|
+
exp: number;
|
|
31
|
+
};
|
|
32
|
+
export type TokenHeader = {
|
|
33
|
+
typ: string;
|
|
34
|
+
alg: string;
|
|
35
|
+
};
|
|
36
|
+
export declare namespace Button {
|
|
37
|
+
type Color = "black" | "white";
|
|
38
|
+
type Theme = "ignore-light" | "ignore-dark" | "aware-invert" | "aware-static";
|
|
39
|
+
type Hover = "pop" | "glow" | "flare" | "none";
|
|
40
|
+
type UpdateScope = "email" | "picture" | "twitter" | "discord" | "github" | "gitlab";
|
|
41
|
+
const STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css";
|
|
42
|
+
const HOVER_MAPPING: {
|
|
43
|
+
pop: string;
|
|
44
|
+
glow: string;
|
|
45
|
+
flare: string;
|
|
46
|
+
none: string;
|
|
47
|
+
};
|
|
48
|
+
const CLASS_MAPPING: {
|
|
49
|
+
black: {
|
|
50
|
+
"ignore-light": string;
|
|
51
|
+
"ignore-dark": string;
|
|
52
|
+
"aware-invert": string;
|
|
53
|
+
"aware-static": string;
|
|
54
|
+
};
|
|
55
|
+
white: {
|
|
56
|
+
"ignore-light": string;
|
|
57
|
+
"ignore-dark": string;
|
|
58
|
+
"aware-invert": string;
|
|
59
|
+
"aware-static": string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export const PRODUCTION_WALLET = 'https://wallet.hello.coop';
|
|
2
|
+
export const DEFAULT_SCOPE = ['openid', 'name', 'email', 'picture'];
|
|
3
|
+
export const DEFAULT_RESPONSE_TYPE = 'code';
|
|
4
|
+
export const DEFAULT_RESPONSE_MODE = 'query';
|
|
5
|
+
export const DEFAULT_PATH = '/authorize?';
|
|
6
|
+
export const VALID_IDENTITY_CLAIMS = [
|
|
7
|
+
'name',
|
|
8
|
+
'nickname',
|
|
9
|
+
'preferred_username',
|
|
10
|
+
'given_name',
|
|
11
|
+
'family_name',
|
|
12
|
+
'email',
|
|
13
|
+
'phone',
|
|
14
|
+
'picture',
|
|
15
|
+
// Hellō extensions -- non-standard claims
|
|
16
|
+
'ethereum',
|
|
17
|
+
'discord',
|
|
18
|
+
'twitter',
|
|
19
|
+
'github',
|
|
20
|
+
'gitlab'
|
|
21
|
+
];
|
|
22
|
+
export const VALID_SCOPES = [
|
|
23
|
+
...VALID_IDENTITY_CLAIMS,
|
|
24
|
+
'openid',
|
|
25
|
+
// Hellō extensions -- non-standard scopes
|
|
26
|
+
'profile_update',
|
|
27
|
+
];
|
|
28
|
+
export const VALID_RESPONSE_TYPE = ['id_token', 'code']; // Default: 'code'
|
|
29
|
+
export const VALID_RESPONSE_MODE = ['fragment', 'query', 'form_post']; // Default: 'query'
|
|
30
|
+
export const VALID_PROVIDER_HINT = [
|
|
31
|
+
// 'google' and 'email' are always in default
|
|
32
|
+
// 'apple' added if on Apple OS
|
|
33
|
+
// 'microsoft' added if on Microsoft OS
|
|
34
|
+
'apple',
|
|
35
|
+
'discord',
|
|
36
|
+
'facebook',
|
|
37
|
+
'github',
|
|
38
|
+
'gitlab',
|
|
39
|
+
'google',
|
|
40
|
+
'twitch',
|
|
41
|
+
'twitter',
|
|
42
|
+
'tumblr',
|
|
43
|
+
'mastodon',
|
|
44
|
+
'microsoft',
|
|
45
|
+
'line',
|
|
46
|
+
'wordpress',
|
|
47
|
+
'yahoo',
|
|
48
|
+
'phone',
|
|
49
|
+
'ethereum',
|
|
50
|
+
'qrcode',
|
|
51
|
+
// the following will remove provider from recommended list
|
|
52
|
+
'apple--',
|
|
53
|
+
'microsoft--',
|
|
54
|
+
'google--',
|
|
55
|
+
'email--',
|
|
56
|
+
'passkey--',
|
|
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
|
+
export var Button;
|
|
73
|
+
(function (Button) {
|
|
74
|
+
Button.STYLES_URL = 'https://cdn.hello.coop/css/hello-btn.css';
|
|
75
|
+
Button.HOVER_MAPPING = {
|
|
76
|
+
"pop": "",
|
|
77
|
+
"glow": "hello-btn-hover-glow",
|
|
78
|
+
"flare": "hello-btn-hover-flare",
|
|
79
|
+
"none": "hello-btn-hover-none"
|
|
80
|
+
};
|
|
81
|
+
Button.CLASS_MAPPING = {
|
|
82
|
+
black: {
|
|
83
|
+
"ignore-light": "",
|
|
84
|
+
"ignore-dark": "hello-btn-black-on-dark",
|
|
85
|
+
"aware-invert": "hello-btn-black-and-invert",
|
|
86
|
+
"aware-static": "hello-btn-black-and-static"
|
|
87
|
+
},
|
|
88
|
+
white: {
|
|
89
|
+
"ignore-light": "hello-btn-white-on-light",
|
|
90
|
+
"ignore-dark": "hello-btn-white-on-dark",
|
|
91
|
+
"aware-invert": "hello-btn-white-and-invert",
|
|
92
|
+
"aware-static": "hello-btn-white-and-static"
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
})(Button || (Button = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hellocoop/svelte",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Svelte SDK for Hellō https://hello.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://www.hello.dev/docs/sdks/svelte",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "svelte-kit sync && svelte-package && publint"
|
|
11
|
+
"build": "cp ../types/types.ts ./src/lib/ && svelte-kit sync && svelte-package && publint"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
"types": "./dist/index.d.ts",
|
|
58
58
|
"type": "module",
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@hellocoop/types": "^1.0.2",
|
|
61
60
|
"sswr": "^2.0.0"
|
|
62
61
|
}
|
|
63
62
|
}
|