@sylphx/auth-solid 0.1.2 → 0.1.3

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.
@@ -1,22 +1,6 @@
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
- acceptance_required: string;
8
- verify_email: string;
9
- verification_failed: string;
10
- invalid_code: string;
11
- method_unavailable: string;
12
- signup_failed: string;
13
- invalid_input: string;
14
- try_later: string;
15
- unavailable: string;
16
- };
17
- export declare const unavailable: string;
18
- export type SignInErrorCode = keyof typeof errors;
19
- export type SignInStep = 'choose' | 'password' | 'signup' | 'check_email' | 'confirm' | 'otp' | 'mfa';
1
+ import { type AuthMethod, type EntryConfig, type Provider } from '@sylphx/auth/client';
2
+ export { type SignInErrorCode, unavailable } from './sign-in-request.js';
3
+ export type SignInStep = 'choose' | 'password' | 'signup' | 'check_email' | 'confirm' | 'otp' | 'mfa' | 'recover' | 'recovery_sent';
20
4
  export type SignInControllerOptions = {
21
5
  /** A path already allowlisted by the application. */
22
6
  next: string;
@@ -32,6 +16,12 @@ export type SignInControllerOptions = {
32
16
  conditionalPasskey?: boolean;
33
17
  /** Return only versions the user has accepted; undefined means no acceptance. */
34
18
  getAcceptance?: () => Readonly<Record<string, string>> | undefined;
19
+ /** Require the host to explicitly grant agreement before any authentication request. */
20
+ requireAgreement?: boolean;
21
+ /** The host's current agreement state. Pass a reactive prop or getter. */
22
+ agreementAccepted?: boolean;
23
+ /** Invoked with the validated provider destination before leaving the page. */
24
+ beforeOAuthNavigate?: (provider: Provider, target: string) => void | Promise<void>;
35
25
  };
36
26
  /** Create under a Solid owner. Requests start on mount and abort on cleanup. */
37
27
  export declare function createSignInController(options: SignInControllerOptions): {
@@ -44,7 +34,8 @@ export declare function createSignInController(options: SignInControllerOptions)
44
34
  email: import("solid-js").Accessor<string>;
45
35
  setEmail: import("solid-js").Setter<string>;
46
36
  error: () => string;
47
- errorCode: import("solid-js").Accessor<"" | "signin" | "cancelled" | "use_existing" | "invalid_credentials" | "acceptance_required" | "verify_email" | "verification_failed" | "invalid_code" | "method_unavailable" | "signup_failed" | "invalid_input" | "try_later" | "unavailable">;
37
+ errorCode: import("solid-js").Accessor<"" | "signin" | "cancelled" | "use_existing" | "invalid_credentials" | "verify_email" | "acceptance_required" | "verification_failed" | "invalid_code" | "method_unavailable" | "signup_failed" | "invalid_input" | "try_later" | "unavailable">;
38
+ agreementAllowed: () => boolean;
48
39
  busy: import("solid-js").Accessor<string>;
49
40
  showPassword: import("solid-js").Accessor<boolean>;
50
41
  setShowPassword: import("solid-js").Setter<boolean>;
@@ -54,12 +45,12 @@ export declare function createSignInController(options: SignInControllerOptions)
54
45
  recovery: import("solid-js").Accessor<boolean>;
55
46
  setRecovery: import("solid-js").Setter<boolean>;
56
47
  wait: () => number;
57
- continueWithEmail: () => Promise<void> | undefined;
48
+ continueWithEmail: (method?: Extract<AuthMethod, "otp" | "password">) => Promise<void> | undefined;
58
49
  social: (provider: Provider) => Promise<void> | undefined;
59
50
  sendCode: () => Promise<void> | undefined;
51
+ sendRecovery: () => Promise<void> | undefined;
60
52
  verifyCode: (value?: string) => Promise<void> | undefined;
61
53
  passkey: () => Promise<void> | undefined;
62
54
  submitPassword: (password: string) => Promise<void> | undefined;
63
55
  submitMfa: (value: string) => Promise<void> | undefined;
64
56
  };
65
- export {};
@@ -0,0 +1,3 @@
1
+ import type { AuthLocale, SignInMessagesOverride } from './messages.js';
2
+ /** Use the host's explicit language tag when the host also provides its copy. */
3
+ export declare function signInLanguage(fallback: AuthLocale, locale: string | undefined, messages: SignInMessagesOverride | undefined): string;
@@ -0,0 +1,24 @@
1
+ declare const errors: {
2
+ signin: string;
3
+ cancelled: string;
4
+ use_existing: string;
5
+ invalid_credentials: string;
6
+ acceptance_required: 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 declare function isErrorCode(value: unknown): value is SignInErrorCode;
19
+ export declare class SignInError extends Error {
20
+ readonly code: SignInErrorCode;
21
+ constructor(code: SignInErrorCode);
22
+ }
23
+ export declare function postAuthJSON(path: string, body: Record<string, unknown>, signal: AbortSignal): Promise<unknown>;
24
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function decodeBase64Url(value: string): Uint8Array<ArrayBuffer>;
2
+ export declare function encodeBase64Url(value: ArrayBuffer): string;
package/dist/sign-in.css CHANGED
@@ -138,3 +138,12 @@
138
138
  outline-offset: 2px;
139
139
  }
140
140
  .auth-sign-in-panel:is(:lang(zh), :lang(ja)) .auth-sign-in-title { letter-spacing: normal; line-height: 1.3; }
141
+ .auth-sign-in-last-used {
142
+ font-size: .75rem;
143
+ font-weight: normal;
144
+ margin-inline-start: .4em;
145
+ border: 1px solid currentColor;
146
+ border-radius: .75em;
147
+ padding: .1em .45em;
148
+ }
149
+ .auth-sign-in-primary, .auth-sign-in-secondary { flex-wrap: wrap; }
package/dist/sign-in.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import { type Provider } from '@sylphx/auth/client';
1
2
  import { type JSX } from 'solid-js';
2
- import { type AuthLocale } from './messages.js';
3
+ import { type AuthLocale, type SignInMessagesOverride } from './messages.js';
3
4
  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 SignInClass = 'panel' | 'content' | 'kicker' | 'title' | 'sub' | 'error' | 'loading' | 'providers' | 'divider' | 'form' | 'primary' | 'secondary' | 'link' | 'switch' | 'password' | 'hint' | 'otp' | 'cells' | 'actions' | 'agreement' | 'last-used' | 'locale';
5
6
  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
7
  export type SignInAppearance = {
7
8
  /** Classes applied to the named sign-in parts. */
@@ -17,6 +18,10 @@ export type SylphxSignInProps = SignInControllerOptions & {
17
18
  kicker?: JSX.Element;
18
19
  /** Optional agreement copy and links supplied by the host. */
19
20
  agreement?: JSX.Element;
21
+ /** App-supplied non-authoritative preference from a completed sign-in. */
22
+ lastUsed?: Provider | 'password' | 'otp' | 'passkey';
23
+ /** Overrides normal strings and individual error messages. */
24
+ messages?: SignInMessagesOverride;
20
25
  appearance?: SignInAppearance;
21
26
  /** Controlled locale, or seed SSR with `localePreferences` and auto-detect in the browser. */
22
27
  locale?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphx/auth-solid",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -20,7 +20,7 @@
20
20
  "build": "tsc -p tsconfig.build.json && node build.mjs"
21
21
  },
22
22
  "dependencies": {
23
- "@sylphx/auth": "0.1.1"
23
+ "@sylphx/auth": "0.1.2"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "solid-js": "^1.9.20"