@meistrari/auth-core 1.28.1 → 1.29.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.mts CHANGED
@@ -14,11 +14,11 @@ declare const AALBrand: unique symbol;
14
14
  declare const ACRBrand: unique symbol;
15
15
  declare const AuthMethodBrand: unique symbol;
16
16
  declare const AMRs: {
17
- readonly Pwd: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
18
- readonly Otp: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
19
- readonly Oauth: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
20
- readonly Sso: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
21
- readonly Saml: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
17
+ readonly Pwd: ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("pwd" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>);
18
+ readonly Otp: ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("pwd" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>);
19
+ readonly Oauth: ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("pwd" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>);
20
+ readonly Sso: ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("pwd" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>);
21
+ readonly Saml: ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("pwd" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>);
22
22
  };
23
23
  declare const AALs: {
24
24
  readonly Aal1: ("aal1" & z.core.$brand<typeof AALBrand>) | ("aal2" & z.core.$brand<typeof AALBrand>) | ("aal3" & z.core.$brand<typeof AALBrand>);
@@ -29,11 +29,11 @@ declare const ACRs: {
29
29
  readonly Unspecified: "urn:tela:auth:unspecified" & z.core.$brand<typeof ACRBrand>;
30
30
  };
31
31
  declare const AuthMethods: {
32
- readonly Password: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
33
- readonly EmailOTP: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
34
- readonly OAuth: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
35
- readonly SAML: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
36
- readonly Unknown: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
32
+ readonly Password: ("unknown" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>);
33
+ readonly EmailOTP: ("unknown" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>);
34
+ readonly OAuth: ("unknown" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>);
35
+ readonly SAML: ("unknown" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>);
36
+ readonly Unknown: ("unknown" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>);
37
37
  };
38
38
  declare const AMR: z.core.$ZodBranded<z.ZodEnum<{
39
39
  readonly Pwd: "pwd";
@@ -390,8 +390,16 @@ type SessionAssurancePolicy = {
390
390
  };
391
391
  declare const SessionAssurancePolicy: z.ZodType<SessionAssurancePolicy>;
392
392
  declare const SENSITIVE_ACTION_ASSURANCE_POLICY: SessionAssurancePolicy;
393
+ /**
394
+ * Maximum age of an elevated (stepped-up) assurance, in seconds. Enforced by
395
+ * `isAssuranceSufficientForPolicy` for any policy that requires AAL2 or higher,
396
+ * so a one-time step-up cannot satisfy a sensitive-action policy indefinitely.
397
+ * Baseline AAL1 policies impose no freshness requirement, so ordinary sessions
398
+ * and their token refreshes are unaffected.
399
+ */
400
+ declare const STEP_UP_MAX_AGE_SECONDS: number;
393
401
  declare function getAalRank(aal: JWTPayload['assurance']['aal']): number;
394
- declare function isAssuranceSufficientForPolicy(assurance: JWTPayload['assurance'] | null | undefined, policy: SessionAssurancePolicy): boolean;
402
+ declare function isAssuranceSufficientForPolicy(assurance: JWTPayload['assurance'] | null | undefined, policy: SessionAssurancePolicy, now?: Date): boolean;
395
403
  declare function canStepUpWithAmr(assurance: JWTPayload['assurance'], amr: AMR): boolean;
396
404
  declare function mergeStepUpAssurance(assurance: JWTPayload['assurance'], amr: AMR, now?: Date): JWTPayload['assurance'];
397
405
 
@@ -4394,15 +4402,15 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
4394
4402
  } & {
4395
4403
  applications: {
4396
4404
  getApplicationAuthContext: (applicationId: string) => Promise<{
4405
+ data: ApplicationAuthContextResponse;
4406
+ error: null;
4407
+ } | {
4397
4408
  data: null;
4398
4409
  error: {
4399
4410
  message?: string | undefined;
4400
4411
  status: number;
4401
4412
  statusText: string;
4402
4413
  };
4403
- } | {
4404
- data: ApplicationAuthContextResponse;
4405
- error: null;
4406
4414
  }>;
4407
4415
  listCandidateOrganizations: (applicationId: string) => Promise<{
4408
4416
  data: ListCandidateOrganizationsResponse;
@@ -5568,8 +5576,16 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
5568
5576
  type APIClient = ReturnType<typeof createAPIClient>;
5569
5577
  /** An authenticated user. */
5570
5578
  type User = APIClient['$Infer']['Session']['user'];
5571
- /** A user session containing the user and session metadata. */
5572
- type Session = APIClient['$Infer']['Session'];
5579
+ /**
5580
+ * A user session record.
5581
+ *
5582
+ * Breaking change in 1.12: this was previously the full `{ user, session }`
5583
+ * response object, even though runtime session state only ever held the
5584
+ * inner record. Use {@link SessionData} for the full response shape.
5585
+ */
5586
+ type Session = APIClient['$Infer']['Session']['session'];
5587
+ /** A full session response containing the user and the session record. */
5588
+ type SessionData = APIClient['$Infer']['Session'];
5573
5589
  /** An organization the user belongs to. */
5574
5590
  type BaseOrganization = Strict<APIClient['$Infer']['Organization']>;
5575
5591
  /** A team within an organization. */
@@ -5641,29 +5657,39 @@ type TeamMember = {
5641
5657
  };
5642
5658
 
5643
5659
  /**
5644
- * Options accepted when listing users through the Better Auth admin plugin.
5660
+ * Options accepted when listing users as a global admin.
5645
5661
  */
5646
5662
  type ListAdminUsersOptions = {
5647
- /** Maximum number of users to return. */
5663
+ /** Maximum number of users to return. Defaults to 50. */
5648
5664
  limit?: number;
5649
- /** Number of users to skip. */
5665
+ /** Number of users to skip. Defaults to 0. */
5650
5666
  offset?: number;
5651
- /** Free-text search value. */
5652
- searchValue?: string;
5653
- /** User field searched by Better Auth. Defaults to email. */
5654
- searchField?: 'email' | 'name';
5655
- /** Search comparison operator. Defaults to contains. */
5656
- searchOperator?: 'contains' | 'starts_with' | 'ends_with';
5657
- /** Field used to sort the listing. */
5658
- sortBy?: string;
5659
- /** Sort direction. */
5667
+ /** Column used to order the listing. Defaults to creation date. */
5668
+ sortBy?: 'createdAt' | 'name';
5669
+ /** Order direction. Defaults to descending. */
5660
5670
  sortDirection?: 'asc' | 'desc';
5661
- /** User field filtered by Better Auth. Defaults to email. */
5662
- filterField?: string;
5663
- /** Filter value. */
5664
- filterValue?: string | number | boolean | string[] | number[];
5665
- /** Filter comparison operator. Defaults to eq. */
5666
- filterOperator?: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'not_in' | 'contains' | 'starts_with' | 'ends_with';
5671
+ /** Free-text search matched against user name, email, and ID. */
5672
+ query?: string;
5673
+ /**
5674
+ * Number of organization previews to include per user (max 10).
5675
+ * When greater than 0, each row also includes the total organization count.
5676
+ * Defaults to 0.
5677
+ */
5678
+ organizationsPreview?: number;
5679
+ /**
5680
+ * When true, invitation-only rows for people invited but not yet registered
5681
+ * are merged into the listing, grouped by email. Defaults to false.
5682
+ */
5683
+ includeInvitations?: boolean;
5684
+ };
5685
+ /**
5686
+ * Organization preview returned alongside each admin user row.
5687
+ */
5688
+ type AdminUserOrganization = {
5689
+ id: string;
5690
+ name: string;
5691
+ logo: string | null;
5692
+ createdAt: string;
5667
5693
  };
5668
5694
  /**
5669
5695
  * Options accepted when listing all organizations as a global admin.
@@ -5767,8 +5793,16 @@ type ListAdminOrganizationMembersOptions = {
5767
5793
  limit?: number;
5768
5794
  /** Number of members to skip. Defaults to 0. */
5769
5795
  offset?: number;
5770
- /** Free-text search matched against member name, email, role, user ID, and member ID. */
5796
+ /** Case-insensitive name/email match; also matches an exact user ID when a UUID. */
5771
5797
  query?: string;
5798
+ /** Organization role filter, e.g. 'org:admin'. */
5799
+ role?: string;
5800
+ /** Restricts the listing to members belonging to any of these teams. */
5801
+ teamIds?: string[];
5802
+ /** When true, pending invitation rows for the organization are merged into the listing. */
5803
+ includeInvitations?: boolean;
5804
+ /** When true, each row includes the member's teams and accessible applications. */
5805
+ includeAccess?: boolean;
5772
5806
  };
5773
5807
  /**
5774
5808
  * Options accepted when listing teams for a single organization as a global admin.
@@ -5798,6 +5832,66 @@ type CreateAdminOrganizationTeamOptions = {
5798
5832
  /** User IDs of organization members to add to the team. */
5799
5833
  memberIds?: string[];
5800
5834
  };
5835
+ /**
5836
+ * Options accepted when updating an organization member's role as a global admin.
5837
+ */
5838
+ type UpdateAdminMemberRoleOptions = {
5839
+ /** ID of the membership to update. */
5840
+ memberId: string;
5841
+ /** New organization role for the membership. */
5842
+ role: string;
5843
+ };
5844
+ /**
5845
+ * Options accepted when removing an organization member as a global admin.
5846
+ */
5847
+ type RemoveAdminMemberOptions = {
5848
+ /** ID of the membership to remove. */
5849
+ memberId: string;
5850
+ };
5851
+ /**
5852
+ * Options accepted when setting a user's effective application role as a global admin.
5853
+ */
5854
+ type SetAdminUserApplicationRoleOptions = {
5855
+ /** ID of the user whose application role is being set. */
5856
+ userId: string;
5857
+ /** Organization the entitlement belongs to. */
5858
+ organizationId: string;
5859
+ /** Application the entitlement grants access to. */
5860
+ applicationId: string;
5861
+ /** Non-null grants access with the role, null denies access (leave application). Ignored when clear is true. */
5862
+ role?: string | null;
5863
+ /** When true, removes the user's override rule so broader organization rules apply again. */
5864
+ clear?: boolean;
5865
+ };
5866
+ /**
5867
+ * Options accepted when assigning or clearing a user's team as a global admin.
5868
+ */
5869
+ type SetAdminUserTeamOptions = {
5870
+ /** ID of the user whose team membership is being set. */
5871
+ userId: string;
5872
+ /** Organization the teams belong to. */
5873
+ organizationId: string;
5874
+ /** Desired teams within the organization; an empty array clears the user's team memberships. */
5875
+ teamIds: string[];
5876
+ };
5877
+ /**
5878
+ * Team row returned by the admin organization team listing endpoint.
5879
+ */
5880
+ type AdminOrganizationTeam = {
5881
+ id: string;
5882
+ name: string;
5883
+ };
5884
+ /**
5885
+ * Organization membership row returned by the admin member mutation endpoints.
5886
+ */
5887
+ type AdminMember = {
5888
+ id: string;
5889
+ organizationId: string;
5890
+ userId: string;
5891
+ role: string;
5892
+ createdAt: string;
5893
+ deletedAt: string | null;
5894
+ };
5801
5895
  /**
5802
5896
  * Options accepted when creating an organization as a global admin.
5803
5897
  */
@@ -5833,7 +5927,36 @@ type UpdateAdminOrganizationOptions = {
5833
5927
  settings?: OrganizationSettings;
5834
5928
  };
5835
5929
  /**
5836
- * User row returned by the Better Auth admin user listing endpoint.
5930
+ * Invitation attached to an invitation row in the admin user listing.
5931
+ */
5932
+ type AdminUserInvitation = {
5933
+ id: string;
5934
+ organizationId: string;
5935
+ organizationName: string;
5936
+ organizationLogo: string | null;
5937
+ applicationId: string | null;
5938
+ role: string | null;
5939
+ teamIds: string[];
5940
+ status: 'pending' | 'expired';
5941
+ expiresAt: string;
5942
+ createdAt: string;
5943
+ };
5944
+ /**
5945
+ * Options accepted when resending an organization invitation as a global admin.
5946
+ */
5947
+ type ResendAdminInviteOptions = {
5948
+ organizationId: string;
5949
+ email: string;
5950
+ role: string;
5951
+ applicationId?: string;
5952
+ /**
5953
+ * Teams joined when the re-sent invitation is accepted. Resending replaces the
5954
+ * invitation, so these must be provided to preserve the original team assignments.
5955
+ */
5956
+ teamIds?: string[];
5957
+ };
5958
+ /**
5959
+ * User row returned by the admin user listing endpoint.
5837
5960
  */
5838
5961
  type AdminUser = {
5839
5962
  id: string;
@@ -5849,15 +5972,25 @@ type AdminUser = {
5849
5972
  banExpires: string | Date | null;
5850
5973
  lastActiveAt?: string | Date | null;
5851
5974
  twoFactorEnabled?: boolean | null;
5975
+ /** Discriminates registered users from invitation-only rows. */
5976
+ type: 'user' | 'invitation';
5977
+ /** Aggregate invitation status. Present on invitation rows. */
5978
+ invitationStatus?: 'pending' | 'expired';
5979
+ /** Pending invitations grouped on this row. Present on invitation rows. */
5980
+ invitations?: AdminUserInvitation[];
5981
+ /** Total number of organizations the user belongs to. Present when requested via organizationsPreview. */
5982
+ organizationCount?: number;
5983
+ /** Preview of the first organizations the user belongs to. Present when requested via organizationsPreview. */
5984
+ organizations?: AdminUserOrganization[];
5852
5985
  };
5853
5986
  /**
5854
- * Paginated Better Auth admin user listing response.
5987
+ * Paginated admin user listing response.
5855
5988
  */
5856
5989
  type ListAdminUsersResult = {
5857
5990
  users: AdminUser[];
5858
5991
  total: number;
5859
- limit?: number;
5860
- offset?: number;
5992
+ limit: number;
5993
+ offset: number;
5861
5994
  };
5862
5995
  /**
5863
5996
  * Member preview returned alongside each admin organization row.
@@ -5869,13 +6002,40 @@ type AdminOrganizationMember = {
5869
6002
  image: string | null;
5870
6003
  };
5871
6004
  /**
5872
- * Full organization member row returned by the admin organization member listing endpoint.
6005
+ * Team row attached to an organization member listing row.
5873
6006
  */
5874
- type AdminOrganizationMemberRecord = AdminOrganizationMember & {
5875
- memberId: string;
6007
+ type AdminOrganizationMemberTeam = {
6008
+ id: string;
6009
+ name: string;
6010
+ };
6011
+ /**
6012
+ * Application row attached to an organization member listing row.
6013
+ */
6014
+ type AdminOrganizationMemberApplication = {
6015
+ id: string;
6016
+ name: string;
6017
+ imageUrl: string | null;
6018
+ };
6019
+ /**
6020
+ * Row returned by the admin organization member listing endpoint. Members and
6021
+ * pending invitations share this shape, discriminated by type.
6022
+ */
6023
+ type AdminOrganizationMemberRecord = {
6024
+ type: 'member' | 'invitation';
6025
+ id: string;
6026
+ memberId: string | null;
5876
6027
  organizationId: string;
5877
- role: string;
6028
+ name: string | null;
6029
+ email: string;
6030
+ image: string | null;
6031
+ role: string | null;
6032
+ lastActiveAt: string | null;
5878
6033
  createdAt: string;
6034
+ invitationId?: string;
6035
+ invitationStatus?: 'pending' | 'expired';
6036
+ expiresAt?: string;
6037
+ teams?: AdminOrganizationMemberTeam[];
6038
+ applications?: AdminOrganizationMemberApplication[];
5879
6039
  };
5880
6040
  /**
5881
6041
  * Paginated organization member listing response.
@@ -5906,6 +6066,41 @@ type ListAdminOrganizationTeamsResult = {
5906
6066
  limit: number;
5907
6067
  offset: number;
5908
6068
  };
6069
+ /**
6070
+ * Application row in an admin user access report.
6071
+ */
6072
+ type AdminUserAccessApplication = {
6073
+ id: string;
6074
+ name: string;
6075
+ imageUrl: string | null;
6076
+ /** Effective role from entitlement rule evaluation. Null when the first matching rule denies access or no rule matches. */
6077
+ role: string | null;
6078
+ };
6079
+ /**
6080
+ * Team row in an admin user access report.
6081
+ */
6082
+ type AdminUserAccessTeam = {
6083
+ id: string;
6084
+ name: string;
6085
+ };
6086
+ /**
6087
+ * Organization row in an admin user access report.
6088
+ */
6089
+ type AdminUserAccessOrganization = {
6090
+ id: string;
6091
+ name: string;
6092
+ logo: string | null;
6093
+ memberId: string;
6094
+ role: string;
6095
+ teams: AdminUserAccessTeam[];
6096
+ applications: AdminUserAccessApplication[];
6097
+ };
6098
+ /**
6099
+ * Access report returned by the admin user access endpoint.
6100
+ */
6101
+ type AdminUserAccess = {
6102
+ organizations: AdminUserAccessOrganization[];
6103
+ };
5909
6104
  /**
5910
6105
  * Organization row embedded in an admin application entitlement.
5911
6106
  */
@@ -6023,6 +6218,27 @@ type ListAdminOrganizationsResult = {
6023
6218
  limit: number;
6024
6219
  offset: number;
6025
6220
  };
6221
+ /**
6222
+ * Options accepted when inviting several users to an organization as a global admin.
6223
+ */
6224
+ type InviteAdminOrganizationUsersOptions = {
6225
+ organizationId: string;
6226
+ emails: string[];
6227
+ role: string;
6228
+ /** Teams joined when each invitation is accepted. */
6229
+ teamIds?: string[];
6230
+ applicationId?: string;
6231
+ };
6232
+ /**
6233
+ * Per-email outcome of a batch organization invite.
6234
+ */
6235
+ type InviteAdminOrganizationUsersResult = {
6236
+ results: {
6237
+ email: string;
6238
+ status: 'invited' | 'added' | 'error';
6239
+ message?: string;
6240
+ }[];
6241
+ };
6026
6242
 
6027
6243
  /**
6028
6244
  * Service for global admin operations.
@@ -6045,20 +6261,21 @@ declare class AdminService {
6045
6261
  * @returns The paginated organization listing
6046
6262
  */
6047
6263
  listOrganizations(options?: ListAdminOrganizationsOptions): Promise<{
6048
- data: ListAdminOrganizationsResult;
6049
- error: null;
6050
- } | {
6051
6264
  data: null;
6052
6265
  error: {
6053
6266
  message?: string | undefined;
6054
6267
  status: number;
6055
6268
  statusText: string;
6056
6269
  };
6270
+ } | {
6271
+ data: ListAdminOrganizationsResult;
6272
+ error: null;
6057
6273
  }>;
6058
6274
  /**
6059
- * Lists all Better Auth users from the user table.
6275
+ * Lists users as a global admin, optionally with organization previews
6276
+ * and totals when a preview size is requested.
6060
6277
  *
6061
- * @param options - Pagination, search, filter, and ordering options
6278
+ * @param options - Pagination, ordering, search, and preview options
6062
6279
  * @returns The paginated user listing
6063
6280
  */
6064
6281
  listUsers(options?: ListAdminUsersOptions): Promise<{
@@ -6082,6 +6299,17 @@ declare class AdminService {
6082
6299
  getOrganization(options: GetAdminOrganizationOptions): Promise<{
6083
6300
  data: AdminOrganization;
6084
6301
  } | null>;
6302
+ /**
6303
+ * Fetches the per-organization access report for a single user: their
6304
+ * organizations with role, membership ID, and teams, plus each
6305
+ * organization's entitled applications with the user's effective role.
6306
+ *
6307
+ * @param userId - The ID of the user to fetch access for
6308
+ * @returns The user access report
6309
+ */
6310
+ getUserAccess(userId: string): Promise<{
6311
+ data: AdminUserAccess;
6312
+ } | null>;
6085
6313
  /**
6086
6314
  * Lists active members for one organization as a global admin.
6087
6315
  *
@@ -6143,11 +6371,73 @@ declare class AdminService {
6143
6371
  updateOrganization(options: UpdateAdminOrganizationOptions): Promise<{
6144
6372
  data: AdminOrganization;
6145
6373
  } | null>;
6374
+ /**
6375
+ * Updates an organization member's role.
6376
+ *
6377
+ * @param options - Membership ID and the new role
6378
+ * @returns The updated membership
6379
+ */
6380
+ updateMemberRole(options: UpdateAdminMemberRoleOptions): Promise<{
6381
+ data: AdminMember;
6382
+ } | null>;
6383
+ /**
6384
+ * Removes an organization member.
6385
+ *
6386
+ * @param options - Membership ID to remove
6387
+ * @returns The removed membership
6388
+ */
6389
+ removeMember(options: RemoveAdminMemberOptions): Promise<{
6390
+ data: AdminMember;
6391
+ } | null>;
6392
+ /**
6393
+ * Sets a user's effective application role within an organization. A
6394
+ * non-null role grants access, a null role denies access (leave
6395
+ * application), and clear removes the user-specific override.
6396
+ *
6397
+ * @param options - User, organization, application, and the role or clear flag
6398
+ */
6399
+ setUserApplicationRole(options: SetAdminUserApplicationRoleOptions): Promise<void>;
6400
+ /**
6401
+ * Reconciles a user's team memberships within an organization to a given set.
6402
+ *
6403
+ * @param options - User, organization, and the desired teams (empty to clear)
6404
+ */
6405
+ setUserTeam(options: SetAdminUserTeamOptions): Promise<void>;
6146
6406
  /**
6147
6407
  * Bans a user from the auth system and invalidates all their sessions.
6148
6408
  * @param userId - The ID of the user to ban
6149
6409
  */
6150
6410
  banUser(userId: string): Promise<void>;
6411
+ /**
6412
+ * Lifts a user's ban.
6413
+ * @param userId - The ID of the user to unban
6414
+ */
6415
+ unbanUser(userId: string): Promise<void>;
6416
+ /**
6417
+ * Permanently removes a user from the auth system.
6418
+ * @param userId - The ID of the user to remove
6419
+ */
6420
+ removeUser(userId: string): Promise<void>;
6421
+ /**
6422
+ * Cancels a pending invitation as a global admin.
6423
+ * @param invitationId - The ID of the invitation to cancel
6424
+ */
6425
+ cancelInvite(invitationId: string): Promise<void>;
6426
+ /**
6427
+ * Re-sends an organization invitation email as a global admin.
6428
+ * @param options - Organization, email, role, and optional application and teams
6429
+ */
6430
+ resendInvite(options: ResendAdminInviteOptions): Promise<void>;
6431
+ /**
6432
+ * Invites several users to an organization in one call. Failures are
6433
+ * isolated per email in the results payload.
6434
+ *
6435
+ * @param options - Organization, emails, role, and optional teams/application
6436
+ * @returns Per-email invite outcomes
6437
+ */
6438
+ inviteOrganizationUsers(options: InviteAdminOrganizationUsersOptions): Promise<{
6439
+ data: InviteAdminOrganizationUsersResult;
6440
+ } | null>;
6151
6441
  }
6152
6442
 
6153
6443
  /**
@@ -7075,5 +7365,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
7075
7365
  */
7076
7366
  declare function extractTokenPayload(token: string): DecodedJWTPayload;
7077
7367
 
7078
- export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
7079
- export type { APIClient, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberRecord, AdminOrganizationTeamRecord, AdminUser, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, DecodedJWTPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, Invitation, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
7368
+ export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
7369
+ export type { APIClient, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, DecodedJWTPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, Invitation, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };