@meistrari/auth-core 3.4.0 → 4.0.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/index.d.ts CHANGED
@@ -2,14 +2,14 @@ import * as better_auth_plugins from 'better-auth/plugins';
2
2
  import * as better_auth from 'better-auth';
3
3
  import { JWTPayload as JWTPayload$1 } from 'better-auth';
4
4
  export { APIError } from 'better-auth';
5
- import * as zod from 'zod';
6
- import zod__default, { z } from 'zod';
5
+ import * as z from 'zod';
6
+ import z__default, { z as z$1 } from 'zod';
7
7
  import * as better_auth_client from 'better-auth/client';
8
8
  import { BetterFetchOption } from 'better-auth/client';
9
+ import * as zod_v4_core from 'zod/v4/core';
9
10
  import * as _better_auth_api_key from '@better-auth/api-key';
10
11
  import { ApiKey as ApiKey$1 } from '@better-auth/api-key';
11
12
  import * as jose from 'jose';
12
- import * as zod_v4_core from 'zod/v4/core';
13
13
  import * as _better_auth_sso from '@better-auth/sso';
14
14
 
15
15
  declare const AMRBrand: unique symbol;
@@ -17,34 +17,34 @@ declare const AALBrand: unique symbol;
17
17
  declare const ACRBrand: unique symbol;
18
18
  declare const AuthMethodBrand: unique symbol;
19
19
  declare const AMRs: {
20
- readonly Pwd: ("sso" & zod__default.core.$brand<typeof AMRBrand>) | ("saml" & zod__default.core.$brand<typeof AMRBrand>) | ("otp" & zod__default.core.$brand<typeof AMRBrand>) | ("pwd" & zod__default.core.$brand<typeof AMRBrand>) | ("oauth" & zod__default.core.$brand<typeof AMRBrand>);
21
- readonly Otp: ("sso" & zod__default.core.$brand<typeof AMRBrand>) | ("saml" & zod__default.core.$brand<typeof AMRBrand>) | ("otp" & zod__default.core.$brand<typeof AMRBrand>) | ("pwd" & zod__default.core.$brand<typeof AMRBrand>) | ("oauth" & zod__default.core.$brand<typeof AMRBrand>);
22
- readonly Oauth: ("sso" & zod__default.core.$brand<typeof AMRBrand>) | ("saml" & zod__default.core.$brand<typeof AMRBrand>) | ("otp" & zod__default.core.$brand<typeof AMRBrand>) | ("pwd" & zod__default.core.$brand<typeof AMRBrand>) | ("oauth" & zod__default.core.$brand<typeof AMRBrand>);
23
- readonly Sso: ("sso" & zod__default.core.$brand<typeof AMRBrand>) | ("saml" & zod__default.core.$brand<typeof AMRBrand>) | ("otp" & zod__default.core.$brand<typeof AMRBrand>) | ("pwd" & zod__default.core.$brand<typeof AMRBrand>) | ("oauth" & zod__default.core.$brand<typeof AMRBrand>);
24
- readonly Saml: ("sso" & zod__default.core.$brand<typeof AMRBrand>) | ("saml" & zod__default.core.$brand<typeof AMRBrand>) | ("otp" & zod__default.core.$brand<typeof AMRBrand>) | ("pwd" & zod__default.core.$brand<typeof AMRBrand>) | ("oauth" & zod__default.core.$brand<typeof AMRBrand>);
20
+ readonly Pwd: ("sso" & z__default.core.$brand<typeof AMRBrand>) | ("otp" & z__default.core.$brand<typeof AMRBrand>) | ("saml" & z__default.core.$brand<typeof AMRBrand>) | ("pwd" & z__default.core.$brand<typeof AMRBrand>) | ("oauth" & z__default.core.$brand<typeof AMRBrand>);
21
+ readonly Otp: ("sso" & z__default.core.$brand<typeof AMRBrand>) | ("otp" & z__default.core.$brand<typeof AMRBrand>) | ("saml" & z__default.core.$brand<typeof AMRBrand>) | ("pwd" & z__default.core.$brand<typeof AMRBrand>) | ("oauth" & z__default.core.$brand<typeof AMRBrand>);
22
+ readonly Oauth: ("sso" & z__default.core.$brand<typeof AMRBrand>) | ("otp" & z__default.core.$brand<typeof AMRBrand>) | ("saml" & z__default.core.$brand<typeof AMRBrand>) | ("pwd" & z__default.core.$brand<typeof AMRBrand>) | ("oauth" & z__default.core.$brand<typeof AMRBrand>);
23
+ readonly Sso: ("sso" & z__default.core.$brand<typeof AMRBrand>) | ("otp" & z__default.core.$brand<typeof AMRBrand>) | ("saml" & z__default.core.$brand<typeof AMRBrand>) | ("pwd" & z__default.core.$brand<typeof AMRBrand>) | ("oauth" & z__default.core.$brand<typeof AMRBrand>);
24
+ readonly Saml: ("sso" & z__default.core.$brand<typeof AMRBrand>) | ("otp" & z__default.core.$brand<typeof AMRBrand>) | ("saml" & z__default.core.$brand<typeof AMRBrand>) | ("pwd" & z__default.core.$brand<typeof AMRBrand>) | ("oauth" & z__default.core.$brand<typeof AMRBrand>);
25
25
  };
26
26
  declare const AALs: {
27
- readonly Aal1: ("aal1" & zod__default.core.$brand<typeof AALBrand>) | ("aal2" & zod__default.core.$brand<typeof AALBrand>) | ("aal3" & zod__default.core.$brand<typeof AALBrand>);
28
- readonly Aal2: ("aal1" & zod__default.core.$brand<typeof AALBrand>) | ("aal2" & zod__default.core.$brand<typeof AALBrand>) | ("aal3" & zod__default.core.$brand<typeof AALBrand>);
29
- readonly Aal3: ("aal1" & zod__default.core.$brand<typeof AALBrand>) | ("aal2" & zod__default.core.$brand<typeof AALBrand>) | ("aal3" & zod__default.core.$brand<typeof AALBrand>);
27
+ readonly Aal1: ("aal1" & z__default.core.$brand<typeof AALBrand>) | ("aal2" & z__default.core.$brand<typeof AALBrand>) | ("aal3" & z__default.core.$brand<typeof AALBrand>);
28
+ readonly Aal2: ("aal1" & z__default.core.$brand<typeof AALBrand>) | ("aal2" & z__default.core.$brand<typeof AALBrand>) | ("aal3" & z__default.core.$brand<typeof AALBrand>);
29
+ readonly Aal3: ("aal1" & z__default.core.$brand<typeof AALBrand>) | ("aal2" & z__default.core.$brand<typeof AALBrand>) | ("aal3" & z__default.core.$brand<typeof AALBrand>);
30
30
  };
31
31
  declare const ACRs: {
32
- readonly Unspecified: "urn:tela:auth:unspecified" & zod__default.core.$brand<typeof ACRBrand>;
32
+ readonly Unspecified: "urn:tela:auth:unspecified" & z__default.core.$brand<typeof ACRBrand>;
33
33
  };
34
34
  declare const AuthMethods: {
35
- readonly Password: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
36
- readonly EmailOTP: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
37
- readonly OAuth: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
38
- readonly SSO: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
39
- readonly SAML: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
40
- readonly Unknown: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
35
+ readonly Password: ("sso" & z__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z__default.core.$brand<typeof AuthMethodBrand>) | ("password" & z__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & z__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z__default.core.$brand<typeof AuthMethodBrand>);
36
+ readonly EmailOTP: ("sso" & z__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z__default.core.$brand<typeof AuthMethodBrand>) | ("password" & z__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & z__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z__default.core.$brand<typeof AuthMethodBrand>);
37
+ readonly OAuth: ("sso" & z__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z__default.core.$brand<typeof AuthMethodBrand>) | ("password" & z__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & z__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z__default.core.$brand<typeof AuthMethodBrand>);
38
+ readonly SSO: ("sso" & z__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z__default.core.$brand<typeof AuthMethodBrand>) | ("password" & z__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & z__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z__default.core.$brand<typeof AuthMethodBrand>);
39
+ readonly SAML: ("sso" & z__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z__default.core.$brand<typeof AuthMethodBrand>) | ("password" & z__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & z__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z__default.core.$brand<typeof AuthMethodBrand>);
40
+ readonly Unknown: ("sso" & z__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z__default.core.$brand<typeof AuthMethodBrand>) | ("password" & z__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & z__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z__default.core.$brand<typeof AuthMethodBrand>);
41
41
  };
42
42
  /**
43
43
  * Reads the legacy `saml` AMR as `sso`, so sessions and application policies
44
44
  * created before SAML and OIDC were unified keep matching each other.
45
45
  */
46
46
  declare function normalizeAmr(amr: AMR): AMR;
47
- declare const AMR: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
47
+ declare const AMR: z__default.core.$ZodBranded<z__default.ZodEnum<{
48
48
  readonly Pwd: "pwd";
49
49
  readonly Otp: "otp";
50
50
  readonly Oauth: "oauth";
@@ -56,18 +56,18 @@ declare const AMR: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
56
56
  */
57
57
  readonly Saml: "saml";
58
58
  }>, typeof AMRBrand, "out">;
59
- type AMR = zod__default.infer<typeof AMR>;
60
- declare const AAL: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
59
+ type AMR = z__default.infer<typeof AMR>;
60
+ declare const AAL: z__default.core.$ZodBranded<z__default.ZodEnum<{
61
61
  readonly Aal1: "aal1";
62
62
  readonly Aal2: "aal2";
63
63
  readonly Aal3: "aal3";
64
64
  }>, typeof AALBrand, "out">;
65
- type AAL = zod__default.infer<typeof AAL>;
66
- declare const ACR: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
65
+ type AAL = z__default.infer<typeof AAL>;
66
+ declare const ACR: z__default.core.$ZodBranded<z__default.ZodEnum<{
67
67
  readonly Unspecified: "urn:tela:auth:unspecified";
68
68
  }>, typeof ACRBrand, "out">;
69
- type ACR = zod__default.infer<typeof ACR>;
70
- declare const AuthMethod: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
69
+ type ACR = z__default.infer<typeof ACR>;
70
+ declare const AuthMethod: z__default.core.$ZodBranded<z__default.ZodEnum<{
71
71
  readonly Password: "password";
72
72
  readonly EmailOTP: "email_otp";
73
73
  readonly OAuth: "oauth";
@@ -79,7 +79,7 @@ declare const AuthMethod: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
79
79
  readonly SAML: "saml";
80
80
  readonly Unknown: "unknown";
81
81
  }>, typeof AuthMethodBrand, "out">;
