@hellocoop/svelte 2.0.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 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,4 +1,3 @@
1
- /// <reference types="svelte" />
2
1
  import type { Readable } from 'svelte/store';
3
2
  import type { Claims } from './types.js';
4
3
  type AuthCookie = {
package/dist/auth.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="svelte" />
2
2
  // @ts-ignore tbd
3
3
  import { useSWR } from "sswr";
4
+ // @ts-ignore tbd - has no exported member?
4
5
  import { getHelloProviderContext, routeConfig } from "./Provider.svelte";
5
6
  const fetcher = async (url) => {
6
7
  try {
@@ -1,6 +1,6 @@
1
1
  <script>import { routeConfig } from "../Provider.svelte";
2
2
  import { onMount } from "svelte";
3
- import { Button } from "../types.js";
3
+ import { Button } from "@hellocoop/definitions";
4
4
  export let label = "\u014D&nbsp;&nbsp;&nbsp;Continue with Hell\u014D";
5
5
  export let style = {};
6
6
  export let color = "black";
@@ -12,6 +12,10 @@ export let targetURI = "";
12
12
  export let providerHint = [];
13
13
  export let showLoader = false;
14
14
  export let disabled = false;
15
+ export let promptLogin = false;
16
+ export let promptConsent = false;
17
+ export let loginHint = "";
18
+ export let domainHint = "";
15
19
  let checkedForStylesheet = false;
16
20
  onMount(() => {
17
21
  if (typeof window != "undefined" && !checkedForStylesheet) {
@@ -30,6 +34,17 @@ if (scope)
30
34
  loginRoute.searchParams.set("target_uri", targetURI || window.location.pathname);
31
35
  if (update)
32
36
  loginRoute.searchParams.set("prompt", "consent");
37
+ if (promptLogin && promptConsent) {
38
+ loginRoute.searchParams.set("prompt", "login consent");
39
+ } else if (promptLogin) {
40
+ loginRoute.searchParams.set("prompt", "login");
41
+ } else if (promptConsent) {
42
+ loginRoute.searchParams.set("prompt", "consent");
43
+ }
44
+ if (loginHint)
45
+ loginRoute.searchParams.set("login_hint", loginHint);
46
+ if (domainHint)
47
+ loginRoute.searchParams.set("login_hint", domainHint);
33
48
  if (providerHint)
34
49
  loginRoute.searchParams.set("provider_hint", providerHint.join(" "));
35
50
  const onClickHandler = () => {
@@ -1,17 +1,23 @@
1
1
  import { SvelteComponent } from "svelte";
2
+ import type { ProviderHint, Scope } from '@hellocoop/definitions';
3
+ import { Button } from '@hellocoop/definitions';
2
4
  declare const __propDef: {
3
5
  props: {
4
- label?: string | undefined;
6
+ label?: string;
5
7
  style?: any;
6
- color?: any;
7
- theme?: any;
8
- hover?: any;
9
- scope?: ("name" | "nickname" | "preferred_username" | "given_name" | "family_name" | "email" | "phone" | "picture" | "ethereum" | "discord" | "twitter" | "github" | "gitlab" | "profile" | "openid" | "profile_update")[] | undefined;
10
- update?: boolean | undefined;
11
- targetURI?: string | undefined;
12
- providerHint?: ("phone" | "ethereum" | "discord" | "twitter" | "github" | "gitlab" | "apple" | "facebook" | "google" | "twitch" | "tumblr" | "mastodon" | "microsoft" | "line" | "wordpress" | "yahoo" | "qrcode" | "apple--" | "microsoft--" | "google--" | "email--" | "passkey--")[] | undefined;
13
- showLoader?: boolean | undefined;
14
- disabled?: boolean | undefined;
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;
15
21
  };
16
22
  events: {
17
23
  [evt: string]: CustomEvent<any>;
@@ -1,4 +1,4 @@
1
1
  <script>import BaseButton from "./BaseButton.svelte";
2
2
  </script>
3
3
 
4
- <BaseButton label="ō&nbsp;&nbsp;&nbsp;Login with Hellō" {...$$props} />
4
+ <BaseButton {...$$props} label="ō&nbsp;&nbsp;&nbsp;Login with Hellō" />
@@ -1,4 +1,4 @@
1
1
  <script>import BaseButton from "./BaseButton.svelte.js";
2
2
  </script>
3
3
 
4
- <BaseButton label="ō&nbsp;&nbsp;&nbsp;Update Profile with Hellō" {...$$props} update={true} />
4
+ <BaseButton {...$$props} label="ō&nbsp;&nbsp;&nbsp;Update Profile with Hellō" update={true} />
package/dist/index.js CHANGED
@@ -11,4 +11,5 @@ export * from './auth.js';
11
11
  //Logout
12
12
  export * from './logout.js';
13
13
  //Provider
14
+ // @ts-ignore tbd - has no exported member?
14
15
  export { default as HelloProvider, routeConfig, getHelloProviderContext } from './Provider.svelte';
package/dist/logout.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="svelte" />
2
+ // @ts-ignore tbd - has no exported member?
2
3
  import { routeConfig } from './Provider.svelte';
3
4
  export const getLogOutRoute = () => routeConfig.logout;
4
5
  export function logOut() {
package/dist/types.d.ts CHANGED
@@ -1,35 +1,25 @@
1
- import { VALID_IDENTITY_STRING_CLAIMS, VALID_IDENTITY_ACCOUNT_CLAIMS, VALID_SCOPES, VALID_RESPONSE_TYPE, VALID_RESPONSE_MODE, VALID_PROVIDER_HINT } from '@hellocoop/constants';
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 IdentityStringClaims = typeof VALID_IDENTITY_STRING_CLAIMS[number];
7
- type IdentityAccountClaims = typeof VALID_IDENTITY_ACCOUNT_CLAIMS[number];
8
- type OptionalStringClaims = {
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 OptionalAccountClaims = {
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 AuthCookie = {
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
- // Hellō types
2
- import { VALID_IDENTITY_STRING_CLAIMS, VALID_IDENTITY_ACCOUNT_CLAIMS, VALID_SCOPES, VALID_RESPONSE_TYPE, VALID_RESPONSE_MODE, VALID_PROVIDER_HINT, } from '@hellocoop/constants';
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.0.0",
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": "cp ../types/src/types.ts ./src/lib/ && svelte-kit sync && svelte-package && publint"
11
+ "build": "svelte-kit sync && svelte-package && publint",
12
+ "prebuild": "rimraf dist node_modules"
12
13
  },
13
14
  "exports": {
14
15
  ".": {
@@ -43,7 +44,7 @@
43
44
  "svelte": "^4.0.0"
44
45
  },
45
46
  "devDependencies": {
46
- "@sveltejs/adapter-auto": "^2.0.0",
47
+ "@sveltejs/adapter-auto": "^2.1.1",
47
48
  "@sveltejs/kit": "^1.20.4",
48
49
  "@sveltejs/package": "^2.0.0",
49
50
  "publint": "^0.1.9",
@@ -57,6 +58,8 @@
57
58
  "types": "./dist/index.d.ts",
58
59
  "type": "module",
59
60
  "dependencies": {
61
+ "@hellocoop/definitions": "^1.0.4",
60
62
  "sswr": "^2.0.0"
61
- }
63
+ },
64
+ "gitHead": "b418b4e249a7fe7025d467688e52132848b465a2"
62
65
  }