@meistrari/auth-core 1.14.0 → 1.16.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
@@ -77,6 +77,11 @@ declare const Roles: {
77
77
  * Type representing a valid organization role.
78
78
  */
79
79
  type Role = typeof Roles[keyof typeof Roles];
80
+ /**
81
+ * Role-based access control definitions mapping each role to its permissions.
82
+ *
83
+ * Used internally by the organization plugin to enforce access control.
84
+ */
80
85
  declare const rolesAccessControl: {
81
86
  "org:admin": {
82
87
  authorize<K_1 extends "member" | "access" | "organization" | "invitation" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins.Subset<"member" | "access" | "organization" | "invitation" | "team", {
@@ -163,6 +168,11 @@ declare const rolesAccessControl: {
163
168
  }>;
164
169
  };
165
170
  };
171
+ /**
172
+ * Additional database fields added to the `user` table.
173
+ *
174
+ * @internal
175
+ */
166
176
  declare const userAdditionalFields: {
167
177
  lastActiveAt: {
168
178
  type: "date";
@@ -170,6 +180,11 @@ declare const userAdditionalFields: {
170
180
  defaultValue: null;
171
181
  };
172
182
  };
183
+ /**
184
+ * Additional database fields added to the `organization` table.
185
+ *
186
+ * @internal
187
+ */
173
188
  declare const organizationAdditionalFields: {
174
189
  settings: {
175
190
  type: "json";
@@ -177,6 +192,11 @@ declare const organizationAdditionalFields: {
177
192
  required: false;
178
193
  };
179
194
  };
195
+ /**
196
+ * Additional database fields added to the `member` table.
197
+ *
198
+ * @internal
199
+ */
180
200
  declare const memberAdditionalFields: {
181
201
  deletedAt: {
182
202
  type: "date";
@@ -189,6 +209,9 @@ declare const memberAdditionalFields: {
189
209
  defaultValue: null;
190
210
  };
191
211
  };
212
+ /**
213
+ * Zod schema and type for the `user` claim within a JWT payload.
214
+ */
192
215
  declare const JWTPayloadUser: z.ZodObject<{
193
216
  id: z.ZodString;
194
217
  name: z.ZodString;
@@ -196,11 +219,20 @@ declare const JWTPayloadUser: z.ZodObject<{
196
219
  role: z.ZodNullable<z.ZodString>;
197
220
  }, z.core.$strip>;
198
221
  type JWTPayloadUser = z.infer<typeof JWTPayloadUser>;
222
+ /**
223
+ * Zod schema and type for the `workspace` claim within a JWT payload.
224
+ */
199
225
  declare const JWTPayloadWorkspace: z.ZodObject<{
200
226
  id: z.ZodString;
201
227
  title: z.ZodString;
202
228
  }, z.core.$strip>;
203
229
  type JWTPayloadWorkspace = z.infer<typeof JWTPayloadWorkspace>;
230
+ /**
231
+ * Zod schema and type for the full JWT payload issued by the auth API.
232
+ *
233
+ * Includes `email`, `user`, `workspace`, and `sessionKey` claims
234
+ * on top of the standard Better Auth JWT fields (`sub`, `iss`, `exp`, etc.).
235
+ */
204
236
  declare const JWTPayload: z.ZodObject<{
205
237
  email: z.ZodString;
206
238
  user: z.ZodObject<{
@@ -217,29 +249,58 @@ declare const JWTPayload: z.ZodObject<{
217
249
  }, z.core.$strip>;
218
250
  type JWTPayload = JWTPayload$1 & z.infer<typeof JWTPayload>;
219
251
 
252
+ /**
253
+ * Metadata attached to an API key, identifying the owning user and workspace.
254
+ */
220
255
  type ApiKeyMetadata = {
256
+ /** The user who owns this API key. */
221
257
  user: {
222
258
  id: string;
223
259
  email: string;
224
260
  };
261
+ /** The workspace this API key belongs to. */
225
262
  workspace: {
226
263
  id: string;
227
264
  title: string;
228
265
  };
229
266
  } & Record<string, unknown>;
267
+ /**
268
+ * A full API key including the secret key value.
269
+ *
270
+ * The secret `key` field is only returned once at creation time.
271
+ */
230
272
  type ApiKey = Omit<ApiKey$1, 'metadata' | 'name'> & {
273
+ /** Display name of the API key. */
231
274
  name: string;
275
+ /** Metadata identifying the key's owner and workspace. */
232
276
  metadata: ApiKeyMetadata;
233
277
  };
278
+ /**
279
+ * An API key with the secret key value omitted.
280
+ *
281
+ * Used in list and get operations where the secret should not be exposed.
282
+ */
234
283
  type ApiKeyWithoutSecret = Omit<ApiKey, 'key'>;
284
+ /**
285
+ * Payload for creating a new API key.
286
+ */
235
287
  type CreateApiKeyPayload = {
288
+ /** Display name for the API key. */
236
289
  name: string;
290
+ /** Time in milliseconds until the key expires. Omit for a non-expiring key. */
237
291
  expiresIn?: number;
292
+ /** Optional prefix prepended to the generated key for identification. */
238
293
  prefix?: string;
294
+ /** Optional metadata to attach to the key. */
239
295
  metadata?: ApiKeyMetadata;
240
296
  };
297
+ /**
298
+ * Payload for updating an existing API key.
299
+ */
241
300
  type UpdateApiKeyPayload = {
301
+ /** The ID of the API key to update. */
242
302
  id: string;
303
+ /** The new display name for the API key. */
243
304
  name: string;
244
305
  };
245
306
 
@@ -260,6 +321,15 @@ type UpdateApiKeyPayload = {
260
321
  type Strict<T> = {
261
322
  [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
262
323
  };
324
+ /**
325
+ * Creates a configured Better Auth API client with all required plugins.
326
+ *
327
+ * @param apiUrl - The base URL of the authentication API
328
+ * @param fetchOptions - Custom fetch options to include in all API requests
329
+ * @returns A fully-configured Better Auth client instance
330
+ *
331
+ * @internal
332
+ */
263
333
  declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOption): {
264
334
  useActiveOrganization: better_auth_client.AuthQueryAtom<better_auth.Prettify<{
265
335
  id: string;
@@ -3401,7 +3471,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
3401
3471
  data: CompleteAuthorizationFlowResponse;
3402
3472
  error: null;
3403
3473
  }>;
3404
- whoAmI: (accessToken: string) => Promise<{
3474
+ whoAmI: (accessToken: string, options?: WhoAmIOptions) => Promise<{
3405
3475
  data: null;
3406
3476
  error: {
3407
3477
  message?: string | undefined;
@@ -4365,112 +4435,281 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
4365
4435
  };
4366
4436
  };
4367
4437
  };
4438
+ /**
4439
+ * The configured Better Auth client type with all plugins applied.
4440
+ *
4441
+ * @internal
4442
+ */
4368
4443
  type APIClient = ReturnType<typeof createAPIClient>;
4444
+ /** An authenticated user. */
4369
4445
  type User = APIClient['$Infer']['Session']['user'];
4446
+ /** A user session containing the user and session metadata. */
4370
4447
  type Session = APIClient['$Infer']['Session'];
4371
- type Organization = Strict<APIClient['$Infer']['Organization']>;
4448
+ /** An organization the user belongs to. */
4449
+ type BaseOrganization = Strict<APIClient['$Infer']['Organization']>;
4450
+ /** A team within an organization. */
4372
4451
  type Team = Strict<APIClient['$Infer']['Team']>;
4452
+ /** A pending invitation to join an organization. */
4373
4453
  type Invitation = Strict<APIClient['$Infer']['Invitation']>;
4454
+ /** A member of an organization with role information. */
4374
4455
  type Member = Strict<APIClient['$Infer']['Member']>;
4456
+ /**
4457
+ * Custom settings that can be applied to an organization.
4458
+ */
4375
4459
  type OrganizationSettings = {
4460
+ /** Whether file storage is disabled for this organization. */
4376
4461
  disableStorage?: boolean;
4462
+ /** Number of hours to retain data before automatic cleanup. */
4377
4463
  dataRetentionHours?: number;
4378
4464
  };
4379
- type ExtendedOrganization = Organization & {
4465
+ /**
4466
+ * An organization with optional custom settings.
4467
+ */
4468
+ type ExtendedOrganization = BaseOrganization & {
4380
4469
  settings?: OrganizationSettings;
4381
4470
  };
4471
+ /**
4472
+ * A complete organization object including its members, invitations, and teams.
4473
+ */
4382
4474
  type FullOrganization = Omit<ExtendedOrganization, 'slug'> & {
4383
4475
  slug: string | null;
4384
4476
  members: Member[];
4385
4477
  invitations: Invitation[];
4386
4478
  teams: Team[];
4387
4479
  };
4480
+ /**
4481
+ * An organization as returned by the "who am I" endpoint, where related
4482
+ * collections (`members`, `teams`, `invitations`) are optional and only
4483
+ * populated when explicitly requested via the `include` query parameter.
4484
+ */
4485
+ type WhoAmIOrganization = Omit<FullOrganization, 'members' | 'invitations' | 'teams'> & {
4486
+ members?: Member[];
4487
+ invitations?: Invitation[];
4488
+ teams?: Team[];
4489
+ };
4490
+ /**
4491
+ * A record linking a user to a team.
4492
+ */
4388
4493
  type TeamMember = {
4494
+ /** Unique identifier for this team membership. */
4389
4495
  id: string;
4496
+ /** The team this membership belongs to. */
4390
4497
  teamId: string;
4498
+ /** The user who is a member of the team. */
4391
4499
  userId: string;
4500
+ /** When the user was added to the team. */
4392
4501
  createdAt: Date;
4393
4502
  };
4394
4503
 
4504
+ /**
4505
+ * Keys of the organization's related collections that can be optionally
4506
+ * included in the "who am I" response.
4507
+ */
4508
+ type WhoAmIInclude = 'members' | 'teams' | 'invitations';
4509
+ /**
4510
+ * Represents a registered OAuth application.
4511
+ */
4395
4512
  type Application = {
4513
+ /** Unique application identifier. */
4396
4514
  id: string;
4515
+ /** Display name of the application. */
4397
4516
  name: string;
4517
+ /** Human-readable description of the application. */
4398
4518
  description: string;
4519
+ /** Allowed OAuth redirect URIs for this application. */
4399
4520
  redirectUris: string[];
4400
4521
  };
4522
+ /**
4523
+ * Response returned when listing candidate organizations for an application.
4524
+ */
4401
4525
  type ListCandidateOrganizationsResponse = {
4526
+ /** The application being queried. */
4402
4527
  application: Application;
4528
+ /** Organizations where the user is a member and the application is entitled. */
4403
4529
  organizations: FullOrganization[];
4404
4530
  };
4531
+ /**
4532
+ * Response returned when starting an authorization flow.
4533
+ */
4405
4534
  type StartAuthorizationFlowResponse = {
4535
+ /** The authorization code to exchange for tokens. */
4406
4536
  code: string;
4407
4537
  };
4538
+ /**
4539
+ * Response returned when completing an authorization flow or refreshing tokens.
4540
+ */
4408
4541
  type CompleteAuthorizationFlowResponse = {
4542
+ /** Short-lived JWT access token. */
4409
4543
  accessToken: string;
4544
+ /** Long-lived refresh token for obtaining new access tokens. */
4410
4545
  refreshToken: string;
4546
+ /** The authenticated user. */
4411
4547
  user: User;
4548
+ /** The organization the tokens are scoped to. */
4412
4549
  organization: FullOrganization;
4413
4550
  };
4551
+ /**
4552
+ * Response returned by the "who am I" endpoint.
4553
+ *
4554
+ * By default, the `organization` only contains the base organization fields.
4555
+ * The `members`, `teams`, and `invitations` collections are only populated
4556
+ * when explicitly requested via the `include` query parameter.
4557
+ */
4414
4558
  type WhoAmIResponse = {
4559
+ /** The authenticated user. */
4415
4560
  user: User;
4416
- organization: FullOrganization;
4561
+ /** The user's active organization. */
4562
+ organization: WhoAmIOrganization;
4563
+ };
4564
+ /**
4565
+ * Options accepted by the "who am I" client method.
4566
+ */
4567
+ type WhoAmIOptions = {
4568
+ /**
4569
+ * Collections to include in the returned organization. When omitted or
4570
+ * empty, only the base organization fields are returned.
4571
+ */
4572
+ include?: WhoAmIInclude[];
4417
4573
  };
4574
+ /**
4575
+ * Response returned when starting a device authorization flow (RFC 8628).
4576
+ */
4418
4577
  type DeviceAuthorizationResponse = {
4578
+ /** The device verification code for polling. */
4419
4579
  device_code: string;
4580
+ /** The user-facing code to enter on the verification page. */
4420
4581
  user_code: string;
4582
+ /** The URI the user should visit to authorize the device. */
4421
4583
  verification_uri: string;
4584
+ /** A complete URI including the user code for convenience. */
4422
4585
  verification_uri_complete: string;
4586
+ /** Number of seconds until the device code expires. */
4423
4587
  expires_in: number;
4588
+ /** Minimum polling interval in seconds. */
4424
4589
  interval: number;
4425
4590
  };
4591
+ /**
4592
+ * Minimal application info shown in device authorization context.
4593
+ *
4594
+ * @internal
4595
+ */
4426
4596
  type DeviceContextApplication = {
4597
+ /** Unique application identifier. */
4427
4598
  id: string;
4599
+ /** Display name of the application. */
4428
4600
  name: string;
4601
+ /** Human-readable description, or `null` if not set. */
4429
4602
  description: string | null;
4430
4603
  };
4604
+ /**
4605
+ * Context information for a pending device authorization request.
4606
+ */
4431
4607
  type DeviceAuthorizationContextResponse = {
4608
+ /** The application that initiated the device flow, with verification status. */
4432
4609
  requester: DeviceContextApplication & {
4433
4610
  isVerified: boolean;
4434
4611
  };
4612
+ /** The target application the requester wants access to. */
4435
4613
  target: DeviceContextApplication;
4614
+ /** Organizations the user can authorize the device for. */
4436
4615
  organizations: FullOrganization[];
4616
+ /** Organization pre-selected by the requester, if any. */
4437
4617
  preselectedOrganizationId: string | null;
4618
+ /** Current status of the device authorization request. */
4438
4619
  status: 'pending' | 'approved' | 'denied';
4620
+ /** Seconds remaining before the device code expires. */
4439
4621
  expiresIn: number;
4440
4622
  };
4623
+ /**
4624
+ * Response returned when approving or denying a device authorization request.
4625
+ */
4441
4626
  type DeviceAuthorizationActionResponse = {
4627
+ /** Whether the action was performed successfully. */
4442
4628
  success: boolean;
4443
4629
  };
4444
4630
 
4631
+ /**
4632
+ * Base error class for all SDK errors.
4633
+ *
4634
+ * Extends the native `Error` with a machine-readable `code` property
4635
+ * that can be used for programmatic error handling.
4636
+ */
4445
4637
  declare class BaseError extends Error {
4638
+ /** Machine-readable error code (e.g. `"INVALID_SOCIAL_PROVIDER"`). */
4446
4639
  code: string;
4640
+ /**
4641
+ * @param code - A machine-readable error code
4642
+ * @param message - A human-readable error message
4643
+ * @param options - Standard `ErrorOptions` (e.g. `cause`)
4644
+ */
4447
4645
  constructor(code: string, message: string, options?: ErrorOptions);
4448
4646
  }
4449
4647
 
4648
+ /**
4649
+ * Generic error thrown by the `ApplicationService`.
4650
+ *
4651
+ * All application-specific errors extend this class, so you can catch
4652
+ * `ApplicationError` to handle any application-related failure.
4653
+ */
4450
4654
  declare class ApplicationError extends BaseError {
4451
4655
  constructor(message: string, options?: ErrorOptions);
4452
4656
  }
4657
+ /**
4658
+ * Thrown when a refresh token has expired or been revoked.
4659
+ *
4660
+ * The client should discard its stored tokens and prompt the user
4661
+ * to re-authenticate.
4662
+ */
4453
4663
  declare class RefreshTokenExpiredError extends ApplicationError {
4454
4664
  constructor(options?: ErrorOptions);
4455
4665
  }
4666
+ /**
4667
+ * Thrown when an authorization flow fails unexpectedly.
4668
+ */
4456
4669
  declare class AuthorizationFlowError extends ApplicationError {
4457
4670
  constructor(message: string, options?: ErrorOptions);
4458
4671
  }
4672
+ /**
4673
+ * Thrown when an operation requires an authenticated user but no session exists.
4674
+ */
4459
4675
  declare class UserNotLoggedInError extends ApplicationError {
4460
4676
  constructor(message: string, options?: ErrorOptions);
4461
4677
  }
4678
+ /**
4679
+ * Thrown during device code polling when the user has not yet authorized the request.
4680
+ *
4681
+ * The client should continue polling at the specified interval.
4682
+ */
4462
4683
  declare class DeviceAuthorizationPendingError extends ApplicationError {
4463
4684
  constructor(options?: ErrorOptions);
4464
4685
  }
4686
+ /**
4687
+ * Thrown when the client is polling too frequently during the device flow.
4688
+ *
4689
+ * The client should increase its polling interval before retrying.
4690
+ */
4465
4691
  declare class DeviceAuthorizationSlowDownError extends ApplicationError {
4466
4692
  constructor(options?: ErrorOptions);
4467
4693
  }
4694
+ /**
4695
+ * Thrown when the user explicitly denies the device authorization request.
4696
+ */
4468
4697
  declare class DeviceAccessDeniedError extends ApplicationError {
4469
4698
  constructor(options?: ErrorOptions);
4470
4699
  }
4700
+ /**
4701
+ * Thrown when the device code has expired or has already been consumed.
4702
+ *
4703
+ * The client must start a new device authorization flow.
4704
+ */
4471
4705
  declare class DeviceCodeExpiredError extends ApplicationError {
4472
4706
  constructor(options?: ErrorOptions);
4473
4707
  }
4708
+ /**
4709
+ * Thrown when the authorization server returns a transient error during the device flow.
4710
+ *
4711
+ * The token exchange can be safely retried.
4712
+ */
4474
4713
  declare class DeviceTransientServerError extends ApplicationError {
4475
4714
  constructor(options?: ErrorOptions);
4476
4715
  }
@@ -4479,7 +4718,10 @@ declare class DeviceTransientServerError extends ApplicationError {
4479
4718
  * Service for managing applications and their candidate organizations.
4480
4719
  *
4481
4720
  * Provides functionality for:
4482
- * - Listing candidate organizations for an application
4721
+ * - OAuth authorization code flow (PKCE)
4722
+ * - Device authorization flow (RFC 8628)
4723
+ * - Token management (refresh, exchange)
4724
+ * - Organization switching
4483
4725
  */
4484
4726
  declare class ApplicationService {
4485
4727
  private client;
@@ -4514,10 +4756,57 @@ declare class ApplicationService {
4514
4756
  * @param organizationId - The organization ID to start the authorization flow for
4515
4757
  */
4516
4758
  startAuthorizationFlow(applicationId: string, redirectUri: string, codeChallenge: string, organizationId: string): Promise<StartAuthorizationFlowResponse>;
4759
+ /**
4760
+ * Starts a device authorization flow (RFC 8628).
4761
+ *
4762
+ * Returns a device code and user code that the end user must enter
4763
+ * on the verification URI to authorize the device.
4764
+ *
4765
+ * @param requesterApplicationId - The application requesting authorization
4766
+ * @param targetApplicationId - The target application to gain access to
4767
+ * @returns Device authorization details including codes and verification URI
4768
+ */
4517
4769
  startDeviceAuthorizationFlow(requesterApplicationId: string, targetApplicationId: string): Promise<DeviceAuthorizationResponse>;
4770
+ /**
4771
+ * Retrieves the context for a pending device authorization request.
4772
+ *
4773
+ * Used by the authorization page to display details about the requesting
4774
+ * and target applications before the user approves or denies.
4775
+ *
4776
+ * @param userCode - The user code from the device authorization response
4777
+ * @returns Context including application info, available organizations, and status
4778
+ */
4518
4779
  getDeviceAuthorizationContext(userCode: string): Promise<DeviceAuthorizationContextResponse>;
4780
+ /**
4781
+ * Approves a pending device authorization request.
4782
+ *
4783
+ * @param userCode - The user code identifying the device authorization request
4784
+ * @param organizationId - The organization to authorize the device for
4785
+ * @returns Confirmation of the approval action
4786
+ */
4519
4787
  approveDeviceAuthorizationFlow(userCode: string, organizationId: string): Promise<DeviceAuthorizationActionResponse>;
4788
+ /**
4789
+ * Denies a pending device authorization request.
4790
+ *
4791
+ * @param userCode - The user code identifying the device authorization request
4792
+ * @returns Confirmation of the denial action
4793
+ */
4520
4794
  denyDeviceAuthorizationFlow(userCode: string): Promise<DeviceAuthorizationActionResponse>;
4795
+ /**
4796
+ * Exchanges a device code for access and refresh tokens.
4797
+ *
4798
+ * This should be called by the device client while polling. It will throw
4799
+ * typed errors to indicate the polling state (pending, slow down, denied, expired).
4800
+ *
4801
+ * @param deviceCode - The device code obtained from {@link startDeviceAuthorizationFlow}
4802
+ * @returns Access and refresh tokens along with user and organization info
4803
+ *
4804
+ * @throws {DeviceAuthorizationPendingError} The user hasn't authorized yet — keep polling
4805
+ * @throws {DeviceAuthorizationSlowDownError} Polling too fast — increase the interval
4806
+ * @throws {DeviceAccessDeniedError} The user denied the request
4807
+ * @throws {DeviceCodeExpiredError} The device code has expired
4808
+ * @throws {DeviceTransientServerError} Transient server error — safe to retry
4809
+ */
4521
4810
  exchangeDeviceCodeForTokens(deviceCode: string): Promise<CompleteAuthorizationFlowResponse>;
4522
4811
  /**
4523
4812
  * Completes an authorization flow for a specific application.
@@ -4533,14 +4822,19 @@ declare class ApplicationService {
4533
4822
  * @throws {RefreshTokenExpiredError} When the refresh token has expired or is invalid
4534
4823
  * @throws {ApplicationError} For other API errors
4535
4824
  */
4536
- refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse>;
4825
+ refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse | null | undefined>;
4537
4826
  /**
4538
4827
  * Gets the current user and organization for a specific application.
4539
4828
  *
4829
+ * By default, the returned organization does not include its `members`,
4830
+ * `teams`, or `invitations` collections. Pass `options.include` to request
4831
+ * any of them explicitly.
4832
+ *
4540
4833
  * @param accessToken - The access token to use for the who am I request
4834
+ * @param options - Optional include list controlling which relations are loaded
4541
4835
  * @returns The current user and organization
4542
4836
  */
4543
- whoAmI(accessToken: string): Promise<WhoAmIResponse>;
4837
+ whoAmI(accessToken: string, options?: WhoAmIOptions): Promise<WhoAmIResponse>;
4544
4838
  /**
4545
4839
  * Switches the active organization for the authenticated user.
4546
4840
  *
@@ -4564,29 +4858,62 @@ declare class ApplicationService {
4564
4858
  logout(refreshToken: string): Promise<void>;
4565
4859
  }
4566
4860
 
4861
+ /**
4862
+ * Fields that can be updated on an organization.
4863
+ */
4567
4864
  type UpdateOrganizationPayload = Partial<Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>>;
4865
+ /**
4866
+ * Pagination options for listing organization members.
4867
+ */
4568
4868
  type ListMembersOptions = {
4869
+ /** Maximum number of members to return. */
4569
4870
  limit?: number;
4871
+ /** Number of members to skip for pagination. */
4570
4872
  offset?: number;
4571
4873
  };
4874
+ /**
4875
+ * Options for inviting a user to the active organization.
4876
+ */
4572
4877
  type InviteUserToOrganizationOptions = {
4878
+ /** Email address of the user to invite. */
4573
4879
  userEmail: string;
4880
+ /** Organization role to assign to the invited user. */
4574
4881
  role: Role;
4882
+ /** Optional team to add the user to upon acceptance. */
4575
4883
  teamId?: string;
4884
+ /** Whether to resend the invitation if one already exists for this email. */
4576
4885
  resend?: boolean;
4577
4886
  };
4887
+ /**
4888
+ * Options for removing a user from the active organization.
4889
+ *
4890
+ * Provide either `memberId` or `userEmail`, but not both.
4891
+ */
4578
4892
  type RemoveUserFromOrganizationOptions = {
4893
+ /** The member ID to remove. */
4579
4894
  memberId: string;
4580
4895
  userEmail?: never;
4581
4896
  } | {
4897
+ /** The user's email address to remove. */
4582
4898
  userEmail: string;
4583
4899
  memberId?: never;
4584
4900
  };
4901
+ /**
4902
+ * Options for updating a member's role within the organization.
4903
+ */
4585
4904
  type UpdateMemberRoleOptions = {
4905
+ /** The member ID whose role should be updated. */
4586
4906
  memberId: string;
4907
+ /** The new role to assign. */
4587
4908
  role: Role;
4588
4909
  };
4910
+ /**
4911
+ * Payload for creating a new team.
4912
+ */
4589
4913
  type CreateTeamPayload = Pick<Team, 'name'>;
4914
+ /**
4915
+ * Payload for updating an existing team.
4916
+ */
4590
4917
  type UpdateTeamPayload = Pick<Team, 'name'>;
4591
4918
 
4592
4919
  /**
@@ -4668,10 +4995,7 @@ declare class OrganizationService {
4668
4995
  /**
4669
4996
  * Updates an organization's details.
4670
4997
  *
4671
- * @param payload - The organization fields to update
4672
- * @param payload.name - New organization name
4673
- * @param payload.logo - New organization logo URL
4674
- * @param payload.settings - New organization settings
4998
+ * @param payload - The organization fields to update (name, logo, settings)
4675
4999
  * @returns The updated organization
4676
5000
  */
4677
5001
  updateOrganization(payload: UpdateOrganizationPayload): Promise<ExtendedOrganization>;
@@ -4786,9 +5110,7 @@ declare class OrganizationService {
4786
5110
  /**
4787
5111
  * Removes a user from the active organization.
4788
5112
  *
4789
- * @param options - User identifier (either memberId or userEmail must be provided)
4790
- * @param options.memberId - The member ID to remove
4791
- * @param options.userEmail - The user email to remove
5113
+ * @param options - Provide either `memberId` or `userEmail` to identify the user
4792
5114
  */
4793
5115
  removeUserFromOrganization({ memberId, userEmail }: RemoveUserFromOrganizationOptions): Promise<void>;
4794
5116
  /**
@@ -4802,8 +5124,7 @@ declare class OrganizationService {
4802
5124
  /**
4803
5125
  * Creates a new team within the active organization.
4804
5126
  *
4805
- * @param payload - Team configuration
4806
- * @param payload.name - The name of the team
5127
+ * @param payload - Team configuration with a `name` field
4807
5128
  * @returns The created team
4808
5129
  */
4809
5130
  createTeam(payload: CreateTeamPayload): Promise<{
@@ -4817,8 +5138,7 @@ declare class OrganizationService {
4817
5138
  * Updates an existing team's details.
4818
5139
  *
4819
5140
  * @param id - The team ID to update
4820
- * @param payload - Team fields to update
4821
- * @param payload.name - The new team name
5141
+ * @param payload - Team fields to update (currently supports `name`)
4822
5142
  * @returns The updated team
4823
5143
  */
4824
5144
  updateTeam(id: string, payload: UpdateTeamPayload): Promise<{
@@ -4880,20 +5200,39 @@ declare class OrganizationService {
4880
5200
  removeTeamMember(teamId: string, userId: string): Promise<void>;
4881
5201
  }
4882
5202
 
5203
+ /**
5204
+ * Options for signing in with a social provider (Google or Microsoft).
5205
+ */
4883
5206
  type SocialSignInOptions = {
5207
+ /** The social identity provider to authenticate with. */
4884
5208
  provider: 'google' | 'microsoft';
5209
+ /** URL to redirect to after successful authentication. */
4885
5210
  callbackURL: string;
5211
+ /** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
4886
5212
  errorCallbackURL?: string;
4887
5213
  };
5214
+ /**
5215
+ * Options for signing in via SAML Single Sign-On.
5216
+ */
4888
5217
  type SignInWithSamlOptions = {
5218
+ /** The user's email address, used to resolve the correct SAML identity provider. */
4889
5219
  email: string;
5220
+ /** URL to redirect to after successful authentication. */
4890
5221
  callbackURL: string;
5222
+ /** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
4891
5223
  errorCallbackURL?: string;
4892
5224
  };
5225
+ /**
5226
+ * Options for signing in with email and password credentials.
5227
+ */
4893
5228
  type SignInWithEmailAndPasswordOptions = {
5229
+ /** The user's email address. */
4894
5230
  email: string;
5231
+ /** The user's password. */
4895
5232
  password: string;
5233
+ /** URL to redirect to after successful authentication. */
4896
5234
  callbackURL: string;
5235
+ /** URL to redirect to if authentication fails. */
4897
5236
  errorCallbackURL?: string;
4898
5237
  };
4899
5238
 
@@ -5026,10 +5365,10 @@ declare class SessionService {
5026
5365
  }
5027
5366
 
5028
5367
  /**
5029
- * Service for managing API keys
5368
+ * Service for managing API keys.
5030
5369
  *
5031
- * Provides comprehensive API key management including:
5032
- * - API key CRUD operations
5370
+ * Provides CRUD operations for API keys scoped to the authenticated
5371
+ * user or their active organization.
5033
5372
  */
5034
5373
  declare class ApiKeyService {
5035
5374
  private client;
@@ -5039,16 +5378,52 @@ declare class ApiKeyService {
5039
5378
  * @param client - The API client for making API key requests
5040
5379
  */
5041
5380
  constructor(client: APIClient);
5381
+ /**
5382
+ * Creates a new API key.
5383
+ *
5384
+ * The returned object includes the secret `key` value, which is only
5385
+ * available at creation time and cannot be retrieved later.
5386
+ *
5387
+ * @param payload - The API key configuration
5388
+ * @returns The created API key including the secret key value
5389
+ */
5042
5390
  createApiKey(payload: CreateApiKeyPayload): Promise<ApiKey>;
5391
+ /**
5392
+ * Retrieves an API key by its ID.
5393
+ *
5394
+ * @param id - The API key ID
5395
+ * @returns The API key (without the secret key value)
5396
+ */
5043
5397
  getApiKey(id: string): Promise<ApiKeyWithoutSecret>;
5398
+ /**
5399
+ * Lists all API keys owned by the authenticated user.
5400
+ *
5401
+ * @returns An object containing the API keys array and pagination metadata
5402
+ */
5044
5403
  listApiKeys(): Promise<{
5045
5404
  apiKeys: ApiKeyWithoutSecret[];
5046
5405
  total: number;
5047
5406
  limit: number | undefined;
5048
5407
  offset: number | undefined;
5049
5408
  }>;
5409
+ /**
5410
+ * Lists all API keys belonging to the active organization.
5411
+ *
5412
+ * @returns An array of API keys (without secret key values)
5413
+ */
5050
5414
  listOrganizationApiKeys(): Promise<ApiKeyWithoutSecret[]>;
5415
+ /**
5416
+ * Updates an existing API key.
5417
+ *
5418
+ * @param payload - The fields to update
5419
+ * @returns The updated API key (without the secret key value)
5420
+ */
5051
5421
  updateApiKey(payload: UpdateApiKeyPayload): Promise<ApiKeyWithoutSecret>;
5422
+ /**
5423
+ * Permanently deletes an API key.
5424
+ *
5425
+ * @param id - The API key ID to delete
5426
+ */
5052
5427
  deleteApiKey(id: string): Promise<{
5053
5428
  success: boolean;
5054
5429
  }>;
@@ -5185,4 +5560,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
5185
5560
  declare function extractTokenPayload(token: string): JWTPayload;
5186
5561
 
5187
5562
  export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
5188
- export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, FullOrganization, Invitation, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIResponse };
5563
+ export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, BaseOrganization, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, FullOrganization, Invitation, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };