@lalternative/auth 0.8.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 +79 -10
- package/dist/index.js +196 -104
- package/dist/index.js.map +1 -1
- package/dist/{invitation-CfZAFUdJ.d.ts → invitation-D0TAHCHq.d.ts} +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/{types-Dmjo9lEL.d.ts → types-8GKMVW7c.d.ts} +92 -16
- 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.
|
|
@@ -81,6 +81,13 @@ interface AuthSubmitProps {
|
|
|
81
81
|
children: ReactNode;
|
|
82
82
|
/** Replaces the default `bg-primary text-primary-foreground hover:bg-primary/90` */
|
|
83
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;
|
|
84
91
|
}
|
|
85
92
|
/**
|
|
86
93
|
* The primary action of an auth screen.
|
|
@@ -92,9 +99,9 @@ interface AuthSubmitProps {
|
|
|
92
99
|
* The press feedback is a 1px translate rather than a scale — scaling a
|
|
93
100
|
* full-width button visibly blurs its text mid-transform.
|
|
94
101
|
*/
|
|
95
|
-
declare function AuthSubmit({ pending, disabled, pendingLabel, children, className, }: AuthSubmitProps): react.JSX.Element;
|
|
102
|
+
declare function AuthSubmit({ pending, disabled, pendingLabel, children, className, spacedAbove, }: AuthSubmitProps): react.JSX.Element;
|
|
96
103
|
|
|
97
|
-
declare function LoginForm({ onSuccess, registerUrl, forgotPasswordUrl, socialCallbackUrl, socialProviders, coreTokenUrl, labels, submitClassName, fieldClassName, error: externalError, authClient, }: LoginFormProps): react.JSX.Element;
|
|
104
|
+
declare function LoginForm({ onSuccess, registerUrl, forgotPasswordUrl, socialCallbackUrl, socialProviders, coreTokenUrl, labels, submitClassName, fieldClassName, error: externalError, linkComponent, invite, authClient, }: LoginFormProps): react.JSX.Element;
|
|
98
105
|
declare namespace LoginForm {
|
|
99
106
|
var defaults: {
|
|
100
107
|
title: string;
|
|
@@ -102,7 +109,7 @@ declare namespace LoginForm {
|
|
|
102
109
|
};
|
|
103
110
|
}
|
|
104
111
|
|
|
105
|
-
declare function RegisterForm({ onSuccess, loginUrl, legal, socialCallbackUrl, socialProviders, labels, submitClassName, fieldClassName, error: externalError, authClient, }: RegisterFormProps): react.JSX.Element;
|
|
112
|
+
declare function RegisterForm({ onSuccess, loginUrl, legal, socialCallbackUrl, socialProviders, labels, submitClassName, fieldClassName, error: externalError, linkComponent, invite, authClient, }: RegisterFormProps): react.JSX.Element;
|
|
106
113
|
declare namespace RegisterForm {
|
|
107
114
|
var defaults: {
|
|
108
115
|
title: string;
|
|
@@ -121,7 +128,7 @@ interface SocialButtonsProps {
|
|
|
121
128
|
}
|
|
122
129
|
declare function SocialButtons({ providers, onSelect, disabled, separator, labels, }: SocialButtonsProps): react.JSX.Element | null;
|
|
123
130
|
|
|
124
|
-
declare function VerifyEmailForm({ email, onSuccess, loginUrl, labels, submitClassName, fieldClassName, authClient, }: VerifyEmailFormProps): react.JSX.Element;
|
|
131
|
+
declare function VerifyEmailForm({ email, onSuccess, loginUrl, labels, submitClassName, fieldClassName, linkComponent, authClient, }: VerifyEmailFormProps): react.JSX.Element;
|
|
125
132
|
declare namespace VerifyEmailForm {
|
|
126
133
|
var defaults: {
|
|
127
134
|
title: string;
|
|
@@ -129,7 +136,7 @@ declare namespace VerifyEmailForm {
|
|
|
129
136
|
};
|
|
130
137
|
}
|
|
131
138
|
|
|
132
|
-
declare function ForgotPasswordForm({ onSuccess, loginUrl, labels, submitClassName, fieldClassName, authClient, }: ForgotPasswordFormProps): react.JSX.Element;
|
|
139
|
+
declare function ForgotPasswordForm({ onSuccess, loginUrl, labels, submitClassName, fieldClassName, linkComponent, authClient, }: ForgotPasswordFormProps): react.JSX.Element;
|
|
133
140
|
declare namespace ForgotPasswordForm {
|
|
134
141
|
var defaults: {
|
|
135
142
|
title: string;
|
|
@@ -137,7 +144,7 @@ declare namespace ForgotPasswordForm {
|
|
|
137
144
|
};
|
|
138
145
|
}
|
|
139
146
|
|
|
140
|
-
declare function ResetPasswordForm({ email, onSuccess, loginUrl, labels, submitClassName, fieldClassName, authClient, }: ResetPasswordFormProps): react.JSX.Element;
|
|
147
|
+
declare function ResetPasswordForm({ email, onSuccess, loginUrl, labels, submitClassName, fieldClassName, linkComponent, authClient, }: ResetPasswordFormProps): react.JSX.Element;
|
|
141
148
|
declare namespace ResetPasswordForm {
|
|
142
149
|
var defaults: {
|
|
143
150
|
title: string;
|
|
@@ -185,4 +192,66 @@ declare function AuthLayout({ logo, panel, title, subtitle, titleClassName, chil
|
|
|
185
192
|
*/
|
|
186
193
|
declare function InvitationNotice({ reason, supportEmail, title, action, }: InvitationNoticeProps): react.JSX.Element;
|
|
187
194
|
|
|
188
|
-
|
|
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 };
|