@authyon/auth 0.2.0-beta.30 → 0.2.0-beta.32

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.
@@ -236,11 +236,41 @@ type TenantOrder = TenantOrderField | {
236
236
  * There is no `status`: only active sub-tenants are listed, since everything
237
237
  * below a disabled one is closed to reads from above.
238
238
  */
239
- interface SubTenantListOptions extends PaginationOptions {
239
+ interface SubTenantListOptions extends PaginationOptions, PermissionFilterOptions {
240
240
  search?: string;
241
241
  filter?: string[];
242
242
  orderBy?: TenantOrder;
243
243
  }
244
+ /**
245
+ * Keep only the tenants where the user holds these permissions.
246
+ *
247
+ * - `permission`: up to 10 concrete values (no wildcards). Custom permissions
248
+ * count as well as Authyon's own.
249
+ * - `permissionMatch`: `"all"` (the default) needs every value; `"any"` needs
250
+ * one.
251
+ *
252
+ * On a tenant the user belongs to, it is what that membership grants. On one
253
+ * reached from above, it is what switching into it would grant (the nearest
254
+ * ancestor membership holding `subtenants:tree:switch`) plus the
255
+ * `subtenants:tree:*` values held above — the same rules the routes apply, so
256
+ * the filter never offers an action that would then be refused. A grant of
257
+ * `tenants:**` holds `tenants:members:invite`. Needs the Authyon API of
258
+ * 2026-11-27 or newer; an older one ignores it.
259
+ */
260
+ interface PermissionFilterOptions {
261
+ permission?: string[];
262
+ permissionMatch?: "all" | "any";
263
+ }
264
+ /**
265
+ * What `tenants.list()` accepts. `search` keeps the tenants whose name, slug
266
+ * or public metadata contain it, ignoring case (at most 100 characters);
267
+ * `skip`/`take` (1-100) cut a window out of the list. Without `take` the whole
268
+ * list comes back, as a plain array — not a `Paged<T>`. Needs the Authyon API
269
+ * of 2026-11-27 or newer, which is the first that reads these options at all.
270
+ */
271
+ interface TenantListParams extends PaginationOptions, PermissionFilterOptions {
272
+ search?: string;
273
+ }
244
274
  /** The tenant another one hangs from: enough to name it in a breadcrumb. */
245
275
  interface TenantParent {
246
276
  id: string;
@@ -268,45 +298,46 @@ interface SubTenant {
268
298
  }
269
299
 
270
300
  /**
271
- * Organization membership (the Authyon API calls this a "tenant" on the
272
- * wire — the SDK exposes it as "organization").
301
+ * A tenant the user can reach: one they belong to, or one below it. The SDK
302
+ * uses the API's own vocabulary — tenant and sub-tenant — on every route,
303
+ * type and field.
273
304
  */
274
- interface Organization {
305
+ interface Tenant {
275
306
  id: string;
276
307
  slug: string;
277
308
  name?: string;
278
309
  description?: string;
279
310
  roles?: string[];
280
- /** JSON-encoded values for the organization's configured custom fields. */
311
+ /** JSON-encoded values for the tenant's configured custom fields. */
281
312
  customFields?: string;
282
- /** JSON-encoded metadata visible to members of the organization. */
313
+ /** JSON-encoded metadata visible to members of the tenant. */
283
314
  publicMetadata?: string;
284
315
  /**
285
- * `false` for an organization the user belongs to. `true` for one they may
316
+ * `false` for a tenant the user belongs to. `true` for one they may
286
317
  * switch into from an ancestor without being a member — show it as borrowed
287
- * rather than owned. Only `organization.list()` fills it.
318
+ * rather than owned. Only `tenants.list()` fills it.
288
319
  *
289
- * Ignoring the field still leaves you with a switchable organization, which
320
+ * Ignoring the field still leaves you with a switchable tenant, which
290
321
  * is what it is. Absent on an API older than 2026-10-31.
291
322
  */
292
323
  inherited?: boolean;
293
- /** Distance from the root: `0` at a root organization. Indent the switcher by it. */
324
+ /** Distance from the root: `0` at a root tenant. Indent the switcher by it. */
294
325
  depth?: number;
295
326
  /**
296
- * The parent's id, `null` for a root. Only `organization.list()` fills it —
327
+ * The parent's id, `null` for a root. Only `tenants.list()` fills it —
297
328
  * with `depth`, it nests the switcher's flat list into a tree. `get`,
298
329
  * `create` and `rename` send `parent` instead. Absent from an API older than
299
330
  * 2026-11-26.
300
331
  */
301
332
  parentTenantId?: string | null;
302
333
  /**
303
- * The organization it hangs from, `null` for a root — the same shape the
304
- * sub-organization listing uses. Filled by `get`, `create` and `rename`;
334
+ * The tenant it hangs from, `null` for a root — the same shape the
335
+ * sub-tenant listing uses. Filled by `get`, `create` and `rename`;
305
336
  * absent from an API older than 2026-11-26.
306
337
  */
307
338
  parent?: TenantParent | null;
308
339
  /**
309
- * A disabled organization still reads, but every change to it is refused
340
+ * A disabled tenant still reads, but every change to it is refused
310
341
  * with `tenant.disabled`. Filled by `get`, `create` and `rename`; absent from
311
342
  * an API older than 2026-11-26.
312
343
  */
@@ -314,8 +345,8 @@ interface Organization {
314
345
  /** Roles the user holds in it; empty when they reach it from an ancestor. Filled by `get`, `create` and `rename`. */
315
346
  myRoles?: string[];
316
347
  /**
317
- * The organization-route permissions the user can use on it, as concrete
318
- * values: `tenants:*` on their own organization, `subtenants:tree:*` from
348
+ * The tenant-route permissions the user can use on it, as concrete
349
+ * values: `tenants:*` on their own tenant, `subtenants:tree:*` from
319
350
  * above. This, not `myRoles`, is what decides which actions to offer — the
320
351
  * creator holds direct grants and no role. Filled by `get`, `create` and
321
352
  * `rename`; absent from an API older than 2026-11-26.
@@ -324,33 +355,25 @@ interface Organization {
324
355
  /** How many members it has. Filled by `get`, `create` and `rename`. */
325
356
  memberCount?: number;
326
357
  }
327
- /** One direct sub-organization, as `organization.subOrganizations` lists it. */
328
- type SubOrganization = SubTenant;
329
- /**
330
- * What `organization.subOrganizations` accepts — see `SubTenantListOptions`:
331
- * `skip`/`take`, `search`, `filter` (public scope only, built with
332
- * `tenantFilter`) and `orderBy`.
333
- */
334
- type SubOrganizationListOptions = SubTenantListOptions;
335
- /** POST /auth/tenants — creates an organization owned by the signed-in user. */
336
- interface CreateOrganizationInput {
358
+ /** POST /auth/tenants — creates a tenant owned by the signed-in user. */
359
+ interface CreateTenantInput {
337
360
  name?: string;
338
361
  slug?: string;
339
362
  description?: string;
340
363
  customFields?: Record<string, unknown>;
341
364
  /**
342
- * Creates the organization underneath an existing one. Omitted creates a
343
- * root organization, which is all this endpoint could do before the
365
+ * Creates the tenant underneath an existing one. Omitted creates a
366
+ * root tenant, which is all this endpoint could do before the
344
367
  * hierarchy existed.
345
368
  *
346
- * The caller has to belong to the parent (or to an organization above it)
369
+ * The caller has to belong to the parent (or to a tenant above it)
347
370
  * and hold `subtenants:tree:create` there, and the environment's
348
371
  * `maxTenantDepth` has to allow the level — it ships as `1`, roots only.
349
372
  */
350
373
  parentTenantId?: string;
351
374
  }
352
- /** GET /auth/tenants/{organizationId}/members — confirmed against the live API. */
353
- interface OrganizationMember {
375
+ /** GET /auth/tenants/{tenantId}/members — confirmed against the live API. */
376
+ interface TenantMember {
354
377
  userId: string;
355
378
  email?: string;
356
379
  username?: string;
@@ -374,11 +397,11 @@ interface InviteMemberInput {
374
397
  roles: string[];
375
398
  }
376
399
  /**
377
- * POST /auth/tenants/{organizationId}/invites — invite an address that may not
400
+ * POST /auth/tenants/{tenantId}/invites — invite an address that may not
378
401
  * have an account yet; accepting creates it. `sendEmail` defaults to `true`;
379
402
  * `false` only returns the link, for delivery through your own channel.
380
403
  */
381
- interface OrganizationInviteInput {
404
+ interface TenantInviteInput {
382
405
  email: string;
383
406
  roles?: string[];
384
407
  sendEmail?: boolean;
@@ -391,7 +414,7 @@ interface OrganizationInviteInput {
391
414
  }
392
415
  /** Returned when an invite is created or re-issued. `acceptUrl` is only ever
393
416
  * readable here — the API keeps a hash of the token, not the token. */
394
- interface OrganizationInviteIssued {
417
+ interface TenantInviteIssued {
395
418
  id: string;
396
419
  tenantId: string;
397
420
  email: string;
@@ -401,13 +424,13 @@ interface OrganizationInviteIssued {
401
424
  emailSent: boolean;
402
425
  redirectUri: string | null;
403
426
  }
404
- type OrganizationInviteStatus = "pending" | "accepted" | "revoked" | "expired";
405
- interface OrganizationInvite {
427
+ type TenantInviteStatus = "pending" | "accepted" | "revoked" | "expired";
428
+ interface TenantInvite {
406
429
  id: string;
407
430
  tenantId: string;
408
431
  email: string;
409
432
  roles: string[];
410
- status: OrganizationInviteStatus;
433
+ status: TenantInviteStatus;
411
434
  createdAt: string;
412
435
  expiresAt: string;
413
436
  emailSentAt: string | null;
@@ -418,7 +441,7 @@ interface OrganizationInvite {
418
441
  redirectUri: string | null;
419
442
  }
420
443
  /** POST /auth/tenant-invites/preview — what an accept page shows before the invitee commits. */
421
- interface OrganizationInvitePreview {
444
+ interface TenantInvitePreview {
422
445
  tenantId: string;
423
446
  tenantName: string;
424
447
  email: string;
@@ -454,7 +477,7 @@ interface PasswordResetCompleted {
454
477
  redirectUri: string | null;
455
478
  }
456
479
  /** POST /auth/tenant-invites/accept — everything but `token` is ignored when the address already has an account. */
457
- interface AcceptOrganizationInviteInput {
480
+ interface AcceptTenantInviteInput {
458
481
  token: string;
459
482
  username?: string;
460
483
  password?: string;
@@ -467,7 +490,7 @@ interface AcceptOrganizationInviteInput {
467
490
  */
468
491
  customFields?: Record<string, unknown>;
469
492
  }
470
- interface OrganizationInviteAccepted {
493
+ interface TenantInviteAccepted {
471
494
  tenantId: string;
472
495
  tenantName: string;
473
496
  userId: string;
@@ -488,8 +511,13 @@ interface User {
488
511
  permissions?: string[];
489
512
  createdAt?: string;
490
513
  lastLoginAt?: string;
491
- organizations?: Organization[];
492
- activeOrganization?: Organization | null;
514
+ tenants?: Tenant[];
515
+ /** The tenant the session is scoped to (the token's `tenant_id`), or `null`. */
516
+ activeTenant?: Tenant | null;
517
+ /** @deprecated Use `tenants`. Same value; removed in a later release. */
518
+ organizations?: Tenant[];
519
+ /** @deprecated Use `activeTenant`. Same value; removed in a later release. */
520
+ activeOrganization?: Tenant | null;
493
521
  /** Actions the user must complete before continuing (e.g. confirm e-mail). */
494
522
  pendencies?: string[];
495
523
  /** Security methods active on the account (authenticator, email code, passkey, SSO…). */
@@ -529,7 +557,9 @@ interface LoginInput {
529
557
  email?: string;
530
558
  username?: string;
531
559
  password: string;
532
- /** Optional organization to scope the session to (sent as `tenantSlug`). */
560
+ /** Optional tenant to scope the session to. */
561
+ tenantSlug?: string;
562
+ /** @deprecated Use `tenantSlug`. */
533
563
  organizationSlug?: string;
534
564
  }
535
565
  /** A completed WebAuthn ceremony, handed back to the server to finish login/registration. */
@@ -601,7 +631,7 @@ interface Activity {
601
631
  /** JSON-encoded string — `JSON.parse` it for the event-specific payload. */
602
632
  payloadJson?: string;
603
633
  }
604
- /** A role available within an organization (tenant). */
634
+ /** A role available within a tenant. */
605
635
  interface Role {
606
636
  id: string;
607
637
  name: string;
@@ -624,7 +654,7 @@ interface SessionInfo {
624
654
  }
625
655
  /**
626
656
  * POST /auth/validate — confirmed against the live API. The wire shape is
627
- * `{ valid, reason, profile }`, not `{ user, organization }` as the
657
+ * `{ valid, reason, profile }`, not `{ user, tenant }` as the
628
658
  * OpenAPI schema (which didn't document response bodies) suggested.
629
659
  * `profile` is `null` for machine tokens (there's no user behind them) and
630
660
  * for tokens that fail validation.
@@ -690,6 +720,31 @@ interface AuthyonClientOptions {
690
720
  fetch?: typeof fetch;
691
721
  }
692
722
 
723
+ /** @deprecated Use `Tenant`. */
724
+ type Organization = Tenant;
725
+ /** @deprecated Use `SubTenant`. */
726
+ type SubOrganization = SubTenant;
727
+ /** @deprecated Use `SubTenantListOptions`. */
728
+ type SubOrganizationListOptions = SubTenantListOptions;
729
+ /** @deprecated Use `CreateTenantInput`. */
730
+ type CreateOrganizationInput = CreateTenantInput;
731
+ /** @deprecated Use `TenantMember`. */
732
+ type OrganizationMember = TenantMember;
733
+ /** @deprecated Use `TenantInviteInput`. */
734
+ type OrganizationInviteInput = TenantInviteInput;
735
+ /** @deprecated Use `TenantInviteIssued`. */
736
+ type OrganizationInviteIssued = TenantInviteIssued;
737
+ /** @deprecated Use `TenantInviteStatus`. */
738
+ type OrganizationInviteStatus = TenantInviteStatus;
739
+ /** @deprecated Use `TenantInvite`. */
740
+ type OrganizationInvite = TenantInvite;
741
+ /** @deprecated Use `TenantInvitePreview`. */
742
+ type OrganizationInvitePreview = TenantInvitePreview;
743
+ /** @deprecated Use `AcceptTenantInviteInput`. */
744
+ type AcceptOrganizationInviteInput = AcceptTenantInviteInput;
745
+ /** @deprecated Use `TenantInviteAccepted`. */
746
+ type OrganizationInviteAccepted = TenantInviteAccepted;
747
+
693
748
  declare class AuthyonClient {
694
749
  private readonly envKey;
695
750
  private readonly clientIp?;
@@ -832,51 +887,70 @@ declare class AuthyonClient {
832
887
  */
833
888
  confirmPasswordReset: (token: string, newPassword: string) => Promise<PasswordResetCompleted>;
834
889
  };
835
- readonly organization: {
890
+ readonly tenants: {
836
891
  /**
837
- * GET /auth/tenants — filterable list of organization memberships.
892
+ * GET /auth/tenants — filterable list of tenant memberships.
838
893
  *
839
- * Also lists the organizations below them that the user may switch into
894
+ * Also lists the tenants below them that the user may switch into
840
895
  * without being a member, marked `inherited` — only the ones that actually
841
- * carry `subtenants:tree:switch`, so the switcher never offers an
842
- * organization the switch would then refuse. `depth` indents the list into
896
+ * carry `subtenants:tree:switch`, so the switcher never offers a
897
+ * tenant the switch would then refuse. `depth` indents the list into
843
898
  * the tree it describes.
899
+ *
900
+ * `search`, `skip`/`take` and the permission filter (`permission`,
901
+ * `permissionMatch`) narrow it — see `TenantListParams`. The answer stays
902
+ * a plain array. A bad option raises `RangeError` before any request.
903
+ * APIs older than 2026-11-27 ignored every option and always answered the
904
+ * whole list.
844
905
  */
845
- list: (params?: {
846
- search?: string;
847
- } & PaginationOptions) => Promise<Organization[]>;
906
+ list: (params?: TenantListParams) => Promise<Tenant[]>;
848
907
  /**
849
- * POST /auth/tenants — creates an organization owned by the signed-in
850
- * user (only available when self-service organization creation is
908
+ * POST /auth/tenants — creates a tenant owned by the signed-in
909
+ * user (only available when self-service tenant creation is
851
910
  * enabled for the environment).
852
911
  *
853
912
  * `parentTenantId` nests it under one the user already belongs to, which
854
913
  * needs `subtenants:tree:create` there. The creator lands as the effective
855
914
  * owner either way, with `tenants:settings:manage`,
856
915
  * `tenants:members:invite` and `tenants:members:remove` granted directly
857
- * inside the new organization.
916
+ * inside the new tenant.
917
+ */
918
+ create: (params?: CreateTenantInput) => Promise<Tenant>;
919
+ /**
920
+ * GET /auth/tenants/{tenantId} — one tenant by id: the user's own,
921
+ * or one below it with `subtenants:tree:read` on an ancestor.
922
+ */
923
+ get: (tenantId: string) => Promise<Tenant>;
924
+ /**
925
+ * One tenant by id **or** slug — a UUID goes to `GET /auth/tenants/{id}`,
926
+ * anything else to `GET /auth/tenants/by-slug/{slug}`. Same access rule and
927
+ * same answer as `get`, so a page that only has the slug from its URL
928
+ * doesn't have to page `subTenants.list` to find it.
929
+ *
930
+ * By slug, every refusal answers `tenant.not_found` (a slug is guessable,
931
+ * so "exists, not yours" is never told apart from "doesn't exist"). An
932
+ * empty value raises `RangeError` before any request. The slug route needs
933
+ * the Authyon API of 2026-11-26 or newer.
858
934
  */
859
- create: (params?: CreateOrganizationInput) => Promise<Organization>;
860
- /** GET /auth/tenants/{organizationId} — fetch one of the user's organizations by id. */
861
- get: (organizationId: string) => Promise<Organization>;
935
+ find: (idOrSlug: string) => Promise<Tenant>;
862
936
  /**
863
- * PATCH /auth/tenants/{organizationId} — renames the organization.
937
+ * PATCH /auth/tenants/{tenantId} — renames the tenant.
864
938
  *
865
939
  * Requires the `tenants:settings:manage` custom permission on it, or
866
- * `subtenants:tree:manage` on an organization above it. The value was
940
+ * `subtenants:tree:manage` on a tenant above it. The value was
867
941
  * spelled `tenants:manage` before 2026-10-31 — two segments, which the API
868
942
  * could not store, so the endpoint refused everyone who had been granted
869
943
  * it.
870
944
  */
871
- rename: (organizationId: string, name: string) => Promise<Organization>;
945
+ rename: (tenantId: string, name: string) => Promise<Tenant>;
872
946
  /**
873
947
  * POST /auth/switch-tenant — issues a fresh token scoped to the new
874
- * organization.
948
+ * tenant.
875
949
  *
876
- * Membership is enough for one of the user's own organizations. Descending
877
- * into one below it takes `subtenants:tree:switch` at the organization they
950
+ * Membership is enough for one of the user's own tenants. Descending
951
+ * into one below it takes `subtenants:tree:switch` at the tenant they
878
952
  * belong to — deliberately not the same permission as administering a
879
- * sub-organization from the outside, since operating AS it is the larger of
953
+ * sub-tenant from the outside, since operating AS it is the larger of
880
954
  * the two powers. The grants then travel from the node the user belongs to,
881
955
  * and the token says so in its `tenant.via`.
882
956
  *
@@ -884,96 +958,276 @@ declare class AuthyonClient {
884
958
  * `tenant.ancestor_disabled`, and `tenant.path_stale` when the tree moved
885
959
  * under a session — sign-in again rather than retrying.
886
960
  */
887
- switch: (organizationSlug: string) => Promise<Session>;
888
- /** The organization the current session is scoped to, from the cached session — no network call. */
889
- current: () => Organization | null;
961
+ switch: (tenantSlug: string) => Promise<Session>;
962
+ /** The tenant the current session is scoped to, from the cached session — no network call. */
963
+ current: () => Tenant | null;
890
964
  members: {
891
965
  /**
892
- * GET /auth/tenants/{organizationId}/members — paginated list of an
893
- * organization's members, newest first, in the `Paged<T>` envelope every
966
+ * GET /auth/tenants/{tenantId}/members — paginated list of an
967
+ * tenant's members, newest first, in the `Paged<T>` envelope every
894
968
  * other `skip`/`take` endpoint returns. `search` matches email, username
895
969
  * or name; at most 100 characters, and `take` 1-100, checked before any
896
970
  * request.
897
971
  */
898
- list: (organizationId: string, params?: MemberListOptions) => Promise<Paged<OrganizationMember>>;
972
+ list: (tenantId: string, params?: MemberListOptions) => Promise<Paged<TenantMember>>;
899
973
  /**
900
- * POST /auth/tenants/{organizationId}/members — add an existing
974
+ * POST /auth/tenants/{tenantId}/members — add an existing
901
975
  * environment user by e-mail (no e-mail is sent). To invite an address
902
- * that may not have an account yet, use `organization.invites.create`.
976
+ * that may not have an account yet, use `tenants.invites.create`.
903
977
  */
904
- invite: (organizationId: string, params: InviteMemberInput) => Promise<void>;
905
- /** DELETE /auth/tenants/{organizationId}/members/{userId} — remove a member. */
906
- remove: (organizationId: string, userId: string) => Promise<void>;
978
+ invite: (tenantId: string, params: InviteMemberInput) => Promise<void>;
979
+ /** DELETE /auth/tenants/{tenantId}/members/{userId} — remove a member. */
980
+ remove: (tenantId: string, userId: string) => Promise<void>;
907
981
  };
908
982
  /**
909
983
  * Invites by e-mail or by link. Managing them requires the
910
- * `tenants:members:invite` permission on the organization; `preview` and
984
+ * `tenants:members:invite` permission on the tenant; `preview` and
911
985
  * `accept` are public — the token in the link is the credential.
912
986
  */
913
987
  invites: {
914
- /** GET /auth/tenants/{organizationId}/invites — every invite with its status, newest first. */
915
- list: (organizationId: string) => Promise<OrganizationInvite[]>;
988
+ /** GET /auth/tenants/{tenantId}/invites — every invite with its status, newest first. */
989
+ list: (tenantId: string) => Promise<TenantInvite[]>;
916
990
  /**
917
- * POST /auth/tenants/{organizationId}/invites — invite an address.
991
+ * POST /auth/tenants/{tenantId}/invites — invite an address.
918
992
  * Always returns `acceptUrl`; with `sendEmail: false` Authyon does not
919
993
  * mail it and you deliver the link yourself. The link is valid for 7
920
994
  * days, once, and can't be read again later.
921
995
  */
922
- create: (organizationId: string, params: OrganizationInviteInput) => Promise<OrganizationInviteIssued>;
996
+ create: (tenantId: string, params: TenantInviteInput) => Promise<TenantInviteIssued>;
923
997
  /**
924
- * POST /auth/tenants/{organizationId}/invites/{inviteId}/resend — issue
998
+ * POST /auth/tenants/{tenantId}/invites/{inviteId}/resend — issue
925
999
  * a new link (the previous one stops working), mailing it unless
926
1000
  * `sendEmail` is `false`.
927
1001
  */
928
- resend: (organizationId: string, inviteId: string, params?: {
1002
+ resend: (tenantId: string, inviteId: string, params?: {
929
1003
  sendEmail?: boolean;
930
- }) => Promise<OrganizationInviteIssued>;
931
- /** DELETE /auth/tenants/{organizationId}/invites/{inviteId} — revoke a pending invite. */
932
- revoke: (organizationId: string, inviteId: string) => Promise<void>;
1004
+ }) => Promise<TenantInviteIssued>;
1005
+ /** DELETE /auth/tenants/{tenantId}/invites/{inviteId} — revoke a pending invite. */
1006
+ revoke: (tenantId: string, inviteId: string) => Promise<void>;
933
1007
  /**
934
1008
  * POST /auth/tenant-invites/preview — public. Read the `token` query
935
1009
  * parameter of the invite link and pick the form: one click when
936
1010
  * `accountExists`, sign-up otherwise.
937
1011
  */
938
- preview: (token: string) => Promise<OrganizationInvitePreview>;
1012
+ preview: (token: string) => Promise<TenantInvitePreview>;
939
1013
  /**
940
- * POST /auth/tenant-invites/accept — public. Joins the organization; for
1014
+ * POST /auth/tenant-invites/accept — public. Joins the tenant; for
941
1015
  * an address with no account, also creates it (password required) with
942
1016
  * the e-mail already confirmed. Does not sign the user in.
943
1017
  */
944
- accept: (params: AcceptOrganizationInviteInput) => Promise<OrganizationInviteAccepted>;
1018
+ accept: (params: AcceptTenantInviteInput) => Promise<TenantInviteAccepted>;
945
1019
  };
946
1020
  /**
947
- * The direct, active sub-organizations of an organization. One level per
1021
+ * The direct, active sub-tenants of a tenant. One level per
948
1022
  * call: each row's `childCount` says where the next call is worth making,
949
1023
  * which is what a lazily expanded tree asks for.
950
1024
  *
951
- * Needs `subtenants:tree:read` on the organization or on one above it —
952
- * even on the user's own organization, since listing the children is
1025
+ * Needs `subtenants:tree:read` on the tenant or on one above it —
1026
+ * even on the user's own tenant, since listing the children is
953
1027
  * reading below it. Paged like every other `skip`/`take` listing, with
954
1028
  * `search` (name, slug, description and public metadata), `filter` (public
955
1029
  * scope only — build them with `tenantFilter`) and `orderBy`
956
1030
  * (`name` | `createdAt` | `updatedAt`, ascending or descending). A bad
957
1031
  * option raises `RangeError` before any request.
958
1032
  *
959
- * Not the same list as `organization.list()`, which is the switcher's and
1033
+ * Not the same list as `tenants.list()`, which is the switcher's and
960
1034
  * only brings what `subtenants:tree:switch` lets the user enter. Requires
961
1035
  * the Authyon API of 2026-11-26 or newer.
962
1036
  */
1037
+ subTenants: {
1038
+ /** GET /auth/tenants/{tenantId}/subtenants. */
1039
+ list: (tenantId: string, params?: SubTenantListOptions) => Promise<Paged<SubTenant>>;
1040
+ /**
1041
+ * GET /auth/tenants/subtenants — the same, for the tenant the
1042
+ * session is scoped to (`tenants.current()`, the token's
1043
+ * `tenant_id`). Same permission rule; answers `tenant.no_active_tenant`
1044
+ * when the session never switched into one.
1045
+ */
1046
+ listCurrent: (params?: SubTenantListOptions) => Promise<Paged<SubTenant>>;
1047
+ };
1048
+ roles: {
1049
+ /** GET /auth/tenants/{tenantId}/roles — roles available in the tenant. */
1050
+ list: (tenantId: string) => Promise<Role[]>;
1051
+ };
1052
+ };
1053
+ /**
1054
+ * @deprecated Use `tenants` — the same methods, named after the API's own
1055
+ * vocabulary (`tenants.subTenants` instead of `subOrganizations`). Kept so
1056
+ * code written against 0.2.0-beta.30 and earlier keeps working; removed in a
1057
+ * later release.
1058
+ */
1059
+ readonly organization: {
963
1060
  subOrganizations: {
964
- /** GET /auth/tenants/{organizationId}/subtenants. */
965
- list: (organizationId: string, params?: SubOrganizationListOptions) => Promise<Paged<SubOrganization>>;
1061
+ /** GET /auth/tenants/{tenantId}/subtenants. */
1062
+ list: (tenantId: string, params?: SubTenantListOptions) => Promise<Paged<SubTenant>>;
1063
+ /**
1064
+ * GET /auth/tenants/subtenants — the same, for the tenant the
1065
+ * session is scoped to (`tenants.current()`, the token's
1066
+ * `tenant_id`). Same permission rule; answers `tenant.no_active_tenant`
1067
+ * when the session never switched into one.
1068
+ */
1069
+ listCurrent: (params?: SubTenantListOptions) => Promise<Paged<SubTenant>>;
1070
+ };
1071
+ /**
1072
+ * GET /auth/tenants — filterable list of tenant memberships.
1073
+ *
1074
+ * Also lists the tenants below them that the user may switch into
1075
+ * without being a member, marked `inherited` — only the ones that actually
1076
+ * carry `subtenants:tree:switch`, so the switcher never offers a
1077
+ * tenant the switch would then refuse. `depth` indents the list into
1078
+ * the tree it describes.
1079
+ *
1080
+ * `search`, `skip`/`take` and the permission filter (`permission`,
1081
+ * `permissionMatch`) narrow it — see `TenantListParams`. The answer stays
1082
+ * a plain array. A bad option raises `RangeError` before any request.
1083
+ * APIs older than 2026-11-27 ignored every option and always answered the
1084
+ * whole list.
1085
+ */
1086
+ list: (params?: TenantListParams) => Promise<Tenant[]>;
1087
+ /**
1088
+ * POST /auth/tenants — creates a tenant owned by the signed-in
1089
+ * user (only available when self-service tenant creation is
1090
+ * enabled for the environment).
1091
+ *
1092
+ * `parentTenantId` nests it under one the user already belongs to, which
1093
+ * needs `subtenants:tree:create` there. The creator lands as the effective
1094
+ * owner either way, with `tenants:settings:manage`,
1095
+ * `tenants:members:invite` and `tenants:members:remove` granted directly
1096
+ * inside the new tenant.
1097
+ */
1098
+ create: (params?: CreateTenantInput) => Promise<Tenant>;
1099
+ /**
1100
+ * GET /auth/tenants/{tenantId} — one tenant by id: the user's own,
1101
+ * or one below it with `subtenants:tree:read` on an ancestor.
1102
+ */
1103
+ get: (tenantId: string) => Promise<Tenant>;
1104
+ /**
1105
+ * One tenant by id **or** slug — a UUID goes to `GET /auth/tenants/{id}`,
1106
+ * anything else to `GET /auth/tenants/by-slug/{slug}`. Same access rule and
1107
+ * same answer as `get`, so a page that only has the slug from its URL
1108
+ * doesn't have to page `subTenants.list` to find it.
1109
+ *
1110
+ * By slug, every refusal answers `tenant.not_found` (a slug is guessable,
1111
+ * so "exists, not yours" is never told apart from "doesn't exist"). An
1112
+ * empty value raises `RangeError` before any request. The slug route needs
1113
+ * the Authyon API of 2026-11-26 or newer.
1114
+ */
1115
+ find: (idOrSlug: string) => Promise<Tenant>;
1116
+ /**
1117
+ * PATCH /auth/tenants/{tenantId} — renames the tenant.
1118
+ *
1119
+ * Requires the `tenants:settings:manage` custom permission on it, or
1120
+ * `subtenants:tree:manage` on a tenant above it. The value was
1121
+ * spelled `tenants:manage` before 2026-10-31 — two segments, which the API
1122
+ * could not store, so the endpoint refused everyone who had been granted
1123
+ * it.
1124
+ */
1125
+ rename: (tenantId: string, name: string) => Promise<Tenant>;
1126
+ /**
1127
+ * POST /auth/switch-tenant — issues a fresh token scoped to the new
1128
+ * tenant.
1129
+ *
1130
+ * Membership is enough for one of the user's own tenants. Descending
1131
+ * into one below it takes `subtenants:tree:switch` at the tenant they
1132
+ * belong to — deliberately not the same permission as administering a
1133
+ * sub-tenant from the outside, since operating AS it is the larger of
1134
+ * the two powers. The grants then travel from the node the user belongs to,
1135
+ * and the token says so in its `tenant.via`.
1136
+ *
1137
+ * Refusals: `tenant.outside_scope` (no path down to it),
1138
+ * `tenant.ancestor_disabled`, and `tenant.path_stale` when the tree moved
1139
+ * under a session — sign-in again rather than retrying.
1140
+ */
1141
+ switch: (tenantSlug: string) => Promise<Session>;
1142
+ /** The tenant the current session is scoped to, from the cached session — no network call. */
1143
+ current: () => Tenant | null;
1144
+ members: {
1145
+ /**
1146
+ * GET /auth/tenants/{tenantId}/members — paginated list of an
1147
+ * tenant's members, newest first, in the `Paged<T>` envelope every
1148
+ * other `skip`/`take` endpoint returns. `search` matches email, username
1149
+ * or name; at most 100 characters, and `take` 1-100, checked before any
1150
+ * request.
1151
+ */
1152
+ list: (tenantId: string, params?: MemberListOptions) => Promise<Paged<TenantMember>>;
1153
+ /**
1154
+ * POST /auth/tenants/{tenantId}/members — add an existing
1155
+ * environment user by e-mail (no e-mail is sent). To invite an address
1156
+ * that may not have an account yet, use `tenants.invites.create`.
1157
+ */
1158
+ invite: (tenantId: string, params: InviteMemberInput) => Promise<void>;
1159
+ /** DELETE /auth/tenants/{tenantId}/members/{userId} — remove a member. */
1160
+ remove: (tenantId: string, userId: string) => Promise<void>;
1161
+ };
1162
+ /**
1163
+ * Invites by e-mail or by link. Managing them requires the
1164
+ * `tenants:members:invite` permission on the tenant; `preview` and
1165
+ * `accept` are public — the token in the link is the credential.
1166
+ */
1167
+ invites: {
1168
+ /** GET /auth/tenants/{tenantId}/invites — every invite with its status, newest first. */
1169
+ list: (tenantId: string) => Promise<TenantInvite[]>;
1170
+ /**
1171
+ * POST /auth/tenants/{tenantId}/invites — invite an address.
1172
+ * Always returns `acceptUrl`; with `sendEmail: false` Authyon does not
1173
+ * mail it and you deliver the link yourself. The link is valid for 7
1174
+ * days, once, and can't be read again later.
1175
+ */
1176
+ create: (tenantId: string, params: TenantInviteInput) => Promise<TenantInviteIssued>;
1177
+ /**
1178
+ * POST /auth/tenants/{tenantId}/invites/{inviteId}/resend — issue
1179
+ * a new link (the previous one stops working), mailing it unless
1180
+ * `sendEmail` is `false`.
1181
+ */
1182
+ resend: (tenantId: string, inviteId: string, params?: {
1183
+ sendEmail?: boolean;
1184
+ }) => Promise<TenantInviteIssued>;
1185
+ /** DELETE /auth/tenants/{tenantId}/invites/{inviteId} — revoke a pending invite. */
1186
+ revoke: (tenantId: string, inviteId: string) => Promise<void>;
1187
+ /**
1188
+ * POST /auth/tenant-invites/preview — public. Read the `token` query
1189
+ * parameter of the invite link and pick the form: one click when
1190
+ * `accountExists`, sign-up otherwise.
1191
+ */
1192
+ preview: (token: string) => Promise<TenantInvitePreview>;
1193
+ /**
1194
+ * POST /auth/tenant-invites/accept — public. Joins the tenant; for
1195
+ * an address with no account, also creates it (password required) with
1196
+ * the e-mail already confirmed. Does not sign the user in.
1197
+ */
1198
+ accept: (params: AcceptTenantInviteInput) => Promise<TenantInviteAccepted>;
1199
+ };
1200
+ /**
1201
+ * The direct, active sub-tenants of a tenant. One level per
1202
+ * call: each row's `childCount` says where the next call is worth making,
1203
+ * which is what a lazily expanded tree asks for.
1204
+ *
1205
+ * Needs `subtenants:tree:read` on the tenant or on one above it —
1206
+ * even on the user's own tenant, since listing the children is
1207
+ * reading below it. Paged like every other `skip`/`take` listing, with
1208
+ * `search` (name, slug, description and public metadata), `filter` (public
1209
+ * scope only — build them with `tenantFilter`) and `orderBy`
1210
+ * (`name` | `createdAt` | `updatedAt`, ascending or descending). A bad
1211
+ * option raises `RangeError` before any request.
1212
+ *
1213
+ * Not the same list as `tenants.list()`, which is the switcher's and
1214
+ * only brings what `subtenants:tree:switch` lets the user enter. Requires
1215
+ * the Authyon API of 2026-11-26 or newer.
1216
+ */
1217
+ subTenants: {
1218
+ /** GET /auth/tenants/{tenantId}/subtenants. */
1219
+ list: (tenantId: string, params?: SubTenantListOptions) => Promise<Paged<SubTenant>>;
966
1220
  /**
967
- * GET /auth/tenants/subtenants — the same, for the organization the
968
- * session is scoped to (`organization.current()`, the token's
1221
+ * GET /auth/tenants/subtenants — the same, for the tenant the
1222
+ * session is scoped to (`tenants.current()`, the token's
969
1223
  * `tenant_id`). Same permission rule; answers `tenant.no_active_tenant`
970
1224
  * when the session never switched into one.
971
1225
  */
972
- listCurrent: (params?: SubOrganizationListOptions) => Promise<Paged<SubOrganization>>;
1226
+ listCurrent: (params?: SubTenantListOptions) => Promise<Paged<SubTenant>>;
973
1227
  };
974
1228
  roles: {
975
- /** GET /auth/tenants/{organizationId}/roles — roles available in the organization. */
976
- list: (organizationId: string) => Promise<Role[]>;
1229
+ /** GET /auth/tenants/{tenantId}/roles — roles available in the tenant. */
1230
+ list: (tenantId: string) => Promise<Role[]>;
977
1231
  };
978
1232
  };
979
1233
  readonly twoFactor: {
@@ -1167,4 +1421,4 @@ declare function hasPermissionGroup(source: AuthyonPermissionSource | readonly s
1167
1421
  /** Converts Authyon's `subject:action` permission strings to authorization rules. */
1168
1422
  declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
1169
1423
 
1170
- export { type Role as $, AuthyonClient as A, type HttpLogger as B, type ConfirmApprovalInput as C, type InviteMemberInput as D, type LoginInput as E, FetchHttpAdapter as F, type LoginResult as G, type HttpAdapter as H, type IntrospectResult as I, type OrganizationInvite as J, type OrganizationInviteAccepted as K, LoggingHttpAdapter as L, type MemberListOptions as M, type OrganizationInviteInput as N, type Organization as O, type OrganizationInviteIssued as P, type OrganizationInvitePreview as Q, type OrganizationInviteStatus as R, type OrganizationMember as S, type TokenStorage as T, type Paged as U, type PaginationOptions as V, type PasswordResetCompleted as W, type PasswordResetPreview as X, type PasswordResetRequestOptions as Y, type PermissionGroup as Z, type RegisterInput as _, type HttpLoggerOptions as a, type SecurityMethods as a0, type Session as a1, type SessionControllerOptions as a2, type SessionInfo as a3, type SessionSnapshot as a4, type SessionSnapshotListener as a5, type SessionStatus as a6, type SsoProvider as a7, type SubOrganization as a8, type SubOrganizationListOptions as a9, type SubTenant as aa, type SubTenantListOptions as ab, type SubjectApprovals as ac, type SubjectSecurity as ad, type TenantOrder as ae, type TenantOrderField as af, type TenantParent as ag, type TwoFactorChallenge as ah, type TwoFactorMethod as ai, type TwoFactorStatus as aj, type User as ak, type ValidateResult as al, type VerifyTwoFactorInput as am, type WebAuthnAssertion as an, type WebAuthnCeremonyStart as ao, type WebAuthnCredential as ap, createAuthyonAbility as aq, createAuthyonRules as ar, createClient as as, hasPermission as at, hasPermissionGroup as au, type AbilityConditions as b, type AbilityEvent as c, type AbilityListener as d, type AbilityRule as e, type AbilitySubject as f, type AcceptOrganizationInviteInput as g, type Activity as h, type Approval as i, type ApprovalAssurance as j, type ApprovalPayload as k, type ApprovalStatus as l, type ApprovalWebAuthnOptions as m, type AuthEvent as n, type AuthState as o, type AuthStateListener as p, type AuthenticatorSetup as q, AuthyonAbility as r, AuthyonAbilityBuilder as s, type AuthyonAbilityOptions as t, type AuthyonClientOptions as u, type AuthyonPermissionSource as v, AuthyonSessionController as w, type CreateOrganizationInput as x, type HttpAdapterRequest as y, type HttpLogEvent as z };
1424
+ export { type PermissionFilterOptions as $, AuthyonClient as A, type HttpAdapterRequest as B, type ConfirmApprovalInput as C, type HttpLogEvent as D, type HttpLogger as E, FetchHttpAdapter as F, type InviteMemberInput as G, type HttpAdapter as H, type IntrospectResult as I, type LoginInput as J, type LoginResult as K, LoggingHttpAdapter as L, type MemberListOptions as M, type OrganizationInvite as N, type Organization as O, type OrganizationInviteAccepted as P, type OrganizationInviteInput as Q, type OrganizationInviteIssued as R, type OrganizationInvitePreview as S, type TokenStorage as T, type OrganizationInviteStatus as U, type OrganizationMember as V, type Paged as W, type PaginationOptions as X, type PasswordResetCompleted as Y, type PasswordResetPreview as Z, type PasswordResetRequestOptions as _, type HttpLoggerOptions as a, type PermissionGroup as a0, type RegisterInput as a1, type Role as a2, type SecurityMethods as a3, type Session as a4, type SessionControllerOptions as a5, type SessionInfo as a6, type SessionSnapshot as a7, type SessionSnapshotListener as a8, type SessionStatus as a9, type WebAuthnCeremonyStart as aA, type WebAuthnCredential as aB, createAuthyonAbility as aC, createAuthyonRules as aD, createClient as aE, hasPermission as aF, hasPermissionGroup as aG, type SsoProvider as aa, type SubOrganization as ab, type SubOrganizationListOptions as ac, type SubTenant as ad, type SubTenantListOptions as ae, type SubjectApprovals as af, type SubjectSecurity as ag, type Tenant as ah, type TenantInvite as ai, type TenantInviteAccepted as aj, type TenantInviteInput as ak, type TenantInviteIssued as al, type TenantInvitePreview as am, type TenantInviteStatus as an, type TenantListParams as ao, type TenantMember as ap, type TenantOrder as aq, type TenantOrderField as ar, type TenantParent as as, type TwoFactorChallenge as at, type TwoFactorMethod as au, type TwoFactorStatus as av, type User as aw, type ValidateResult as ax, type VerifyTwoFactorInput as ay, type WebAuthnAssertion as az, type AbilityConditions as b, type AbilityEvent as c, type AbilityListener as d, type AbilityRule as e, type AbilitySubject as f, type AcceptOrganizationInviteInput as g, type AcceptTenantInviteInput as h, type Activity as i, type Approval as j, type ApprovalAssurance as k, type ApprovalPayload as l, type ApprovalStatus as m, type ApprovalWebAuthnOptions as n, type AuthEvent as o, type AuthState as p, type AuthStateListener as q, type AuthenticatorSetup as r, AuthyonAbility as s, AuthyonAbilityBuilder as t, type AuthyonAbilityOptions as u, type AuthyonClientOptions as v, type AuthyonPermissionSource as w, AuthyonSessionController as x, type CreateOrganizationInput as y, type CreateTenantInput as z };