82
- type AuthMethod = zod__default.infer<typeof AuthMethod>;
82
+ type AuthMethod = z__default.infer<typeof AuthMethod>;
83
83
  declare const assuranceFields: {
84
84
  authMethod: {
85
85
  type: "string";
@@ -285,21 +285,21 @@ declare const invitationAdditionalFields: {
285
285
  /**
286
286
  * Zod schema and type for the `user` claim within a JWT payload.
287
287
  */
288
- declare const JWTPayloadUser: z.ZodObject<{
289
- id: z.ZodString;
290
- name: z.ZodString;
291
- image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
292
- role: z.ZodNullable<z.ZodString>;
293
- }, z.core.$strip>;
294
- type JWTPayloadUser = z.infer<typeof JWTPayloadUser>;
288
+ declare const JWTPayloadUser: z$1.ZodObject<{
289
+ id: z$1.ZodString;
290
+ name: z$1.ZodString;
291
+ image: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
292
+ role: z$1.ZodNullable<z$1.ZodString>;
293
+ }, z$1.core.$strip>;
294
+ type JWTPayloadUser = z$1.infer<typeof JWTPayloadUser>;
295
295
  /**
296
296
  * Zod schema and type for the `workspace` claim within a JWT payload.
297
297
  */
298
- declare const JWTPayloadWorkspace: z.ZodObject<{
299
- id: z.ZodString;
300
- title: z.ZodString;
301
- }, z.core.$strip>;
302
- type JWTPayloadWorkspace = z.infer<typeof JWTPayloadWorkspace>;
298
+ declare const JWTPayloadWorkspace: z$1.ZodObject<{
299
+ id: z$1.ZodString;
300
+ title: z$1.ZodString;
301
+ }, z$1.core.$strip>;
302
+ type JWTPayloadWorkspace = z$1.infer<typeof JWTPayloadWorkspace>;
303
303
  type JWTPayloadAssurance = {
304
304
  authMethod: AuthMethod;
305
305
  amr: AMR[];
@@ -307,7 +307,7 @@ type JWTPayloadAssurance = {
307
307
  acr: ACR;
308
308
  assuredAt: string;
309
309
  };
310
- declare const JWTPayloadAssurance: z.ZodType<JWTPayloadAssurance>;
310
+ declare const JWTPayloadAssurance: z$1.ZodType<JWTPayloadAssurance>;
311
311
  declare const DEFAULT_JWT_ASSURANCE: JWTPayloadAssurance;
312
312
  type JWTPayloadData = {
313
313
  email: string;
@@ -322,7 +322,7 @@ type JWTPayloadData = {
322
322
  * Includes `email`, `user`, `workspace`, and `sessionKey` claims
323
323
  * on top of the standard Better Auth JWT fields (`sub`, `iss`, `exp`, etc.).
324
324
  */
325
- declare const JWTPayload: z.ZodType<JWTPayloadData>;
325
+ declare const JWTPayload: z$1.ZodType<JWTPayloadData>;
326
326
  type JWTPayload = JWTPayload$1 & JWTPayloadData;
327
327
 
328
328
  /**
@@ -349,11 +349,61 @@ type JWTPayload = JWTPayload$1 & JWTPayloadData;
349
349
  */
350
350
  declare function isTokenExpired(token: string, expiresInMs?: number): boolean;
351
351
 
352
- declare const OAuthStepUpProvider: zod__default.ZodEnum<{
352
+ /** Configuration for an in-memory application token cache. */
353
+ type ApplicationTokenStorageOptions = {
354
+ /** Base URL of the Auth API. */
355
+ authApiUrl: string;
356
+ /** Application identifier used for client-credentials exchanges. */
357
+ clientId: string;
358
+ /** Application secret used for client-credentials exchanges. */
359
+ clientSecret: string;
360
+ /** Full-jitter upper bound for the first retry delay. Defaults to 100 milliseconds. */
361
+ initialBackoffMs?: number;
362
+ /** Maximum number of exchange attempts, including the initial request. Defaults to 3. */
363
+ maxAttempts?: number;
364
+ /** Maximum number of organization tokens retained in memory. Defaults to 300. */
365
+ maxOrganizations?: number;
366
+ };
367
+ /** Per-call retry overrides for {@link ApplicationTokenStorage.getToken}. */
368
+ type GetTokenOptions = {
369
+ /** Full-jitter upper bound for the first retry delay. */
370
+ initialBackoffMs?: number;
371
+ /** Maximum number of exchange attempts, including the initial request. */
372
+ maxAttempts?: number;
373
+ };
374
+ /**
375
+ * Caches organization-scoped application tokens in memory.
376
+ *
377
+ * Tokens are reissued one minute before expiry. Cache hits promote their
378
+ * organization to the most-recently-used position, and insertions beyond the
379
+ * configured limit evict the least recently used organization. Transient
380
+ * exchange failures use full-jitter exponential backoff.
381
+ */
382
+ declare class ApplicationTokenStorage {
383
+ private readonly auth;
384
+ private readonly clientId;
385
+ private readonly clientSecret;
386
+ private readonly initialBackoffMs;
387
+ private readonly inFlight;
388
+ private readonly maxAttempts;
389
+ private readonly maxOrganizations;
390
+ private readonly tokens;
391
+ /** Creates an application token cache for one client-credentials identity. */
392
+ constructor({ authApiUrl, clientId, clientSecret, initialBackoffMs, maxAttempts, maxOrganizations, }: ApplicationTokenStorageOptions);
393
+ /** Returns a fresh access token scoped to the requested organization. */
394
+ getToken(organizationId: string, { initialBackoffMs, maxAttempts, }?: GetTokenOptions): Promise<string>;
395
+ private exchangeTokenWithRetry;
396
+ /** Performs the client-credentials exchange for one organization. */
397
+ protected exchangeToken(organizationId: string): Promise<string>;
398
+ /** Waits before the next exchange attempt. */
399
+ protected wait(delayMs: number): Promise<void>;
400
+ }
401
+
402
+ declare const OAuthStepUpProvider: z__default.ZodEnum<{
353
403
  google: "google";
354
404
  microsoft: "microsoft";
355
405
  }>;
356
- type OAuthStepUpProvider = zod__default.infer<typeof OAuthStepUpProvider>;
406
+ type OAuthStepUpProvider = z__default.infer<typeof OAuthStepUpProvider>;
357
407
  type StepUpOption = {
358
408
  method: typeof AMRs.Pwd;
359
409
  } | {
@@ -362,12 +412,12 @@ type StepUpOption = {
362
412
  method: typeof AMRs.Oauth;
363
413
  providers: OAuthStepUpProvider[];
364
414
  };
365
- declare const StepUpOption: zod__default.ZodType<StepUpOption>;
415
+ declare const StepUpOption: z__default.ZodType<StepUpOption>;
366
416
  type SessionAssurancePolicy = {
367
417
  minAal: typeof AALs.Aal1 | typeof AALs.Aal2 | typeof AALs.Aal3;
368
418
  acceptedAmr: AMR[];
369
419
  };
370
- declare const SessionAssurancePolicy: zod__default.ZodType<SessionAssurancePolicy>;
420
+ declare const SessionAssurancePolicy: z__default.ZodType<SessionAssurancePolicy>;
371
421
  declare const SENSITIVE_ACTION_ASSURANCE_POLICY: SessionAssurancePolicy;
372
422
  /**
373
423
  * Maximum age of an elevated (stepped-up) assurance, in seconds. Enforced by
@@ -399,16 +449,16 @@ declare class BaseError extends Error {
399
449
  constructor(code: string, message: string, options?: ErrorOptions);
400
450
  }
401
451
 
402
- declare const SessionAssuranceRequiredPayload: zod__default.ZodObject<{
403
- code: zod__default.ZodEnum<{
452
+ declare const SessionAssuranceRequiredPayload: z__default.ZodObject<{
453
+ code: z__default.ZodEnum<{
404
454
  session_assurance_required: "session_assurance_required";
405
455
  application_session_assurance_not_met: "application_session_assurance_not_met";
406
456
  }>;
407
- currentAssurance: zod__default.ZodPipe<zod__default.ZodTransform<unknown, unknown>, zod__default.ZodType<JWTPayloadAssurance, unknown, zod__default.core.$ZodTypeInternals<JWTPayloadAssurance, unknown>>>;
408
- requiredAssurance: zod__default.ZodType<SessionAssurancePolicy, unknown, zod__default.core.$ZodTypeInternals<SessionAssurancePolicy, unknown>>;
409
- validStepUps: zod__default.ZodArray<zod__default.ZodType<StepUpOption, unknown, zod__default.core.$ZodTypeInternals<StepUpOption, unknown>>>;
410
- }, zod__default.core.$strip>;
411
- type SessionAssuranceRequiredPayload = zod__default.infer<typeof SessionAssuranceRequiredPayload>;
457
+ currentAssurance: z__default.ZodPreprocess<z__default.ZodType<JWTPayloadAssurance, unknown, z__default.core.$ZodTypeInternals<JWTPayloadAssurance, unknown>>, unknown>;
458
+ requiredAssurance: z__default.ZodType<SessionAssurancePolicy, unknown, z__default.core.$ZodTypeInternals<SessionAssurancePolicy, unknown>>;
459
+ validStepUps: z__default.ZodArray<z__default.ZodType<StepUpOption, unknown, z__default.core.$ZodTypeInternals<StepUpOption, unknown>>>;
460
+ }, z__default.core.$strip>;
461
+ type SessionAssuranceRequiredPayload = z__default.infer<typeof SessionAssuranceRequiredPayload>;
412
462
  declare function parseSessionAssuranceRequiredPayload(error: unknown): {
413
463
  code: "session_assurance_required" | "application_session_assurance_not_met";
414
464
  currentAssurance: JWTPayloadAssurance;
@@ -511,26 +561,26 @@ type BeginOAuthStepUpParams = {
511
561
  provider: OAuthStepUpProvider;
512
562
  returnUrl?: string;
513
563
  };
514
- declare const SessionAssuranceResponse: zod__default.ZodObject<{
515
- assurance: zod__default.ZodType<AssuranceFields, unknown, zod__default.core.$ZodTypeInternals<AssuranceFields, unknown>>;
516
- validStepUps: zod__default.ZodArray<zod__default.ZodType<StepUpOption, unknown, zod__default.core.$ZodTypeInternals<StepUpOption, unknown>>>;
517
- }, zod__default.core.$strip>;
518
- type SessionAssuranceResponse = zod__default.infer<typeof SessionAssuranceResponse>;
519
- declare const OAuthBeginStepUpResponse: zod__default.ZodObject<{
520
- stepUpToken: zod__default.ZodString;
521
- callbackURL: zod__default.ZodString;
522
- }, zod__default.core.$strip>;
523
- type OAuthBeginStepUpResponse = zod__default.infer<typeof OAuthBeginStepUpResponse>;
524
- declare const OAuthCompleteStepUpResponse: zod__default.ZodObject<{
525
- assurance: zod__default.ZodType<AssuranceFields, unknown, zod__default.core.$ZodTypeInternals<AssuranceFields, unknown>>;
526
- validStepUps: zod__default.ZodArray<zod__default.ZodType<StepUpOption, unknown, zod__default.core.$ZodTypeInternals<StepUpOption, unknown>>>;
527
- returnPath: zod__default.ZodString;
528
- }, zod__default.core.$strip>;
529
- type OAuthCompleteStepUpResponse = zod__default.infer<typeof OAuthCompleteStepUpResponse>;
530
- declare const SendOtpResponse: zod__default.ZodObject<{
531
- success: zod__default.ZodBoolean;
532
- }, zod__default.core.$strip>;
533
- type SendOtpResponse = zod__default.infer<typeof SendOtpResponse>;
564
+ declare const SessionAssuranceResponse: z__default.ZodObject<{
565
+ assurance: z__default.ZodType<AssuranceFields, unknown, z__default.core.$ZodTypeInternals<AssuranceFields, unknown>>;
566
+ validStepUps: z__default.ZodArray<z__default.ZodType<StepUpOption, unknown, z__default.core.$ZodTypeInternals<StepUpOption, unknown>>>;
567
+ }, z__default.core.$strip>;
568
+ type SessionAssuranceResponse = z__default.infer<typeof SessionAssuranceResponse>;
569
+ declare const OAuthBeginStepUpResponse: z__default.ZodObject<{
570
+ stepUpToken: z__default.ZodString;
571
+ callbackURL: z__default.ZodString;
572
+ }, z__default.core.$strip>;
573
+ type OAuthBeginStepUpResponse = z__default.infer<typeof OAuthBeginStepUpResponse>;
574
+ declare const OAuthCompleteStepUpResponse: z__default.ZodObject<{
575
+ assurance: z__default.ZodType<AssuranceFields, unknown, z__default.core.$ZodTypeInternals<AssuranceFields, unknown>>;
576
+ validStepUps: z__default.ZodArray<z__default.ZodType<StepUpOption, unknown, z__default.core.$ZodTypeInternals<StepUpOption, unknown>>>;
577
+ returnPath: z__default.ZodString;
578
+ }, z__default.core.$strip>;
579
+ type OAuthCompleteStepUpResponse = z__default.infer<typeof OAuthCompleteStepUpResponse>;
580
+ declare const SendOtpResponse: z__default.ZodObject<{
581
+ success: z__default.ZodBoolean;
582
+ }, z__default.core.$strip>;
583
+ type SendOtpResponse = z__default.infer<typeof SendOtpResponse>;
534
584
  declare class SessionAssuranceService {
535
585
  private readonly client;
536
586
  constructor(client: APIClient);
@@ -601,12 +651,12 @@ type ApplicationSessionAssuranceConfig = {
601
651
  acceptedAmr: AMR[];
602
652
  minAal: AAL;
603
653
  };
604
- declare const ApplicationSessionAssuranceConfig: zod__default.ZodType<ApplicationSessionAssuranceConfig>;
654
+ declare const ApplicationSessionAssuranceConfig: z__default.ZodType<ApplicationSessionAssuranceConfig>;
605
655
  type ApplicationConfig = {
606
656
  version: 1;
607
657
  sessionAssurance: ApplicationSessionAssuranceConfig;
608
658
  };
609
- declare const ApplicationConfig: zod__default.ZodType<ApplicationConfig>;
659
+ declare const ApplicationConfig: z__default.ZodType<ApplicationConfig>;
610
660
  /**
611
661
  * Keys of the organization's related collections that can be optionally
612
662
  * included in the "who am I" response.
@@ -1106,24 +1156,24 @@ declare class ApplicationService {
1106
1156
  listRoles(): Promise<ApplicationRole[]>;
1107
1157
  }
1108
1158
 
1109
- declare const ApiKeyMetadata: zod__default.ZodObject<{
1110
- user: zod__default.ZodObject<{
1111
- id: zod__default.ZodString;
1112
- email: zod__default.ZodString;
1113
- }, zod__default.core.$strip>;
1114
- workspace: zod__default.ZodObject<{
1115
- id: zod__default.ZodString;
1116
- title: zod__default.ZodString;
1117
- }, zod__default.core.$strip>;
1118
- application: zod__default.ZodNullable<zod__default.ZodOptional<zod__default.ZodObject<{
1119
- id: zod__default.ZodString;
1120
- name: zod__default.ZodString;
1121
- }, zod__default.core.$strip>>>;
1122
- }, zod__default.core.$strip>;
1159
+ declare const ApiKeyMetadata: z__default.ZodObject<{
1160
+ user: z__default.ZodObject<{
1161
+ id: z__default.ZodString;
1162
+ email: z__default.ZodString;
1163
+ }, z__default.core.$strip>;
1164
+ workspace: z__default.ZodObject<{
1165
+ id: z__default.ZodString;
1166
+ title: z__default.ZodString;
1167
+ }, z__default.core.$strip>;
1168
+ application: z__default.ZodNullable<z__default.ZodOptional<z__default.ZodObject<{
1169
+ id: z__default.ZodString;
1170
+ name: z__default.ZodString;
1171
+ }, z__default.core.$strip>>>;
1172
+ }, z__default.core.$strip>;
1123
1173
  /**
1124
1174
  * Metadata attached to an API key, identifying the owning user and workspace.
1125
1175
  */
1126
- type ApiKeyMetadata = zod__default.infer<typeof ApiKeyMetadata> & Record<string, unknown>;
1176
+ type ApiKeyMetadata = z__default.infer<typeof ApiKeyMetadata> & Record<string, unknown>;
1127
1177
  /**
1128
1178
  * A full API key including the secret key value.
1129
1179
  *
@@ -1519,8 +1569,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1519
1569
  id: "invitation-signup";
1520
1570
  getActions: ($fetch: better_auth_client.BetterFetch) => {
1521
1571
  invitationSignup: {
1522
- status: (invitationId: string) => Promise<InvitationSignupStatus>;
1523
- setupPassword: (invitationId: string, password: string) => Promise<InvitationPasswordSetupResult>;
1572
+ status: (token: string) => Promise<InvitationSignupStatus>;
1573
+ setupPassword: (token: string, password: string) => Promise<InvitationPasswordSetupResult>;
1524
1574
  };
1525
1575
  };
1526
1576
  } | {
@@ -1530,6 +1580,13 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1530
1580
  domainVerification: {
1531
1581
  enabled: false;
1532
1582
  };
1583
+ schema: {
1584
+ ssoProvider?: {
1585
+ additionalFields?: {
1586
+ [key: string]: better_auth.DBFieldAttribute;
1587
+ };
1588
+ };
1589
+ } | undefined;
1533
1590
  }>;
1534
1591
  pathMethods: {
1535
1592
  "/sso/providers": "GET";
@@ -1538,22 +1595,173 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1538
1595
  } | {
1539
1596
  id: "two-factor";
1540
1597
  version: string;
1541
- $InferServerPlugin: ReturnType<(<O extends better_auth_plugins.TwoFactorOptions>(options?: O) => {
1542
- id: "two-factor";
1598
+ $InferServerPlugin: ReturnType<typeof better_auth_plugins.twoFactor>;
1599
+ atomListeners: {
1600
+ matcher: (path: string) => boolean;
1601
+ signal: "$sessionSignal";
1602
+ }[];
1603
+ pathMethods: {
1604
+ "/two-factor/disable": "POST";
1605
+ "/two-factor/enable": "POST";
1606
+ "/two-factor/send-otp": "POST";
1607
+ "/two-factor/generate-backup-codes": "POST";
1608
+ "/two-factor/get-totp-uri": "POST";
1609
+ "/two-factor/verify-totp": "POST";
1610
+ "/two-factor/verify-otp": "POST";
1611
+ "/two-factor/verify-backup-code": "POST";
1612
+ };
1613
+ fetchPlugins: {
1614
+ id: string;
1615
+ name: string;
1616
+ hooks: {
1617
+ onSuccess(context: better_auth_client.SuccessContext<any>): Promise<void>;
1618
+ };
1619
+ }[];
1620
+ $ERROR_CODES: {
1621
+ OTP_NOT_ENABLED: better_auth.RawError<"OTP_NOT_ENABLED">;
1622
+ OTP_NOT_CONFIGURED: better_auth.RawError<"OTP_NOT_CONFIGURED">;
1623
+ OTP_HAS_EXPIRED: better_auth.RawError<"OTP_HAS_EXPIRED">;
1624
+ TOTP_NOT_ENABLED: better_auth.RawError<"TOTP_NOT_ENABLED">;
1625
+ TOTP_ALREADY_ENABLED: better_auth.RawError<"TOTP_ALREADY_ENABLED">;
1626
+ TOTP_NOT_CONFIGURED: better_auth.RawError<"TOTP_NOT_CONFIGURED">;
1627
+ TWO_FACTOR_NOT_ENABLED: better_auth.RawError<"TWO_FACTOR_NOT_ENABLED">;
1628
+ BACKUP_CODES_NOT_ENABLED: better_auth.RawError<"BACKUP_CODES_NOT_ENABLED">;
1629
+ INVALID_BACKUP_CODE: better_auth.RawError<"INVALID_BACKUP_CODE">;
1630
+ INVALID_CODE: better_auth.RawError<"INVALID_CODE">;
1631
+ TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: better_auth.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
1632
+ ACCOUNT_TEMPORARILY_LOCKED: better_auth.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
1633
+ INVALID_TWO_FACTOR_COOKIE: better_auth.RawError<"INVALID_TWO_FACTOR_COOKIE">;
1634
+ };
1635
+ } | {
1636
+ id: "better-auth-client";
1637
+ version: string;
1638
+ $InferServerPlugin: ReturnType<typeof better_auth_plugins.jwt>;
1639
+ pathMethods: {
1640
+ [x: string]: "GET";
1641
+ };
1642
+ getActions: ($fetch: better_auth_client.BetterFetch, _$store: better_auth.ClientStore, _options: better_auth.BetterAuthClientOptions | undefined) => {
1643
+ jwks: (fetchOptions?: better_auth.ClientFetchOption) => Promise<{
1644
+ data: null;
1645
+ error: {
1646
+ message?: string | undefined;
1647
+ status: number;
1648
+ statusText: string;
1649
+ };
1650
+ } | {
1651
+ data: jose.JSONWebKeySet;
1652
+ error: null;
1653
+ }>;
1654
+ };
1655
+ } | {
1656
+ id: "api-key";
1657
+ version: string;
1658
+ $InferServerPlugin: ReturnType<typeof _better_auth_api_key.apiKey>;
1659
+ pathMethods: {
1660
+ "/api-key/create": "POST";
1661
+ "/api-key/delete": "POST";
1662
+ "/api-key/delete-all-expired-api-keys": "POST";
1663
+ };
1664
+ $ERROR_CODES: {
1665
+ INVALID_METADATA_TYPE: better_auth.RawError<"INVALID_METADATA_TYPE">;
1666
+ REFILL_AMOUNT_AND_INTERVAL_REQUIRED: better_auth.RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
1667
+ REFILL_INTERVAL_AND_AMOUNT_REQUIRED: better_auth.RawError<"REFILL_INTERVAL_AND_AMOUNT_REQUIRED">;
1668
+ USER_BANNED: better_auth.RawError<"USER_BANNED">;
1669
+ UNAUTHORIZED_SESSION: better_auth.RawError<"UNAUTHORIZED_SESSION">;
1670
+ KEY_NOT_FOUND: better_auth.RawError<"KEY_NOT_FOUND">;
1671
+ KEY_DISABLED: better_auth.RawError<"KEY_DISABLED">;
1672
+ KEY_EXPIRED: better_auth.RawError<"KEY_EXPIRED">;
1673
+ USAGE_EXCEEDED: better_auth.RawError<"USAGE_EXCEEDED">;
1674
+ KEY_NOT_RECOVERABLE: better_auth.RawError<"KEY_NOT_RECOVERABLE">;
1675
+ EXPIRES_IN_IS_TOO_SMALL: better_auth.RawError<"EXPIRES_IN_IS_TOO_SMALL">;
1676
+ EXPIRES_IN_IS_TOO_LARGE: better_auth.RawError<"EXPIRES_IN_IS_TOO_LARGE">;
1677
+ INVALID_REMAINING: better_auth.RawError<"INVALID_REMAINING">;
1678
+ INVALID_PREFIX_LENGTH: better_auth.RawError<"INVALID_PREFIX_LENGTH">;
1679
+ INVALID_NAME_LENGTH: better_auth.RawError<"INVALID_NAME_LENGTH">;
1680
+ METADATA_DISABLED: better_auth.RawError<"METADATA_DISABLED">;
1681
+ RATE_LIMIT_EXCEEDED: better_auth.RawError<"RATE_LIMIT_EXCEEDED">;
1682
+ NO_VALUES_TO_UPDATE: better_auth.RawError<"NO_VALUES_TO_UPDATE">;
1683
+ KEY_DISABLED_EXPIRATION: better_auth.RawError<"KEY_DISABLED_EXPIRATION">;
1684
+ INVALID_API_KEY: better_auth.RawError<"INVALID_API_KEY">;
1685
+ INVALID_USER_ID_FROM_API_KEY: better_auth.RawError<"INVALID_USER_ID_FROM_API_KEY">;
1686
+ INVALID_REFERENCE_ID_FROM_API_KEY: better_auth.RawError<"INVALID_REFERENCE_ID_FROM_API_KEY">;
1687
+ INVALID_API_KEY_GETTER_RETURN_TYPE: better_auth.RawError<"INVALID_API_KEY_GETTER_RETURN_TYPE">;
1688
+ SERVER_ONLY_PROPERTY: better_auth.RawError<"SERVER_ONLY_PROPERTY">;
1689
+ FAILED_TO_UPDATE_API_KEY: better_auth.RawError<"FAILED_TO_UPDATE_API_KEY">;
1690
+ NAME_REQUIRED: better_auth.RawError<"NAME_REQUIRED">;
1691
+ ORGANIZATION_ID_REQUIRED: better_auth.RawError<"ORGANIZATION_ID_REQUIRED">;
1692
+ USER_NOT_MEMBER_OF_ORGANIZATION: better_auth.RawError<"USER_NOT_MEMBER_OF_ORGANIZATION">;
1693
+ INSUFFICIENT_API_KEY_PERMISSIONS: better_auth.RawError<"INSUFFICIENT_API_KEY_PERMISSIONS">;
1694
+ NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: better_auth.RawError<"NO_DEFAULT_API_KEY_CONFIGURATION_FOUND">;
1695
+ ORGANIZATION_PLUGIN_REQUIRED: better_auth.RawError<"ORGANIZATION_PLUGIN_REQUIRED">;
1696
+ };
1697
+ } | {
1698
+ id: "admin-client";
1699
+ version: string;
1700
+ $InferServerPlugin: {
1701
+ id: "admin";
1543
1702
  version: string;
1703
+ init(): {
1704
+ options: {
1705
+ databaseHooks: {
1706
+ user: {
1707
+ create: {
1708
+ before(user: {
1709
+ id: string;
1710
+ createdAt: Date;
1711
+ updatedAt: Date;
1712
+ email: string;
1713
+ emailVerified: boolean;
1714
+ name: string;
1715
+ image?: string | null | undefined;
1716
+ } & Record<string, unknown>): Promise<{
1717
+ data: {
1718
+ id: string;
1719
+ createdAt: Date;
1720
+ updatedAt: Date;
1721
+ email: string;
1722
+ emailVerified: boolean;
1723
+ name: string;
1724
+ image?: string | null | undefined;
1725
+ role: string;
1726
+ };
1727
+ }>;
1728
+ };
1729
+ };
1730
+ session: {
1731
+ create: {
1732
+ before(session: {
1733
+ id: string;
1734
+ createdAt: Date;
1735
+ updatedAt: Date;
1736
+ userId: string;
1737
+ expiresAt: Date;
1738
+ token: string;
1739
+ ipAddress?: string | null | undefined;
1740
+ userAgent?: string | null | undefined;
1741
+ } & Record<string, unknown>, ctx: better_auth.GenericEndpointContext | null): Promise<void>;
1742
+ };
1743
+ };
1744
+ };
1745
+ };
1746
+ };
1747
+ hooks: {
1748
+ after: {
1749
+ matcher(context: better_auth.HookEndpointContext): boolean;
1750
+ handler: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<better_auth_plugins.SessionWithImpersonatedBy[] | undefined>>;
1751
+ }[];
1752
+ };
1544
1753
  endpoints: {
1545
- enableTwoFactor: better_auth.StrictEndpoint<"/two-factor/enable", {
1754
+ setRole: better_auth.StrictEndpoint<"/admin/set-role", {
1546
1755
  method: "POST";
1547
- body: zod.ZodObject<{
1548
- password: zod.ZodOptional<zod.ZodString>;
1549
- issuer: zod.ZodOptional<zod.ZodString>;
1550
- }, zod_v4_core.$strip> | zod.ZodObject<{
1551
- password: zod.ZodString;
1552
- issuer: zod.ZodOptional<zod.ZodString>;
1756
+ body: z.ZodObject<{
1757
+ userId: z.ZodCoercedString<unknown>;
1758
+ role: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
1553
1759
  }, zod_v4_core.$strip>;
1554
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1760
+ requireHeaders: true;
1761
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1555
1762
  session: {
1556
- session: Record<string, any> & {
1763
+ user: better_auth_plugins.UserWithRole;
1764
+ session: {
1557
1765
  id: string;
1558
1766
  createdAt: Date;
1559
1767
  updatedAt: Date;
@@ -1563,19 +1771,11 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1563
1771
  ipAddress?: string | null | undefined;
1564
1772
  userAgent?: string | null | undefined;
1565
1773
  };
1566
- user: Record<string, any> & {
1567
- id: string;
1568
- createdAt: Date;
1569
- updatedAt: Date;
1570
- email: string;
1571
- emailVerified: boolean;
1572
- name: string;
1573
- image?: string | null | undefined;
1574
- };
1575
1774
  };
1576
- }>)[];
1775
+ }>>[];
1577
1776
  metadata: {
1578
1777
  openapi: {
1778
+ operationId: string;
1579
1779
  summary: string;
1580
1780
  description: string;
1581
1781
  responses: {
@@ -1586,16 +1786,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1586
1786
  schema: {
1587
1787
  type: "object";
1588
1788
  properties: {
1589
- totpURI: {
1590
- type: string;
1591
- description: string;
1592
- };
1593
- backupCodes: {
1594
- type: string;
1595
- items: {
1596
- type: string;
1597
- };
1598
- description: string;
1789
+ user: {
1790
+ $ref: string;
1599
1791
  };
1600
1792
  };
1601
1793
  };
@@ -1604,21 +1796,25 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1604
1796
  };
1605
1797
  };
1606
1798
  };
1799
+ $Infer: {
1800
+ body: {
1801
+ userId: string;
1802
+ role: "admin" | "user" | ("admin" | "user")[];
1803
+ };
1804
+ };
1607
1805
  };
1608
1806
  }, {
1609
- totpURI: string;
1610
- backupCodes: string[];
1807
+ user: better_auth_plugins.UserWithRole;
1611
1808
  }>;
1612
- disableTwoFactor: better_auth.StrictEndpoint<"/two-factor/disable", {
1613
- method: "POST";
1614
- body: zod.ZodObject<{
1615
- password: zod.ZodOptional<zod.ZodString>;
1616
- }, zod_v4_core.$strip> | zod.ZodObject<{
1617
- password: zod.ZodString;
1809
+ getUser: better_auth.StrictEndpoint<"/admin/get-user", {
1810
+ method: "GET";
1811
+ query: z.ZodObject<{
1812
+ id: z.ZodString;
1618
1813
  }, zod_v4_core.$strip>;
1619
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1814
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1620
1815
  session: {
1621
- session: Record<string, any> & {
1816
+ user: better_auth_plugins.UserWithRole;
1817
+ session: {
1622
1818
  id: string;
1623
1819
  createdAt: Date;
1624
1820
  updatedAt: Date;
@@ -1628,19 +1824,11 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1628
1824
  ipAddress?: string | null | undefined;
1629
1825
  userAgent?: string | null | undefined;
1630
1826
  };
1631
- user: Record<string, any> & {
1632
- id: string;
1633
- createdAt: Date;
1634
- updatedAt: Date;
1635
- email: string;
1636
- emailVerified: boolean;
1637
- name: string;
1638
- image?: string | null | undefined;
1639
- };
1640
1827
  };
1641
- }>)[];
1828
+ }>>[];
1642
1829
  metadata: {
1643
1830
  openapi: {
1831
+ operationId: string;
1644
1832
  summary: string;
1645
1833
  description: string;
1646
1834
  responses: {
@@ -1651,8 +1839,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1651
1839
  schema: {
1652
1840
  type: "object";
1653
1841
  properties: {
1654
- status: {
1655
- type: string;
1842
+ user: {
1843
+ $ref: string;
1656
1844
  };
1657
1845
  };
1658
1846
  };
@@ -1662,21 +1850,23 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1662
1850
  };
1663
1851
  };
1664
1852
  };
1665
- }, {
1666
- status: boolean;
1667
- }>;
1668
- verifyBackupCode: better_auth.StrictEndpoint<"/two-factor/verify-backup-code", {
1853
+ }, better_auth_plugins.UserWithRole>;
1854
+ createUser: better_auth.StrictEndpoint<"/admin/create-user", {
1669
1855
  method: "POST";
1670
- body: zod.ZodObject<{
1671
- code: zod.ZodString;
1672
- disableSession: zod.ZodOptional<zod.ZodBoolean>;
1673
- trustDevice: zod.ZodOptional<zod.ZodBoolean>;
1856
+ body: z.ZodObject<{
1857
+ email: z.ZodString;
1858
+ password: z.ZodOptional<z.ZodString>;
1859
+ name: z.ZodString;
1860
+ role: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1861
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1674
1862
  }, zod_v4_core.$strip>;
1675
1863
  metadata: {
1676
1864
  openapi: {
1865
+ operationId: string;
1866
+ summary: string;
1677
1867
  description: string;
1678
1868
  responses: {
1679
- "200": {
1869
+ 200: {
1680
1870
  description: string;
1681
1871
  content: {
1682
1872
  "application/json": {
@@ -1684,108 +1874,38 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1684
1874
  type: "object";
1685
1875
  properties: {
1686
1876
  user: {
1687
- type: string;
1688
- properties: {
1689
- id: {
1690
- type: string;
1691
- description: string;
1692
- };
1693
- email: {
1694
- type: string;
1695
- format: string;
1696
- nullable: boolean;
1697
- description: string;
1698
- };
1699
- emailVerified: {
1700
- type: string;
1701
- nullable: boolean;
1702
- description: string;
1703
- };
1704
- name: {
1705
- type: string;
1706
- nullable: boolean;
1707
- description: string;
1708
- };
1709
- image: {
1710
- type: string;
1711
- format: string;
1712
- nullable: boolean;
1713
- description: string;
1714
- };
1715
- twoFactorEnabled: {
1716
- type: string;
1717
- description: string;
1718
- };
1719
- createdAt: {
1720
- type: string;
1721
- format: string;
1722
- description: string;
1723
- };
1724
- updatedAt: {
1725
- type: string;
1726
- format: string;
1727
- description: string;
1728
- };
1729
- };
1730
- required: string[];
1731
- description: string;
1732
- };
1733
- session: {
1734
- type: string;
1735
- properties: {
1736
- token: {
1737
- type: string;
1738
- description: string;
1739
- };
1740
- userId: {
1741
- type: string;
1742
- description: string;
1743
- };
1744
- createdAt: {
1745
- type: string;
1746
- format: string;
1747
- description: string;
1748
- };
1749
- expiresAt: {
1750
- type: string;
1751
- format: string;
1752
- description: string;
1753
- };
1754
- };
1755
- required: string[];
1756
- description: string;
1877
+ $ref: string;
1757
1878
  };
1758
1879
  };
1759
- required: string[];
1760
1880
  };
1761
1881
  };
1762
1882
  };
1763
1883
  };
1764
1884
  };
1765
1885
  };
1886
+ $Infer: {
1887
+ body: {
1888
+ email: string;
1889
+ password?: string | undefined;
1890
+ name: string;
1891
+ role?: "admin" | "user" | ("admin" | "user")[] | undefined;
1892
+ data?: Record<string, any> | undefined;
1893
+ };
1894
+ };
1766
1895
  };
1767
1896
  }, {
1768
- token: string | undefined;
1769
- user: (Record<string, any> & {
1770
- id: string;
1771
- createdAt: Date;
1772
- updatedAt: Date;
1773
- email: string;
1774
- emailVerified: boolean;
1775
- name: string;
1776
- image?: string | null | undefined;
1777
- }) | better_auth_plugins.UserWithTwoFactor;
1897
+ user: better_auth_plugins.UserWithRole;
1778
1898
  }>;
1779
- generateBackupCodes: better_auth.StrictEndpoint<"/two-factor/generate-backup-codes", {
1899
+ adminUpdateUser: better_auth.StrictEndpoint<"/admin/update-user", {
1780
1900
  method: "POST";
1781
- body: zod.ZodObject<{
1782
- password: zod.ZodOptional<zod.ZodString>;
1783
- }, zod_v4_core.$strip> | zod.ZodObject<{
1784
- password: zod.ZodString;
1901
+ body: z.ZodObject<{
1902
+ userId: z.ZodCoercedString<unknown>;
1903
+ data: z.ZodRecord<z.ZodAny, z.ZodAny>;
1785
1904
  }, zod_v4_core.$strip>;
1786
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1905
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1787
1906
  session: {
1788
- session: Record<string, any> & {
1907
+ user: better_auth_plugins.UserWithRole;
1908
+ session: {
1789
1909
  id: string;
1790
1910
  createdAt: Date;
1791
1911
  updatedAt: Date;
@@ -1795,39 +1915,111 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1795
1915
  ipAddress?: string | null | undefined;
1796
1916
  userAgent?: string | null | undefined;
1797
1917
  };
1798
- user: Record<string, any> & {
1918
+ };
1919
+ }>>[];
1920
+ metadata: {
1921
+ openapi: {
1922
+ operationId: string;
1923
+ summary: string;
1924
+ description: string;
1925
+ responses: {
1926
+ 200: {
1927
+ description: string;
1928
+ content: {
1929
+ "application/json": {
1930
+ schema: {
1931
+ type: "object";
1932
+ properties: {
1933
+ user: {
1934
+ $ref: string;
1935
+ };
1936
+ };
1937
+ };
1938
+ };
1939
+ };
1940
+ };
1941
+ };
1942
+ };
1943
+ };
1944
+ }, better_auth_plugins.UserWithRole>;
1945
+ listUsers: better_auth.StrictEndpoint<"/admin/list-users", {
1946
+ method: "GET";
1947
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1948
+ session: {
1949
+ user: better_auth_plugins.UserWithRole;
1950
+ session: {
1799
1951
  id: string;
1800
1952
  createdAt: Date;
1801
1953
  updatedAt: Date;
1802
- email: string;
1803
- emailVerified: boolean;
1804
- name: string;
1805
- image?: string | null | undefined;
1954
+ userId: string;
1955
+ expiresAt: Date;
1956
+ token: string;
1957
+ ipAddress?: string | null | undefined;
1958
+ userAgent?: string | null | undefined;
1806
1959
  };
1807
1960
  };
1808
- }>)[];
1961
+ }>>[];
1962
+ query: z.ZodObject<{
1963
+ searchValue: z.ZodOptional<z.ZodString>;
1964
+ searchField: z.ZodOptional<z.ZodEnum<{
1965
+ email: "email";
1966
+ name: "name";
1967
+ }>>;
1968
+ searchOperator: z.ZodOptional<z.ZodEnum<{
1969
+ contains: "contains";
1970
+ starts_with: "starts_with";
1971
+ ends_with: "ends_with";
1972
+ }>>;
1973
+ limit: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1974
+ offset: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1975
+ sortBy: z.ZodOptional<z.ZodString>;
1976
+ sortDirection: z.ZodOptional<z.ZodEnum<{
1977
+ asc: "asc";
1978
+ desc: "desc";
1979
+ }>>;
1980
+ filterField: z.ZodOptional<z.ZodString>;
1981
+ filterValue: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber]>, z.ZodBoolean]>, z.ZodArray<z.ZodString>]>, z.ZodArray<z.ZodNumber>]>>;
1982
+ filterOperator: z.ZodOptional<z.ZodEnum<{
1983
+ in: "in";
1984
+ lte: "lte";
1985
+ eq: "eq";
1986
+ ne: "ne";
1987
+ lt: "lt";
1988
+ gt: "gt";
1989
+ gte: "gte";
1990
+ not_in: "not_in";
1991
+ contains: "contains";
1992
+ starts_with: "starts_with";
1993
+ ends_with: "ends_with";
1994
+ }>>;
1995
+ }, zod_v4_core.$strip>;
1809
1996
  metadata: {
1810
1997
  openapi: {
1998
+ operationId: string;
1999
+ summary: string;
1811
2000
  description: string;
1812
2001
  responses: {
1813
- "200": {
2002
+ 200: {
1814
2003
  description: string;
1815
2004
  content: {
1816
2005
  "application/json": {
1817
2006
  schema: {
1818
2007
  type: "object";
1819
2008
  properties: {
1820
- status: {
1821
- type: string;
1822
- description: string;
1823
- enum: boolean[];
1824
- };
1825
- backupCodes: {
2009
+ users: {
1826
2010
  type: string;
1827
2011
  items: {
1828
- type: string;
2012
+ $ref: string;
1829
2013
  };
1830
- description: string;
2014
+ };
2015
+ total: {
2016
+ type: string;
2017
+ };
2018
+ limit: {
2019
+ type: string;
2020
+ };
2021
+ offset: {
2022
+ type: string;
1831
2023
  };
1832
2024
  };
1833
2025
  required: string[];
@@ -1839,25 +2031,32 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1839
2031
  };
1840
2032
  };
1841
2033
  }, {
1842
- status: boolean;
1843
- backupCodes: string[];
2034
+ users: better_auth_plugins.UserWithRole[];
2035
+ total: number;
1844
2036
  }>;
1845
- viewBackupCodes: better_auth.StrictEndpoint<string, {
2037
+ listUserSessions: better_auth.StrictEndpoint<"/admin/list-user-sessions", {
1846
2038
  method: "POST";
1847
- body: zod.ZodObject<{
1848
- userId: zod.ZodCoercedString<unknown>;
2039
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2040
+ session: {
2041
+ user: better_auth_plugins.UserWithRole;
2042
+ session: {
2043
+ id: string;
2044
+ createdAt: Date;
2045
+ updatedAt: Date;
2046
+ userId: string;
2047
+ expiresAt: Date;
2048
+ token: string;
2049
+ ipAddress?: string | null | undefined;
2050
+ userAgent?: string | null | undefined;
2051
+ };
2052
+ };
2053
+ }>>[];
2054
+ body: z.ZodObject<{
2055
+ userId: z.ZodCoercedString<unknown>;
1849
2056
  }, zod_v4_core.$strip>;
1850
- }, {
1851
- status: boolean;
1852
- backupCodes: string[];
1853
- }>;
1854
- sendTwoFactorOTP: better_auth.StrictEndpoint<"/two-factor/send-otp", {
1855
- method: "POST";
1856
- body: zod.ZodOptional<zod.ZodObject<{
1857
- trustDevice: zod.ZodOptional<zod.ZodBoolean>;
1858
- }, zod_v4_core.$strip>>;
1859
2057
  metadata: {
1860
2058
  openapi: {
2059
+ operationId: string;
1861
2060
  summary: string;
1862
2061
  description: string;
1863
2062
  responses: {
@@ -1868,8 +2067,11 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1868
2067
  schema: {
1869
2068
  type: "object";
1870
2069
  properties: {
1871
- status: {
2070
+ sessions: {
1872
2071
  type: string;
2072
+ items: {
2073
+ $ref: string;
2074
+ };
1873
2075
  };
1874
2076
  };
1875
2077
  };
@@ -1880,75 +2082,45 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1880
2082
  };
1881
2083
  };
1882
2084
  }, {
1883
- status: boolean;
2085
+ sessions: better_auth_plugins.SessionWithImpersonatedBy[];
1884
2086
  }>;
1885
- verifyTwoFactorOTP: better_auth.StrictEndpoint<"/two-factor/verify-otp", {
2087
+ unbanUser: better_auth.StrictEndpoint<"/admin/unban-user", {
1886
2088
  method: "POST";
1887
- body: zod.ZodObject<{
1888
- code: zod.ZodString;
1889
- trustDevice: zod.ZodOptional<zod.ZodBoolean>;
2089
+ body: z.ZodObject<{
2090
+ userId: z.ZodCoercedString<unknown>;
1890
2091
  }, zod_v4_core.$strip>;
2092
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2093
+ session: {
2094
+ user: better_auth_plugins.UserWithRole;
2095
+ session: {
2096
+ id: string;
2097
+ createdAt: Date;
2098
+ updatedAt: Date;
2099
+ userId: string;
2100
+ expiresAt: Date;
2101
+ token: string;
2102
+ ipAddress?: string | null | undefined;
2103
+ userAgent?: string | null | undefined;
2104
+ };
2105
+ };
2106
+ }>>[];
1891
2107
  metadata: {
1892
2108
  openapi: {
2109
+ operationId: string;
1893
2110
  summary: string;
1894
2111
  description: string;
1895
2112
  responses: {
1896
- "200": {
2113
+ 200: {
1897
2114
  description: string;
1898
2115
  content: {
1899
2116
  "application/json": {
1900
2117
  schema: {
1901
2118
  type: "object";
1902
2119
  properties: {
1903
- token: {
1904
- type: string;
1905
- description: string;
1906
- };
1907
2120
  user: {
1908
- type: string;
1909
- properties: {
1910
- id: {
1911
- type: string;
1912
- description: string;
1913
- };
1914
- email: {
1915
- type: string;
1916
- format: string;
1917
- nullable: boolean;
1918
- description: string;
1919
- };
1920
- emailVerified: {
1921
- type: string;
1922
- nullable: boolean;
1923
- description: string;
1924
- };
1925
- name: {
1926
- type: string;
1927
- nullable: boolean;
1928
- description: string;
1929
- };
1930
- image: {
1931
- type: string;
1932
- format: string;
1933
- nullable: boolean;
1934
- description: string;
1935
- };
1936
- createdAt: {
1937
- type: string;
1938
- format: string;
1939
- description: string;
1940
- };
1941
- updatedAt: {
1942
- type: string;
1943
- format: string;
1944
- description: string;
1945
- };
1946
- };
1947
- required: string[];
1948
- description: string;
2121
+ $ref: string;
1949
2122
  };
1950
2123
  };
1951
- required: string[];
1952
2124
  };
1953
2125
  };
1954
2126
  };
@@ -1957,27 +2129,33 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1957
2129
  };
1958
2130
  };
1959
2131
  }, {
1960
- token: string;
1961
- user: better_auth_plugins.UserWithTwoFactor;
1962
- } | {
1963
- token: string;
1964
- user: Record<string, any> & {
1965
- id: string;
1966
- createdAt: Date;
1967
- updatedAt: Date;
1968
- email: string;
1969
- emailVerified: boolean;
1970
- name: string;
1971
- image?: string | null | undefined;
1972
- };
2132
+ user: better_auth_plugins.UserWithRole;
1973
2133
  }>;
1974
- generateTOTP: better_auth.StrictEndpoint<string, {
2134
+ banUser: better_auth.StrictEndpoint<"/admin/ban-user", {
1975
2135
  method: "POST";
1976
- body: zod.ZodObject<{
1977
- secret: zod.ZodString;
2136
+ body: z.ZodObject<{
2137
+ userId: z.ZodCoercedString<unknown>;
2138
+ banReason: z.ZodOptional<z.ZodString>;
2139
+ banExpiresIn: z.ZodOptional<z.ZodNumber>;
1978
2140
  }, zod_v4_core.$strip>;
2141
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2142
+ session: {
2143
+ user: better_auth_plugins.UserWithRole;
2144
+ session: {
2145
+ id: string;
2146
+ createdAt: Date;
2147
+ updatedAt: Date;
2148
+ userId: string;
2149
+ expiresAt: Date;
2150
+ token: string;
2151
+ ipAddress?: string | null | undefined;
2152
+ userAgent?: string | null | undefined;
2153
+ };
2154
+ };
2155
+ }>>[];
1979
2156
  metadata: {
1980
2157
  openapi: {
2158
+ operationId: string;
1981
2159
  summary: string;
1982
2160
  description: string;
1983
2161
  responses: {
@@ -1988,8 +2166,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
1988
2166
  schema: {
1989
2167
  type: "object";
1990
2168
  properties: {
1991
- code: {
1992
- type: string;
2169
+ user: {
2170
+ $ref: string;
1993
2171
  };
1994
2172
  };
1995
2173
  };
@@ -2000,13 +2178,17 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2000
2178
  };
2001
2179
  };
2002
2180
  }, {
2003
- code: string;
2181
+ user: better_auth_plugins.UserWithRole;
2004
2182
  }>;
2005
- getTOTPURI: better_auth.StrictEndpoint<"/two-factor/get-totp-uri", {
2183
+ impersonateUser: better_auth.StrictEndpoint<"/admin/impersonate-user", {
2006
2184
  method: "POST";
2007
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2185
+ body: z.ZodObject<{
2186
+ userId: z.ZodCoercedString<unknown>;
2187
+ }, zod_v4_core.$strip>;
2188
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2008
2189
  session: {
2009
- session: Record<string, any> & {
2190
+ user: better_auth_plugins.UserWithRole;
2191
+ session: {
2010
2192
  id: string;
2011
2193
  createdAt: Date;
2012
2194
  updatedAt: Date;
@@ -2016,24 +2198,11 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2016
2198
  ipAddress?: string | null | undefined;
2017
2199
  userAgent?: string | null | undefined;
2018
2200
  };
2019
- user: Record<string, any> & {
2020
- id: string;
2021
- createdAt: Date;
2022
- updatedAt: Date;
2023
- email: string;
2024
- emailVerified: boolean;
2025
- name: string;
2026
- image?: string | null | undefined;
2027
- };
2028
2201
  };
2029
- }>)[];
2030
- body: zod.ZodObject<{
2031
- password: zod.ZodOptional<zod.ZodString>;
2032
- }, zod_v4_core.$strip> | zod.ZodObject<{
2033
- password: zod.ZodString;
2034
- }, zod_v4_core.$strip>;
2202
+ }>>[];
2035
2203
  metadata: {
2036
2204
  openapi: {
2205
+ operationId: string;
2037
2206
  summary: string;
2038
2207
  description: string;
2039
2208
  responses: {
@@ -2044,8 +2213,11 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2044
2213
  schema: {
2045
2214
  type: "object";
2046
2215
  properties: {
2047
- totpURI: {
2048
- type: string;
2216
+ session: {
2217
+ $ref: string;
2218
+ };
2219
+ user: {
2220
+ $ref: string;
2049
2221
  };
2050
2222
  };
2051
2223
  };
@@ -2056,16 +2228,65 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2056
2228
  };
2057
2229
  };
2058
2230
  }, {
2059
- totpURI: string;
2231
+ session: {
2232
+ id: string;
2233
+ createdAt: Date;
2234
+ updatedAt: Date;
2235
+ userId: string;
2236
+ expiresAt: Date;
2237
+ token: string;
2238
+ ipAddress?: string | null | undefined;
2239
+ userAgent?: string | null | undefined;
2240
+ };
2241
+ user: better_auth_plugins.UserWithRole;
2242
+ }>;
2243
+ stopImpersonating: better_auth.StrictEndpoint<"/admin/stop-impersonating", {
2244
+ method: "POST";
2245
+ requireHeaders: true;
2246
+ }, {
2247
+ session: {
2248
+ id: string;
2249
+ createdAt: Date;
2250
+ updatedAt: Date;
2251
+ userId: string;
2252
+ expiresAt: Date;
2253
+ token: string;
2254
+ ipAddress?: string | null | undefined;
2255
+ userAgent?: string | null | undefined;
2256
+ } & Record<string, any>;
2257
+ user: {
2258
+ id: string;
2259
+ createdAt: Date;
2260
+ updatedAt: Date;
2261
+ email: string;
2262
+ emailVerified: boolean;
2263
+ name: string;
2264
+ image?: string | null | undefined;
2265
+ } & Record<string, any>;
2060
2266
  }>;
2061
- verifyTOTP: better_auth.StrictEndpoint<"/two-factor/verify-totp", {
2267
+ revokeUserSession: better_auth.StrictEndpoint<"/admin/revoke-user-session", {
2062
2268
  method: "POST";
2063
- body: zod.ZodObject<{
2064
- code: zod.ZodString;
2065
- trustDevice: zod.ZodOptional<zod.ZodBoolean>;
2269
+ body: z.ZodObject<{
2270
+ sessionToken: z.ZodString;
2066
2271
  }, zod_v4_core.$strip>;
2272
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2273
+ session: {
2274
+ user: better_auth_plugins.UserWithRole;
2275
+ session: {
2276
+ id: string;
2277
+ createdAt: Date;
2278
+ updatedAt: Date;
2279
+ userId: string;
2280
+ expiresAt: Date;
2281
+ token: string;
2282
+ ipAddress?: string | null | undefined;
2283
+ userAgent?: string | null | undefined;
2284
+ };
2285
+ };
2286
+ }>>[];
2067
2287
  metadata: {
2068
2288
  openapi: {
2289
+ operationId: string;
2069
2290
  summary: string;
2070
2291
  description: string;
2071
2292
  responses: {
@@ -2076,7 +2297,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2076
2297
  schema: {
2077
2298
  type: "object";
2078
2299
  properties: {
2079
- status: {
2300
+ success: {
2080
2301
  type: string;
2081
2302
  };
2082
2303
  };
@@ -2088,215 +2309,45 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2088
2309
  };
2089
2310
  };
2090
2311
  }, {
2091
- token: string;
2092
- user: better_auth_plugins.UserWithTwoFactor;
2093
- } | {
2094
- token: string;
2095
- user: Record<string, any> & {
2096
- id: string;
2097
- createdAt: Date;
2098
- updatedAt: Date;
2099
- email: string;
2100
- emailVerified: boolean;
2101
- name: string;
2102
- image?: string | null | undefined;
2103
- };
2312
+ success: boolean;
2104
2313
  }>;
2105
- };
2106
- options: NoInfer<O>;
2107
- hooks: {
2108
- after: {
2109
- matcher(context: better_auth.HookEndpointContext): boolean;
2110
- handler: (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2111
- twoFactorRedirect: boolean;
2112
- twoFactorMethods: string[];
2113
- } | undefined>;
2114
- }[];
2115
- };
2116
- schema: {
2117
- user: {
2118
- fields: {
2119
- twoFactorEnabled: {
2120
- type: "boolean";
2121
- required: false;
2122
- defaultValue: false;
2123
- input: false;
2124
- };
2125
- };
2126
- };
2127
- twoFactor: {
2128
- fields: {
2129
- secret: {
2130
- type: "string";
2131
- required: true;
2132
- returned: false;
2133
- index: true;
2134
- };
2135
- backupCodes: {
2136
- type: "string";
2137
- required: true;
2138
- returned: false;
2139
- };
2140
- userId: {
2141
- type: "string";
2142
- required: true;
2143
- returned: false;
2144
- references: {
2145
- model: string;
2146
- field: string;
2314
+ revokeUserSessions: better_auth.StrictEndpoint<"/admin/revoke-user-sessions", {
2315
+ method: "POST";
2316
+ body: z.ZodObject<{
2317
+ userId: z.ZodCoercedString<unknown>;
2318
+ }, zod_v4_core.$strip>;
2319
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2320
+ session: {
2321
+ user: better_auth_plugins.UserWithRole;
2322
+ session: {
2323
+ id: string;
2324
+ createdAt: Date;
2325
+ updatedAt: Date;
2326
+ userId: string;
2327
+ expiresAt: Date;
2328
+ token: string;
2329
+ ipAddress?: string | null | undefined;
2330
+ userAgent?: string | null | undefined;
2147
2331
  };
2148
- index: true;
2149
- };
2150
- verified: {
2151
- type: "boolean";
2152
- required: false;
2153
- defaultValue: true;
2154
- input: false;
2155
- };
2156
- failedVerificationCount: {
2157
- type: "number";
2158
- required: false;
2159
- defaultValue: number;
2160
- input: false;
2161
- returned: false;
2162
2332
  };
2163
- lockedUntil: {
2164
- type: "date";
2165
- required: false;
2166
- input: false;
2167
- returned: false;
2168
- };
2169
- };
2170
- };
2171
- };
2172
- rateLimit: {
2173
- pathMatcher(path: string): boolean;
2174
- window: number;
2175
- max: number;
2176
- }[];
2177
- $ERROR_CODES: {
2178
- OTP_NOT_ENABLED: better_auth.RawError<"OTP_NOT_ENABLED">;
2179
- OTP_HAS_EXPIRED: better_auth.RawError<"OTP_HAS_EXPIRED">;
2180
- TOTP_NOT_ENABLED: better_auth.RawError<"TOTP_NOT_ENABLED">;
2181
- TWO_FACTOR_NOT_ENABLED: better_auth.RawError<"TWO_FACTOR_NOT_ENABLED">;
2182
- BACKUP_CODES_NOT_ENABLED: better_auth.RawError<"BACKUP_CODES_NOT_ENABLED">;
2183
- INVALID_BACKUP_CODE: better_auth.RawError<"INVALID_BACKUP_CODE">;
2184
- INVALID_CODE: better_auth.RawError<"INVALID_CODE">;
2185
- TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: better_auth.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
2186
- ACCOUNT_TEMPORARILY_LOCKED: better_auth.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
2187
- INVALID_TWO_FACTOR_COOKIE: better_auth.RawError<"INVALID_TWO_FACTOR_COOKIE">;
2188
- };
2189
- })>;
2190
- atomListeners: {
2191
- matcher: (path: string) => boolean;
2192
- signal: "$sessionSignal";
2193
- }[];
2194
- pathMethods: {
2195
- "/two-factor/disable": "POST";
2196
- "/two-factor/enable": "POST";
2197
- "/two-factor/send-otp": "POST";
2198
- "/two-factor/generate-backup-codes": "POST";
2199
- "/two-factor/get-totp-uri": "POST";
2200
- "/two-factor/verify-totp": "POST";
2201
- "/two-factor/verify-otp": "POST";
2202
- "/two-factor/verify-backup-code": "POST";
2203
- };
2204
- fetchPlugins: {
2205
- id: string;
2206
- name: string;
2207
- hooks: {
2208
- onSuccess(context: better_auth_client.SuccessContext<any>): Promise<void>;
2209
- };
2210
- }[];
2211
- $ERROR_CODES: {
2212
- OTP_NOT_ENABLED: better_auth.RawError<"OTP_NOT_ENABLED">;
2213
- OTP_HAS_EXPIRED: better_auth.RawError<"OTP_HAS_EXPIRED">;
2214
- TOTP_NOT_ENABLED: better_auth.RawError<"TOTP_NOT_ENABLED">;
2215
- TWO_FACTOR_NOT_ENABLED: better_auth.RawError<"TWO_FACTOR_NOT_ENABLED">;
2216
- BACKUP_CODES_NOT_ENABLED: better_auth.RawError<"BACKUP_CODES_NOT_ENABLED">;
2217
- INVALID_BACKUP_CODE: better_auth.RawError<"INVALID_BACKUP_CODE">;
2218
- INVALID_CODE: better_auth.RawError<"INVALID_CODE">;
2219
- TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: better_auth.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
2220
- ACCOUNT_TEMPORARILY_LOCKED: better_auth.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
2221
- INVALID_TWO_FACTOR_COOKIE: better_auth.RawError<"INVALID_TWO_FACTOR_COOKIE">;
2222
- };
2223
- } | {
2224
- id: "better-auth-client";
2225
- version: string;
2226
- $InferServerPlugin: ReturnType<(<O extends better_auth_plugins.JwtOptions>(options?: O) => {
2227
- id: "jwt";
2228
- version: string;
2229
- options: NoInfer<O>;
2230
- endpoints: {
2231
- getJwks: better_auth.StrictEndpoint<string, {
2232
- method: "GET";
2333
+ }>>[];
2233
2334
  metadata: {
2234
2335
  openapi: {
2235
2336
  operationId: string;
2337
+ summary: string;
2236
2338
  description: string;
2237
2339
  responses: {
2238
- "200": {
2340
+ 200: {
2239
2341
  description: string;
2240
2342
  content: {
2241
2343
  "application/json": {
2242
2344
  schema: {
2243
2345
  type: "object";
2244
2346
  properties: {
2245
- keys: {
2347
+ success: {
2246
2348
  type: string;
2247
- description: string;
2248
- items: {
2249
- type: string;
2250
- properties: {
2251
- kid: {
2252
- type: string;
2253
- description: string;
2254
- };
2255
- kty: {
2256
- type: string;
2257
- description: string;
2258
- };
2259
- alg: {
2260
- type: string;
2261
- description: string;
2262
- };
2263
- use: {
2264
- type: string;
2265
- description: string;
2266
- enum: string[];
2267
- nullable: boolean;
2268
- };
2269
- n: {
2270
- type: string;
2271
- description: string;
2272
- nullable: boolean;
2273
- };
2274
- e: {
2275
- type: string;
2276
- description: string;
2277
- nullable: boolean;
2278
- };
2279
- crv: {
2280
- type: string;
2281
- description: string;
2282
- nullable: boolean;
2283
- };
2284
- x: {
2285
- type: string;
2286
- description: string;
2287
- nullable: boolean;
2288
- };
2289
- y: {
2290
- type: string;
2291
- description: string;
2292
- nullable: boolean;
2293
- };
2294
- };
2295
- required: string[];
2296
- };
2297
2349
  };
2298
2350
  };
2299
- required: string[];
2300
2351
  };
2301
2352
  };
2302
2353
  };
@@ -2304,13 +2355,18 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2304
2355
  };
2305
2356
  };
2306
2357
  };
2307
- }, jose.JSONWebKeySet>;
2308
- getToken: better_auth.StrictEndpoint<"/token", {
2309
- method: "GET";
2310
- requireHeaders: true;
2311
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2358
+ }, {
2359
+ success: boolean;
2360
+ }>;
2361
+ removeUser: better_auth.StrictEndpoint<"/admin/remove-user", {
2362
+ method: "POST";
2363
+ body: z.ZodObject<{
2364
+ userId: z.ZodCoercedString<unknown>;
2365
+ }, zod_v4_core.$strip>;
2366
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2312
2367
  session: {
2313
- session: Record<string, any> & {
2368
+ user: better_auth_plugins.UserWithRole;
2369
+ session: {
2314
2370
  id: string;
2315
2371
  createdAt: Date;
2316
2372
  updatedAt: Date;
@@ -2320,20 +2376,12 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2320
2376
  ipAddress?: string | null | undefined;
2321
2377
  userAgent?: string | null | undefined;
2322
2378
  };
2323
- user: Record<string, any> & {
2324
- id: string;
2325
- createdAt: Date;
2326
- updatedAt: Date;
2327
- email: string;
2328
- emailVerified: boolean;
2329
- name: string;
2330
- image?: string | null | undefined;
2331
- };
2332
2379
  };
2333
- }>)[];
2380
+ }>>[];
2334
2381
  metadata: {
2335
2382
  openapi: {
2336
2383
  operationId: string;
2384
+ summary: string;
2337
2385
  description: string;
2338
2386
  responses: {
2339
2387
  200: {
@@ -2343,7 +2391,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2343
2391
  schema: {
2344
2392
  type: "object";
2345
2393
  properties: {
2346
- token: {
2394
+ success: {
2347
2395
  type: string;
2348
2396
  };
2349
2397
  };
@@ -2355,1119 +2403,279 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2355
2403
  };
2356
2404
  };
2357
2405
  }, {
2358
- token: string;
2406
+ success: boolean;
2359
2407
  }>;
2360
- signJWT: better_auth.StrictEndpoint<string, {
2408
+ setUserPassword: better_auth.StrictEndpoint<"/admin/set-user-password", {
2361
2409
  method: "POST";
2410
+ body: z.ZodObject<{
2411
+ newPassword: z.ZodString;
2412
+ userId: z.ZodCoercedString<unknown>;
2413
+ }, zod_v4_core.$strip>;
2414
+ use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2415
+ session: {
2416
+ user: better_auth_plugins.UserWithRole;
2417
+ session: {
2418
+ id: string;
2419
+ createdAt: Date;
2420
+ updatedAt: Date;
2421
+ userId: string;
2422
+ expiresAt: Date;
2423
+ token: string;
2424
+ ipAddress?: string | null | undefined;
2425
+ userAgent?: string | null | undefined;
2426
+ };
2427
+ };
2428
+ }>>[];
2362
2429
  metadata: {
2363
- $Infer: {
2364
- body: {
2365
- payload: jose.JWTPayload;
2366
- overrideOptions?: better_auth_plugins.JwtOptions | undefined;
2430
+ openapi: {
2431
+ operationId: string;
2432
+ summary: string;
2433
+ description: string;
2434
+ responses: {
2435
+ 200: {
2436
+ description: string;
2437
+ content: {
2438
+ "application/json": {
2439
+ schema: {
2440
+ type: "object";
2441
+ properties: {
2442
+ status: {
2443
+ type: string;
2444
+ };
2445
+ };
2446
+ };
2447
+ };
2448
+ };
2449
+ };
2367
2450
  };
2368
2451
  };
2369
2452
  };
2370
- body: zod.ZodObject<{
2371
- payload: zod.ZodRecord<zod.ZodString, zod.ZodAny>;
2372
- overrideOptions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
2373
- }, zod_v4_core.$strip>;
2374
2453
  }, {
2375
- token: string;
2454
+ status: boolean;
2376
2455
  }>;
2377
- verifyJWT: better_auth.StrictEndpoint<string, {
2456
+ userHasPermission: better_auth.StrictEndpoint<"/admin/has-permission", {
2378
2457
  method: "POST";
2458
+ body: z.ZodIntersection<z.ZodObject<{
2459
+ userId: z.ZodOptional<z.ZodCoercedString<unknown>>;
2460
+ role: z.ZodOptional<z.ZodString>;
2461
+ }, zod_v4_core.$strip>, z.ZodXor<readonly [z.ZodObject<{
2462
+ permission: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
2463
+ }, zod_v4_core.$strip>, z.ZodObject<{
2464
+ permissions: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
2465
+ }, zod_v4_core.$strip>]>>;
2379
2466
  metadata: {
2467
+ openapi: {
2468
+ description: string;
2469
+ requestBody: {
2470
+ content: {
2471
+ "application/json": {
2472
+ schema: {
2473
+ type: "object";
2474
+ properties: {
2475
+ permissions: {
2476
+ type: string;
2477
+ description: string;
2478
+ };
2479
+ };
2480
+ required: string[];
2481
+ };
2482
+ };
2483
+ };
2484
+ };
2485
+ responses: {
2486
+ "200": {
2487
+ description: string;
2488
+ content: {
2489
+ "application/json": {
2490
+ schema: {
2491
+ type: "object";
2492
+ properties: {
2493
+ error: {
2494
+ type: string;
2495
+ };
2496
+ success: {
2497
+ type: string;
2498
+ };
2499
+ };
2500
+ required: string[];
2501
+ };
2502
+ };
2503
+ };
2504
+ };
2505
+ };
2506
+ };
2380
2507
  $Infer: {
2381
2508
  body: {
2382
- token: string;
2383
- issuer?: string;
2384
- };
2385
- response: {
2386
- payload: {
2387
- sub: string;
2388
- aud: string;
2389
- [key: string]: any;
2390
- } | null;
2509
+ permissions: {
2510
+ readonly user?: ("update" | "delete" | "create" | "list" | "set-role" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
2511
+ readonly session?: ("delete" | "list" | "revoke")[] | undefined;
2512
+ };
2513
+ } & {
2514
+ userId?: string | undefined;
2515
+ role?: "admin" | "user" | undefined;
2391
2516
  };
2392
2517
  };
2393
2518
  };
2394
- body: zod.ZodObject<{
2395
- token: zod.ZodString;
2396
- issuer: zod.ZodOptional<zod.ZodString>;
2397
- }, zod_v4_core.$strip>;
2398
2519
  }, {
2399
- payload: (jose.JWTPayload & Required<Pick<jose.JWTPayload, "sub" | "aud">>) | null;
2520
+ error: null;
2521
+ success: boolean;
2400
2522
  }>;
2401
2523
  };
2402
- hooks: {
2403
- after: {
2404
- matcher(context: better_auth.HookEndpointContext): boolean;
2405
- handler: (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<void>;
2406
- }[];
2524
+ $ERROR_CODES: {
2525
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: better_auth.RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
2526
+ FAILED_TO_CREATE_USER: better_auth.RawError<"FAILED_TO_CREATE_USER">;
2527
+ USER_ALREADY_EXISTS: better_auth.RawError<"USER_ALREADY_EXISTS">;
2528
+ YOU_CANNOT_BAN_YOURSELF: better_auth.RawError<"YOU_CANNOT_BAN_YOURSELF">;
2529
+ YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
2530
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
2531
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS">;
2532
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS">;
2533
+ YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS">;
2534
+ YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS">;
2535
+ YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS">;
2536
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS">;
2537
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD">;
2538
+ BANNED_USER: better_auth.RawError<"BANNED_USER">;
2539
+ YOU_ARE_NOT_ALLOWED_TO_GET_USER: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_USER">;
2540
+ NO_DATA_TO_UPDATE: better_auth.RawError<"NO_DATA_TO_UPDATE">;
2541
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS">;
2542
+ YOU_CANNOT_REMOVE_YOURSELF: better_auth.RawError<"YOU_CANNOT_REMOVE_YOURSELF">;
2543
+ YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE">;
2544
+ YOU_CANNOT_IMPERSONATE_ADMINS: better_auth.RawError<"YOU_CANNOT_IMPERSONATE_ADMINS">;
2545
+ INVALID_ROLE_TYPE: better_auth.RawError<"INVALID_ROLE_TYPE">;
2546
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL">;
2547
+ PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: better_auth.RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
2407
2548
  };
2408
2549
  schema: {
2409
- jwks: {
2550
+ user: {
2410
2551
  fields: {
2411
- publicKey: {
2552
+ role: {
2412
2553
  type: "string";
2413
- required: true;
2554
+ required: false;
2555
+ input: false;
2414
2556
  };
2415
- privateKey: {
2557
+ banned: {
2558
+ type: "boolean";
2559
+ defaultValue: false;
2560
+ required: false;
2561
+ input: false;
2562
+ };
2563
+ banReason: {
2416
2564
  type: "string";
2417
- required: true;
2565
+ required: false;
2566
+ input: false;
2418
2567
  };
2419
- createdAt: {
2568
+ banExpires: {
2420
2569
  type: "date";
2421
- required: true;
2570
+ required: false;
2571
+ input: false;
2422
2572
  };
2423
- expiresAt: {
2424
- type: "date";
2573
+ };
2574
+ };
2575
+ session: {
2576
+ fields: {
2577
+ impersonatedBy: {
2578
+ type: "string";
2425
2579
  required: false;
2580
+ input: false;
2426
2581
  };
2427
2582
  };
2428
2583
  };
2429
2584
  };
2430
- })>;
2431
- pathMethods: {
2432
- [x: string]: "GET";
2433
- };
2434
- getActions: ($fetch: better_auth_client.BetterFetch, _$store: better_auth.ClientStore, _options: better_auth.BetterAuthClientOptions | undefined) => {
2435
- jwks: (fetchOptions?: better_auth.ClientFetchOption) => Promise<{
2436
- data: null;
2437
- error: {
2438
- message?: string | undefined;
2439
- status: number;
2440
- statusText: string;
2585
+ options: NoInfer<{
2586
+ ac: better_auth_plugins.AccessControl<{
2587
+ readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
2588
+ readonly session: readonly ["list", "revoke", "delete"];
2589
+ }>;
2590
+ roles: {
2591
+ admin: better_auth_plugins.Role;
2592
+ user: better_auth_plugins.Role;
2441
2593
  };
2442
- } | {
2443
- data: jose.JSONWebKeySet;
2444
- error: null;
2445
2594
  }>;
2446
2595
  };
2447
- } | {
2448
- id: "api-key";
2449
- version: string;
2450
- $InferServerPlugin: ReturnType<typeof _better_auth_api_key.apiKey>;
2596
+ getActions: () => {
2597
+ admin: {
2598
+ checkRolePermission: <R extends "admin" | "user">(data: {
2599
+ permissions: {
2600
+ readonly user?: ("update" | "delete" | "create" | "list" | "set-role" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
2601
+ readonly session?: ("delete" | "list" | "revoke")[] | undefined;
2602
+ };
2603
+ } & {
2604
+ role: R;
2605
+ }) => boolean;
2606
+ };
2607
+ };
2451
2608
  pathMethods: {
2452
- "/api-key/create": "POST";
2453
- "/api-key/delete": "POST";
2454
- "/api-key/delete-all-expired-api-keys": "POST";
2609
+ "/admin/list-users": "GET";
2610
+ "/admin/impersonate-user": "POST";
2611
+ "/admin/stop-impersonating": "POST";
2455
2612
  };
2613
+ atomListeners: {
2614
+ matcher: (path: string) => path is "/admin/impersonate-user" | "/admin/stop-impersonating";
2615
+ signal: "$sessionSignal";
2616
+ }[];
2456
2617
  $ERROR_CODES: {
2457
- INVALID_METADATA_TYPE: better_auth.RawError<"INVALID_METADATA_TYPE">;
2458
- REFILL_AMOUNT_AND_INTERVAL_REQUIRED: better_auth.RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
2459
- REFILL_INTERVAL_AND_AMOUNT_REQUIRED: better_auth.RawError<"REFILL_INTERVAL_AND_AMOUNT_REQUIRED">;
2460
- USER_BANNED: better_auth.RawError<"USER_BANNED">;
2461
- UNAUTHORIZED_SESSION: better_auth.RawError<"UNAUTHORIZED_SESSION">;
2462
- KEY_NOT_FOUND: better_auth.RawError<"KEY_NOT_FOUND">;
2463
- KEY_DISABLED: better_auth.RawError<"KEY_DISABLED">;
2464
- KEY_EXPIRED: better_auth.RawError<"KEY_EXPIRED">;
2465
- USAGE_EXCEEDED: better_auth.RawError<"USAGE_EXCEEDED">;
2466
- KEY_NOT_RECOVERABLE: better_auth.RawError<"KEY_NOT_RECOVERABLE">;
2467
- EXPIRES_IN_IS_TOO_SMALL: better_auth.RawError<"EXPIRES_IN_IS_TOO_SMALL">;
2468
- EXPIRES_IN_IS_TOO_LARGE: better_auth.RawError<"EXPIRES_IN_IS_TOO_LARGE">;
2469
- INVALID_REMAINING: better_auth.RawError<"INVALID_REMAINING">;
2470
- INVALID_PREFIX_LENGTH: better_auth.RawError<"INVALID_PREFIX_LENGTH">;
2471
- INVALID_NAME_LENGTH: better_auth.RawError<"INVALID_NAME_LENGTH">;
2472
- METADATA_DISABLED: better_auth.RawError<"METADATA_DISABLED">;
2473
- RATE_LIMIT_EXCEEDED: better_auth.RawError<"RATE_LIMIT_EXCEEDED">;
2474
- NO_VALUES_TO_UPDATE: better_auth.RawError<"NO_VALUES_TO_UPDATE">;
2475
- KEY_DISABLED_EXPIRATION: better_auth.RawError<"KEY_DISABLED_EXPIRATION">;
2476
- INVALID_API_KEY: better_auth.RawError<"INVALID_API_KEY">;
2477
- INVALID_USER_ID_FROM_API_KEY: better_auth.RawError<"INVALID_USER_ID_FROM_API_KEY">;
2478
- INVALID_REFERENCE_ID_FROM_API_KEY: better_auth.RawError<"INVALID_REFERENCE_ID_FROM_API_KEY">;
2479
- INVALID_API_KEY_GETTER_RETURN_TYPE: better_auth.RawError<"INVALID_API_KEY_GETTER_RETURN_TYPE">;
2480
- SERVER_ONLY_PROPERTY: better_auth.RawError<"SERVER_ONLY_PROPERTY">;
2481
- FAILED_TO_UPDATE_API_KEY: better_auth.RawError<"FAILED_TO_UPDATE_API_KEY">;
2482
- NAME_REQUIRED: better_auth.RawError<"NAME_REQUIRED">;
2483
- ORGANIZATION_ID_REQUIRED: better_auth.RawError<"ORGANIZATION_ID_REQUIRED">;
2484
- USER_NOT_MEMBER_OF_ORGANIZATION: better_auth.RawError<"USER_NOT_MEMBER_OF_ORGANIZATION">;
2485
- INSUFFICIENT_API_KEY_PERMISSIONS: better_auth.RawError<"INSUFFICIENT_API_KEY_PERMISSIONS">;
2486
- NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: better_auth.RawError<"NO_DEFAULT_API_KEY_CONFIGURATION_FOUND">;
2487
- ORGANIZATION_PLUGIN_REQUIRED: better_auth.RawError<"ORGANIZATION_PLUGIN_REQUIRED">;
2618
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: better_auth.RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
2619
+ FAILED_TO_CREATE_USER: better_auth.RawError<"FAILED_TO_CREATE_USER">;
2620
+ USER_ALREADY_EXISTS: better_auth.RawError<"USER_ALREADY_EXISTS">;
2621
+ YOU_CANNOT_BAN_YOURSELF: better_auth.RawError<"YOU_CANNOT_BAN_YOURSELF">;
2622
+ YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
2623
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
2624
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS">;
2625
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS">;
2626
+ YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS">;
2627
+ YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS">;
2628
+ YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS">;
2629
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS">;
2630
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD">;
2631
+ BANNED_USER: better_auth.RawError<"BANNED_USER">;
2632
+ YOU_ARE_NOT_ALLOWED_TO_GET_USER: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_USER">;
2633
+ NO_DATA_TO_UPDATE: better_auth.RawError<"NO_DATA_TO_UPDATE">;
2634
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS">;
2635
+ YOU_CANNOT_REMOVE_YOURSELF: better_auth.RawError<"YOU_CANNOT_REMOVE_YOURSELF">;
2636
+ YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE">;
2637
+ YOU_CANNOT_IMPERSONATE_ADMINS: better_auth.RawError<"YOU_CANNOT_IMPERSONATE_ADMINS">;
2638
+ INVALID_ROLE_TYPE: better_auth.RawError<"INVALID_ROLE_TYPE">;
2639
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL">;
2640
+ PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: better_auth.RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
2488
2641
  };
2489
2642
  } | {
2490
- id: "admin-client";
2643
+ id: "additional-fields-client";
2491
2644
  version: string;
2492
2645
  $InferServerPlugin: {
2493
- id: "admin";
2646
+ id: "additional-fields-client";
2494
2647
  version: string;
2495
- init(): {
2496
- options: {
2497
- databaseHooks: {
2498
- user: {
2499
- create: {
2500
- before(user: {
2501
- id: string;
2502
- createdAt: Date;
2503
- updatedAt: Date;
2504
- email: string;
2505
- emailVerified: boolean;
2506
- name: string;
2507
- image?: string | null | undefined;
2508
- } & Record<string, unknown>): Promise<{
2509
- data: {
2510
- id: string;
2511
- createdAt: Date;
2512
- updatedAt: Date;
2513
- email: string;
2514
- emailVerified: boolean;
2515
- name: string;
2516
- image?: string | null | undefined;
2517
- role: string;
2518
- };
2519
- }>;
2520
- };
2648
+ schema: {
2649
+ user: {
2650
+ fields: {
2651
+ lastActiveAt: {
2652
+ type: "date";
2653
+ required: false;
2654
+ defaultValue: null;
2521
2655
  };
2522
- session: {
2523
- create: {
2524
- before(session: {
2525
- id: string;
2526
- createdAt: Date;
2527
- updatedAt: Date;
2528
- userId: string;
2529
- expiresAt: Date;
2530
- token: string;
2531
- ipAddress?: string | null | undefined;
2532
- userAgent?: string | null | undefined;
2533
- } & Record<string, unknown>, ctx: better_auth.GenericEndpointContext | null): Promise<void>;
2534
- };
2656
+ displayName: {
2657
+ type: "string";
2658
+ input: true;
2659
+ required: false;
2660
+ defaultValue: null;
2535
2661
  };
2536
- };
2537
- };
2538
- };
2539
- hooks: {
2540
- after: {
2541
- matcher(context: better_auth.HookEndpointContext): boolean;
2542
- handler: (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<better_auth_plugins.SessionWithImpersonatedBy[] | undefined>;
2543
- }[];
2544
- };
2545
- endpoints: {
2546
- setRole: better_auth.StrictEndpoint<"/admin/set-role", {
2547
- method: "POST";
2548
- body: zod.ZodObject<{
2549
- userId: zod.ZodCoercedString<unknown>;
2550
- role: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodString>]>;
2551
- }, zod_v4_core.$strip>;
2552
- requireHeaders: true;
2553
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2554
- session: {
2555
- user: better_auth_plugins.UserWithRole;
2556
- session: {
2557
- id: string;
2558
- createdAt: Date;
2559
- updatedAt: Date;
2560
- userId: string;
2561
- expiresAt: Date;
2562
- token: string;
2563
- ipAddress?: string | null | undefined;
2564
- userAgent?: string | null | undefined;
2565
- };
2662
+ title: {
2663
+ type: "string";
2664
+ input: true;
2665
+ required: false;
2666
+ defaultValue: null;
2566
2667
  };
2567
- }>)[];
2568
- metadata: {
2569
- openapi: {
2570
- operationId: string;
2571
- summary: string;
2572
- description: string;
2573
- responses: {
2574
- 200: {
2575
- description: string;
2576
- content: {
2577
- "application/json": {
2578
- schema: {
2579
- type: "object";
2580
- properties: {
2581
- user: {
2582
- $ref: string;
2583
- };
2584
- };
2585
- };
2586
- };
2587
- };
2588
- };
2589
- };
2668
+ pronouns: {
2669
+ type: "string";
2670
+ input: true;
2671
+ required: false;
2672
+ defaultValue: null;
2590
2673
  };
2591
- $Infer: {
2592
- body: {
2593
- userId: string;
2594
- role: "admin" | "user" | ("admin" | "user")[];
2595
- };
2596
- };
2597
- };
2598
- }, {
2599
- user: better_auth_plugins.UserWithRole;
2600
- }>;
2601
- getUser: better_auth.StrictEndpoint<"/admin/get-user", {
2602
- method: "GET";
2603
- query: zod.ZodObject<{
2604
- id: zod.ZodString;
2605
- }, zod_v4_core.$strip>;
2606
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2607
- session: {
2608
- user: better_auth_plugins.UserWithRole;
2609
- session: {
2610
- id: string;
2611
- createdAt: Date;
2612
- updatedAt: Date;
2613
- userId: string;
2614
- expiresAt: Date;
2615
- token: string;
2616
- ipAddress?: string | null | undefined;
2617
- userAgent?: string | null | undefined;
2618
- };
2619
- };
2620
- }>)[];
2621
- metadata: {
2622
- openapi: {
2623
- operationId: string;
2624
- summary: string;
2625
- description: string;
2626
- responses: {
2627
- 200: {
2628
- description: string;
2629
- content: {
2630
- "application/json": {
2631
- schema: {
2632
- type: "object";
2633
- properties: {
2634
- user: {
2635
- $ref: string;
2636
- };
2637
- };
2638
- };
2639
- };
2640
- };
2641
- };
2642
- };
2643
- };
2644
- };
2645
- }, better_auth_plugins.UserWithRole>;
2646
- createUser: better_auth.StrictEndpoint<"/admin/create-user", {
2647
- method: "POST";
2648
- body: zod.ZodObject<{
2649
- email: zod.ZodString;
2650
- password: zod.ZodOptional<zod.ZodString>;
2651
- name: zod.ZodString;
2652
- role: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodString>]>>;
2653
- data: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
2654
- }, zod_v4_core.$strip>;
2655
- metadata: {
2656
- openapi: {
2657
- operationId: string;
2658
- summary: string;
2659
- description: string;
2660
- responses: {
2661
- 200: {
2662
- description: string;
2663
- content: {
2664
- "application/json": {
2665
- schema: {
2666
- type: "object";
2667
- properties: {
2668
- user: {
2669
- $ref: string;
2670
- };
2671
- };
2672
- };
2673
- };
2674
- };
2675
- };
2676
- };
2677
- };
2678
- $Infer: {
2679
- body: {
2680
- email: string;
2681
- password?: string | undefined;
2682
- name: string;
2683
- role?: "admin" | "user" | ("admin" | "user")[] | undefined;
2684
- data?: Record<string, any> | undefined;
2685
- };
2686
- };
2687
- };
2688
- }, {
2689
- user: better_auth_plugins.UserWithRole;
2690
- }>;
2691
- adminUpdateUser: better_auth.StrictEndpoint<"/admin/update-user", {
2692
- method: "POST";
2693
- body: zod.ZodObject<{
2694
- userId: zod.ZodCoercedString<unknown>;
2695
- data: zod.ZodRecord<zod.ZodAny, zod.ZodAny>;
2696
- }, zod_v4_core.$strip>;
2697
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2698
- session: {
2699
- user: better_auth_plugins.UserWithRole;
2700
- session: {
2701
- id: string;
2702
- createdAt: Date;
2703
- updatedAt: Date;
2704
- userId: string;
2705
- expiresAt: Date;
2706
- token: string;
2707
- ipAddress?: string | null | undefined;
2708
- userAgent?: string | null | undefined;
2709
- };
2710
- };
2711
- }>)[];
2712
- metadata: {
2713
- openapi: {
2714
- operationId: string;
2715
- summary: string;
2716
- description: string;
2717
- responses: {
2718
- 200: {
2719
- description: string;
2720
- content: {
2721
- "application/json": {
2722
- schema: {
2723
- type: "object";
2724
- properties: {
2725
- user: {
2726
- $ref: string;
2727
- };
2728
- };
2729
- };
2730
- };
2731
- };
2732
- };
2733
- };
2734
- };
2735
- };
2736
- }, better_auth_plugins.UserWithRole>;
2737
- listUsers: better_auth.StrictEndpoint<"/admin/list-users", {
2738
- method: "GET";
2739
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2740
- session: {
2741
- user: better_auth_plugins.UserWithRole;
2742
- session: {
2743
- id: string;
2744
- createdAt: Date;
2745
- updatedAt: Date;
2746
- userId: string;
2747
- expiresAt: Date;
2748
- token: string;
2749
- ipAddress?: string | null | undefined;
2750
- userAgent?: string | null | undefined;
2751
- };
2752
- };
2753
- }>)[];
2754
- query: zod.ZodObject<{
2755
- searchValue: zod.ZodOptional<zod.ZodString>;
2756
- searchField: zod.ZodOptional<zod.ZodEnum<{
2757
- email: "email";
2758
- name: "name";
2759
- }>>;
2760
- searchOperator: zod.ZodOptional<zod.ZodEnum<{
2761
- contains: "contains";
2762
- starts_with: "starts_with";
2763
- ends_with: "ends_with";
2764
- }>>;
2765
- limit: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>>;
2766
- offset: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>>;
2767
- sortBy: zod.ZodOptional<zod.ZodString>;
2768
- sortDirection: zod.ZodOptional<zod.ZodEnum<{
2769
- asc: "asc";
2770
- desc: "desc";
2771
- }>>;
2772
- filterField: zod.ZodOptional<zod.ZodString>;
2773
- filterValue: zod.ZodOptional<zod.ZodUnion<[zod.ZodUnion<[zod.ZodUnion<[zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, zod.ZodBoolean]>, zod.ZodArray<zod.ZodString>]>, zod.ZodArray<zod.ZodNumber>]>>;
2774
- filterOperator: zod.ZodOptional<zod.ZodEnum<{
2775
- eq: "eq";
2776
- ne: "ne";
2777
- gt: "gt";
2778
- gte: "gte";
2779
- lt: "lt";
2780
- lte: "lte";
2781
- in: "in";
2782
- not_in: "not_in";
2783
- contains: "contains";
2784
- starts_with: "starts_with";
2785
- ends_with: "ends_with";
2786
- }>>;
2787
- }, zod_v4_core.$strip>;
2788
- metadata: {
2789
- openapi: {
2790
- operationId: string;
2791
- summary: string;
2792
- description: string;
2793
- responses: {
2794
- 200: {
2795
- description: string;
2796
- content: {
2797
- "application/json": {
2798
- schema: {
2799
- type: "object";
2800
- properties: {
2801
- users: {
2802
- type: string;
2803
- items: {
2804
- $ref: string;
2805
- };
2806
- };
2807
- total: {
2808
- type: string;
2809
- };
2810
- limit: {
2811
- type: string;
2812
- };
2813
- offset: {
2814
- type: string;
2815
- };
2816
- };
2817
- required: string[];
2818
- };
2819
- };
2820
- };
2821
- };
2822
- };
2823
- };
2824
- };
2825
- }, {
2826
- users: better_auth_plugins.UserWithRole[];
2827
- total: number;
2828
- }>;
2829
- listUserSessions: better_auth.StrictEndpoint<"/admin/list-user-sessions", {
2830
- method: "POST";
2831
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2832
- session: {
2833
- user: better_auth_plugins.UserWithRole;
2834
- session: {
2835
- id: string;
2836
- createdAt: Date;
2837
- updatedAt: Date;
2838
- userId: string;
2839
- expiresAt: Date;
2840
- token: string;
2841
- ipAddress?: string | null | undefined;
2842
- userAgent?: string | null | undefined;
2843
- };
2844
- };
2845
- }>)[];
2846
- body: zod.ZodObject<{
2847
- userId: zod.ZodCoercedString<unknown>;
2848
- }, zod_v4_core.$strip>;
2849
- metadata: {
2850
- openapi: {
2851
- operationId: string;
2852
- summary: string;
2853
- description: string;
2854
- responses: {
2855
- 200: {
2856
- description: string;
2857
- content: {
2858
- "application/json": {
2859
- schema: {
2860
- type: "object";
2861
- properties: {
2862
- sessions: {
2863
- type: string;
2864
- items: {
2865
- $ref: string;
2866
- };
2867
- };
2868
- };
2869
- };
2870
- };
2871
- };
2872
- };
2873
- };
2874
- };
2875
- };
2876
- }, {
2877
- sessions: better_auth_plugins.SessionWithImpersonatedBy[];
2878
- }>;
2879
- unbanUser: better_auth.StrictEndpoint<"/admin/unban-user", {
2880
- method: "POST";
2881
- body: zod.ZodObject<{
2882
- userId: zod.ZodCoercedString<unknown>;
2883
- }, zod_v4_core.$strip>;
2884
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2885
- session: {
2886
- user: better_auth_plugins.UserWithRole;
2887
- session: {
2888
- id: string;
2889
- createdAt: Date;
2890
- updatedAt: Date;
2891
- userId: string;
2892
- expiresAt: Date;
2893
- token: string;
2894
- ipAddress?: string | null | undefined;
2895
- userAgent?: string | null | undefined;
2896
- };
2897
- };
2898
- }>)[];
2899
- metadata: {
2900
- openapi: {
2901
- operationId: string;
2902
- summary: string;
2903
- description: string;
2904
- responses: {
2905
- 200: {
2906
- description: string;
2907
- content: {
2908
- "application/json": {
2909
- schema: {
2910
- type: "object";
2911
- properties: {
2912
- user: {
2913
- $ref: string;
2914
- };
2915
- };
2916
- };
2917
- };
2918
- };
2919
- };
2920
- };
2921
- };
2922
- };
2923
- }, {
2924
- user: better_auth_plugins.UserWithRole;
2925
- }>;
2926
- banUser: better_auth.StrictEndpoint<"/admin/ban-user", {
2927
- method: "POST";
2928
- body: zod.ZodObject<{
2929
- userId: zod.ZodCoercedString<unknown>;
2930
- banReason: zod.ZodOptional<zod.ZodString>;
2931
- banExpiresIn: zod.ZodOptional<zod.ZodNumber>;
2932
- }, zod_v4_core.$strip>;
2933
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2934
- session: {
2935
- user: better_auth_plugins.UserWithRole;
2936
- session: {
2937
- id: string;
2938
- createdAt: Date;
2939
- updatedAt: Date;
2940
- userId: string;
2941
- expiresAt: Date;
2942
- token: string;
2943
- ipAddress?: string | null | undefined;
2944
- userAgent?: string | null | undefined;
2945
- };
2946
- };
2947
- }>)[];
2948
- metadata: {
2949
- openapi: {
2950
- operationId: string;
2951
- summary: string;
2952
- description: string;
2953
- responses: {
2954
- 200: {
2955
- description: string;
2956
- content: {
2957
- "application/json": {
2958
- schema: {
2959
- type: "object";
2960
- properties: {
2961
- user: {
2962
- $ref: string;
2963
- };
2964
- };
2965
- };
2966
- };
2967
- };
2968
- };
2969
- };
2970
- };
2971
- };
2972
- }, {
2973
- user: better_auth_plugins.UserWithRole;
2974
- }>;
2975
- impersonateUser: better_auth.StrictEndpoint<"/admin/impersonate-user", {
2976
- method: "POST";
2977
- body: zod.ZodObject<{
2978
- userId: zod.ZodCoercedString<unknown>;
2979
- }, zod_v4_core.$strip>;
2980
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
2981
- session: {
2982
- user: better_auth_plugins.UserWithRole;
2983
- session: {
2984
- id: string;
2985
- createdAt: Date;
2986
- updatedAt: Date;
2987
- userId: string;
2988
- expiresAt: Date;
2989
- token: string;
2990
- ipAddress?: string | null | undefined;
2991
- userAgent?: string | null | undefined;
2992
- };
2993
- };
2994
- }>)[];
2995
- metadata: {
2996
- openapi: {
2997
- operationId: string;
2998
- summary: string;
2999
- description: string;
3000
- responses: {
3001
- 200: {
3002
- description: string;
3003
- content: {
3004
- "application/json": {
3005
- schema: {
3006
- type: "object";
3007
- properties: {
3008
- session: {
3009
- $ref: string;
3010
- };
3011
- user: {
3012
- $ref: string;
3013
- };
3014
- };
3015
- };
3016
- };
3017
- };
3018
- };
3019
- };
3020
- };
3021
- };
3022
- }, {
3023
- session: {
3024
- id: string;
3025
- createdAt: Date;
3026
- updatedAt: Date;
3027
- userId: string;
3028
- expiresAt: Date;
3029
- token: string;
3030
- ipAddress?: string | null | undefined;
3031
- userAgent?: string | null | undefined;
3032
- };
3033
- user: better_auth_plugins.UserWithRole;
3034
- }>;
3035
- stopImpersonating: better_auth.StrictEndpoint<"/admin/stop-impersonating", {
3036
- method: "POST";
3037
- requireHeaders: true;
3038
- }, {
3039
- session: {
3040
- id: string;
3041
- createdAt: Date;
3042
- updatedAt: Date;
3043
- userId: string;
3044
- expiresAt: Date;
3045
- token: string;
3046
- ipAddress?: string | null | undefined;
3047
- userAgent?: string | null | undefined;
3048
- } & Record<string, any>;
3049
- user: {
3050
- id: string;
3051
- createdAt: Date;
3052
- updatedAt: Date;
3053
- email: string;
3054
- emailVerified: boolean;
3055
- name: string;
3056
- image?: string | null | undefined;
3057
- } & Record<string, any>;
3058
- }>;
3059
- revokeUserSession: better_auth.StrictEndpoint<"/admin/revoke-user-session", {
3060
- method: "POST";
3061
- body: zod.ZodObject<{
3062
- sessionToken: zod.ZodString;
3063
- }, zod_v4_core.$strip>;
3064
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3065
- session: {
3066
- user: better_auth_plugins.UserWithRole;
3067
- session: {
3068
- id: string;
3069
- createdAt: Date;
3070
- updatedAt: Date;
3071
- userId: string;
3072
- expiresAt: Date;
3073
- token: string;
3074
- ipAddress?: string | null | undefined;
3075
- userAgent?: string | null | undefined;
3076
- };
3077
- };
3078
- }>)[];
3079
- metadata: {
3080
- openapi: {
3081
- operationId: string;
3082
- summary: string;
3083
- description: string;
3084
- responses: {
3085
- 200: {
3086
- description: string;
3087
- content: {
3088
- "application/json": {
3089
- schema: {
3090
- type: "object";
3091
- properties: {
3092
- success: {
3093
- type: string;
3094
- };
3095
- };
3096
- };
3097
- };
3098
- };
3099
- };
3100
- };
3101
- };
3102
- };
3103
- }, {
3104
- success: boolean;
3105
- }>;
3106
- revokeUserSessions: better_auth.StrictEndpoint<"/admin/revoke-user-sessions", {
3107
- method: "POST";
3108
- body: zod.ZodObject<{
3109
- userId: zod.ZodCoercedString<unknown>;
3110
- }, zod_v4_core.$strip>;
3111
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3112
- session: {
3113
- user: better_auth_plugins.UserWithRole;
3114
- session: {
3115
- id: string;
3116
- createdAt: Date;
3117
- updatedAt: Date;
3118
- userId: string;
3119
- expiresAt: Date;
3120
- token: string;
3121
- ipAddress?: string | null | undefined;
3122
- userAgent?: string | null | undefined;
3123
- };
3124
- };
3125
- }>)[];
3126
- metadata: {
3127
- openapi: {
3128
- operationId: string;
3129
- summary: string;
3130
- description: string;
3131
- responses: {
3132
- 200: {
3133
- description: string;
3134
- content: {
3135
- "application/json": {
3136
- schema: {
3137
- type: "object";
3138
- properties: {
3139
- success: {
3140
- type: string;
3141
- };
3142
- };
3143
- };
3144
- };
3145
- };
3146
- };
3147
- };
3148
- };
3149
- };
3150
- }, {
3151
- success: boolean;
3152
- }>;
3153
- removeUser: better_auth.StrictEndpoint<"/admin/remove-user", {
3154
- method: "POST";
3155
- body: zod.ZodObject<{
3156
- userId: zod.ZodCoercedString<unknown>;
3157
- }, zod_v4_core.$strip>;
3158
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3159
- session: {
3160
- user: better_auth_plugins.UserWithRole;
3161
- session: {
3162
- id: string;
3163
- createdAt: Date;
3164
- updatedAt: Date;
3165
- userId: string;
3166
- expiresAt: Date;
3167
- token: string;
3168
- ipAddress?: string | null | undefined;
3169
- userAgent?: string | null | undefined;
3170
- };
3171
- };
3172
- }>)[];
3173
- metadata: {
3174
- openapi: {
3175
- operationId: string;
3176
- summary: string;
3177
- description: string;
3178
- responses: {
3179
- 200: {
3180
- description: string;
3181
- content: {
3182
- "application/json": {
3183
- schema: {
3184
- type: "object";
3185
- properties: {
3186
- success: {
3187
- type: string;
3188
- };
3189
- };
3190
- };
3191
- };
3192
- };
3193
- };
3194
- };
3195
- };
3196
- };
3197
- }, {
3198
- success: boolean;
3199
- }>;
3200
- setUserPassword: better_auth.StrictEndpoint<"/admin/set-user-password", {
3201
- method: "POST";
3202
- body: zod.ZodObject<{
3203
- newPassword: zod.ZodString;
3204
- userId: zod.ZodCoercedString<unknown>;
3205
- }, zod_v4_core.$strip>;
3206
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
3207
- session: {
3208
- user: better_auth_plugins.UserWithRole;
3209
- session: {
3210
- id: string;
3211
- createdAt: Date;
3212
- updatedAt: Date;
3213
- userId: string;
3214
- expiresAt: Date;
3215
- token: string;
3216
- ipAddress?: string | null | undefined;
3217
- userAgent?: string | null | undefined;
3218
- };
3219
- };
3220
- }>)[];
3221
- metadata: {
3222
- openapi: {
3223
- operationId: string;
3224
- summary: string;
3225
- description: string;
3226
- responses: {
3227
- 200: {
3228
- description: string;
3229
- content: {
3230
- "application/json": {
3231
- schema: {
3232
- type: "object";
3233
- properties: {
3234
- status: {
3235
- type: string;
3236
- };
3237
- };
3238
- };
3239
- };
3240
- };
3241
- };
3242
- };
3243
- };
3244
- };
3245
- }, {
3246
- status: boolean;
3247
- }>;
3248
- userHasPermission: better_auth.StrictEndpoint<"/admin/has-permission", {
3249
- method: "POST";
3250
- body: zod.ZodIntersection<zod.ZodObject<{
3251
- userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
3252
- role: zod.ZodOptional<zod.ZodString>;
3253
- }, zod_v4_core.$strip>, zod.ZodXor<readonly [zod.ZodObject<{
3254
- permission: zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>;
3255
- }, zod_v4_core.$strip>, zod.ZodObject<{
3256
- permissions: zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>;
3257
- }, zod_v4_core.$strip>]>>;
3258
- metadata: {
3259
- openapi: {
3260
- description: string;
3261
- requestBody: {
3262
- content: {
3263
- "application/json": {
3264
- schema: {
3265
- type: "object";
3266
- properties: {
3267
- permissions: {
3268
- type: string;
3269
- description: string;
3270
- };
3271
- };
3272
- required: string[];
3273
- };
3274
- };
3275
- };
3276
- };
3277
- responses: {
3278
- "200": {
3279
- description: string;
3280
- content: {
3281
- "application/json": {
3282
- schema: {
3283
- type: "object";
3284
- properties: {
3285
- error: {
3286
- type: string;
3287
- };
3288
- success: {
3289
- type: string;
3290
- };
3291
- };
3292
- required: string[];
3293
- };
3294
- };
3295
- };
3296
- };
3297
- };
3298
- };
3299
- $Infer: {
3300
- body: {
3301
- permissions: {
3302
- readonly user?: ("update" | "delete" | "create" | "list" | "set-role" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
3303
- readonly session?: ("delete" | "list" | "revoke")[] | undefined;
3304
- };
3305
- } & {
3306
- userId?: string | undefined;
3307
- role?: "admin" | "user" | undefined;
3308
- };
3309
- };
3310
- };
3311
- }, {
3312
- error: null;
3313
- success: boolean;
3314
- }>;
3315
- };
3316
- $ERROR_CODES: {
3317
- USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: better_auth.RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
3318
- FAILED_TO_CREATE_USER: better_auth.RawError<"FAILED_TO_CREATE_USER">;
3319
- USER_ALREADY_EXISTS: better_auth.RawError<"USER_ALREADY_EXISTS">;
3320
- YOU_CANNOT_BAN_YOURSELF: better_auth.RawError<"YOU_CANNOT_BAN_YOURSELF">;
3321
- YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
3322
- YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
3323
- YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS">;
3324
- YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS">;
3325
- YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS">;
3326
- YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS">;
3327
- YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS">;
3328
- YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS">;
3329
- YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD">;
3330
- BANNED_USER: better_auth.RawError<"BANNED_USER">;
3331
- YOU_ARE_NOT_ALLOWED_TO_GET_USER: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_USER">;
3332
- NO_DATA_TO_UPDATE: better_auth.RawError<"NO_DATA_TO_UPDATE">;
3333
- YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS">;
3334
- YOU_CANNOT_REMOVE_YOURSELF: better_auth.RawError<"YOU_CANNOT_REMOVE_YOURSELF">;
3335
- YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE">;
3336
- YOU_CANNOT_IMPERSONATE_ADMINS: better_auth.RawError<"YOU_CANNOT_IMPERSONATE_ADMINS">;
3337
- INVALID_ROLE_TYPE: better_auth.RawError<"INVALID_ROLE_TYPE">;
3338
- YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL">;
3339
- PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: better_auth.RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
3340
- };
3341
- schema: {
3342
- user: {
3343
- fields: {
3344
- role: {
3345
- type: "string";
3346
- required: false;
3347
- input: false;
3348
- };
3349
- banned: {
3350
- type: "boolean";
3351
- defaultValue: false;
3352
- required: false;
3353
- input: false;
3354
- };
3355
- banReason: {
3356
- type: "string";
3357
- required: false;
3358
- input: false;
3359
- };
3360
- banExpires: {
3361
- type: "date";
3362
- required: false;
3363
- input: false;
3364
- };
3365
- };
3366
- };
3367
- session: {
3368
- fields: {
3369
- impersonatedBy: {
3370
- type: "string";
3371
- required: false;
3372
- input: false;
3373
- };
3374
- };
3375
- };
3376
- };
3377
- options: NoInfer<{
3378
- ac: better_auth_plugins.AccessControl<{
3379
- readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
3380
- readonly session: readonly ["list", "revoke", "delete"];
3381
- }>;
3382
- roles: {
3383
- admin: better_auth_plugins.Role;
3384
- user: better_auth_plugins.Role;
3385
- };
3386
- }>;
3387
- };
3388
- getActions: () => {
3389
- admin: {
3390
- checkRolePermission: <R extends "admin" | "user">(data: {
3391
- permissions: {
3392
- readonly user?: ("update" | "delete" | "create" | "list" | "set-role" | "ban" | "impersonate" | "impersonate-admins" | "set-password" | "set-email" | "get")[] | undefined;
3393
- readonly session?: ("delete" | "list" | "revoke")[] | undefined;
3394
- };
3395
- } & {
3396
- role: R;
3397
- }) => boolean;
3398
- };
3399
- };
3400
- pathMethods: {
3401
- "/admin/list-users": "GET";
3402
- "/admin/impersonate-user": "POST";
3403
- "/admin/stop-impersonating": "POST";
3404
- };
3405
- atomListeners: {
3406
- matcher: (path: string) => path is "/admin/impersonate-user" | "/admin/stop-impersonating";
3407
- signal: "$sessionSignal";
3408
- }[];
3409
- $ERROR_CODES: {
3410
- USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: better_auth.RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
3411
- FAILED_TO_CREATE_USER: better_auth.RawError<"FAILED_TO_CREATE_USER">;
3412
- USER_ALREADY_EXISTS: better_auth.RawError<"USER_ALREADY_EXISTS">;
3413
- YOU_CANNOT_BAN_YOURSELF: better_auth.RawError<"YOU_CANNOT_BAN_YOURSELF">;
3414
- YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
3415
- YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
3416
- YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS">;
3417
- YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS">;
3418
- YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS">;
3419
- YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS">;
3420
- YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS">;
3421
- YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS">;
3422
- YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD">;
3423
- BANNED_USER: better_auth.RawError<"BANNED_USER">;
3424
- YOU_ARE_NOT_ALLOWED_TO_GET_USER: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_USER">;
3425
- NO_DATA_TO_UPDATE: better_auth.RawError<"NO_DATA_TO_UPDATE">;
3426
- YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS">;
3427
- YOU_CANNOT_REMOVE_YOURSELF: better_auth.RawError<"YOU_CANNOT_REMOVE_YOURSELF">;
3428
- YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE">;
3429
- YOU_CANNOT_IMPERSONATE_ADMINS: better_auth.RawError<"YOU_CANNOT_IMPERSONATE_ADMINS">;
3430
- INVALID_ROLE_TYPE: better_auth.RawError<"INVALID_ROLE_TYPE">;
3431
- YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL">;
3432
- PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: better_auth.RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
3433
- };
3434
- } | {
3435
- id: "additional-fields-client";
3436
- version: string;
3437
- $InferServerPlugin: {
3438
- id: "additional-fields-client";
3439
- version: string;
3440
- schema: {
3441
- user: {
3442
- fields: {
3443
- lastActiveAt: {
3444
- type: "date";
3445
- required: false;
3446
- defaultValue: null;
3447
- };
3448
- displayName: {
3449
- type: "string";
3450
- input: true;
3451
- required: false;
3452
- defaultValue: null;
3453
- };
3454
- title: {
3455
- type: "string";
3456
- input: true;
3457
- required: false;
3458
- defaultValue: null;
3459
- };
3460
- pronouns: {
3461
- type: "string";
3462
- input: true;
3463
- required: false;
3464
- defaultValue: null;
3465
- };
3466
- preferredLanguage: {
3467
- type: "string";
3468
- input: true;
3469
- required: true;
3470
- defaultValue: string;
2674
+ preferredLanguage: {
2675
+ type: "string";
2676
+ input: true;
2677
+ required: true;
2678
+ defaultValue: string;
3471
2679
  };
3472
2680
  };
3473
2681
  };
@@ -3575,705 +2783,173 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
3575
2783
  completeAuthorizationFlow: (code: string, codeVerifier: string) => Promise<{
3576
2784
  data: null;
3577
2785
  error: {
3578
- message?: string | undefined;
3579
- status: number;
3580
- statusText: string;
3581
- };
3582
- } | {
3583
- data: CompleteAuthorizationFlowResponse;
3584
- error: null;
3585
- }>;
3586
- refreshAccessToken: (refreshToken: string) => Promise<{
3587
- data: null;
3588
- error: {
3589
- message?: string | undefined;
3590
- status: number;
3591
- statusText: string;
3592
- };
3593
- } | {
3594
- data: CompleteAuthorizationFlowResponse;
3595
- error: null;
3596
- }>;
3597
- whoAmI: (accessToken: string, options?: WhoAmIOptions) => Promise<{
3598
- data: null;
3599
- error: {
3600
- message?: string | undefined;
3601
- status: number;
3602
- statusText: string;
3603
- };
3604
- } | {
3605
- data: WhoAmIResponse;
3606
- error: null;
3607
- }>;
3608
- switchOrganization: (organizationId: string, accessToken: string) => Promise<{
3609
- data: null;
3610
- error: {
3611
- message?: string | undefined;
3612
- status: number;
3613
- statusText: string;
3614
- };
3615
- } | {
3616
- data: CompleteAuthorizationFlowResponse;
3617
- error: null;
3618
- }>;
3619
- logout: (refreshToken: string) => Promise<{
3620
- data: null;
3621
- error: {
3622
- message?: string | undefined;
3623
- status: number;
3624
- statusText: string;
3625
- };
3626
- } | {
3627
- data: void;
3628
- error: null;
3629
- }>;
3630
- listApplicationRoles: () => Promise<{
3631
- data: null;
3632
- error: {
3633
- message?: string | undefined;
3634
- status: number;
3635
- statusText: string;
3636
- };
3637
- } | {
3638
- data: ApplicationRole[];
3639
- error: null;
3640
- }>;
3641
- };
3642
- };
3643
- } | {
3644
- id: "session-assurance";
3645
- getActions: ($fetch: better_auth_client.BetterFetch) => {
3646
- sessionAssurance: {
3647
- getSessionAssurance: () => Promise<{
3648
- data: null;
3649
- error: {
3650
- message?: string | undefined;
3651
- status: number;
3652
- statusText: string;
3653
- };
3654
- } | {
3655
- data: unknown;
3656
- error: null;
3657
- }>;
3658
- stepUpWithPassword: (body: {
3659
- password: string;
3660
- }) => Promise<{
3661
- data: null;
3662
- error: {
3663
- message?: string | undefined;
3664
- status: number;
3665
- statusText: string;
3666
- };
3667
- } | {
3668
- data: unknown;
3669
- error: null;
3670
- }>;
3671
- sendOtp: () => Promise<{
3672
- data: null;
3673
- error: {
3674
- message?: string | undefined;
3675
- status: number;
3676
- statusText: string;
3677
- };
3678
- } | {
3679
- data: unknown;
3680
- error: null;
3681
- }>;
3682
- verifyOtp: (body: {
3683
- otp: string;
3684
- }) => Promise<{
3685
- data: null;
3686
- error: {
3687
- message?: string | undefined;
3688
- status: number;
3689
- statusText: string;
3690
- };
3691
- } | {
3692
- data: unknown;
3693
- error: null;
3694
- }>;
3695
- beginOAuthStepUp: (body: {
3696
- provider: OAuthStepUpProvider;
3697
- returnUrl?: string;
3698
- }) => Promise<{
3699
- data: null;
3700
- error: {
3701
- message?: string | undefined;
3702
- status: number;
3703
- statusText: string;
3704
- };
3705
- } | {
3706
- data: unknown;
3707
- error: null;
3708
- }>;
3709
- completeOAuthStepUp: (body: {
3710
- stepUpToken: string;
3711
- }) => Promise<{
3712
- data: null;
3713
- error: {
3714
- message?: string | undefined;
3715
- status: number;
3716
- statusText: string;
3717
- };
3718
- } | {
3719
- data: unknown;
3720
- error: null;
3721
- }>;
3722
- };
3723
- };
3724
- } | {
3725
- id: "login-methods";
3726
- getActions: ($fetch: better_auth_client.BetterFetch) => {
3727
- loginMethods: {
3728
- get: () => Promise<{
3729
- data: null;
3730
- error: {
3731
- message?: string | undefined;
3732
- status: number;
3733
- statusText: string;
3734
- };
3735
- } | {
3736
- data: LoginMethodsResponse;
3737
- error: null;
3738
- }>;
3739
- };
3740
- };
3741
- } | {
3742
- id: "email-otp";
3743
- version: string;
3744
- $InferServerPlugin: ReturnType<(options: better_auth_plugins.EmailOTPOptions) => {
3745
- id: "email-otp";
3746
- version: string;
3747
- init(ctx: better_auth.AuthContext): {
3748
- options: {
3749
- emailVerification: {
3750
- sendVerificationEmail(data: {
3751
- user: better_auth.User;
3752
- url: string;
3753
- token: string;
3754
- }, request: Request | undefined): Promise<void>;
3755
- };
3756
- };
3757
- } | undefined;
3758
- endpoints: {
3759
- sendVerificationOTP: better_auth.StrictEndpoint<"/email-otp/send-verification-otp", {
3760
- method: "POST";
3761
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<void>)[];
3762
- body: zod.ZodObject<{
3763
- email: zod.ZodString;
3764
- type: zod.ZodEnum<{
3765
- "sign-in": "sign-in";
3766
- "change-email": "change-email";
3767
- "email-verification": "email-verification";
3768
- "forget-password": "forget-password";
3769
- }>;
3770
- }, zod_v4_core.$strip>;
3771
- metadata: {
3772
- openapi: {
3773
- operationId: string;
3774
- description: string;
3775
- responses: {
3776
- 200: {
3777
- description: string;
3778
- content: {
3779
- "application/json": {
3780
- schema: {
3781
- type: "object";
3782
- properties: {
3783
- success: {
3784
- type: string;
3785
- };
3786
- };
3787
- };
3788
- };
3789
- };
3790
- };
3791
- };
3792
- };
3793
- };
3794
- }, {
3795
- success: boolean;
3796
- }>;
3797
- createVerificationOTP: better_auth.StrictEndpoint<string, {
3798
- method: "POST";
3799
- body: zod.ZodObject<{
3800
- email: zod.ZodString;
3801
- type: zod.ZodEnum<{
3802
- "sign-in": "sign-in";
3803
- "change-email": "change-email";
3804
- "email-verification": "email-verification";
3805
- "forget-password": "forget-password";
3806
- }>;
3807
- }, zod_v4_core.$strip>;
3808
- metadata: {
3809
- openapi: {
3810
- operationId: string;
3811
- description: string;
3812
- responses: {
3813
- 200: {
3814
- description: string;
3815
- content: {
3816
- "application/json": {
3817
- schema: {
3818
- type: "string";
3819
- };
3820
- };
3821
- };
3822
- };
3823
- };
3824
- };
2786
+ message?: string | undefined;
2787
+ status: number;
2788
+ statusText: string;
3825
2789
  };
3826
- }, string>;
3827
- getVerificationOTP: better_auth.StrictEndpoint<string, {
3828
- method: "GET";
3829
- query: zod.ZodObject<{
3830
- email: zod.ZodString;
3831
- type: zod.ZodEnum<{
3832
- "sign-in": "sign-in";
3833
- "change-email": "change-email";
3834
- "email-verification": "email-verification";
3835
- "forget-password": "forget-password";
3836
- }>;
3837
- }, zod_v4_core.$strip>;
3838
- metadata: {
3839
- openapi: {
3840
- operationId: string;
3841
- description: string;
3842
- responses: {
3843
- "200": {
3844
- description: string;
3845
- content: {
3846
- "application/json": {
3847
- schema: {
3848
- type: "object";
3849
- properties: {
3850
- otp: {
3851
- type: string;
3852
- nullable: boolean;
3853
- description: string;
3854
- };
3855
- };
3856
- required: string[];
3857
- };
3858
- };
3859
- };
3860
- };
3861
- };
3862
- };
2790
+ } | {
2791
+ data: CompleteAuthorizationFlowResponse;
2792
+ error: null;
2793
+ }>;
2794
+ refreshAccessToken: (refreshToken: string) => Promise<{
2795
+ data: null;
2796
+ error: {
2797
+ message?: string | undefined;
2798
+ status: number;
2799
+ statusText: string;
3863
2800
  };
3864
- }, {
3865
- otp: null;
3866
2801
  } | {
3867
- otp: string;
2802
+ data: CompleteAuthorizationFlowResponse;
2803
+ error: null;
3868
2804
  }>;
3869
- checkVerificationOTP: better_auth.StrictEndpoint<"/email-otp/check-verification-otp", {
3870
- method: "POST";
3871
- body: zod.ZodObject<{
3872
- email: zod.ZodString;
3873
- type: zod.ZodEnum<{
3874
- "sign-in": "sign-in";
3875
- "change-email": "change-email";
3876
- "email-verification": "email-verification";
3877
- "forget-password": "forget-password";
3878
- }>;
3879
- otp: zod.ZodString;
3880
- }, zod_v4_core.$strip>;
3881
- metadata: {
3882
- openapi: {
3883
- operationId: string;
3884
- description: string;
3885
- responses: {
3886
- 200: {
3887
- description: string;
3888
- content: {
3889
- "application/json": {
3890
- schema: {
3891
- type: "object";
3892
- properties: {
3893
- success: {
3894
- type: string;
3895
- };
3896
- };
3897
- };
3898
- };
3899
- };
3900
- };
3901
- };
3902
- };
2805
+ whoAmI: (accessToken: string, options?: WhoAmIOptions) => Promise<{
2806
+ data: null;
2807
+ error: {
2808
+ message?: string | undefined;
2809
+ status: number;
2810
+ statusText: string;
3903
2811
  };
3904
- }, {
3905
- success: boolean;
2812
+ } | {
2813
+ data: WhoAmIResponse;
2814
+ error: null;
3906
2815
  }>;
3907
- verifyEmailOTP: better_auth.StrictEndpoint<"/email-otp/verify-email", {
3908
- method: "POST";
3909
- body: zod.ZodObject<{
3910
- email: zod.ZodString;
3911
- otp: zod.ZodString;
3912
- }, zod_v4_core.$strip>;
3913
- metadata: {
3914
- openapi: {
3915
- description: string;
3916
- responses: {
3917
- 200: {
3918
- description: string;
3919
- content: {
3920
- "application/json": {
3921
- schema: {
3922
- type: "object";
3923
- properties: {
3924
- status: {
3925
- type: string;
3926
- description: string;
3927
- enum: boolean[];
3928
- };
3929
- token: {
3930
- type: string;
3931
- nullable: boolean;
3932
- description: string;
3933
- };
3934
- user: {
3935
- $ref: string;
3936
- };
3937
- };
3938
- required: string[];
3939
- };
3940
- };
3941
- };
3942
- };
3943
- };
3944
- };
2816
+ switchOrganization: (organizationId: string, accessToken: string) => Promise<{
2817
+ data: null;
2818
+ error: {
2819
+ message?: string | undefined;
2820
+ status: number;
2821
+ statusText: string;
3945
2822
  };
3946
- }, {
3947
- status: boolean;
3948
- token: string;
3949
- user: {
3950
- id: string;
3951
- createdAt: Date;
3952
- updatedAt: Date;
3953
- email: string;
3954
- emailVerified: boolean;
3955
- name: string;
3956
- image?: string | null | undefined;
3957
- } & Record<string, any>;
3958
2823
  } | {
3959
- status: boolean;
3960
- token: null;
3961
- user: {
3962
- id: string;
3963
- createdAt: Date;
3964
- updatedAt: Date;
3965
- email: string;
3966
- emailVerified: boolean;
3967
- name: string;
3968
- image?: string | null | undefined;
3969
- } & Record<string, any>;
2824
+ data: CompleteAuthorizationFlowResponse;
2825
+ error: null;
3970
2826
  }>;
3971
- signInEmailOTP: better_auth.StrictEndpoint<"/sign-in/email-otp", {
3972
- method: "POST";
3973
- body: zod.ZodIntersection<zod.ZodObject<{
3974
- email: zod.ZodString;
3975
- otp: zod.ZodString;
3976
- name: zod.ZodOptional<zod.ZodString>;
3977
- image: zod.ZodOptional<zod.ZodString>;
3978
- }, zod_v4_core.$strip>, zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
3979
- metadata: {
3980
- openapi: {
3981
- operationId: string;
3982
- description: string;
3983
- responses: {
3984
- 200: {
3985
- description: string;
3986
- content: {
3987
- "application/json": {
3988
- schema: {
3989
- type: "object";
3990
- properties: {
3991
- token: {
3992
- type: string;
3993
- description: string;
3994
- };
3995
- user: {
3996
- $ref: string;
3997
- };
3998
- };
3999
- required: string[];
4000
- };
4001
- };
4002
- };
4003
- };
4004
- };
4005
- };
2827
+ logout: (refreshToken: string) => Promise<{
2828
+ data: null;
2829
+ error: {
2830
+ message?: string | undefined;
2831
+ status: number;
2832
+ statusText: string;
4006
2833
  };
4007
- }, {
4008
- token: string;
4009
- user: {
4010
- id: string;
4011
- createdAt: Date;
4012
- updatedAt: Date;
4013
- email: string;
4014
- emailVerified: boolean;
4015
- name: string;
4016
- image?: string | null | undefined;
2834
+ } | {
2835
+ data: void;
2836
+ error: null;
2837
+ }>;
2838
+ listApplicationRoles: () => Promise<{
2839
+ data: null;
2840
+ error: {
2841
+ message?: string | undefined;
2842
+ status: number;
2843
+ statusText: string;
4017
2844
  };
2845
+ } | {
2846
+ data: ApplicationRole[];
2847
+ error: null;
4018
2848
  }>;
4019
- requestPasswordResetEmailOTP: better_auth.StrictEndpoint<"/email-otp/request-password-reset", {
4020
- method: "POST";
4021
- body: zod.ZodObject<{
4022
- email: zod.ZodString;
4023
- }, zod_v4_core.$strip>;
4024
- metadata: {
4025
- openapi: {
4026
- operationId: string;
4027
- description: string;
4028
- responses: {
4029
- 200: {
4030
- description: string;
4031
- content: {
4032
- "application/json": {
4033
- schema: {
4034
- type: "object";
4035
- properties: {
4036
- success: {
4037
- type: string;
4038
- description: string;
4039
- };
4040
- };
4041
- };
4042
- };
4043
- };
4044
- };
4045
- };
4046
- };
2849
+ };
2850
+ };
2851
+ } | {
2852
+ id: "session-assurance";
2853
+ getActions: ($fetch: better_auth_client.BetterFetch) => {
2854
+ sessionAssurance: {
2855
+ getSessionAssurance: () => Promise<{
2856
+ data: null;
2857
+ error: {
2858
+ message?: string | undefined;
2859
+ status: number;
2860
+ statusText: string;
4047
2861
  };
4048
- }, {
4049
- success: boolean;
2862
+ } | {
2863
+ data: unknown;
2864
+ error: null;
4050
2865
  }>;
4051
- forgetPasswordEmailOTP: better_auth.StrictEndpoint<"/forget-password/email-otp", {
4052
- method: "POST";
4053
- body: zod.ZodObject<{
4054
- email: zod.ZodString;
4055
- }, zod_v4_core.$strip>;
4056
- metadata: {
4057
- openapi: {
4058
- operationId: string;
4059
- description: string;
4060
- responses: {
4061
- 200: {
4062
- description: string;
4063
- content: {
4064
- "application/json": {
4065
- schema: {
4066
- type: "object";
4067
- properties: {
4068
- success: {
4069
- type: string;
4070
- description: string;
4071
- };
4072
- };
4073
- };
4074
- };
4075
- };
4076
- };
4077
- };
4078
- };
2866
+ stepUpWithPassword: (body: {
2867
+ password: string;
2868
+ }) => Promise<{
2869
+ data: null;
2870
+ error: {
2871
+ message?: string | undefined;
2872
+ status: number;
2873
+ statusText: string;
4079
2874
  };
4080
- }, {
4081
- success: boolean;
2875
+ } | {
2876
+ data: unknown;
2877
+ error: null;
4082
2878
  }>;
4083
- resetPasswordEmailOTP: better_auth.StrictEndpoint<"/email-otp/reset-password", {
4084
- method: "POST";
4085
- body: zod.ZodObject<{
4086
- email: zod.ZodString;
4087
- otp: zod.ZodString;
4088
- password: zod.ZodString;
4089
- }, zod_v4_core.$strip>;
4090
- metadata: {
4091
- openapi: {
4092
- operationId: string;
4093
- description: string;
4094
- responses: {
4095
- 200: {
4096
- description: string;
4097
- content: {
4098
- "application/json": {
4099
- schema: {
4100
- type: "object";
4101
- properties: {
4102
- success: {
4103
- type: string;
4104
- };
4105
- };
4106
- };
4107
- };
4108
- };
4109
- };
4110
- };
4111
- };
2879
+ sendOtp: () => Promise<{
2880
+ data: null;
2881
+ error: {
2882
+ message?: string | undefined;
2883
+ status: number;
2884
+ statusText: string;
4112
2885
  };
4113
- }, {
4114
- success: boolean;
2886
+ } | {
2887
+ data: unknown;
2888
+ error: null;
4115
2889
  }>;
4116
- requestEmailChangeEmailOTP: better_auth.StrictEndpoint<"/email-otp/request-email-change", {
4117
- method: "POST";
4118
- body: zod.ZodObject<{
4119
- newEmail: zod.ZodString;
4120
- otp: zod.ZodOptional<zod.ZodString>;
4121
- }, zod_v4_core.$strip>;
4122
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
4123
- session: {
4124
- session: Record<string, any> & {
4125
- id: string;
4126
- createdAt: Date;
4127
- updatedAt: Date;
4128
- userId: string;
4129
- expiresAt: Date;
4130
- token: string;
4131
- ipAddress?: string | null | undefined;
4132
- userAgent?: string | null | undefined;
4133
- };
4134
- user: Record<string, any> & {
4135
- id: string;
4136
- createdAt: Date;
4137
- updatedAt: Date;
4138
- email: string;
4139
- emailVerified: boolean;
4140
- name: string;
4141
- image?: string | null | undefined;
4142
- };
4143
- };
4144
- }>)[];
4145
- metadata: {
4146
- openapi: {
4147
- operationId: string;
4148
- description: string;
4149
- responses: {
4150
- 200: {
4151
- description: string;
4152
- content: {
4153
- "application/json": {
4154
- schema: {
4155
- type: "object";
4156
- properties: {
4157
- success: {
4158
- type: string;
4159
- };
4160
- };
4161
- };
4162
- };
4163
- };
4164
- };
4165
- };
4166
- };
2890
+ verifyOtp: (body: {
2891
+ otp: string;
2892
+ }) => Promise<{
2893
+ data: null;
2894
+ error: {
2895
+ message?: string | undefined;
2896
+ status: number;
2897
+ statusText: string;
4167
2898
  };
4168
- }, {
4169
- success: boolean;
2899
+ } | {
2900
+ data: unknown;
2901
+ error: null;
4170
2902
  }>;
4171
- changeEmailEmailOTP: better_auth.StrictEndpoint<"/email-otp/change-email", {
4172
- method: "POST";
4173
- body: zod.ZodObject<{
4174
- newEmail: zod.ZodString;
4175
- otp: zod.ZodString;
4176
- }, zod_v4_core.$strip>;
4177
- use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
4178
- session: {
4179
- session: Record<string, any> & {
4180
- id: string;
4181
- createdAt: Date;
4182
- updatedAt: Date;
4183
- userId: string;
4184
- expiresAt: Date;
4185
- token: string;
4186
- ipAddress?: string | null | undefined;
4187
- userAgent?: string | null | undefined;
4188
- };
4189
- user: Record<string, any> & {
4190
- id: string;
4191
- createdAt: Date;
4192
- updatedAt: Date;
4193
- email: string;
4194
- emailVerified: boolean;
4195
- name: string;
4196
- image?: string | null | undefined;
4197
- };
4198
- };
4199
- }>)[];
4200
- metadata: {
4201
- openapi: {
4202
- operationId: string;
4203
- description: string;
4204
- responses: {
4205
- 200: {
4206
- description: string;
4207
- content: {
4208
- "application/json": {
4209
- schema: {
4210
- type: "object";
4211
- properties: {
4212
- success: {
4213
- type: string;
4214
- };
4215
- };
4216
- };
4217
- };
4218
- };
4219
- };
4220
- };
4221
- };
2903
+ beginOAuthStepUp: (body: {
2904
+ provider: OAuthStepUpProvider;
2905
+ returnUrl?: string;
2906
+ }) => Promise<{
2907
+ data: null;
2908
+ error: {
2909
+ message?: string | undefined;
2910
+ status: number;
2911
+ statusText: string;
4222
2912
  };
4223
- }, {
4224
- success: boolean;
2913
+ } | {
2914
+ data: unknown;
2915
+ error: null;
2916
+ }>;
2917
+ completeOAuthStepUp: (body: {
2918
+ stepUpToken: string;
2919
+ }) => Promise<{
2920
+ data: null;
2921
+ error: {
2922
+ message?: string | undefined;
2923
+ status: number;
2924
+ statusText: string;
2925
+ };
2926
+ } | {
2927
+ data: unknown;
2928
+ error: null;
4225
2929
  }>;
4226
2930
  };
4227
- hooks: {
4228
- after: {
4229
- matcher(context: better_auth.HookEndpointContext): boolean;
4230
- handler: (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<void>;
4231
- }[];
4232
- };
4233
- rateLimit: ({
4234
- pathMatcher(path: string): path is "/email-otp/send-verification-otp";
4235
- window: number;
4236
- max: number;
4237
- } | {
4238
- pathMatcher(path: string): path is "/email-otp/check-verification-otp";
4239
- window: number;
4240
- max: number;
4241
- } | {
4242
- pathMatcher(path: string): path is "/email-otp/verify-email";
4243
- window: number;
4244
- max: number;
4245
- } | {
4246
- pathMatcher(path: string): path is "/sign-in/email-otp";
4247
- window: number;
4248
- max: number;
4249
- } | {
4250
- pathMatcher(path: string): path is "/email-otp/request-password-reset";
4251
- window: number;
4252
- max: number;
4253
- } | {
4254
- pathMatcher(path: string): path is "/email-otp/reset-password";
4255
- window: number;
4256
- max: number;
4257
- } | {
4258
- pathMatcher(path: string): path is "/forget-password/email-otp";
4259
- window: number;
4260
- max: number;
4261
- } | {
4262
- pathMatcher(path: string): path is "/email-otp/request-email-change";
4263
- window: number;
4264
- max: number;
4265
- } | {
4266
- pathMatcher(path: string): path is "/email-otp/change-email";
4267
- window: number;
4268
- max: number;
4269
- })[];
4270
- options: better_auth_plugins.EmailOTPOptions;
4271
- $ERROR_CODES: {
4272
- OTP_EXPIRED: better_auth.RawError<"OTP_EXPIRED">;
4273
- INVALID_OTP: better_auth.RawError<"INVALID_OTP">;
4274
- TOO_MANY_ATTEMPTS: better_auth.RawError<"TOO_MANY_ATTEMPTS">;
2931
+ };
2932
+ } | {
2933
+ id: "login-methods";
2934
+ getActions: ($fetch: better_auth_client.BetterFetch) => {
2935
+ loginMethods: {
2936
+ get: () => Promise<{
2937
+ data: null;
2938
+ error: {
2939
+ message?: string | undefined;
2940
+ status: number;
2941
+ statusText: string;
2942
+ };
2943
+ } | {
2944
+ data: LoginMethodsResponse;
2945
+ error: null;
2946
+ }>;
4275
2947
  };
4276
- }>;
2948
+ };
2949
+ } | {
2950
+ id: "email-otp";
2951
+ version: string;
2952
+ $InferServerPlugin: ReturnType<typeof better_auth_plugins.emailOTP>;
4277
2953
  atomListeners: {
4278
2954
  matcher: (path: string) => path is "/email-otp/verify-email" | "/sign-in/email-otp" | "/email-otp/request-email-change";
4279
2955
  signal: "$sessionSignal";
@@ -4293,13 +2969,13 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
4293
2969
  cache?: RequestCache | undefined;
4294
2970
  integrity?: string | undefined;
4295
2971
  keepalive?: boolean | undefined;
4296
- method?: string | undefined;
2972
+ method?: string;
4297
2973
  mode?: RequestMode | undefined;
4298
2974
  priority?: RequestPriority | undefined;
4299
2975
  redirect?: RequestRedirect | undefined;
4300
2976
  referrer?: string | undefined;
4301
2977
  referrerPolicy?: ReferrerPolicy | undefined;
4302
- signal?: (AbortSignal | null) | undefined;
2978
+ signal?: AbortSignal | null;
4303
2979
  window?: null | undefined;
4304
2980
  onRequest?: (<T extends Record<string, any>>(context: better_auth_client.RequestContext<T>) => Promise<better_auth_client.RequestContext | void> | better_auth_client.RequestContext | void) | undefined;
4305
2981
  onResponse?: ((context: better_auth_client.ResponseContext) => Promise<Response | void | better_auth_client.ResponseContext> | Response | better_auth_client.ResponseContext | void) | undefined;
@@ -5830,22 +4506,22 @@ type UpdateTeamPayload = Pick<Team, 'name'>;
5830
4506
  /**
5831
4507
  * Status of an invitation as seen by the pre-login invite flow.
5832
4508
  *
5833
- * `email` and `requiresAccountSetup` are only present while the invitation is
5834
- * still pending; other statuses return the status alone.
4509
+ * Requires a pending invitation and an unexpired, unused setup token.
4510
+ * Invalid tokens and inactive invitations return an error without email details.
5835
4511
  */
5836
4512
  type InvitationSignupStatus = {
4513
+ invitationId: string;
5837
4514
  status: 'pending';
5838
4515
  email: string;
5839
4516
  /** True when the invited user has no account yet and has never signed in. */
5840
4517
  requiresAccountSetup: boolean;
5841
- } | {
5842
- status: 'accepted' | 'canceled' | 'rejected' | 'expired';
5843
4518
  };
5844
4519
  /**
5845
4520
  * Result of creating a password from an invitation. The user is signed in
5846
4521
  * as part of the call; the session cookie is set on the response.
5847
4522
  */
5848
4523
  type InvitationPasswordSetupResult = {
4524
+ invitationId: string;
5849
4525
  token: string;
5850
4526
  user: {
5851
4527
  id: string;
@@ -6038,14 +4714,14 @@ declare class OrganizationService {
6038
4714
  /**
6039
4715
  * Gets the pre-login signup status for an invitation.
6040
4716
  *
6041
- * Public endpoint keyed by the invitation id from the emailed invite link.
4717
+ * Requires the opaque token delivered only in the invitation email.
6042
4718
  * While the invitation is pending, the result includes the invited email
6043
4719
  * and whether the invited user still needs to set up their account.
6044
4720
  *
6045
- * @param id - The invitation ID from the invite link
4721
+ * @param token - The opaque token from the invite link
6046
4722
  * @returns The invitation status with account-setup information
6047
4723
  */
6048
- getInvitationSignupStatus(id: string): Promise<InvitationSignupStatus>;
4724
+ getInvitationSignupStatus(token: string): Promise<InvitationSignupStatus>;
6049
4725
  /**
6050
4726
  * Creates a password for an invited user who has no account yet.
6051
4727
  *
@@ -6053,11 +4729,11 @@ declare class OrganizationService {
6053
4729
  * the invited user has never signed in. The user is signed in as part of
6054
4730
  * the call; the session cookie is set on the response.
6055
4731
  *
6056
- * @param id - The invitation ID from the invite link
4732
+ * @param token - The single-use opaque token from the invite link
6057
4733
  * @param password - The password to create (minimum 8 characters)
6058
4734
  * @returns The session token and signed-in user
6059
4735
  */
6060
- setupInvitationPassword(id: string, password: string): Promise<InvitationPasswordSetupResult>;
4736
+ setupInvitationPassword(token: string, password: string): Promise<InvitationPasswordSetupResult>;
6061
4737
  /**
6062
4738
  * Removes a user from the active organization.
6063
4739
  *
@@ -6236,7 +4912,7 @@ declare class SessionService {
6236
4912
  *
6237
4913
  * @returns The enabled login methods
6238
4914
  */
6239
- getLoginMethods(): Promise<("sso" | "google" | "microsoft" | "password" | "otp")[]>;
4915
+ getLoginMethods(): Promise<("sso" | "google" | "microsoft" | "otp" | "password")[]>;
6240
4916
  /**
6241
4917
  * Initiates social authentication flow with Google or Microsoft.
6242
4918
  *
@@ -6534,12 +5210,14 @@ declare class UserService {
6534
5210
  redirect: boolean;
6535
5211
  }>;
6536
5212
  /**
6537
- * Unlinks a provider from the current user. Requires an AAL2 session (gated
5213
+ * Unlinks an account from the current user. Requires an AAL2 session (gated
6538
5214
  * server-side). The server refuses to remove the user's last account.
5215
+ *
5216
+ * @param params.accountId - The account's `id` from {@link listAccounts}, not
5217
+ * the provider's account identifier
6539
5218
  */
6540
5219
  unlinkAccount(params: {
6541
- providerId: string;
6542
- accountId?: string;
5220
+ accountId: string;
6543
5221
  }): Promise<{
6544
5222
  status: boolean;
6545
5223
  }>;
@@ -6643,56 +5321,6 @@ declare class AuthClient {
6643
5321
  constructor(apiUrl: string, fetchOptions?: BetterFetchOption);
6644
5322
  }
6645
5323
 
6646
- /** Configuration for an in-memory application token cache. */
6647
- type ApplicationTokenStorageOptions = {
6648
- /** Base URL of the Auth API. */
6649
- authApiUrl: string;
6650
- /** Application identifier used for client-credentials exchanges. */
6651
- clientId: string;
6652
- /** Application secret used for client-credentials exchanges. */
6653
- clientSecret: string;
6654
- /** Full-jitter upper bound for the first retry delay. Defaults to 100 milliseconds. */
6655
- initialBackoffMs?: number;
6656
- /** Maximum number of exchange attempts, including the initial request. Defaults to 3. */
6657
- maxAttempts?: number;
6658
- /** Maximum number of organization tokens retained in memory. Defaults to 300. */
6659
- maxOrganizations?: number;
6660
- };
6661
- /** Per-call retry overrides for {@link ApplicationTokenStorage.getToken}. */
6662
- type GetTokenOptions = {
6663
- /** Full-jitter upper bound for the first retry delay. */
6664
- initialBackoffMs?: number;
6665
- /** Maximum number of exchange attempts, including the initial request. */
6666
- maxAttempts?: number;
6667
- };
6668
- /**
6669
- * Caches organization-scoped application tokens in memory.
6670
- *
6671
- * Tokens are reissued one minute before expiry. Cache hits promote their
6672
- * organization to the most-recently-used position, and insertions beyond the
6673
- * configured limit evict the least recently used organization. Transient
6674
- * exchange failures use full-jitter exponential backoff.
6675
- */
6676
- declare class ApplicationTokenStorage {
6677
- private readonly auth;
6678
- private readonly clientId;
6679
- private readonly clientSecret;
6680
- private readonly initialBackoffMs;
6681
- private readonly inFlight;
6682
- private readonly maxAttempts;
6683
- private readonly maxOrganizations;
6684
- private readonly tokens;
6685
- /** Creates an application token cache for one client-credentials identity. */
6686
- constructor({ authApiUrl, clientId, clientSecret, initialBackoffMs, maxAttempts, maxOrganizations, }: ApplicationTokenStorageOptions);
6687
- /** Returns a fresh access token scoped to the requested organization. */
6688
- getToken(organizationId: string, { initialBackoffMs, maxAttempts, }?: GetTokenOptions): Promise<string>;
6689
- private exchangeTokenWithRetry;
6690
- /** Performs the client-credentials exchange for one organization. */
6691
- protected exchangeToken(organizationId: string): Promise<string>;
6692
- /** Waits before the next exchange attempt. */
6693
- protected wait(delayMs: number): Promise<void>;
6694
- }
6695
-
6696
5324
  type DecodedJWTPayload = Omit<JWTPayload, 'assurance'> & {
6697
5325
  assurance?: JWTPayloadAssurance;
6698
5326
  };