@hellocoop/svelte 2.1.0 → 2.1.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/LICENSE +21 -0
- package/dist/auth.d.ts +0 -1
- package/dist/buttons/BaseButton.svelte +4 -4
- package/dist/buttons/BaseButton.svelte.d.ts +16 -15
- package/dist/types.d.ts +42 -25
- package/dist/types.js +95 -2
- package/package.json +7 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { routeConfig } from "../Provider.svelte";
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
|
-
import { Button } from "@hellocoop/
|
|
3
|
+
import { Button } from "@hellocoop/definitions";
|
|
4
4
|
export let label = "\u014D Continue with Hell\u014D";
|
|
5
5
|
export let style = {};
|
|
6
6
|
export let color = "black";
|
|
@@ -15,7 +15,7 @@ export let disabled = false;
|
|
|
15
15
|
export let promptLogin = false;
|
|
16
16
|
export let promptConsent = false;
|
|
17
17
|
export let loginHint = "";
|
|
18
|
-
export let
|
|
18
|
+
export let domainHint = "";
|
|
19
19
|
let checkedForStylesheet = false;
|
|
20
20
|
onMount(() => {
|
|
21
21
|
if (typeof window != "undefined" && !checkedForStylesheet) {
|
|
@@ -43,8 +43,8 @@ if (promptLogin && promptConsent) {
|
|
|
43
43
|
}
|
|
44
44
|
if (loginHint)
|
|
45
45
|
loginRoute.searchParams.set("login_hint", loginHint);
|
|
46
|
-
if (
|
|
47
|
-
loginRoute.searchParams.set("
|
|
46
|
+
if (domainHint)
|
|
47
|
+
loginRoute.searchParams.set("login_hint", domainHint);
|
|
48
48
|
if (providerHint)
|
|
49
49
|
loginRoute.searchParams.set("provider_hint", providerHint.join(" "));
|
|
50
50
|
const onClickHandler = () => {
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderHint, Scope } from '@hellocoop/definitions';
|
|
3
|
+
import { Button } from '@hellocoop/definitions';
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
|
-
label?: string
|
|
6
|
+
label?: string;
|
|
6
7
|
style?: any;
|
|
7
|
-
color?: Button.Color
|
|
8
|
-
theme?: Button.Theme
|
|
9
|
-
hover?: Button.Hover
|
|
10
|
-
scope?:
|
|
11
|
-
update?: boolean
|
|
12
|
-
targetURI?: string
|
|
13
|
-
providerHint?:
|
|
14
|
-
showLoader?: boolean
|
|
15
|
-
disabled?: boolean
|
|
16
|
-
promptLogin?: boolean
|
|
17
|
-
promptConsent?: boolean
|
|
18
|
-
loginHint?: string
|
|
19
|
-
|
|
8
|
+
color?: Button.Color;
|
|
9
|
+
theme?: Button.Theme;
|
|
10
|
+
hover?: Button.Hover;
|
|
11
|
+
scope?: Scope[];
|
|
12
|
+
update?: boolean;
|
|
13
|
+
targetURI?: string;
|
|
14
|
+
providerHint?: ProviderHint[];
|
|
15
|
+
showLoader?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
promptLogin?: boolean;
|
|
18
|
+
promptConsent?: boolean;
|
|
19
|
+
loginHint?: string;
|
|
20
|
+
domainHint?: string;
|
|
20
21
|
};
|
|
21
22
|
events: {
|
|
22
23
|
[evt: string]: CustomEvent<any>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
|
|
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--"];
|
|
2
11
|
export type Scope = typeof VALID_SCOPES[number];
|
|
3
12
|
export type AuthResponseType = typeof VALID_RESPONSE_TYPE[number];
|
|
4
13
|
export type AuthResponseMode = typeof VALID_RESPONSE_MODE[number];
|
|
5
14
|
export type ProviderHint = typeof VALID_PROVIDER_HINT[number];
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
[K in IdentityStringClaims]?: string;
|
|
15
|
+
type IdentityClaims = typeof VALID_IDENTITY_CLAIMS[number];
|
|
16
|
+
type OptionalClaims = {
|
|
17
|
+
[K in IdentityClaims]?: unknown;
|
|
10
18
|
};
|
|
11
|
-
type
|
|
12
|
-
[K in IdentityAccountClaims]?: {
|
|
13
|
-
id: string;
|
|
14
|
-
username: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export type Claims = OptionalStringClaims & OptionalAccountClaims & {
|
|
19
|
+
export type Claims = OptionalClaims & {
|
|
18
20
|
sub: string;
|
|
19
21
|
};
|
|
20
|
-
type
|
|
21
|
-
sub: string;
|
|
22
|
-
iat: number;
|
|
23
|
-
} & Claims & {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
};
|
|
26
|
-
export type Auth = {
|
|
27
|
-
isLoggedIn: false;
|
|
28
|
-
} | ({
|
|
29
|
-
isLoggedIn: true;
|
|
30
|
-
cookieToken?: string;
|
|
31
|
-
} & AuthCookie);
|
|
32
|
-
export type TokenPayload = OptionalStringClaims & OptionalAccountClaims & {
|
|
22
|
+
export type TokenPayload = OptionalClaims & {
|
|
33
23
|
iss: string;
|
|
34
24
|
aud: string;
|
|
35
25
|
nonce: string;
|
|
@@ -43,4 +33,31 @@ export type TokenHeader = {
|
|
|
43
33
|
typ: string;
|
|
44
34
|
alg: string;
|
|
45
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 Update = boolean;
|
|
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
|
+
}
|
|
46
63
|
export {};
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Svelte SDK for Hellō https://hello.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://www.hello.dev/docs/sdks/svelte",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "
|
|
11
|
+
"build": "svelte-kit sync && svelte-package && publint",
|
|
12
|
+
"prebuild": "rimraf dist node_modules"
|
|
12
13
|
},
|
|
13
14
|
"exports": {
|
|
14
15
|
".": {
|
|
@@ -57,7 +58,8 @@
|
|
|
57
58
|
"types": "./dist/index.d.ts",
|
|
58
59
|
"type": "module",
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
}
|
|
61
|
+
"@hellocoop/definitions": "^1.0.4",
|
|
62
|
+
"sswr": "^2.0.0"
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "b418b4e249a7fe7025d467688e52132848b465a2"
|
|
63
65
|
}
|