@sylphx/auth-solid 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +56 -2
- package/dist/browser.js +1067 -0
- package/dist/index.d.ts +4 -0
- package/dist/locale.d.ts +6 -0
- package/dist/messages.d.ts +413 -0
- package/dist/provider-icons.d.ts +5 -0
- package/dist/server.js +1072 -0
- package/dist/sign-in-controller.d.ts +55 -0
- package/dist/sign-in.css +140 -0
- package/dist/sign-in.d.ts +29 -0
- package/package.json +53 -5
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type EntryConfig, type Provider } from '@sylphx/auth/client';
|
|
2
|
+
declare const errors: {
|
|
3
|
+
signin: string;
|
|
4
|
+
cancelled: string;
|
|
5
|
+
use_existing: string;
|
|
6
|
+
invalid_credentials: string;
|
|
7
|
+
verify_email: string;
|
|
8
|
+
verification_failed: string;
|
|
9
|
+
invalid_code: string;
|
|
10
|
+
method_unavailable: string;
|
|
11
|
+
signup_failed: string;
|
|
12
|
+
invalid_input: string;
|
|
13
|
+
try_later: string;
|
|
14
|
+
unavailable: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const unavailable: string;
|
|
17
|
+
export type SignInErrorCode = keyof typeof errors;
|
|
18
|
+
export type SignInStep = 'choose' | 'password' | 'signup' | 'check_email' | 'confirm' | 'otp' | 'mfa';
|
|
19
|
+
export type SignInControllerOptions = {
|
|
20
|
+
/** A path already allowlisted by the application. */
|
|
21
|
+
next: string;
|
|
22
|
+
/** The login URL's query string, read once at construction. */
|
|
23
|
+
search: string;
|
|
24
|
+
/** The same-origin login pathname, used to scrub a confirmation link. */
|
|
25
|
+
loginPath?: string;
|
|
26
|
+
};
|
|
27
|
+
/** Create under a Solid owner. Requests start on mount and abort on cleanup. */
|
|
28
|
+
export declare function createSignInController(options: SignInControllerOptions): {
|
|
29
|
+
config: import("solid-js").Accessor<EntryConfig | undefined>;
|
|
30
|
+
configFailed: import("solid-js").Accessor<boolean>;
|
|
31
|
+
loadConfig: () => Promise<void>;
|
|
32
|
+
step: import("solid-js").Accessor<SignInStep>;
|
|
33
|
+
go: (to: SignInStep) => void;
|
|
34
|
+
email: import("solid-js").Accessor<string>;
|
|
35
|
+
setEmail: import("solid-js").Setter<string>;
|
|
36
|
+
error: () => string;
|
|
37
|
+
errorCode: import("solid-js").Accessor<"" | "signin" | "cancelled" | "use_existing" | "invalid_credentials" | "verify_email" | "verification_failed" | "invalid_code" | "method_unavailable" | "signup_failed" | "invalid_input" | "try_later" | "unavailable">;
|
|
38
|
+
busy: import("solid-js").Accessor<string>;
|
|
39
|
+
showPassword: import("solid-js").Accessor<boolean>;
|
|
40
|
+
setShowPassword: import("solid-js").Setter<boolean>;
|
|
41
|
+
canPasskey: import("solid-js").Accessor<boolean>;
|
|
42
|
+
code: import("solid-js").Accessor<string>;
|
|
43
|
+
setCode: import("solid-js").Setter<string>;
|
|
44
|
+
recovery: import("solid-js").Accessor<boolean>;
|
|
45
|
+
setRecovery: import("solid-js").Setter<boolean>;
|
|
46
|
+
wait: () => number;
|
|
47
|
+
continueWithEmail: () => Promise<void> | undefined;
|
|
48
|
+
social: (provider: Provider) => Promise<void> | undefined;
|
|
49
|
+
sendCode: () => Promise<void> | undefined;
|
|
50
|
+
verifyCode: (value?: string) => Promise<void> | undefined;
|
|
51
|
+
passkey: () => Promise<void> | undefined;
|
|
52
|
+
submitPassword: (password: string) => Promise<void> | undefined;
|
|
53
|
+
submitMfa: (value: string) => Promise<void> | undefined;
|
|
54
|
+
};
|
|
55
|
+
export {};
|
package/dist/sign-in.css
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
.auth-sign-in-panel {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
color-scheme: light dark;
|
|
4
|
+
color: var(--auth-text, light-dark(#17191e, #f1f2f5));
|
|
5
|
+
background: var(--auth-surface, light-dark(#fff, #181a20));
|
|
6
|
+
font: 400 15px/1.5 var(--auth-font, system-ui, sans-serif);
|
|
7
|
+
display: grid;
|
|
8
|
+
justify-items: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
min-inline-size: 0;
|
|
11
|
+
padding: clamp(16px, 4vw, 48px);
|
|
12
|
+
}
|
|
13
|
+
.auth-sign-in-panel *, .auth-sign-in-panel *::before, .auth-sign-in-panel *::after {
|
|
14
|
+
box-sizing: inherit;
|
|
15
|
+
}
|
|
16
|
+
.auth-sign-in-panel :where(p, h1) { margin: 0; }
|
|
17
|
+
.auth-sign-in-panel :where(button, input) { font: inherit; }
|
|
18
|
+
.auth-sign-in-panel :where(button, input, a):focus-visible {
|
|
19
|
+
outline: 2px solid var(--auth-accent, light-dark(#174fc7, #a7c5ff));
|
|
20
|
+
outline-offset: 2px;
|
|
21
|
+
}
|
|
22
|
+
.auth-sign-in-panel button:disabled { opacity: .62; cursor: default; }
|
|
23
|
+
.auth-sign-in-content { width: min(100%, var(--auth-width, 368px)); }
|
|
24
|
+
.auth-sign-in-title { font-size: clamp(28px, 4vw, 40px); font-weight: 600; line-height: 1.12; letter-spacing: -.035em; }
|
|
25
|
+
.auth-sign-in-kicker {
|
|
26
|
+
margin-bottom: 8px;
|
|
27
|
+
font: 600 12px/1.4 var(--auth-font-mono, ui-monospace, monospace);
|
|
28
|
+
text-transform: uppercase;
|
|
29
|
+
letter-spacing: .1em;
|
|
30
|
+
color: var(--auth-accent, light-dark(#174fc7, #a7c5ff));
|
|
31
|
+
}
|
|
32
|
+
.auth-sign-in-sub { margin: 10px 0 24px; overflow-wrap: anywhere; }
|
|
33
|
+
.auth-sign-in-sub, .auth-sign-in-loading, .auth-sign-in-switch, .auth-sign-in-hint, .auth-sign-in-agreement, .auth-sign-in-divider {
|
|
34
|
+
color: var(--auth-muted, light-dark(#4e5565, #bfc5d2));
|
|
35
|
+
}
|
|
36
|
+
.auth-sign-in-providers, .auth-sign-in-form { display: grid; gap: 8px; }
|
|
37
|
+
.auth-sign-in-providers:empty { display: none; }
|
|
38
|
+
.auth-sign-in-primary, .auth-sign-in-secondary, .auth-sign-in-link {
|
|
39
|
+
min-block-size: 44px;
|
|
40
|
+
min-inline-size: 44px;
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
.auth-sign-in-primary, .auth-sign-in-secondary {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
gap: 10px;
|
|
50
|
+
width: 100%;
|
|
51
|
+
padding: 8px 14px;
|
|
52
|
+
border: 1px solid var(--auth-border, light-dark(#7e8595, #727a8f));
|
|
53
|
+
border-radius: var(--auth-radius, 10px);
|
|
54
|
+
}
|
|
55
|
+
.auth-sign-in-secondary { background: var(--auth-surface, light-dark(#fff, #181a20)); color: inherit; }
|
|
56
|
+
.auth-sign-in-secondary svg { flex: none; }
|
|
57
|
+
.auth-sign-in-secondary:hover:not(:disabled) { background: var(--auth-muted-surface, light-dark(#eef1f6, #252934)); }
|
|
58
|
+
.auth-sign-in-primary {
|
|
59
|
+
margin-top: 4px;
|
|
60
|
+
background: var(--auth-action, light-dark(#17191e, #f1f2f5));
|
|
61
|
+
color: var(--auth-action-text, light-dark(#fff, #181a20));
|
|
62
|
+
border-color: transparent;
|
|
63
|
+
}
|
|
64
|
+
.auth-sign-in-primary:hover:not(:disabled) { opacity: .88; }
|
|
65
|
+
.auth-sign-in-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; font-size: 12px; }
|
|
66
|
+
.auth-sign-in-divider::before, .auth-sign-in-divider::after {
|
|
67
|
+
content: '';
|
|
68
|
+
height: 1px;
|
|
69
|
+
background: var(--auth-border, light-dark(#7e8595, #727a8f));
|
|
70
|
+
flex: 1;
|
|
71
|
+
}
|
|
72
|
+
.auth-sign-in-form label { font-size: 13px; font-weight: 600; }
|
|
73
|
+
.auth-sign-in-form input {
|
|
74
|
+
width: 100%;
|
|
75
|
+
min-width: 0;
|
|
76
|
+
min-height: 46px;
|
|
77
|
+
padding: 8px 12px;
|
|
78
|
+
border: 1px solid var(--auth-border, light-dark(#7e8595, #727a8f));
|
|
79
|
+
border-radius: var(--auth-radius, 10px);
|
|
80
|
+
color: inherit;
|
|
81
|
+
background: var(--auth-surface, light-dark(#fff, #181a20));
|
|
82
|
+
font-size: 16px;
|
|
83
|
+
}
|
|
84
|
+
.auth-sign-in-form input::placeholder { color: var(--auth-muted, light-dark(#4e5565, #bfc5d2)); }
|
|
85
|
+
.auth-sign-in-password { position: relative; }
|
|
86
|
+
.auth-sign-in-password input { padding-inline-end: 64px; }
|
|
87
|
+
.auth-sign-in-password button { position: absolute; inset: 1px 2px auto auto; }
|
|
88
|
+
.auth-sign-in-link {
|
|
89
|
+
color: var(--auth-accent, light-dark(#174fc7, #a7c5ff));
|
|
90
|
+
padding: 0 5px;
|
|
91
|
+
border: 0;
|
|
92
|
+
background: transparent;
|
|
93
|
+
}
|
|
94
|
+
.auth-sign-in-link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
|
|
95
|
+
.auth-sign-in-content > .auth-sign-in-link { padding-inline-start: 0; }
|
|
96
|
+
.auth-sign-in-actions { display: flex; flex-wrap: wrap; column-gap: 12px; margin-top: 6px; }
|
|
97
|
+
.auth-sign-in-hint, .auth-sign-in-agreement { font-size: 13px; }
|
|
98
|
+
.auth-sign-in-agreement { border-top: 1px solid var(--auth-border, light-dark(#7e8595, #727a8f)); padding-top: 12px; margin-top: 12px; }
|
|
99
|
+
.auth-sign-in-agreement a { color: var(--auth-accent, light-dark(#174fc7, #a7c5ff)); }
|
|
100
|
+
.auth-sign-in-error {
|
|
101
|
+
margin-bottom: 16px;
|
|
102
|
+
padding: 10px 12px;
|
|
103
|
+
background: var(--auth-muted-surface, light-dark(#eef1f6, #252934));
|
|
104
|
+
border-radius: var(--auth-radius, 10px);
|
|
105
|
+
border-inline-start: 3px solid var(--auth-accent, light-dark(#174fc7, #a7c5ff));
|
|
106
|
+
}
|
|
107
|
+
.auth-sign-in-loading { display: block; min-height: 110px; }
|
|
108
|
+
.auth-sign-in-otp { position: relative; }
|
|
109
|
+
.auth-sign-in-otp input { position: absolute; inset: 0; height: 100%; opacity: 0; }
|
|
110
|
+
.auth-sign-in-cells { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; pointer-events: none; }
|
|
111
|
+
.auth-sign-in-cells span {
|
|
112
|
+
display: grid;
|
|
113
|
+
place-items: center;
|
|
114
|
+
min-height: 46px;
|
|
115
|
+
border-radius: var(--auth-radius, 10px);
|
|
116
|
+
border: 1px solid var(--auth-border, light-dark(#7e8595, #727a8f));
|
|
117
|
+
font: 600 20px/1 var(--auth-font-mono, ui-monospace, monospace);
|
|
118
|
+
}
|
|
119
|
+
.auth-sign-in-otp:focus-within .auth-sign-in-cells {
|
|
120
|
+
outline: 2px solid var(--auth-accent, light-dark(#174fc7, #a7c5ff));
|
|
121
|
+
outline-offset: 3px;
|
|
122
|
+
border-radius: var(--auth-radius, 10px);
|
|
123
|
+
}
|
|
124
|
+
.auth-sign-in-locale { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-block-start: 16px; }
|
|
125
|
+
.auth-sign-in-locale select {
|
|
126
|
+
min-block-size: 44px;
|
|
127
|
+
min-inline-size: 44px;
|
|
128
|
+
max-inline-size: 100%;
|
|
129
|
+
padding-inline: 8px;
|
|
130
|
+
border: 1px solid var(--auth-border, light-dark(#7e8595, #727a8f));
|
|
131
|
+
border-radius: var(--auth-radius, 10px);
|
|
132
|
+
font: inherit;
|
|
133
|
+
color: inherit;
|
|
134
|
+
background: var(--auth-surface, light-dark(#fff, #181a20));
|
|
135
|
+
}
|
|
136
|
+
.auth-sign-in-locale select:focus-visible {
|
|
137
|
+
outline: 2px solid var(--auth-accent, light-dark(#174fc7, #a7c5ff));
|
|
138
|
+
outline-offset: 2px;
|
|
139
|
+
}
|
|
140
|
+
.auth-sign-in-panel:is(:lang(zh), :lang(ja)) .auth-sign-in-title { letter-spacing: normal; line-height: 1.3; }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import { type AuthLocale } from './messages.js';
|
|
3
|
+
import { type SignInControllerOptions } from './sign-in-controller.js';
|
|
4
|
+
export type SignInClass = 'panel' | 'content' | 'kicker' | 'title' | 'sub' | 'error' | 'loading' | 'providers' | 'divider' | 'form' | 'primary' | 'secondary' | 'link' | 'switch' | 'password' | 'hint' | 'otp' | 'cells' | 'actions' | 'agreement' | 'locale';
|
|
5
|
+
export type SignInToken = '--auth-surface' | '--auth-muted-surface' | '--auth-text' | '--auth-muted' | '--auth-border' | '--auth-action' | '--auth-action-text' | '--auth-accent' | '--auth-radius' | '--auth-width' | '--auth-font' | '--auth-font-mono';
|
|
6
|
+
export type SignInAppearance = {
|
|
7
|
+
/** Classes applied to the named sign-in parts. */
|
|
8
|
+
classes?: Partial<Record<SignInClass, string>>;
|
|
9
|
+
/** CSS custom properties for the default stylesheet. */
|
|
10
|
+
tokens?: Partial<Record<SignInToken, string>>;
|
|
11
|
+
/** Omit default classes when the host owns all styling. */
|
|
12
|
+
unstyled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type SylphxSignInProps = SignInControllerOptions & {
|
|
15
|
+
title?: JSX.Element;
|
|
16
|
+
description?: JSX.Element;
|
|
17
|
+
kicker?: JSX.Element;
|
|
18
|
+
/** Optional agreement copy and links supplied by the host. */
|
|
19
|
+
agreement?: JSX.Element;
|
|
20
|
+
appearance?: SignInAppearance;
|
|
21
|
+
/** Controlled locale, or seed SSR with `localePreferences` and auto-detect in the browser. */
|
|
22
|
+
locale?: string;
|
|
23
|
+
/** Ordered locale hints resolved by the host, e.g. Accept-Language preferences on SSR. */
|
|
24
|
+
localePreferences?: readonly string[];
|
|
25
|
+
/** Show the language selector (defaults to true for an uncontrolled widget). */
|
|
26
|
+
showLocaleSelector?: boolean;
|
|
27
|
+
onLocaleChange?: (locale: AuthLocale) => void;
|
|
28
|
+
};
|
|
29
|
+
export declare function SylphxSignIn(props: SylphxSignInProps): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@sylphx/auth-solid",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"browser": "./dist/browser.js",
|
|
9
|
+
"default": "./dist/server.js"
|
|
10
|
+
},
|
|
11
|
+
"./sign-in.css": "./dist/sign-in.css"
|
|
12
|
+
},
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"**/*.css"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"lint": "biome check .",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"test": "bun test",
|
|
20
|
+
"build": "tsc -p tsconfig.build.json && node build.mjs"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@sylphx/auth": "0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"solid-js": "^1.9.20"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/bun": "1.4.0",
|
|
30
|
+
"solid-js": "1.9.20",
|
|
31
|
+
"typescript": "6.0.2",
|
|
32
|
+
"vite": "8.3.8",
|
|
33
|
+
"vite-plugin-solid": "2.11.17"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/SylphxAI/sylphx-clients.git",
|
|
39
|
+
"directory": "auth-solid"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=22.12"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"tag": "next",
|
|
52
|
+
"provenance": true
|
|
53
|
+
}
|
|
54
|
+
}
|