@zenauth/react 0.0.0-stage → 0.5.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 +132 -2
- package/dist/index.cjs +1468 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +470 -0
- package/dist/index.d.ts +470 -0
- package/dist/index.js +1429 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Security facts about a sign-in, delivered when the app requests the `login_context` scope.
|
|
6
|
+
* Location is derived from the IP: approximate, never a GPS position.
|
|
7
|
+
*/
|
|
8
|
+
interface LoginContext {
|
|
9
|
+
event_id: string;
|
|
10
|
+
/** password | email_code | mfa | google | github ... */
|
|
11
|
+
method: string;
|
|
12
|
+
/** ISO 8601 time of the sign-in. */
|
|
13
|
+
at: string;
|
|
14
|
+
/** First time this browser + OS + country was used by this user. */
|
|
15
|
+
is_new_device: boolean;
|
|
16
|
+
ip: string | null;
|
|
17
|
+
device: {
|
|
18
|
+
type: string;
|
|
19
|
+
browser: string;
|
|
20
|
+
browser_version: string | null;
|
|
21
|
+
os: string;
|
|
22
|
+
};
|
|
23
|
+
language: string | null;
|
|
24
|
+
location: {
|
|
25
|
+
country: string | null;
|
|
26
|
+
region: string | null;
|
|
27
|
+
city: string | null;
|
|
28
|
+
timezone: string | null;
|
|
29
|
+
latitude: number | null;
|
|
30
|
+
longitude: number | null;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** A team the user belongs to in your app. Needs the `organizations` scope. */
|
|
34
|
+
interface ZenAuthOrganization {
|
|
35
|
+
id: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
name: string;
|
|
38
|
+
role: "owner" | "admin" | "member";
|
|
39
|
+
}
|
|
40
|
+
interface ZenAuthUser {
|
|
41
|
+
sub: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
email?: string;
|
|
44
|
+
email_verified?: boolean;
|
|
45
|
+
/** The user's role in your app (defined in the developer console). */
|
|
46
|
+
role?: string;
|
|
47
|
+
/** Present when the `organizations` scope was granted. */
|
|
48
|
+
orgs?: ZenAuthOrganization[];
|
|
49
|
+
/** Only after a sign-in that requested the `login_context` scope (browser-only mode). */
|
|
50
|
+
login_context?: LoginContext;
|
|
51
|
+
}
|
|
52
|
+
type AuthStatus = "loading" | "authenticated" | "unauthenticated";
|
|
53
|
+
interface AuthState {
|
|
54
|
+
status: AuthStatus;
|
|
55
|
+
user: ZenAuthUser | null;
|
|
56
|
+
/** Message of the last failed sign-in (denied, expired, tampered redirect, ...). */
|
|
57
|
+
error: string | null;
|
|
58
|
+
}
|
|
59
|
+
interface StorageLike {
|
|
60
|
+
getItem(key: string): string | null;
|
|
61
|
+
setItem(key: string, value: string): void;
|
|
62
|
+
removeItem(key: string): void;
|
|
63
|
+
}
|
|
64
|
+
interface ZenAuthConfig {
|
|
65
|
+
/** Client ID of the application, from the ZenAuth developer console. */
|
|
66
|
+
clientId: string;
|
|
67
|
+
/** Must match the application's registered redirect URI exactly. */
|
|
68
|
+
redirectUri: string;
|
|
69
|
+
/** Base URL of the ZenAuth API (the OpenID issuer), e.g. `https://auth.example.com`. */
|
|
70
|
+
issuer: string;
|
|
71
|
+
/** Defaults to `openid profile email`. */
|
|
72
|
+
scope?: string;
|
|
73
|
+
/** Where the session lives. Defaults to `sessionStorage` (per tab, cleared when the tab closes). */
|
|
74
|
+
storage?: StorageLike;
|
|
75
|
+
/** Override for tests or non-browser runtimes. */
|
|
76
|
+
fetch?: typeof fetch;
|
|
77
|
+
/** How to send the browser to the sign-in page. Defaults to `window.location.assign`. */
|
|
78
|
+
navigate?: (url: string) => void;
|
|
79
|
+
now?: () => number;
|
|
80
|
+
}
|
|
81
|
+
/** Everything ZenAuth needs to resume an authorization request after the user has authenticated. */
|
|
82
|
+
interface AuthContext {
|
|
83
|
+
client_id: string;
|
|
84
|
+
redirect_uri: string;
|
|
85
|
+
scope: string;
|
|
86
|
+
state: string;
|
|
87
|
+
nonce?: string;
|
|
88
|
+
code_challenge?: string;
|
|
89
|
+
code_challenge_method?: "S256";
|
|
90
|
+
}
|
|
91
|
+
interface PasswordCredentials {
|
|
92
|
+
/** Email address. */
|
|
93
|
+
email?: string;
|
|
94
|
+
/** Username, if the app allows it. */
|
|
95
|
+
username?: string;
|
|
96
|
+
password: string;
|
|
97
|
+
}
|
|
98
|
+
interface SignOutOptions {
|
|
99
|
+
/** Also end the user's session at ZenAuth, not just in this app. */
|
|
100
|
+
endSession?: boolean;
|
|
101
|
+
/** Where ZenAuth sends the browser afterwards. Implies `endSession`. */
|
|
102
|
+
postLogoutRedirectUri?: string;
|
|
103
|
+
}
|
|
104
|
+
interface EmbeddedSignInOptions {
|
|
105
|
+
/** Path on your site to return to afterwards (browser-only mode). */
|
|
106
|
+
returnTo?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Backend mode: an authorization context created by YOUR server (which keeps the PKCE verifier and
|
|
109
|
+
* the client secret). The browser then hands the resulting code to your server's redirect URI.
|
|
110
|
+
* Without it, the SDK runs as a public client and finishes the sign-in in the browser.
|
|
111
|
+
*/
|
|
112
|
+
context?: AuthContext;
|
|
113
|
+
}
|
|
114
|
+
/** Result of a credentials sign-in step. */
|
|
115
|
+
type SignInResult = {
|
|
116
|
+
status: "complete";
|
|
117
|
+
returnTo?: string;
|
|
118
|
+
} | {
|
|
119
|
+
status: "mfa_required";
|
|
120
|
+
mfaToken: string;
|
|
121
|
+
context: AuthContext;
|
|
122
|
+
};
|
|
123
|
+
declare class ZenAuthError extends Error {
|
|
124
|
+
readonly code: string;
|
|
125
|
+
constructor(code: string, message: string);
|
|
126
|
+
}
|
|
127
|
+
interface InitResult {
|
|
128
|
+
/** True when the current URL was a sign-in redirect, so the caller should clean it up. */
|
|
129
|
+
handledRedirect: boolean;
|
|
130
|
+
/** Where the app asked to go back to after sign-in (same-origin path only). */
|
|
131
|
+
returnTo?: string;
|
|
132
|
+
}
|
|
133
|
+
declare const createMemoryStorage: () => StorageLike;
|
|
134
|
+
/**
|
|
135
|
+
* Framework-agnostic OpenID Connect client for ZenAuth: Authorization Code flow with PKCE (S256),
|
|
136
|
+
* as a public client (no client secret is ever needed in the browser).
|
|
137
|
+
*/
|
|
138
|
+
declare class ZenAuthClient {
|
|
139
|
+
private readonly config;
|
|
140
|
+
private state;
|
|
141
|
+
private readonly listeners;
|
|
142
|
+
private metadataPromise?;
|
|
143
|
+
private initPromise?;
|
|
144
|
+
private refreshPromise?;
|
|
145
|
+
private readonly scope;
|
|
146
|
+
private readonly storage;
|
|
147
|
+
private readonly fetchFn;
|
|
148
|
+
private readonly navigate;
|
|
149
|
+
private readonly now;
|
|
150
|
+
private readonly issuer;
|
|
151
|
+
constructor(config: ZenAuthConfig);
|
|
152
|
+
getState: () => AuthState;
|
|
153
|
+
getServerState: () => AuthState;
|
|
154
|
+
subscribe: (listener: () => void) => (() => void);
|
|
155
|
+
private setState;
|
|
156
|
+
/**
|
|
157
|
+
* Call once on page load with the current URL. Finishes a sign-in redirect if there is one,
|
|
158
|
+
* otherwise restores the stored session. Safe to call repeatedly (e.g. React StrictMode).
|
|
159
|
+
*/
|
|
160
|
+
initialize(currentUrl: string): Promise<InitResult>;
|
|
161
|
+
private run;
|
|
162
|
+
private restoreSession;
|
|
163
|
+
/**
|
|
164
|
+
* Sends the browser to ZenAuth. Resolves right before navigation starts.
|
|
165
|
+
* Failures (e.g. ZenAuth unreachable) are reported through `state.error` instead of throwing,
|
|
166
|
+
* so it is safe to call straight from a click handler.
|
|
167
|
+
*/
|
|
168
|
+
signIn(options?: {
|
|
169
|
+
returnTo?: string;
|
|
170
|
+
}): Promise<void>;
|
|
171
|
+
private buildAuthorizeUrl;
|
|
172
|
+
/** Fresh PKCE verifier, state and nonce for one sign-in attempt. The verifier stays in storage. */
|
|
173
|
+
private createAuthContext;
|
|
174
|
+
/**
|
|
175
|
+
* Signs in with email/username + password using the app's OWN form. Throws a `ZenAuthError` with a
|
|
176
|
+
* user-presentable message on failure. A `complete` result means signed in (browser-only mode) or
|
|
177
|
+
* that the browser is already navigating to your server's redirect URI (backend mode).
|
|
178
|
+
* `mfa_required` means the account has two-factor: collect a code and call `verifyMfa`.
|
|
179
|
+
*/
|
|
180
|
+
signInWithPassword(credentials: PasswordCredentials, options?: EmbeddedSignInOptions): Promise<SignInResult>;
|
|
181
|
+
/** Passwordless step 1: emails a 6-digit sign-in code. Always succeeds for unknown emails (no enumeration). */
|
|
182
|
+
sendEmailCode(email: string): Promise<void>;
|
|
183
|
+
/** Passwordless step 2: signs in with the emailed code. */
|
|
184
|
+
signInWithEmailCode(input: {
|
|
185
|
+
email: string;
|
|
186
|
+
code: string;
|
|
187
|
+
}, options?: EmbeddedSignInOptions): Promise<SignInResult>;
|
|
188
|
+
/** Second factor: the `mfaToken` and `context` come from the `mfa_required` result. Accepts an authenticator or backup code. */
|
|
189
|
+
verifyMfa(input: {
|
|
190
|
+
mfaToken: string;
|
|
191
|
+
code: string;
|
|
192
|
+
context: AuthContext;
|
|
193
|
+
}, options?: Pick<EmbeddedSignInOptions, "returnTo"> & {
|
|
194
|
+
backend?: boolean;
|
|
195
|
+
}): Promise<SignInResult>;
|
|
196
|
+
/**
|
|
197
|
+
* Creates an account. ZenAuth emails a verification link; the user can sign in after confirming it.
|
|
198
|
+
* `captchaToken` is the Cloudflare Turnstile token (see `<SignUpForm turnstileSiteKey>`).
|
|
199
|
+
*/
|
|
200
|
+
signUp(input: {
|
|
201
|
+
name: string;
|
|
202
|
+
email: string;
|
|
203
|
+
password: string;
|
|
204
|
+
captchaToken?: string;
|
|
205
|
+
}): Promise<string>;
|
|
206
|
+
/**
|
|
207
|
+
* "Email me a reset link". The email goes out under YOUR app's name and its link opens your own
|
|
208
|
+
* `/reset-password` page. Always succeeds for unknown emails (no account enumeration).
|
|
209
|
+
*/
|
|
210
|
+
forgotPassword(input: {
|
|
211
|
+
email: string;
|
|
212
|
+
captchaToken?: string;
|
|
213
|
+
}): Promise<string>;
|
|
214
|
+
/** Sets a new password with the token from the reset link. */
|
|
215
|
+
resetPassword(input: {
|
|
216
|
+
token: string;
|
|
217
|
+
password: string;
|
|
218
|
+
}): Promise<string>;
|
|
219
|
+
/** Confirms an email address with the token from the verification link. */
|
|
220
|
+
verifyEmail(token: string): Promise<string>;
|
|
221
|
+
/** Starts a social sign-in (e.g. Google). The provider has to leave the page; you come back signed in. */
|
|
222
|
+
signInWithProvider(provider: string, options?: EmbeddedSignInOptions): Promise<void>;
|
|
223
|
+
/** First step of a credentials sign-in: PKCE context (or the server's), credentials, then finish or ask for MFA. */
|
|
224
|
+
private authorize;
|
|
225
|
+
/** Turns an authorization response into a finished sign-in (or the navigation that finishes it). */
|
|
226
|
+
private finish;
|
|
227
|
+
/** POST JSON to a ZenAuth endpoint; failures become a `ZenAuthError` with the server's message. */
|
|
228
|
+
private post;
|
|
229
|
+
/** Completes the redirect back from ZenAuth. Returns the `returnTo` path, if any. */
|
|
230
|
+
handleRedirect(url: string): Promise<string | undefined>;
|
|
231
|
+
/**
|
|
232
|
+
* A valid access token for calling your own API, refreshed when it is about to expire.
|
|
233
|
+
* `null` means signed out. Throws on transient network failures (the session is kept: retry).
|
|
234
|
+
*/
|
|
235
|
+
getAccessToken(): Promise<string | null>;
|
|
236
|
+
private refreshTokens;
|
|
237
|
+
private doRefresh;
|
|
238
|
+
private requestTokens;
|
|
239
|
+
/**
|
|
240
|
+
* Checks the claims that bind the token to this login. The token arrives straight from the token
|
|
241
|
+
* endpoint over TLS (OIDC Core 3.1.3.7), so the signature check is not required for this flow.
|
|
242
|
+
*/
|
|
243
|
+
private verifyIdToken;
|
|
244
|
+
private fetchUser;
|
|
245
|
+
/**
|
|
246
|
+
* Ends the local session and revokes the refresh token at ZenAuth (best effort).
|
|
247
|
+
*
|
|
248
|
+
* Pass `endSession` (or `postLogoutRedirectUri`) to also sign out of ZenAuth itself: the browser goes
|
|
249
|
+
* to ZenAuth's logout page and comes back to `postLogoutRedirectUri`, which must be listed under the
|
|
250
|
+
* app's "Logout redirect URIs".
|
|
251
|
+
*/
|
|
252
|
+
signOut(options?: SignOutOptions): Promise<void>;
|
|
253
|
+
private getMetadata;
|
|
254
|
+
private loadMetadata;
|
|
255
|
+
private key;
|
|
256
|
+
private readJson;
|
|
257
|
+
private readTokens;
|
|
258
|
+
private saveTokens;
|
|
259
|
+
private readCachedUser;
|
|
260
|
+
private readPending;
|
|
261
|
+
private writePending;
|
|
262
|
+
private clearPending;
|
|
263
|
+
private clearSession;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
interface ZenAuthContextValue extends AuthState {
|
|
267
|
+
isLoading: boolean;
|
|
268
|
+
isAuthenticated: boolean;
|
|
269
|
+
user: ZenAuthUser | null;
|
|
270
|
+
/** Redirects to ZenAuth. Pass `returnTo` (a path on your site) to land there afterwards. */
|
|
271
|
+
signIn: (options?: {
|
|
272
|
+
returnTo?: string;
|
|
273
|
+
}) => Promise<void>;
|
|
274
|
+
/** Email/username + password sign-in with your own form. Throws a ZenAuthError on failure. */
|
|
275
|
+
signInWithPassword: (credentials: PasswordCredentials, options?: EmbeddedSignInOptions) => Promise<SignInResult>;
|
|
276
|
+
/** Passwordless step 1: emails a 6-digit sign-in code. */
|
|
277
|
+
sendEmailCode: (email: string) => Promise<void>;
|
|
278
|
+
/** Passwordless step 2: signs in with the emailed code. */
|
|
279
|
+
signInWithEmailCode: (input: {
|
|
280
|
+
email: string;
|
|
281
|
+
code: string;
|
|
282
|
+
}, options?: EmbeddedSignInOptions) => Promise<SignInResult>;
|
|
283
|
+
/** Second factor after a `mfa_required` result. Pass the `mfaToken` and `context` you were given. */
|
|
284
|
+
verifyMfa: (input: {
|
|
285
|
+
mfaToken: string;
|
|
286
|
+
code: string;
|
|
287
|
+
context: AuthContext;
|
|
288
|
+
}, options?: {
|
|
289
|
+
returnTo?: string;
|
|
290
|
+
backend?: boolean;
|
|
291
|
+
}) => Promise<SignInResult>;
|
|
292
|
+
/** "Email me a reset link": sent as your app, opening your own /reset-password page. */
|
|
293
|
+
forgotPassword: (input: {
|
|
294
|
+
email: string;
|
|
295
|
+
captchaToken?: string;
|
|
296
|
+
}) => Promise<string>;
|
|
297
|
+
/** Sets a new password with the token from the reset link. */
|
|
298
|
+
resetPassword: (input: {
|
|
299
|
+
token: string;
|
|
300
|
+
password: string;
|
|
301
|
+
}) => Promise<string>;
|
|
302
|
+
/** Confirms an email address with the token from the verification link. */
|
|
303
|
+
verifyEmail: (token: string) => Promise<string>;
|
|
304
|
+
/** Creates an account; ZenAuth emails a verification link. Returns the confirmation message. */
|
|
305
|
+
signUp: (input: {
|
|
306
|
+
name: string;
|
|
307
|
+
email: string;
|
|
308
|
+
password: string;
|
|
309
|
+
captchaToken?: string;
|
|
310
|
+
}) => Promise<string>;
|
|
311
|
+
/** Social sign-in, e.g. "google". Leaves the page and comes back signed in. */
|
|
312
|
+
signInWithProvider: (provider: string, options?: EmbeddedSignInOptions) => Promise<void>;
|
|
313
|
+
signOut: (options?: SignOutOptions) => Promise<void>;
|
|
314
|
+
/** A fresh access token for calling your own backend, or `null` when signed out. */
|
|
315
|
+
getAccessToken: () => Promise<string | null>;
|
|
316
|
+
}
|
|
317
|
+
interface ZenAuthProviderProps extends Omit<ZenAuthConfig, "fetch" | "navigate" | "now"> {
|
|
318
|
+
children: ReactNode;
|
|
319
|
+
}
|
|
320
|
+
declare function ZenAuthProvider({ children, clientId, redirectUri, issuer, scope, storage }: ZenAuthProviderProps): react_jsx_runtime.JSX.Element;
|
|
321
|
+
declare function useZenAuth(): ZenAuthContextValue;
|
|
322
|
+
|
|
323
|
+
/** Renders its children only when a user is signed in. */
|
|
324
|
+
declare function SignedIn({ children }: {
|
|
325
|
+
children: ReactNode;
|
|
326
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
327
|
+
/** Renders its children only when nobody is signed in (not while the session is still loading). */
|
|
328
|
+
declare function SignedOut({ children }: {
|
|
329
|
+
children: ReactNode;
|
|
330
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
331
|
+
interface SignInProps {
|
|
332
|
+
children?: ReactNode;
|
|
333
|
+
className?: string;
|
|
334
|
+
/** Path on your site to return to after signing in, e.g. `/dashboard`. */
|
|
335
|
+
returnTo?: string;
|
|
336
|
+
}
|
|
337
|
+
/** "Sign in with ZenAuth" button. */
|
|
338
|
+
declare function SignIn({ children, className, returnTo }: SignInProps): react_jsx_runtime.JSX.Element;
|
|
339
|
+
interface UserButtonProps {
|
|
340
|
+
/** Adds a "Manage account" link, e.g. your ZenAuth dashboard URL. */
|
|
341
|
+
accountUrl?: string;
|
|
342
|
+
/** Where to go after signing out. Defaults to staying on the page. */
|
|
343
|
+
afterSignOutUrl?: string;
|
|
344
|
+
}
|
|
345
|
+
/** Avatar with a menu showing the signed-in user and a sign-out action. Renders nothing when signed out. */
|
|
346
|
+
declare function UserButton({ accountUrl, afterSignOutUrl }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
347
|
+
|
|
348
|
+
interface SignInFormAppearance {
|
|
349
|
+
/**
|
|
350
|
+
* Theme tokens, applied as CSS variables. Anything you leave out inherits from the surrounding page
|
|
351
|
+
* (text colour, font) or uses a neutral default, so the form blends into your design.
|
|
352
|
+
*/
|
|
353
|
+
variables?: {
|
|
354
|
+
/** Button and focus colour. */
|
|
355
|
+
primary?: string;
|
|
356
|
+
/** Text on the primary button. */
|
|
357
|
+
primaryForeground?: string;
|
|
358
|
+
/** Page text colour. Defaults to the inherited colour. */
|
|
359
|
+
foreground?: string;
|
|
360
|
+
/** Secondary text. */
|
|
361
|
+
muted?: string;
|
|
362
|
+
/** Input background. Defaults to transparent. */
|
|
363
|
+
inputBackground?: string;
|
|
364
|
+
/** Input and divider border. */
|
|
365
|
+
border?: string;
|
|
366
|
+
danger?: string;
|
|
367
|
+
radius?: string;
|
|
368
|
+
fontFamily?: string;
|
|
369
|
+
};
|
|
370
|
+
/** Your own class names (Tailwind etc.), added next to the built-in ones. */
|
|
371
|
+
classNames?: Partial<Record<"root" | "title" | "subtitle" | "field" | "label" | "input" | "button" | "providerButton" | "error" | "success" | "divider" | "link", string>>;
|
|
372
|
+
}
|
|
373
|
+
interface TurnstileApi {
|
|
374
|
+
render: (el: HTMLElement, options: Record<string, unknown>) => string;
|
|
375
|
+
reset: (widgetId?: string) => void;
|
|
376
|
+
remove: (widgetId?: string) => void;
|
|
377
|
+
}
|
|
378
|
+
declare global {
|
|
379
|
+
interface Window {
|
|
380
|
+
turnstile?: TurnstileApi;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
interface SignInFormProps {
|
|
385
|
+
/** Path on your site to return to after signing in (browser-only mode). */
|
|
386
|
+
returnTo?: string;
|
|
387
|
+
/** Called after a browser-only sign-in succeeds. (In backend mode the browser navigates to your server.) */
|
|
388
|
+
onSuccess?: (returnTo?: string) => void;
|
|
389
|
+
/**
|
|
390
|
+
* Backend mode: fetch an authorization context from YOUR server (PKCE verifier + client secret stay there).
|
|
391
|
+
* Called on every attempt; the server must remember the matching state/verifier (e.g. in a signed cookie).
|
|
392
|
+
*/
|
|
393
|
+
getAuthContext?: () => Promise<AuthContext>;
|
|
394
|
+
/** Social providers to offer. Must be enabled for your app in ZenAuth. Example: `["google"]`. */
|
|
395
|
+
providers?: string[];
|
|
396
|
+
/** Offer "Email me a sign-in code" as a passwordless alternative to the password. */
|
|
397
|
+
emailCode?: boolean;
|
|
398
|
+
title?: ReactNode;
|
|
399
|
+
subtitle?: ReactNode;
|
|
400
|
+
submitLabel?: string;
|
|
401
|
+
/** Link shown next to the password field. */
|
|
402
|
+
forgotPasswordHref?: string;
|
|
403
|
+
/** Shown below the form, e.g. "Don't have an account? Sign up". */
|
|
404
|
+
footer?: ReactNode;
|
|
405
|
+
appearance?: SignInFormAppearance;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Sign-in rendered inside YOUR page: email + password, optional email code and social buttons, and
|
|
409
|
+
* the two-factor step for accounts that have it.
|
|
410
|
+
*/
|
|
411
|
+
declare function SignInForm({ returnTo, onSuccess, getAuthContext, providers, emailCode, title, subtitle, submitLabel, forgotPasswordHref, footer, appearance, }: SignInFormProps): react_jsx_runtime.JSX.Element;
|
|
412
|
+
|
|
413
|
+
interface SignUpFormProps {
|
|
414
|
+
/**
|
|
415
|
+
* Cloudflare Turnstile site key. ZenAuth requires the anti-bot check for sign-ups, so this is needed in
|
|
416
|
+
* production. Add your site's domain to the widget in the Cloudflare dashboard.
|
|
417
|
+
*/
|
|
418
|
+
turnstileSiteKey?: string;
|
|
419
|
+
/** Called after the account was created (the user still has to verify their email before signing in). */
|
|
420
|
+
onSuccess?: (message: string) => void;
|
|
421
|
+
title?: ReactNode;
|
|
422
|
+
subtitle?: ReactNode;
|
|
423
|
+
submitLabel?: string;
|
|
424
|
+
/** Shown below the form, e.g. "Already have an account? Sign in". */
|
|
425
|
+
footer?: ReactNode;
|
|
426
|
+
appearance?: SignInFormAppearance;
|
|
427
|
+
}
|
|
428
|
+
/** Account creation rendered inside YOUR page. ZenAuth emails a verification link afterwards. */
|
|
429
|
+
declare function SignUpForm({ turnstileSiteKey, onSuccess, title, subtitle, submitLabel, footer, appearance, }: SignUpFormProps): react_jsx_runtime.JSX.Element;
|
|
430
|
+
|
|
431
|
+
interface CommonProps {
|
|
432
|
+
title?: ReactNode;
|
|
433
|
+
subtitle?: ReactNode;
|
|
434
|
+
/** Shown below the form, e.g. a "Back to sign in" link. */
|
|
435
|
+
footer?: ReactNode;
|
|
436
|
+
appearance?: SignInFormAppearance;
|
|
437
|
+
}
|
|
438
|
+
interface ForgotPasswordFormProps extends CommonProps {
|
|
439
|
+
/** Cloudflare Turnstile site key. ZenAuth requires the anti-bot check for emails it sends. */
|
|
440
|
+
turnstileSiteKey?: string;
|
|
441
|
+
submitLabel?: string;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* "Email me a reset link". The email goes out under YOUR app's name and its link opens YOUR
|
|
445
|
+
* `/reset-password` page, where you render `<ResetPasswordForm />`.
|
|
446
|
+
*/
|
|
447
|
+
declare function ForgotPasswordForm({ turnstileSiteKey, submitLabel, title, subtitle, footer, appearance, }: ForgotPasswordFormProps): react_jsx_runtime.JSX.Element;
|
|
448
|
+
interface ResetPasswordFormProps extends CommonProps {
|
|
449
|
+
/** The `token` query parameter from the link in the email. */
|
|
450
|
+
token: string | null | undefined;
|
|
451
|
+
/** Called after the password was changed. */
|
|
452
|
+
onSuccess?: () => void;
|
|
453
|
+
submitLabel?: string;
|
|
454
|
+
/** Shown after success, e.g. a "Sign in" link. */
|
|
455
|
+
successFooter?: ReactNode;
|
|
456
|
+
}
|
|
457
|
+
/** Choose a new password. Render it on the page your reset links open (`/reset-password?token=…`). */
|
|
458
|
+
declare function ResetPasswordForm({ token, onSuccess, submitLabel, title, subtitle, footer, successFooter, appearance, }: ResetPasswordFormProps): react_jsx_runtime.JSX.Element;
|
|
459
|
+
interface VerifyEmailProps extends CommonProps {
|
|
460
|
+
/** The `token` query parameter from the link in the email. */
|
|
461
|
+
token: string | null | undefined;
|
|
462
|
+
/** Called once the address is verified. */
|
|
463
|
+
onVerified?: () => void;
|
|
464
|
+
/** Shown after success, e.g. a "Continue to sign in" link. */
|
|
465
|
+
successFooter?: ReactNode;
|
|
466
|
+
}
|
|
467
|
+
/** Confirms the email address. Render it on the page your verification links open (`/verify-email?token=…`). */
|
|
468
|
+
declare function VerifyEmail({ token, onVerified, title, footer, successFooter, appearance }: VerifyEmailProps): react_jsx_runtime.JSX.Element;
|
|
469
|
+
|
|
470
|
+
export { type AuthContext, type AuthState, type AuthStatus, type EmbeddedSignInOptions, ForgotPasswordForm, type ForgotPasswordFormProps, type InitResult, type LoginContext, type PasswordCredentials, ResetPasswordForm, type ResetPasswordFormProps, SignIn, SignInForm, type SignInFormAppearance, type SignInFormProps, type SignInProps, type SignInResult, type SignOutOptions, SignUpForm, type SignUpFormProps, SignedIn, SignedOut, type StorageLike, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps, ZenAuthClient, type ZenAuthConfig, type ZenAuthContextValue, ZenAuthError, type ZenAuthOrganization, ZenAuthProvider, type ZenAuthProviderProps, type ZenAuthUser, createMemoryStorage, useZenAuth };
|