@authyon/server 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.
package/README.md CHANGED
@@ -40,7 +40,7 @@ O client também aceita `httpLogger: { enabled, logger? }`. A configuração é
40
40
  ## Sessão web no BFF (código ainda não publicado)
41
41
 
42
42
  O novo entrypoint `@authyon/server/bff` oferece login, 2FA, sessão HttpOnly,
43
- renovação sob demanda, logout e troca de organização. Os tokens ficam no servidor,
43
+ renovação sob demanda, logout e troca de tenant. Os tokens ficam no servidor,
44
44
  com adaptador Redis cifrado e compare-and-swap para concorrência entre instâncias.
45
45
  Reutiliza os endpoints existentes e o cliente de validação server-side.
46
46
 
@@ -93,7 +93,7 @@ const authyon = createClient({
93
93
 
94
94
  ```ts
95
95
  const { active, sub } = await authyon.introspect(token); // leve
96
- const { user, organization } = await authyon.validate(token); // recomendado — cross-checa revogação
96
+ const { valid, user } = await authyon.validate(token); // recomendado — cross-checa revogação
97
97
  ```
98
98
 
99
99
  Veja [`examples/tokenVerification.ts`](./examples/tokenVerification.ts) para um middleware completo.
@@ -118,7 +118,7 @@ await authyon.environment.roles.create({ name: "support", permissions: ["tickets
118
118
  await authyon.environment.audit.list({ take: 50 });
119
119
  ```
120
120
 
121
- Veja [`examples/organizationMembership.ts`](./examples/organizationMembership.ts) para o fluxo completo, incluindo as rotas de backend que o `@authyon/auth` chamaria.
121
+ Veja [`examples/tenantMembership.ts`](./examples/tenantMembership.ts) para o fluxo completo, incluindo as rotas de backend que o `@authyon/auth` chamaria.
122
122
 
123
123
  Namespaces disponíveis: `environment.users`, `environment.tenants` (com `.members` e `.roles` aninhados), `environment.roles`, `environment.permissions`, `environment.audit`. OTP e aprovações ficam em `security` (veja abaixo).
124
124
 
@@ -493,7 +493,7 @@ Configure `envKey` para `user()`. `members.invite` associa um usuário já
493
493
  cadastrado no ambiente pelo e-mail; não cria conta e não envia link por e-mail.
494
494
  Para isso, use os convites abaixo.
495
495
  A API exige associação/permissões do usuário chamador. No browser, os métodos
496
- existentes `@authyon/auth` → `organization.members.invite/remove` continuam
496
+ existentes `@authyon/auth` → `tenants.members.invite/remove` continuam
497
497
  atendendo esse fluxo. Nunca importe `@authyon/server` no browser.
498
498
 
499
499
  ## Convites de tenant (e-mail ou link)
@@ -1,4 +1,4 @@
1
- import { J as JwksTokenVerifier, A as AuthyonServerClient } from './authyonServerClient-C_iWckru.cjs';
1
+ import { J as JwksTokenVerifier, A as AuthyonServerClient } from './authyonServerClient-DqY5OtxL.cjs';
2
2
 
3
3
  type AbilitySubject = string | Record<string, unknown>;
4
4
  type AbilityConditions = Record<string, unknown>;
@@ -1,4 +1,4 @@
1
- import { J as JwksTokenVerifier, A as AuthyonServerClient } from './authyonServerClient-C_iWckru.js';
1
+ import { J as JwksTokenVerifier, A as AuthyonServerClient } from './authyonServerClient-DqY5OtxL.js';
2
2
 
3
3
  type AbilitySubject = string | Record<string, unknown>;
4
4
  type AbilityConditions = Record<string, unknown>;
@@ -209,11 +209,31 @@ type TenantOrder = TenantOrderField | {
209
209
  * There is no `status`: only active sub-tenants are listed, since everything
210
210
  * below a disabled one is closed to reads from above.
211
211
  */
212
- interface SubTenantListOptions extends PaginationOptions {
212
+ interface SubTenantListOptions extends PaginationOptions, PermissionFilterOptions {
213
213
  search?: string;
214
214
  filter?: string[];
215
215
  orderBy?: TenantOrder;
216
216
  }
217
+ /**
218
+ * Keep only the tenants where the user holds these permissions.
219
+ *
220
+ * - `permission`: up to 10 concrete values (no wildcards). Custom permissions
221
+ * count as well as Authyon's own.
222
+ * - `permissionMatch`: `"all"` (the default) needs every value; `"any"` needs
223
+ * one.
224
+ *
225
+ * On a tenant the user belongs to, it is what that membership grants. On one
226
+ * reached from above, it is what switching into it would grant (the nearest
227
+ * ancestor membership holding `subtenants:tree:switch`) plus the
228
+ * `subtenants:tree:*` values held above — the same rules the routes apply, so
229
+ * the filter never offers an action that would then be refused. A grant of
230
+ * `tenants:**` holds `tenants:members:invite`. Needs the Authyon API of
231
+ * 2026-11-27 or newer; an older one ignores it.
232
+ */
233
+ interface PermissionFilterOptions {
234
+ permission?: string[];
235
+ permissionMatch?: "all" | "any";
236
+ }
217
237
  /** The tenant another one hangs from: enough to name it in a breadcrumb. */
218
238
  interface TenantParent {
219
239
  id: string;
@@ -239,6 +259,36 @@ interface SubTenant {
239
259
  /** The tenant it hangs from — the same on every row of a page, carried so a row stands on its own. */
240
260
  parent: TenantParent;
241
261
  }
262
+ /**
263
+ * One tenant as the end-user routes return it (`GET /auth/tenants/{id}` and
264
+ * `/auth/tenants/by-slug/{slug}`): the user's own, or one below it read with
265
+ * `subtenants:tree:read` from an ancestor.
266
+ */
267
+ interface MyTenant {
268
+ id: string;
269
+ slug: string;
270
+ name: string;
271
+ description?: string | null;
272
+ createdAt: string;
273
+ updatedAt?: string | null;
274
+ memberCount: number;
275
+ /** Roles the user holds in it; empty when they reach it from an ancestor. */
276
+ myRoles: string[];
277
+ /**
278
+ * The end-user-route permissions the user can use on it, as concrete values.
279
+ * This, not `myRoles`, is what decides which actions to offer.
280
+ */
281
+ myPermissions?: string[];
282
+ /** JSON-encoded metadata visible to members. */
283
+ publicMetadata: string;
284
+ isDisabled: boolean;
285
+ /** Distance from the root: `0` at a root tenant. */
286
+ depth: number;
287
+ /** `true` when the user reaches it from an ancestor rather than as a member. */
288
+ inherited: boolean;
289
+ /** The tenant it hangs from, `null` for a root. */
290
+ parent: TenantParent | null;
291
+ }
242
292
 
243
293
  /**
244
294
  * Builders for the tenant list's structured filters.
@@ -278,7 +328,7 @@ declare const tenantFilter: {
278
328
  };
279
329
 
280
330
  /** GET/POST /env/tenants — confirmed against the live API. */
281
- interface Organization {
331
+ interface Tenant {
282
332
  id: string;
283
333
  slug: string;
284
334
  name?: string;
@@ -318,7 +368,7 @@ interface Organization {
318
368
  */
319
369
  ancestors?: TenantAncestor[];
320
370
  }
321
- /** One step of the chain above a tenant, as `Organization.ancestors` carries it. */
371
+ /** One step of the chain above a tenant, as `Tenant.ancestors` carries it. */
322
372
  interface TenantAncestor {
323
373
  id: string;
324
374
  name: string;
@@ -496,7 +546,7 @@ interface PermissionsByRole {
496
546
  roles: RolePermissions[];
497
547
  orphans: Permission[];
498
548
  /**
499
- * The permissions Authyon itself checks on the end-user organization routes
549
+ * The permissions Authyon itself checks on the end-user tenant routes
500
550
  * (`tenants:settings:manage`, `tenants:members:invite`,
501
551
  * `tenants:members:remove` and `subtenants:tree:*`), listed whether or not
502
552
  * a role names them. Absent from an API older than 2026-11-25.
@@ -522,7 +572,7 @@ interface CreatePermissionInput {
522
572
  /** Attach the new permission to this role immediately. */
523
573
  attachToRoleId?: string;
524
574
  }
525
- interface CreateOrganizationInput {
575
+ interface CreateTenantInput {
526
576
  name: string;
527
577
  slug: string;
528
578
  description?: string;
@@ -541,7 +591,7 @@ interface CreateOrganizationInput {
541
591
  */
542
592
  parentTenantId?: string;
543
593
  }
544
- interface UpdateOrganizationInput {
594
+ interface UpdateTenantInput {
545
595
  name: string;
546
596
  description?: string;
547
597
  customFields?: Record<string, unknown>;
@@ -561,7 +611,7 @@ interface CreateUserInput {
561
611
  customFields?: Record<string, unknown>;
562
612
  emailConfirmed?: boolean;
563
613
  roles?: string[];
564
- /** Tenants (organizations) to add the user to on creation. */
614
+ /** Tenants to add the user to on creation. */
565
615
  tenantIds?: string[];
566
616
  }
567
617
  /** GET /env/audit — one audit-trail entry, confirmed against the live API. */
@@ -703,6 +753,13 @@ interface AuthyonServerClientOptions {
703
753
  fetch?: typeof fetch;
704
754
  }
705
755
 
756
+ /** @deprecated Use `Tenant`. */
757
+ type Organization = Tenant;
758
+ /** @deprecated Use `CreateTenantInput`. */
759
+ type CreateOrganizationInput = CreateTenantInput;
760
+ /** @deprecated Use `UpdateTenantInput`. */
761
+ type UpdateOrganizationInput = UpdateTenantInput;
762
+
706
763
  /** A token of the requested authentication plane, or a provider called for each request. */
707
764
  type AccessTokenSource = string | (() => string | Promise<string>);
708
765
  interface CredentialListOptions extends PaginationOptions {
@@ -956,6 +1013,19 @@ declare class UserScopedClient {
956
1013
  */
957
1014
  readonly security: SubjectSecurity;
958
1015
  readonly tenants: {
1016
+ /**
1017
+ * GET /auth/tenants/{tenantId} — one tenant, acting as the user: their own,
1018
+ * or one below it with `subtenants:tree:read` on an ancestor.
1019
+ */
1020
+ get: (tenantId: string) => Promise<MyTenant>;
1021
+ /**
1022
+ * One tenant by id **or** slug: a UUID goes to `GET /auth/tenants/{id}`,
1023
+ * anything else to `GET /auth/tenants/by-slug/{slug}`. Same rule and answer
1024
+ * as `get`; by slug every refusal is `tenant.not_found`. An empty value
1025
+ * raises `RangeError` before any request. The slug route needs the Authyon
1026
+ * API of 2026-11-26 or newer.
1027
+ */
1028
+ find: (idOrSlug: string) => Promise<MyTenant>;
959
1029
  /**
960
1030
  * The direct, active sub-tenants of a tenant, acting as the user. One level
961
1031
  * per call: each row's `childCount` says where the next call is worth
@@ -1327,7 +1397,7 @@ declare class AuthyonServerClient {
1327
1397
  * 2026-10-22 ignores `filter` and one older than 2026-10-31 ignores
1328
1398
  * `parentId`, which read as a page that is too wide rather than an error.
1329
1399
  */
1330
- list: (params?: TenantListOptions) => Promise<Paged<Organization>>;
1400
+ list: (params?: TenantListOptions) => Promise<Paged<Tenant>>;
1331
1401
  /**
1332
1402
  * One page of a tenant's direct sub-tenants — `list()` with `parentId`.
1333
1403
  *
@@ -1335,7 +1405,7 @@ declare class AuthyonServerClient {
1335
1405
  * view asks again where that is above zero instead of reading the whole
1336
1406
  * subtree to draw the first level of it.
1337
1407
  */
1338
- children: (parentTenantId: string, params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Organization>>;
1408
+ children: (parentTenantId: string, params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Tenant>>;
1339
1409
  /**
1340
1410
  * One page of the environment's root tenants — `list()` with no parent.
1341
1411
  *
@@ -1344,7 +1414,7 @@ declare class AuthyonServerClient {
1344
1414
  * depth, which is what a flat picker wants and what a tree view must not
1345
1415
  * start from.
1346
1416
  */
1347
- roots: (params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Organization>>;
1417
+ roots: (params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Tenant>>;
1348
1418
  /**
1349
1419
  * Every sub-tenant in the environment, at any depth and under any
1350
1420
  * parent — `list()` with `minDepth: 1`. This is the one page
@@ -1356,7 +1426,7 @@ declare class AuthyonServerClient {
1356
1426
  * Against an Authyon API older than 2026-10-31 the floor is ignored and
1357
1427
  * the roots come back too.
1358
1428
  */
1359
- subTenants: (params?: Omit<TenantListOptions, "parentId" | "minDepth">) => Promise<Paged<Organization>>;
1429
+ subTenants: (params?: Omit<TenantListOptions, "parentId" | "minDepth">) => Promise<Paged<Tenant>>;
1360
1430
  /**
1361
1431
  * POST /env/tenants — create a tenant in the environment.
1362
1432
  *
@@ -1365,18 +1435,18 @@ declare class AuthyonServerClient {
1365
1435
  * so this answers `tenant.depth.not_allowed` until an operator raises it
1366
1436
  * in the console.
1367
1437
  */
1368
- create: (input: CreateOrganizationInput) => Promise<Organization>;
1438
+ create: (input: CreateTenantInput) => Promise<Tenant>;
1369
1439
  /**
1370
1440
  * GET /env/tenants/{tenantId} — fetch a tenant by id.
1371
1441
  *
1372
1442
  * Returns `ancestors` as well, the chain above it root first, so a
1373
1443
  * breadcrumb costs this one call rather than one per level.
1374
1444
  */
1375
- get: (tenantId: string) => Promise<Organization>;
1445
+ get: (tenantId: string) => Promise<Tenant>;
1376
1446
  /** PUT /env/tenants/{tenantId} — update a tenant. */
1377
- update: (tenantId: string, input: UpdateOrganizationInput) => Promise<Organization>;
1447
+ update: (tenantId: string, input: UpdateTenantInput) => Promise<Tenant>;
1378
1448
  /** PUT /env/tenants/{tenantId}/metadata - replace public and private metadata. */
1379
- updateMetadata: (tenantId: string, input: Pick<CreateOrganizationInput, "publicMetadata" | "privateMetadata">) => Promise<void>;
1449
+ updateMetadata: (tenantId: string, input: Pick<CreateTenantInput, "publicMetadata" | "privateMetadata">) => Promise<void>;
1380
1450
  /**
1381
1451
  * POST /env/tenants/{tenantId}/disable — disable without removing tenant
1382
1452
  * data.
@@ -1656,4 +1726,4 @@ declare class TenantScopedClient {
1656
1726
  /** Convenience factory: `const authyon = createClient({ clientId, clientSecret })`. */
1657
1727
  declare function createClient(options?: AuthyonServerClientOptions): AuthyonServerClient;
1658
1728
 
1659
- export { type Permission as $, AuthyonServerClient as A, type BuiltInPermission as B, CLIENT_IP_HEADER as C, type CredentialPermissionsInput as D, type EnvironmentUser as E, FetchHttpAdapter as F, type HttpAdapterRequest as G, type HttpAdapter as H, type HttpLogEvent as I, JwksTokenVerifier as J, type HttpLogger as K, type IntrospectResult as L, type InviteTenantMemberInput as M, type IssuePasswordResetInput as N, type JsonWebKeySet as O, type JwksTokenVerifierOptions as P, LoggingHttpAdapter as Q, type LoginActivity as R, type MemberListOptions as S, type OpenIdConfiguration as T, type Organization as U, type OtpCheckResult as V, type Paged as W, type PaginationOptions as X, type PasswordResetCompleted as Y, type PasswordResetIssued as Z, type PasswordResetPreview as _, type HttpLoggerOptions as a, type PermissionsByRole as a0, type ReservedPermissions as a1, type Role as a2, type RoleGrant as a3, type RoleInput as a4, type RoleList as a5, type RolePermissions as a6, type SafeJwtAlgorithm as a7, type SecurityMethods as a8, type SubTenant as a9, TenantScopedClient as aA, type TokenResult as aB, TokenVerificationError as aC, type TokenVerificationErrorCode as aD, type UpdateOrganizationInput as aE, type User as aF, UserScopedClient as aG, type ValidateResult as aH, type VerifiedAccessToken as aI, createClient as aJ, normalizeClientIp as aK, tenantFilter as aL, type SubTenantListOptions as aa, type SubjectApprovals as ab, type SubjectSecurity as ac, TENANT_FILTER_MAX_DEPTH as ad, TENANT_FILTER_MAX_VALUES as ae, TENANT_FILTER_MAX_VALUE_LENGTH as af, type TenantAncestor as ag, type TenantClientValidationResult as ah, type TenantCredentialIssued as ai, type TenantCredentialSummary as aj, type TenantFilterExpression as ak, type TenantFilterValue as al, type TenantInvite as am, type TenantInviteAccepted as an, type TenantInviteInput as ao, type TenantInviteIssued as ap, type TenantInviteListOptions as aq, type TenantInvitePreview as ar, type TenantInviteStatus as as, type TenantListOptions as at, type TenantMember as au, type TenantMemberPage as av, type TenantMembership as aw, type TenantOrder as ax, type TenantOrderField as ay, type TenantParent as az, type AcceptTenantInviteInput as b, type AccessTokenSource as c, type Approval as d, type ApprovalAssurance as e, type ApprovalPayload as f, type ApprovalStatus as g, type ApprovalWebAuthnOptions as h, type AuditEvent as i, type AuthyonJwksDiscoveryOptions as j, type AuthyonJwtClaims as k, type AuthyonServerClientOptions as l, type AuthyonTenantClaim as m, type ClientCredentials as n, type ClientRequestContext as o, type ConfirmApprovalInput as p, type ConsumedApproval as q, type CreateApprovalInput as r, type CreateCredentialInput as s, type CreateOrganizationInput as t, type CreatePermissionInput as u, type CreateTenantCredentialInput as v, type CreateUserInput as w, type CredentialCreator as x, type CredentialDetail as y, type CredentialListOptions as z };
1729
+ export { type PasswordResetIssued as $, AuthyonServerClient as A, type BuiltInPermission as B, CLIENT_IP_HEADER as C, type CredentialListOptions as D, type CredentialPermissionsInput as E, type EnvironmentUser as F, FetchHttpAdapter as G, type HttpAdapter as H, type HttpAdapterRequest as I, JwksTokenVerifier as J, type HttpLogEvent as K, type HttpLogger as L, type IntrospectResult as M, type InviteTenantMemberInput as N, type IssuePasswordResetInput as O, type JsonWebKeySet as P, type JwksTokenVerifierOptions as Q, LoggingHttpAdapter as R, type LoginActivity as S, type MemberListOptions as T, type MyTenant as U, type OpenIdConfiguration as V, type Organization as W, type OtpCheckResult as X, type Paged as Y, type PaginationOptions as Z, type PasswordResetCompleted as _, type HttpLoggerOptions as a, type PasswordResetPreview as a0, type Permission as a1, type PermissionFilterOptions as a2, type PermissionsByRole as a3, type ReservedPermissions as a4, type Role as a5, type RoleGrant as a6, type RoleInput as a7, type RoleList as a8, type RolePermissions as a9, type TenantMembership as aA, type TenantOrder as aB, type TenantOrderField as aC, type TenantParent as aD, TenantScopedClient as aE, type TokenResult as aF, TokenVerificationError as aG, type TokenVerificationErrorCode as aH, type UpdateOrganizationInput as aI, type UpdateTenantInput as aJ, type User as aK, UserScopedClient as aL, type ValidateResult as aM, type VerifiedAccessToken as aN, createClient as aO, normalizeClientIp as aP, tenantFilter as aQ, type SafeJwtAlgorithm as aa, type SecurityMethods as ab, type SubTenant as ac, type SubTenantListOptions as ad, type SubjectApprovals as ae, type SubjectSecurity as af, TENANT_FILTER_MAX_DEPTH as ag, TENANT_FILTER_MAX_VALUES as ah, TENANT_FILTER_MAX_VALUE_LENGTH as ai, type Tenant as aj, type TenantAncestor as ak, type TenantClientValidationResult as al, type TenantCredentialIssued as am, type TenantCredentialSummary as an, type TenantFilterExpression as ao, type TenantFilterValue as ap, type TenantInvite as aq, type TenantInviteAccepted as ar, type TenantInviteInput as as, type TenantInviteIssued as at, type TenantInviteListOptions as au, type TenantInvitePreview as av, type TenantInviteStatus as aw, type TenantListOptions as ax, type TenantMember as ay, type TenantMemberPage as az, type AcceptTenantInviteInput as b, type AccessTokenSource as c, type Approval as d, type ApprovalAssurance as e, type ApprovalPayload as f, type ApprovalStatus as g, type ApprovalWebAuthnOptions as h, type AuditEvent as i, type AuthyonJwksDiscoveryOptions as j, type AuthyonJwtClaims as k, type AuthyonServerClientOptions as l, type AuthyonTenantClaim as m, type ClientCredentials as n, type ClientRequestContext as o, type ConfirmApprovalInput as p, type ConsumedApproval as q, type CreateApprovalInput as r, type CreateCredentialInput as s, type CreateOrganizationInput as t, type CreatePermissionInput as u, type CreateTenantCredentialInput as v, type CreateTenantInput as w, type CreateUserInput as x, type CredentialCreator as y, type CredentialDetail as z };
@@ -209,11 +209,31 @@ type TenantOrder = TenantOrderField | {
209
209
  * There is no `status`: only active sub-tenants are listed, since everything
210
210
  * below a disabled one is closed to reads from above.
211
211
  */
212
- interface SubTenantListOptions extends PaginationOptions {
212
+ interface SubTenantListOptions extends PaginationOptions, PermissionFilterOptions {
213
213
  search?: string;
214
214
  filter?: string[];
215
215
  orderBy?: TenantOrder;
216
216
  }
217
+ /**
218
+ * Keep only the tenants where the user holds these permissions.
219
+ *
220
+ * - `permission`: up to 10 concrete values (no wildcards). Custom permissions
221
+ * count as well as Authyon's own.
222
+ * - `permissionMatch`: `"all"` (the default) needs every value; `"any"` needs
223
+ * one.
224
+ *
225
+ * On a tenant the user belongs to, it is what that membership grants. On one
226
+ * reached from above, it is what switching into it would grant (the nearest
227
+ * ancestor membership holding `subtenants:tree:switch`) plus the
228
+ * `subtenants:tree:*` values held above — the same rules the routes apply, so
229
+ * the filter never offers an action that would then be refused. A grant of
230
+ * `tenants:**` holds `tenants:members:invite`. Needs the Authyon API of
231
+ * 2026-11-27 or newer; an older one ignores it.
232
+ */
233
+ interface PermissionFilterOptions {
234
+ permission?: string[];
235
+ permissionMatch?: "all" | "any";
236
+ }
217
237
  /** The tenant another one hangs from: enough to name it in a breadcrumb. */
218
238
  interface TenantParent {
219
239
  id: string;
@@ -239,6 +259,36 @@ interface SubTenant {
239
259
  /** The tenant it hangs from — the same on every row of a page, carried so a row stands on its own. */
240
260
  parent: TenantParent;
241
261
  }
262
+ /**
263
+ * One tenant as the end-user routes return it (`GET /auth/tenants/{id}` and
264
+ * `/auth/tenants/by-slug/{slug}`): the user's own, or one below it read with
265
+ * `subtenants:tree:read` from an ancestor.
266
+ */
267
+ interface MyTenant {
268
+ id: string;
269
+ slug: string;
270
+ name: string;
271
+ description?: string | null;
272
+ createdAt: string;
273
+ updatedAt?: string | null;
274
+ memberCount: number;
275
+ /** Roles the user holds in it; empty when they reach it from an ancestor. */
276
+ myRoles: string[];
277
+ /**
278
+ * The end-user-route permissions the user can use on it, as concrete values.
279
+ * This, not `myRoles`, is what decides which actions to offer.
280
+ */
281
+ myPermissions?: string[];
282
+ /** JSON-encoded metadata visible to members. */
283
+ publicMetadata: string;
284
+ isDisabled: boolean;
285
+ /** Distance from the root: `0` at a root tenant. */
286
+ depth: number;
287
+ /** `true` when the user reaches it from an ancestor rather than as a member. */
288
+ inherited: boolean;
289
+ /** The tenant it hangs from, `null` for a root. */
290
+ parent: TenantParent | null;
291
+ }
242
292
 
243
293
  /**
244
294
  * Builders for the tenant list's structured filters.
@@ -278,7 +328,7 @@ declare const tenantFilter: {
278
328
  };
279
329
 
280
330
  /** GET/POST /env/tenants — confirmed against the live API. */
281
- interface Organization {
331
+ interface Tenant {
282
332
  id: string;
283
333
  slug: string;
284
334
  name?: string;
@@ -318,7 +368,7 @@ interface Organization {
318
368
  */
319
369
  ancestors?: TenantAncestor[];
320
370
  }
321
- /** One step of the chain above a tenant, as `Organization.ancestors` carries it. */
371
+ /** One step of the chain above a tenant, as `Tenant.ancestors` carries it. */
322
372
  interface TenantAncestor {
323
373
  id: string;
324
374
  name: string;
@@ -496,7 +546,7 @@ interface PermissionsByRole {
496
546
  roles: RolePermissions[];
497
547
  orphans: Permission[];
498
548
  /**
499
- * The permissions Authyon itself checks on the end-user organization routes
549
+ * The permissions Authyon itself checks on the end-user tenant routes
500
550
  * (`tenants:settings:manage`, `tenants:members:invite`,
501
551
  * `tenants:members:remove` and `subtenants:tree:*`), listed whether or not
502
552
  * a role names them. Absent from an API older than 2026-11-25.
@@ -522,7 +572,7 @@ interface CreatePermissionInput {
522
572
  /** Attach the new permission to this role immediately. */
523
573
  attachToRoleId?: string;
524
574
  }
525
- interface CreateOrganizationInput {
575
+ interface CreateTenantInput {
526
576
  name: string;
527
577
  slug: string;
528
578
  description?: string;
@@ -541,7 +591,7 @@ interface CreateOrganizationInput {
541
591
  */
542
592
  parentTenantId?: string;
543
593
  }
544
- interface UpdateOrganizationInput {
594
+ interface UpdateTenantInput {
545
595
  name: string;
546
596
  description?: string;
547
597
  customFields?: Record<string, unknown>;
@@ -561,7 +611,7 @@ interface CreateUserInput {
561
611
  customFields?: Record<string, unknown>;
562
612
  emailConfirmed?: boolean;
563
613
  roles?: string[];
564
- /** Tenants (organizations) to add the user to on creation. */
614
+ /** Tenants to add the user to on creation. */
565
615
  tenantIds?: string[];
566
616
  }
567
617
  /** GET /env/audit — one audit-trail entry, confirmed against the live API. */
@@ -703,6 +753,13 @@ interface AuthyonServerClientOptions {
703
753
  fetch?: typeof fetch;
704
754
  }
705
755
 
756
+ /** @deprecated Use `Tenant`. */
757
+ type Organization = Tenant;
758
+ /** @deprecated Use `CreateTenantInput`. */
759
+ type CreateOrganizationInput = CreateTenantInput;
760
+ /** @deprecated Use `UpdateTenantInput`. */
761
+ type UpdateOrganizationInput = UpdateTenantInput;
762
+
706
763
  /** A token of the requested authentication plane, or a provider called for each request. */
707
764
  type AccessTokenSource = string | (() => string | Promise<string>);
708
765
  interface CredentialListOptions extends PaginationOptions {
@@ -956,6 +1013,19 @@ declare class UserScopedClient {
956
1013
  */
957
1014
  readonly security: SubjectSecurity;
958
1015
  readonly tenants: {
1016
+ /**
1017
+ * GET /auth/tenants/{tenantId} — one tenant, acting as the user: their own,
1018
+ * or one below it with `subtenants:tree:read` on an ancestor.
1019
+ */
1020
+ get: (tenantId: string) => Promise<MyTenant>;
1021
+ /**
1022
+ * One tenant by id **or** slug: a UUID goes to `GET /auth/tenants/{id}`,
1023
+ * anything else to `GET /auth/tenants/by-slug/{slug}`. Same rule and answer
1024
+ * as `get`; by slug every refusal is `tenant.not_found`. An empty value
1025
+ * raises `RangeError` before any request. The slug route needs the Authyon
1026
+ * API of 2026-11-26 or newer.
1027
+ */
1028
+ find: (idOrSlug: string) => Promise<MyTenant>;
959
1029
  /**
960
1030
  * The direct, active sub-tenants of a tenant, acting as the user. One level
961
1031
  * per call: each row's `childCount` says where the next call is worth
@@ -1327,7 +1397,7 @@ declare class AuthyonServerClient {
1327
1397
  * 2026-10-22 ignores `filter` and one older than 2026-10-31 ignores
1328
1398
  * `parentId`, which read as a page that is too wide rather than an error.
1329
1399
  */
1330
- list: (params?: TenantListOptions) => Promise<Paged<Organization>>;
1400
+ list: (params?: TenantListOptions) => Promise<Paged<Tenant>>;
1331
1401
  /**
1332
1402
  * One page of a tenant's direct sub-tenants — `list()` with `parentId`.
1333
1403
  *
@@ -1335,7 +1405,7 @@ declare class AuthyonServerClient {
1335
1405
  * view asks again where that is above zero instead of reading the whole
1336
1406
  * subtree to draw the first level of it.
1337
1407
  */
1338
- children: (parentTenantId: string, params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Organization>>;
1408
+ children: (parentTenantId: string, params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Tenant>>;
1339
1409
  /**
1340
1410
  * One page of the environment's root tenants — `list()` with no parent.
1341
1411
  *
@@ -1344,7 +1414,7 @@ declare class AuthyonServerClient {
1344
1414
  * depth, which is what a flat picker wants and what a tree view must not
1345
1415
  * start from.
1346
1416
  */
1347
- roots: (params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Organization>>;
1417
+ roots: (params?: Omit<TenantListOptions, "parentId">) => Promise<Paged<Tenant>>;
1348
1418
  /**
1349
1419
  * Every sub-tenant in the environment, at any depth and under any
1350
1420
  * parent — `list()` with `minDepth: 1`. This is the one page
@@ -1356,7 +1426,7 @@ declare class AuthyonServerClient {
1356
1426
  * Against an Authyon API older than 2026-10-31 the floor is ignored and
1357
1427
  * the roots come back too.
1358
1428
  */
1359
- subTenants: (params?: Omit<TenantListOptions, "parentId" | "minDepth">) => Promise<Paged<Organization>>;
1429
+ subTenants: (params?: Omit<TenantListOptions, "parentId" | "minDepth">) => Promise<Paged<Tenant>>;
1360
1430
  /**
1361
1431
  * POST /env/tenants — create a tenant in the environment.
1362
1432
  *
@@ -1365,18 +1435,18 @@ declare class AuthyonServerClient {
1365
1435
  * so this answers `tenant.depth.not_allowed` until an operator raises it
1366
1436
  * in the console.
1367
1437
  */
1368
- create: (input: CreateOrganizationInput) => Promise<Organization>;
1438
+ create: (input: CreateTenantInput) => Promise<Tenant>;
1369
1439
  /**
1370
1440
  * GET /env/tenants/{tenantId} — fetch a tenant by id.
1371
1441
  *
1372
1442
  * Returns `ancestors` as well, the chain above it root first, so a
1373
1443
  * breadcrumb costs this one call rather than one per level.
1374
1444
  */
1375
- get: (tenantId: string) => Promise<Organization>;
1445
+ get: (tenantId: string) => Promise<Tenant>;
1376
1446
  /** PUT /env/tenants/{tenantId} — update a tenant. */
1377
- update: (tenantId: string, input: UpdateOrganizationInput) => Promise<Organization>;
1447
+ update: (tenantId: string, input: UpdateTenantInput) => Promise<Tenant>;
1378
1448
  /** PUT /env/tenants/{tenantId}/metadata - replace public and private metadata. */
1379
- updateMetadata: (tenantId: string, input: Pick<CreateOrganizationInput, "publicMetadata" | "privateMetadata">) => Promise<void>;
1449
+ updateMetadata: (tenantId: string, input: Pick<CreateTenantInput, "publicMetadata" | "privateMetadata">) => Promise<void>;
1380
1450
  /**
1381
1451
  * POST /env/tenants/{tenantId}/disable — disable without removing tenant
1382
1452
  * data.
@@ -1656,4 +1726,4 @@ declare class TenantScopedClient {
1656
1726
  /** Convenience factory: `const authyon = createClient({ clientId, clientSecret })`. */
1657
1727
  declare function createClient(options?: AuthyonServerClientOptions): AuthyonServerClient;
1658
1728
 
1659
- export { type Permission as $, AuthyonServerClient as A, type BuiltInPermission as B, CLIENT_IP_HEADER as C, type CredentialPermissionsInput as D, type EnvironmentUser as E, FetchHttpAdapter as F, type HttpAdapterRequest as G, type HttpAdapter as H, type HttpLogEvent as I, JwksTokenVerifier as J, type HttpLogger as K, type IntrospectResult as L, type InviteTenantMemberInput as M, type IssuePasswordResetInput as N, type JsonWebKeySet as O, type JwksTokenVerifierOptions as P, LoggingHttpAdapter as Q, type LoginActivity as R, type MemberListOptions as S, type OpenIdConfiguration as T, type Organization as U, type OtpCheckResult as V, type Paged as W, type PaginationOptions as X, type PasswordResetCompleted as Y, type PasswordResetIssued as Z, type PasswordResetPreview as _, type HttpLoggerOptions as a, type PermissionsByRole as a0, type ReservedPermissions as a1, type Role as a2, type RoleGrant as a3, type RoleInput as a4, type RoleList as a5, type RolePermissions as a6, type SafeJwtAlgorithm as a7, type SecurityMethods as a8, type SubTenant as a9, TenantScopedClient as aA, type TokenResult as aB, TokenVerificationError as aC, type TokenVerificationErrorCode as aD, type UpdateOrganizationInput as aE, type User as aF, UserScopedClient as aG, type ValidateResult as aH, type VerifiedAccessToken as aI, createClient as aJ, normalizeClientIp as aK, tenantFilter as aL, type SubTenantListOptions as aa, type SubjectApprovals as ab, type SubjectSecurity as ac, TENANT_FILTER_MAX_DEPTH as ad, TENANT_FILTER_MAX_VALUES as ae, TENANT_FILTER_MAX_VALUE_LENGTH as af, type TenantAncestor as ag, type TenantClientValidationResult as ah, type TenantCredentialIssued as ai, type TenantCredentialSummary as aj, type TenantFilterExpression as ak, type TenantFilterValue as al, type TenantInvite as am, type TenantInviteAccepted as an, type TenantInviteInput as ao, type TenantInviteIssued as ap, type TenantInviteListOptions as aq, type TenantInvitePreview as ar, type TenantInviteStatus as as, type TenantListOptions as at, type TenantMember as au, type TenantMemberPage as av, type TenantMembership as aw, type TenantOrder as ax, type TenantOrderField as ay, type TenantParent as az, type AcceptTenantInviteInput as b, type AccessTokenSource as c, type Approval as d, type ApprovalAssurance as e, type ApprovalPayload as f, type ApprovalStatus as g, type ApprovalWebAuthnOptions as h, type AuditEvent as i, type AuthyonJwksDiscoveryOptions as j, type AuthyonJwtClaims as k, type AuthyonServerClientOptions as l, type AuthyonTenantClaim as m, type ClientCredentials as n, type ClientRequestContext as o, type ConfirmApprovalInput as p, type ConsumedApproval as q, type CreateApprovalInput as r, type CreateCredentialInput as s, type CreateOrganizationInput as t, type CreatePermissionInput as u, type CreateTenantCredentialInput as v, type CreateUserInput as w, type CredentialCreator as x, type CredentialDetail as y, type CredentialListOptions as z };
1729
+ export { type PasswordResetIssued as $, AuthyonServerClient as A, type BuiltInPermission as B, CLIENT_IP_HEADER as C, type CredentialListOptions as D, type CredentialPermissionsInput as E, type EnvironmentUser as F, FetchHttpAdapter as G, type HttpAdapter as H, type HttpAdapterRequest as I, JwksTokenVerifier as J, type HttpLogEvent as K, type HttpLogger as L, type IntrospectResult as M, type InviteTenantMemberInput as N, type IssuePasswordResetInput as O, type JsonWebKeySet as P, type JwksTokenVerifierOptions as Q, LoggingHttpAdapter as R, type LoginActivity as S, type MemberListOptions as T, type MyTenant as U, type OpenIdConfiguration as V, type Organization as W, type OtpCheckResult as X, type Paged as Y, type PaginationOptions as Z, type PasswordResetCompleted as _, type HttpLoggerOptions as a, type PasswordResetPreview as a0, type Permission as a1, type PermissionFilterOptions as a2, type PermissionsByRole as a3, type ReservedPermissions as a4, type Role as a5, type RoleGrant as a6, type RoleInput as a7, type RoleList as a8, type RolePermissions as a9, type TenantMembership as aA, type TenantOrder as aB, type TenantOrderField as aC, type TenantParent as aD, TenantScopedClient as aE, type TokenResult as aF, TokenVerificationError as aG, type TokenVerificationErrorCode as aH, type UpdateOrganizationInput as aI, type UpdateTenantInput as aJ, type User as aK, UserScopedClient as aL, type ValidateResult as aM, type VerifiedAccessToken as aN, createClient as aO, normalizeClientIp as aP, tenantFilter as aQ, type SafeJwtAlgorithm as aa, type SecurityMethods as ab, type SubTenant as ac, type SubTenantListOptions as ad, type SubjectApprovals as ae, type SubjectSecurity as af, TENANT_FILTER_MAX_DEPTH as ag, TENANT_FILTER_MAX_VALUES as ah, TENANT_FILTER_MAX_VALUE_LENGTH as ai, type Tenant as aj, type TenantAncestor as ak, type TenantClientValidationResult as al, type TenantCredentialIssued as am, type TenantCredentialSummary as an, type TenantFilterExpression as ao, type TenantFilterValue as ap, type TenantInvite as aq, type TenantInviteAccepted as ar, type TenantInviteInput as as, type TenantInviteIssued as at, type TenantInviteListOptions as au, type TenantInvitePreview as av, type TenantInviteStatus as aw, type TenantListOptions as ax, type TenantMember as ay, type TenantMemberPage as az, type AcceptTenantInviteInput as b, type AccessTokenSource as c, type Approval as d, type ApprovalAssurance as e, type ApprovalPayload as f, type ApprovalStatus as g, type ApprovalWebAuthnOptions as h, type AuditEvent as i, type AuthyonJwksDiscoveryOptions as j, type AuthyonJwtClaims as k, type AuthyonServerClientOptions as l, type AuthyonTenantClaim as m, type ClientCredentials as n, type ClientRequestContext as o, type ConfirmApprovalInput as p, type ConsumedApproval as q, type CreateApprovalInput as r, type CreateCredentialInput as s, type CreateOrganizationInput as t, type CreatePermissionInput as u, type CreateTenantCredentialInput as v, type CreateTenantInput as w, type CreateUserInput as x, type CredentialCreator as y, type CredentialDetail as z };