@lalternative/auth 0.10.5 → 0.10.6

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createAuthClient } from 'better-auth/react';
2
- import { d as AuthClientSurface, j as MagicLinkClientSurface, P as PlatformAuthClientConfig } from './types-CxpBvjn9.js';
2
+ import { f as AuthClientSurface, l as MagicLinkClientSurface, d as AdminClientSurface, P as PlatformAuthClientConfig } from './types-BEd3aSYE.js';
3
3
  import 'better-auth';
4
4
 
5
5
  /**
@@ -13,9 +13,14 @@ import 'better-auth';
13
13
  * signIn carries both halves: the client always mounts magicLinkClient, since
14
14
  * which methods exist client-side costs nothing — whether the route answers is
15
15
  * decided server-side by passing `magicLink` to createPlatformAuth.
16
+ *
17
+ * admin is optional on AuthClientSurface, whose job is to type the prop the
18
+ * forms take, and required here: this client always mounts adminClient(), so a
19
+ * back-office calling admin.listUsers() off it must not have to widen the type.
16
20
  */
17
- type PlatformAuthClient = Omit<AuthClientSurface, "signIn"> & {
21
+ type PlatformAuthClient = Omit<AuthClientSurface, "signIn" | "admin"> & {
18
22
  signIn: AuthClientSurface["signIn"] & MagicLinkClientSurface["signIn"];
23
+ admin: AdminClientSurface;
19
24
  } & Omit<ReturnType<typeof createAuthClient>, keyof AuthClientSurface | keyof MagicLinkClientSurface>;
20
25
  /**
21
26
  * Creates a Better Auth client for React usage.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { createAuthClient } from \"better-auth/react\"\nimport {\n emailOTPClient,\n adminClient,\n magicLinkClient,\n} from \"better-auth/client/plugins\"\nimport type {\n AuthClientSurface,\n MagicLinkClientSurface,\n PlatformAuthClientConfig,\n} 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 *\n * signIn carries both halves: the client always mounts magicLinkClient, since\n * which methods exist client-side costs nothing — whether the route answers is\n * decided server-side by passing `magicLink` to createPlatformAuth.\n */\nexport type PlatformAuthClient = Omit<AuthClientSurface, \"signIn\"> & {\n signIn: AuthClientSurface[\"signIn\"] & MagicLinkClientSurface[\"signIn\"]\n} & Omit<\n ReturnType<typeof createAuthClient>,\n keyof AuthClientSurface | keyof MagicLinkClientSurface\n >\n\n/**\n * Creates a Better Auth client for React usage.\n * Provides useSession() and the email-OTP / magic-link / 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: [\n emailOTPClient(),\n magicLinkClient(),\n adminClient(),\n ...(config?.plugins ?? []),\n ],\n }) as unknown as PlatformAuthClient\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA8BA,SAAS,yBACd,QACoB;AACpB,SAAO,iBAAiB;AAAA,IACtB,SACE,QAAQ,YACP,OAAO,WAAW,cACf,OAAO,SAAS,SAChB;AAAA,IACN,SAAS;AAAA,MACP,eAAe;AAAA,MACf,gBAAgB;AAAA,MAChB,YAAY;AAAA,MACZ,GAAI,QAAQ,WAAW,CAAC;AAAA,IAC1B;AAAA,EACF,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { createAuthClient } from \"better-auth/react\"\nimport {\n emailOTPClient,\n adminClient,\n magicLinkClient,\n} from \"better-auth/client/plugins\"\nimport type {\n AdminClientSurface,\n AuthClientSurface,\n MagicLinkClientSurface,\n PlatformAuthClientConfig,\n} 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 *\n * signIn carries both halves: the client always mounts magicLinkClient, since\n * which methods exist client-side costs nothing — whether the route answers is\n * decided server-side by passing `magicLink` to createPlatformAuth.\n *\n * admin is optional on AuthClientSurface, whose job is to type the prop the\n * forms take, and required here: this client always mounts adminClient(), so a\n * back-office calling admin.listUsers() off it must not have to widen the type.\n */\nexport type PlatformAuthClient = Omit<AuthClientSurface, \"signIn\" | \"admin\"> & {\n signIn: AuthClientSurface[\"signIn\"] & MagicLinkClientSurface[\"signIn\"]\n admin: AdminClientSurface\n} & Omit<\n ReturnType<typeof createAuthClient>,\n keyof AuthClientSurface | keyof MagicLinkClientSurface\n >\n\n/**\n * Creates a Better Auth client for React usage.\n * Provides useSession() and the email-OTP / magic-link / 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: [\n emailOTPClient(),\n magicLinkClient(),\n adminClient(),\n ...(config?.plugins ?? []),\n ],\n }) as unknown as PlatformAuthClient\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAoCA,SAAS,yBACd,QACoB;AACpB,SAAO,iBAAiB;AAAA,IACtB,SACE,QAAQ,YACP,OAAO,WAAW,cACf,OAAO,SAAS,SAChB;AAAA,IACN,SAAS;AAAA,MACP,eAAe;AAAA,MACf,gBAAgB;AAAA,MAChB,YAAY;AAAA,MACZ,GAAI,QAAQ,WAAW,CAAC;AAAA,IAC1B;AAAA,EACF,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, M as MagicLinkFormProps, a as ResetPasswordFormProps, A as AuthLayoutProps, I as InvitationNoticeProps, b as AuthClientResult, c as LinkComponent } from './types-CxpBvjn9.js';
2
- export { d as AuthClientSurface, e as AuthInviteProps, f as AuthNavProps, g as AuthThemeProps, h as InvitationFailure, i as LoginFormLabels, j as MagicLinkClientSurface, k as MagicLinkConfig, l as MagicLinkFormLabels, P as PlatformAuthClientConfig, m as PlatformAuthConfig, n as PlatformAuthMailer, o as PlatformAuthMailerArgs, p as PlatformAuthMailerType, q as PlatformSession, r as PlatformSessionData, s as PlatformUser, t as RegisterFormLabels } from './types-CxpBvjn9.js';
1
+ import { L as LoginFormProps, R as RegisterFormProps, V as VerifyEmailFormProps, F as ForgotPasswordFormProps, M as MagicLinkFormProps, a as ResetPasswordFormProps, A as AuthLayoutProps, I as InvitationNoticeProps, b as AuthClientResult, c as LinkComponent } from './types-BEd3aSYE.js';
2
+ export { d as AdminClientSurface, e as AuthClientDataResult, f as AuthClientSurface, g as AuthInviteProps, h as AuthNavProps, i as AuthThemeProps, j as InvitationFailure, k as LoginFormLabels, l as MagicLinkClientSurface, m as MagicLinkConfig, n as MagicLinkFormLabels, P as PlatformAuthClientConfig, o as PlatformAuthConfig, p as PlatformAuthMailer, q as PlatformAuthMailerArgs, r as PlatformAuthMailerType, s as PlatformSession, t as PlatformSessionData, u as PlatformUser, v as RegisterFormLabels } from './types-BEd3aSYE.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-DQL5hv6t.js';
8
+ export { C as ClaimOutcome, i as isInvitationFailure } from './invitation-Bcrd8t1_.js';
9
9
 
10
10
  /**
11
11
  * Returns a useSession hook bound to the given auth client.
@@ -1,4 +1,4 @@
1
- import { h as InvitationFailure } from './types-CxpBvjn9.js';
1
+ import { j as InvitationFailure } from './types-BEd3aSYE.js';
2
2
 
3
3
  /**
4
4
  * What became of a claim, in terms the invitee can be told.
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Auth, BetterAuthOptions } from 'better-auth';
2
- import { m as PlatformAuthConfig } from './types-CxpBvjn9.js';
3
- export { q as PlatformSession, r as PlatformSessionData, s as PlatformUser } from './types-CxpBvjn9.js';
4
- export { a as ClaimInvitationOptions, C as ClaimOutcome, c as claimInvitation, b as completesSignup, h as holdInviteTokenCookie, d as invitationOutcomeCookie, e as inviteTokenFrom, i as isInvitationFailure, p as pinInviteToken, r as releaseInviteTokenCookie } from './invitation-DQL5hv6t.js';
2
+ import { o as PlatformAuthConfig } from './types-BEd3aSYE.js';
3
+ export { s as PlatformSession, t as PlatformSessionData, u as PlatformUser } from './types-BEd3aSYE.js';
4
+ export { a as ClaimInvitationOptions, C as ClaimOutcome, c as claimInvitation, b as completesSignup, h as holdInviteTokenCookie, d as invitationOutcomeCookie, e as inviteTokenFrom, i as isInvitationFailure, p as pinInviteToken, r as releaseInviteTokenCookie } from './invitation-Bcrd8t1_.js';
5
5
 
6
6
  /**
7
7
  * Creates a Better Auth instance with platform defaults.
@@ -271,6 +271,36 @@ interface AuthClientResult {
271
271
  status?: number;
272
272
  } | null;
273
273
  }
274
+ interface AuthClientDataResult<T> extends AuthClientResult {
275
+ data?: T | null;
276
+ }
277
+ /**
278
+ * The admin() plugin's client half. Part of {@link AuthClientSurface} rather
279
+ * than kept apart like {@link MagicLinkClientSurface}: createPlatformAuthClient
280
+ * always mounts adminClient(), so a client built by it always answers here.
281
+ *
282
+ * The user shape is left open — each app stores its own columns, and this
283
+ * surface exists to type the calls, not the rows they return.
284
+ */
285
+ interface AdminClientSurface {
286
+ listUsers(input: {
287
+ query?: Record<string, unknown>;
288
+ }): Promise<AuthClientDataResult<{
289
+ users?: unknown[];
290
+ total?: number;
291
+ }>>;
292
+ banUser(input: {
293
+ userId: string;
294
+ banReason?: string;
295
+ }): Promise<AuthClientResult>;
296
+ unbanUser(input: {
297
+ userId: string;
298
+ }): Promise<AuthClientResult>;
299
+ setRole(input: {
300
+ userId: string;
301
+ role: "admin" | "user";
302
+ }): Promise<AuthClientResult>;
303
+ }
274
304
  interface AuthClientSurface {
275
305
  signIn: {
276
306
  email(input: {
@@ -289,6 +319,7 @@ interface AuthClientSurface {
289
319
  name?: string;
290
320
  email: string;
291
321
  password: string;
322
+ callbackURL?: string;
292
323
  }): Promise<AuthClientResult>;
293
324
  };
294
325
  emailOtp: {
@@ -306,6 +337,12 @@ interface AuthClientSurface {
306
337
  password: string;
307
338
  }): Promise<AuthClientResult>;
308
339
  };
340
+ /**
341
+ * Optional: the forms take an AuthClientSurface as a prop, and a client built
342
+ * by hand for a login screen has no reason to mount adminClient(). Required
343
+ * on PlatformAuthClient, which always does.
344
+ */
345
+ admin?: AdminClientSurface;
309
346
  }
310
347
  /**
311
348
  * The magic-link half of the client surface, kept apart from
@@ -563,4 +600,4 @@ interface AuthLayoutProps extends AuthHeadingProps {
563
600
  footer?: React.ReactNode;
564
601
  }
565
602
 
566
- export type { AuthLayoutProps as A, ForgotPasswordFormProps as F, InvitationNoticeProps as I, LoginFormProps as L, MagicLinkFormProps as M, PlatformAuthClientConfig as P, RegisterFormProps as R, VerifyEmailFormProps as V, ResetPasswordFormProps as a, AuthClientResult as b, LinkComponent as c, AuthClientSurface as d, AuthInviteProps as e, AuthNavProps as f, AuthThemeProps as g, InvitationFailure as h, LoginFormLabels as i, MagicLinkClientSurface as j, MagicLinkConfig as k, MagicLinkFormLabels as l, PlatformAuthConfig as m, PlatformAuthMailer as n, PlatformAuthMailerArgs as o, PlatformAuthMailerType as p, PlatformSession as q, PlatformSessionData as r, PlatformUser as s, RegisterFormLabels as t };
603
+ export type { AuthLayoutProps as A, ForgotPasswordFormProps as F, InvitationNoticeProps as I, LoginFormProps as L, MagicLinkFormProps as M, PlatformAuthClientConfig as P, RegisterFormProps as R, VerifyEmailFormProps as V, ResetPasswordFormProps as a, AuthClientResult as b, LinkComponent as c, AdminClientSurface as d, AuthClientDataResult as e, AuthClientSurface as f, AuthInviteProps as g, AuthNavProps as h, AuthThemeProps as i, InvitationFailure as j, LoginFormLabels as k, MagicLinkClientSurface as l, MagicLinkConfig as m, MagicLinkFormLabels as n, PlatformAuthConfig as o, PlatformAuthMailer as p, PlatformAuthMailerArgs as q, PlatformAuthMailerType as r, PlatformSession as s, PlatformSessionData as t, PlatformUser as u, RegisterFormLabels as v };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lalternative/auth",
3
- "version": "0.10.5",
3
+ "version": "0.10.6",
4
4
  "description": "Shared Better Auth wrapper for L'Alternative apps (server + React client + auth UI)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",