@lalternative/auth 0.7.0 → 0.9.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/dist/client.d.ts +13 -8
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +127 -20
- package/dist/index.js +310 -183
- package/dist/index.js.map +1 -1
- package/dist/{invitation-BUqM_BF8.d.ts → invitation-D0TAHCHq.d.ts} +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/{types-SieiPwdd.d.ts → types-8GKMVW7c.d.ts} +122 -21
- package/package.json +3 -2
package/dist/client.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { P as PlatformAuthClientConfig } from './types-
|
|
1
|
+
import { createAuthClient } from 'better-auth/react';
|
|
2
|
+
import { d as AuthClientSurface, P as PlatformAuthClientConfig } from './types-8GKMVW7c.js';
|
|
3
3
|
import 'better-auth';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A Better Auth React client carrying the platform plugins.
|
|
7
|
+
*
|
|
8
|
+
* The concrete inferred type cannot be named in a published .d.ts (TS2742 — it
|
|
9
|
+
* reaches into zod's internals), so the surface the auth screens call is
|
|
10
|
+
* declared by hand in AuthClientSurface and intersected with the rest of the
|
|
11
|
+
* client. Keep it in sync with the plugins enabled below.
|
|
12
|
+
*/
|
|
13
|
+
type PlatformAuthClient = AuthClientSurface & Omit<ReturnType<typeof createAuthClient>, keyof AuthClientSurface>;
|
|
5
14
|
/**
|
|
6
15
|
* Creates a Better Auth client for React usage.
|
|
7
|
-
* Provides useSession()
|
|
16
|
+
* Provides useSession() and the email-OTP / admin plugin methods.
|
|
8
17
|
*/
|
|
9
|
-
declare function createPlatformAuthClient(config?: PlatformAuthClientConfig):
|
|
10
|
-
baseURL: string;
|
|
11
|
-
plugins: any[];
|
|
12
|
-
}>;
|
|
13
|
-
type PlatformAuthClient = ReturnType<typeof createPlatformAuthClient>;
|
|
18
|
+
declare function createPlatformAuthClient(config?: PlatformAuthClientConfig): PlatformAuthClient;
|
|
14
19
|
|
|
15
20
|
export { type PlatformAuthClient, createPlatformAuthClient };
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { createAuthClient } from \"better-auth/react\"\nimport { emailOTPClient, adminClient } from \"better-auth/client/plugins\"\nimport type { PlatformAuthClientConfig } from \"./types\"\n\n/**\n * Creates a Better Auth client for React usage.\n * Provides useSession()
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { createAuthClient } from \"better-auth/react\"\nimport { emailOTPClient, adminClient } from \"better-auth/client/plugins\"\nimport type { AuthClientSurface, PlatformAuthClientConfig } from \"./types\"\n\n/**\n * A Better Auth React client carrying the platform plugins.\n *\n * The concrete inferred type cannot be named in a published .d.ts (TS2742 — it\n * reaches into zod's internals), so the surface the auth screens call is\n * declared by hand in AuthClientSurface and intersected with the rest of the\n * client. Keep it in sync with the plugins enabled below.\n */\nexport type PlatformAuthClient = AuthClientSurface &\n Omit<ReturnType<typeof createAuthClient>, keyof AuthClientSurface>\n\n/**\n * Creates a Better Auth client for React usage.\n * Provides useSession() and the email-OTP / admin plugin methods.\n */\nexport function createPlatformAuthClient(\n config?: PlatformAuthClientConfig,\n): PlatformAuthClient {\n return createAuthClient({\n baseURL:\n config?.baseURL ??\n (typeof window !== \"undefined\"\n ? window.location.origin\n : \"http://localhost:3000\"),\n plugins: [emailOTPClient(), adminClient(), ...(config?.plugins ?? [])],\n }) as unknown as PlatformAuthClient\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,mBAAmB;AAkBrC,SAAS,yBACd,QACoB;AACpB,SAAO,iBAAiB;AAAA,IACtB,SACE,QAAQ,YACP,OAAO,WAAW,cACf,OAAO,SAAS,SAChB;AAAA,IACN,SAAS,CAAC,eAAe,GAAG,YAAY,GAAG,GAAI,QAAQ,WAAW,CAAC,CAAE;AAAA,EACvE,CAAC;AACH;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { L as LoginFormProps, R as RegisterFormProps, V as VerifyEmailFormProps, F as ForgotPasswordFormProps, a as ResetPasswordFormProps, A as AuthLayoutProps, I as InvitationNoticeProps } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { L as LoginFormProps, R as RegisterFormProps, V as VerifyEmailFormProps, F as ForgotPasswordFormProps, a as ResetPasswordFormProps, A as AuthLayoutProps, I as InvitationNoticeProps, b as LinkComponent } from './types-8GKMVW7c.js';
|
|
2
|
+
export { c as AuthClientResult, d as AuthClientSurface, e as AuthInviteProps, f as AuthNavProps, g as AuthThemeProps, h as InvitationFailure, i as LoginFormLabels, P as PlatformAuthClientConfig, j as PlatformAuthConfig, k as PlatformAuthMailer, l as PlatformAuthMailerArgs, m as PlatformAuthMailerType, n as PlatformSession, o as PlatformSessionData, p as PlatformUser, q as RegisterFormLabels } from './types-8GKMVW7c.js';
|
|
3
3
|
import * as better_auth_react from 'better-auth/react';
|
|
4
4
|
import * as better_auth from 'better-auth';
|
|
5
5
|
import { PlatformAuthClient } from './client.js';
|
|
6
6
|
import * as react from 'react';
|
|
7
7
|
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
8
|
-
export { C as ClaimOutcome, i as isInvitationFailure } from './invitation-
|
|
8
|
+
export { C as ClaimOutcome, i as isInvitationFailure } from './invitation-D0TAHCHq.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Returns a useSession hook bound to the given auth client.
|
|
@@ -54,6 +54,8 @@ interface AuthFieldProps extends NativeProps {
|
|
|
54
54
|
/** Persistent helper text under the field, tied to it for screen readers */
|
|
55
55
|
description?: string;
|
|
56
56
|
invalid?: boolean;
|
|
57
|
+
/** Replaces the default border and background utilities */
|
|
58
|
+
fieldClassName?: string;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* A single credential field.
|
|
@@ -70,13 +72,22 @@ interface AuthFieldProps extends NativeProps {
|
|
|
70
72
|
* corners exactly, and the border darkens at the same time — the border is what
|
|
71
73
|
* survives forced-colors mode, where the ring is dropped.
|
|
72
74
|
*/
|
|
73
|
-
declare function AuthField({ label, hint, description, invalid, ...props }: AuthFieldProps): react.JSX.Element;
|
|
75
|
+
declare function AuthField({ label, hint, description, invalid, fieldClassName, ...props }: AuthFieldProps): react.JSX.Element;
|
|
74
76
|
|
|
75
77
|
interface AuthSubmitProps {
|
|
76
78
|
pending?: boolean;
|
|
77
79
|
disabled?: boolean;
|
|
78
80
|
pendingLabel: string;
|
|
79
81
|
children: ReactNode;
|
|
82
|
+
/** Replaces the default `bg-primary text-primary-foreground hover:bg-primary/90` */
|
|
83
|
+
className?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Adds the step that detaches the action from the fields above it. The
|
|
86
|
+
* inputs sit on a tighter rhythm so they read as one block to fill in; the
|
|
87
|
+
* button is what you do once that block is done, and an even gap would put
|
|
88
|
+
* it on the same footing as another field.
|
|
89
|
+
*/
|
|
90
|
+
spacedAbove?: boolean;
|
|
80
91
|
}
|
|
81
92
|
/**
|
|
82
93
|
* The primary action of an auth screen.
|
|
@@ -88,11 +99,23 @@ interface AuthSubmitProps {
|
|
|
88
99
|
* The press feedback is a 1px translate rather than a scale — scaling a
|
|
89
100
|
* full-width button visibly blurs its text mid-transform.
|
|
90
101
|
*/
|
|
91
|
-
declare function AuthSubmit({ pending, disabled, pendingLabel, children, }: AuthSubmitProps): react.JSX.Element;
|
|
102
|
+
declare function AuthSubmit({ pending, disabled, pendingLabel, children, className, spacedAbove, }: AuthSubmitProps): react.JSX.Element;
|
|
92
103
|
|
|
93
|
-
declare function LoginForm({ onSuccess, registerUrl, forgotPasswordUrl, socialCallbackUrl, socialProviders, coreTokenUrl, labels,
|
|
104
|
+
declare function LoginForm({ onSuccess, registerUrl, forgotPasswordUrl, socialCallbackUrl, socialProviders, coreTokenUrl, labels, submitClassName, fieldClassName, error: externalError, linkComponent, invite, authClient, }: LoginFormProps): react.JSX.Element;
|
|
105
|
+
declare namespace LoginForm {
|
|
106
|
+
var defaults: {
|
|
107
|
+
title: string;
|
|
108
|
+
subtitle: string;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
94
111
|
|
|
95
|
-
declare function RegisterForm({ onSuccess, loginUrl, legal, socialCallbackUrl, socialProviders, labels,
|
|
112
|
+
declare function RegisterForm({ onSuccess, loginUrl, legal, socialCallbackUrl, socialProviders, labels, submitClassName, fieldClassName, error: externalError, linkComponent, invite, authClient, }: RegisterFormProps): react.JSX.Element;
|
|
113
|
+
declare namespace RegisterForm {
|
|
114
|
+
var defaults: {
|
|
115
|
+
title: string;
|
|
116
|
+
subtitle: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
96
119
|
|
|
97
120
|
interface SocialButtonsProps {
|
|
98
121
|
providers: Array<"google" | "github">;
|
|
@@ -105,16 +128,38 @@ interface SocialButtonsProps {
|
|
|
105
128
|
}
|
|
106
129
|
declare function SocialButtons({ providers, onSelect, disabled, separator, labels, }: SocialButtonsProps): react.JSX.Element | null;
|
|
107
130
|
|
|
108
|
-
declare function VerifyEmailForm({ email, onSuccess, loginUrl, labels,
|
|
131
|
+
declare function VerifyEmailForm({ email, onSuccess, loginUrl, labels, submitClassName, fieldClassName, linkComponent, authClient, }: VerifyEmailFormProps): react.JSX.Element;
|
|
132
|
+
declare namespace VerifyEmailForm {
|
|
133
|
+
var defaults: {
|
|
134
|
+
title: string;
|
|
135
|
+
subtitle: string;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
109
138
|
|
|
110
|
-
declare function ForgotPasswordForm({ onSuccess, loginUrl, labels,
|
|
139
|
+
declare function ForgotPasswordForm({ onSuccess, loginUrl, labels, submitClassName, fieldClassName, linkComponent, authClient, }: ForgotPasswordFormProps): react.JSX.Element;
|
|
140
|
+
declare namespace ForgotPasswordForm {
|
|
141
|
+
var defaults: {
|
|
142
|
+
title: string;
|
|
143
|
+
subtitle: string;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
111
146
|
|
|
112
|
-
declare function ResetPasswordForm({ email, onSuccess, loginUrl, labels,
|
|
147
|
+
declare function ResetPasswordForm({ email, onSuccess, loginUrl, labels, submitClassName, fieldClassName, linkComponent, authClient, }: ResetPasswordFormProps): react.JSX.Element;
|
|
148
|
+
declare namespace ResetPasswordForm {
|
|
149
|
+
var defaults: {
|
|
150
|
+
title: string;
|
|
151
|
+
subtitle: string;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
113
154
|
|
|
114
155
|
/**
|
|
115
|
-
* The frame every auth screen sits in. It owns the ground, the
|
|
116
|
-
* app's own marks (logo, illustration, legal footer); the
|
|
117
|
-
*
|
|
156
|
+
* The frame every auth screen sits in. It owns the ground, the heading and the
|
|
157
|
+
* app's own marks (logo, illustration, legal footer); the card holds only the
|
|
158
|
+
* fields and their actions.
|
|
159
|
+
*
|
|
160
|
+
* The heading sits ABOVE the card rather than inside it: the card is then
|
|
161
|
+
* exactly the thing you fill in, and the mark reads as the app's rather than
|
|
162
|
+
* as the form's first row.
|
|
118
163
|
*
|
|
119
164
|
* Mobile and desktop are two layouts, not one scaled down. On a phone the form
|
|
120
165
|
* IS the page: no card, no border, edge-to-edge padding, top-aligned so the
|
|
@@ -122,16 +167,16 @@ declare function ResetPasswordForm({ email, onSuccess, loginUrl, labels, titleCl
|
|
|
122
167
|
* centering. From sm up it becomes a bounded card on a tinted ground — a
|
|
123
168
|
* full-width form on a 1440px display is unreadable.
|
|
124
169
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
170
|
+
* A `panel` is an app-supplied illustration and nothing else: without one the
|
|
171
|
+
* card stays a single column rather than inventing decoration to fill a half
|
|
172
|
+
* it has no content for. When given, it takes the LEFT half from md up and is
|
|
173
|
+
* dropped below that width — a decorative half-screen above a form costs a
|
|
174
|
+
* full swipe before the first field.
|
|
130
175
|
*
|
|
131
176
|
* min-h-dvh rather than min-h-screen: on mobile browsers 100vh includes the
|
|
132
177
|
* retracting URL bar, so a screen-height container overflows by its height.
|
|
133
178
|
*/
|
|
134
|
-
declare function AuthLayout({ logo, panel, children, footer, }: AuthLayoutProps): react.JSX.Element;
|
|
179
|
+
declare function AuthLayout({ logo, panel, title, subtitle, titleClassName, children, footer, }: AuthLayoutProps): react.JSX.Element;
|
|
135
180
|
|
|
136
181
|
/**
|
|
137
182
|
* What an invitee sees when their link does not work.
|
|
@@ -147,4 +192,66 @@ declare function AuthLayout({ logo, panel, children, footer, }: AuthLayoutProps)
|
|
|
147
192
|
*/
|
|
148
193
|
declare function InvitationNotice({ reason, supportEmail, title, action, }: InvitationNoticeProps): react.JSX.Element;
|
|
149
194
|
|
|
150
|
-
|
|
195
|
+
declare function normalizeInviteToken(value: unknown): string | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Appends the invitation to a link between auth screens.
|
|
198
|
+
*
|
|
199
|
+
* An invitee who lands on /register and clicks through to /login must keep the
|
|
200
|
+
* offer: the token lives only in the URL, so a plain href to the sibling screen
|
|
201
|
+
* silently drops it and the account is created on the default tier.
|
|
202
|
+
*/
|
|
203
|
+
declare function withInviteToken(href: string, token?: string): string;
|
|
204
|
+
|
|
205
|
+
type OAuthErrorLabels = {
|
|
206
|
+
accountNotLinked: string;
|
|
207
|
+
socialCancelled: string;
|
|
208
|
+
socialFailed: string;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Turns Better Auth's machine-readable OAuth failure code into something an
|
|
212
|
+
* invitee can act on.
|
|
213
|
+
*
|
|
214
|
+
* `account_not_linked` is the one worth naming: createPlatformAuth disables
|
|
215
|
+
* account linking on purpose, so "Continue with Google" on an address already
|
|
216
|
+
* registered with a password is REFUSED. Better Auth's default error route
|
|
217
|
+
* bounces the browser back with nothing shown, so without this the button
|
|
218
|
+
* simply looks broken.
|
|
219
|
+
*/
|
|
220
|
+
declare function oauthErrorMessage(code: string | null | undefined, labels: OAuthErrorLabels): string;
|
|
221
|
+
/**
|
|
222
|
+
* Reads the failure Better Auth redirected back with.
|
|
223
|
+
*
|
|
224
|
+
* A social sign-in leaves the app entirely, so component state does not survive
|
|
225
|
+
* it: the only carrier left when the browser returns is the `?error=` Better
|
|
226
|
+
* Auth appends to the errorCallbackURL. Read from the address bar rather than
|
|
227
|
+
* from a typed route search, because the auth routes deliberately declare no
|
|
228
|
+
* search schema — adding one would make `search` required on every navigate to
|
|
229
|
+
* them across the app.
|
|
230
|
+
*/
|
|
231
|
+
declare function initialOAuthError(labels: OAuthErrorLabels, param?: string): string | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* Drops the failure from the address bar once it has been shown.
|
|
234
|
+
*
|
|
235
|
+
* Without this the message comes back on every reload, and outlives the retry
|
|
236
|
+
* that succeeded. replaceState rather than a router navigate: these screens
|
|
237
|
+
* have no typed search to navigate against, and the entry being rewritten is
|
|
238
|
+
* the one the OAuth provider pushed, not one the person chose.
|
|
239
|
+
*/
|
|
240
|
+
declare function clearOAuthError(param?: string): void;
|
|
241
|
+
|
|
242
|
+
interface AuthLinkProps {
|
|
243
|
+
to: string;
|
|
244
|
+
as?: LinkComponent;
|
|
245
|
+
className?: string;
|
|
246
|
+
children: ReactNode;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* A link between auth screens.
|
|
250
|
+
*
|
|
251
|
+
* Falls back to an anchor, which is right for an app without a router and wrong
|
|
252
|
+
* for every app with one: the full page load it triggers restarts the app and
|
|
253
|
+
* loses whatever the URL was carrying.
|
|
254
|
+
*/
|
|
255
|
+
declare function AuthLink({ to, as: Link, className, children }: AuthLinkProps): react.JSX.Element;
|
|
256
|
+
|
|
257
|
+
export { AuthField, type AuthFieldProps, AuthLayout, AuthLayoutProps, AuthLink, AuthSubmit, ForgotPasswordForm, ForgotPasswordFormProps, InvitationNotice, InvitationNoticeProps, LinkComponent, LoginForm, LoginFormProps, type OAuthErrorLabels, RegisterForm, RegisterFormProps, ResetPasswordForm, ResetPasswordFormProps, SocialButtons, VerifyEmailForm, VerifyEmailFormProps, clearOAuthError, initialOAuthError, normalizeInviteToken, oauthErrorMessage, useLogout, useSession, withInviteToken };
|