@authyon/auth 0.2.0-beta.31 → 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
@@ -228,27 +228,27 @@ Métodos de sessão/auth ficam soltos no client; os que giram em torno de um rec
228
228
 
229
229
  ### `authyon.tenants`
230
230
 
231
- | Método | Endpoint |
232
- | ----------------------------------------------------- | --------------------------------------------------- |
233
- | `tenants.list({ search?, skip?, take? })` | `GET /auth/tenants` |
234
- | `tenants.create(params?)` | `POST /auth/tenants` |
235
- | `tenants.get(tenantId)` | `GET /auth/tenants/{id}` |
236
- | `tenants.find(idOrSlug)` | `GET /auth/tenants/{id}` ou `/by-slug/{slug}` |
237
- | `tenants.rename(tenantId, name)` | `PATCH /auth/tenants/{id}` |
238
- | `tenants.switch(slug)` | `POST /auth/switch-tenant` |
239
- | `tenants.current()` | — (lê `activeTenant` da sessão em cache) |
240
- | `tenants.members.list(tenantId, params?)` | `GET /auth/tenants/{id}/members` |
241
- | `tenants.members.invite(tenantId, params)` | `POST /auth/tenants/{id}/members` |
242
- | `tenants.members.remove(tenantId, userId)` | `DELETE /auth/tenants/{id}/members/{userId}` |
243
- | `tenants.roles.list(tenantId)` | `GET /auth/tenants/{id}/roles` |
244
- | `tenants.subTenants.list(tenantId, params?)` | `GET /auth/tenants/{id}/subtenants` |
245
- | `tenants.subTenants.listCurrent(params?)` | `GET /auth/tenants/subtenants` (tenant ativo) |
246
- | `tenants.invites.list(tenantId)` | `GET /auth/tenants/{id}/invites` |
247
- | `tenants.invites.create(tenantId, params)` | `POST /auth/tenants/{id}/invites` |
248
- | `tenants.invites.resend(tenantId, inviteId, params?)` | `POST /auth/tenants/{id}/invites/{inviteId}/resend` |
249
- | `tenants.invites.revoke(tenantId, inviteId)` | `DELETE /auth/tenants/{id}/invites/{inviteId}` |
250
- | `tenants.invites.preview(token)` | `POST /auth/tenant-invites/preview` (público) |
251
- | `tenants.invites.accept(params)` | `POST /auth/tenant-invites/accept` (público) |
231
+ | Método | Endpoint |
232
+ | ------------------------------------------------------------------------ | --------------------------------------------------- |
233
+ | `tenants.list({ search?, skip?, take?, permission?, permissionMatch? })` | `GET /auth/tenants` |
234
+ | `tenants.create(params?)` | `POST /auth/tenants` |
235
+ | `tenants.get(tenantId)` | `GET /auth/tenants/{id}` |
236
+ | `tenants.find(idOrSlug)` | `GET /auth/tenants/{id}` ou `/by-slug/{slug}` |
237
+ | `tenants.rename(tenantId, name)` | `PATCH /auth/tenants/{id}` |
238
+ | `tenants.switch(slug)` | `POST /auth/switch-tenant` |
239
+ | `tenants.current()` | — (lê `activeTenant` da sessão em cache) |
240
+ | `tenants.members.list(tenantId, params?)` | `GET /auth/tenants/{id}/members` |
241
+ | `tenants.members.invite(tenantId, params)` | `POST /auth/tenants/{id}/members` |
242
+ | `tenants.members.remove(tenantId, userId)` | `DELETE /auth/tenants/{id}/members/{userId}` |
243
+ | `tenants.roles.list(tenantId)` | `GET /auth/tenants/{id}/roles` |
244
+ | `tenants.subTenants.list(tenantId, params?)` | `GET /auth/tenants/{id}/subtenants` |
245
+ | `tenants.subTenants.listCurrent(params?)` | `GET /auth/tenants/subtenants` (tenant ativo) |
246
+ | `tenants.invites.list(tenantId)` | `GET /auth/tenants/{id}/invites` |
247
+ | `tenants.invites.create(tenantId, params)` | `POST /auth/tenants/{id}/invites` |
248
+ | `tenants.invites.resend(tenantId, inviteId, params?)` | `POST /auth/tenants/{id}/invites/{inviteId}/resend` |
249
+ | `tenants.invites.revoke(tenantId, inviteId)` | `DELETE /auth/tenants/{id}/invites/{inviteId}` |
250
+ | `tenants.invites.preview(token)` | `POST /auth/tenant-invites/preview` (público) |
251
+ | `tenants.invites.accept(params)` | `POST /auth/tenant-invites/accept` (público) |
252
252
 
253
253
  `tenants.members.invite` adiciona um usuário que já existe no ambiente. Para convidar
254
254
  um e-mail que talvez ainda não tenha conta, use `tenants.invites.create`: a resposta
@@ -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;
@@ -863,13 +893,17 @@ declare class AuthyonClient {
863
893
  *
864
894
  * Also lists the tenants below them that the user may switch into
865
895
  * without being a member, marked `inherited` — only the ones that actually
866
- * carry `subtenants:tree:switch`, so the switcher never offers an
896
+ * carry `subtenants:tree:switch`, so the switcher never offers a
867
897
  * tenant the switch would then refuse. `depth` indents the list into
868
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.
869
905
  */
870
- list: (params?: {
871
- search?: string;
872
- } & PaginationOptions) => Promise<Tenant[]>;
906
+ list: (params?: TenantListParams) => Promise<Tenant[]>;
873
907
  /**
874
908
  * POST /auth/tenants — creates a tenant owned by the signed-in
875
909
  * user (only available when self-service tenant creation is
@@ -1039,13 +1073,17 @@ declare class AuthyonClient {
1039
1073
  *
1040
1074
  * Also lists the tenants below them that the user may switch into
1041
1075
  * without being a member, marked `inherited` — only the ones that actually
1042
- * carry `subtenants:tree:switch`, so the switcher never offers an
1076
+ * carry `subtenants:tree:switch`, so the switcher never offers a
1043
1077
  * tenant the switch would then refuse. `depth` indents the list into
1044
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.
1045
1085
  */
1046
- list: (params?: {
1047
- search?: string;
1048
- } & PaginationOptions) => Promise<Tenant[]>;
1086
+ list: (params?: TenantListParams) => Promise<Tenant[]>;
1049
1087
  /**
1050
1088
  * POST /auth/tenants — creates a tenant owned by the signed-in
1051
1089
  * user (only available when self-service tenant creation is
@@ -1383,4 +1421,4 @@ declare function hasPermissionGroup(source: AuthyonPermissionSource | readonly s
1383
1421
  /** Converts Authyon's `subject:action` permission strings to authorization rules. */
1384
1422
  declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
1385
1423
 
1386
- export { type PermissionGroup 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 RegisterInput as a0, type Role as a1, type SecurityMethods as a2, type Session as a3, type SessionControllerOptions as a4, type SessionInfo as a5, type SessionSnapshot as a6, type SessionSnapshotListener as a7, type SessionStatus as a8, type SsoProvider as a9, createAuthyonAbility as aA, createAuthyonRules as aB, createClient as aC, hasPermission as aD, hasPermissionGroup as aE, type SubOrganization as aa, type SubOrganizationListOptions as ab, type SubTenant as ac, type SubTenantListOptions as ad, type SubjectApprovals as ae, type SubjectSecurity as af, type Tenant as ag, type TenantInvite as ah, type TenantInviteAccepted as ai, type TenantInviteInput as aj, type TenantInviteIssued as ak, type TenantInvitePreview as al, type TenantInviteStatus as am, type TenantMember as an, type TenantOrder as ao, type TenantOrderField as ap, type TenantParent as aq, type TwoFactorChallenge as ar, type TwoFactorMethod as as, type TwoFactorStatus as at, type User as au, type ValidateResult as av, type VerifyTwoFactorInput as aw, type WebAuthnAssertion as ax, type WebAuthnCeremonyStart as ay, type WebAuthnCredential 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 };
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 };
@@ -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;
@@ -863,13 +893,17 @@ declare class AuthyonClient {
863
893
  *
864
894
  * Also lists the tenants below them that the user may switch into
865
895
  * without being a member, marked `inherited` — only the ones that actually
866
- * carry `subtenants:tree:switch`, so the switcher never offers an
896
+ * carry `subtenants:tree:switch`, so the switcher never offers a
867
897
  * tenant the switch would then refuse. `depth` indents the list into
868
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.
869
905
  */
870
- list: (params?: {
871
- search?: string;
872
- } & PaginationOptions) => Promise<Tenant[]>;
906
+ list: (params?: TenantListParams) => Promise<Tenant[]>;
873
907
  /**
874
908
  * POST /auth/tenants — creates a tenant owned by the signed-in
875
909
  * user (only available when self-service tenant creation is
@@ -1039,13 +1073,17 @@ declare class AuthyonClient {
1039
1073
  *
1040
1074
  * Also lists the tenants below them that the user may switch into
1041
1075
  * without being a member, marked `inherited` — only the ones that actually
1042
- * carry `subtenants:tree:switch`, so the switcher never offers an
1076
+ * carry `subtenants:tree:switch`, so the switcher never offers a
1043
1077
  * tenant the switch would then refuse. `depth` indents the list into
1044
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.
1045
1085
  */
1046
- list: (params?: {
1047
- search?: string;
1048
- } & PaginationOptions) => Promise<Tenant[]>;
1086
+ list: (params?: TenantListParams) => Promise<Tenant[]>;
1049
1087
  /**
1050
1088
  * POST /auth/tenants — creates a tenant owned by the signed-in
1051
1089
  * user (only available when self-service tenant creation is
@@ -1383,4 +1421,4 @@ declare function hasPermissionGroup(source: AuthyonPermissionSource | readonly s
1383
1421
  /** Converts Authyon's `subject:action` permission strings to authorization rules. */
1384
1422
  declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
1385
1423
 
1386
- export { type PermissionGroup 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 RegisterInput as a0, type Role as a1, type SecurityMethods as a2, type Session as a3, type SessionControllerOptions as a4, type SessionInfo as a5, type SessionSnapshot as a6, type SessionSnapshotListener as a7, type SessionStatus as a8, type SsoProvider as a9, createAuthyonAbility as aA, createAuthyonRules as aB, createClient as aC, hasPermission as aD, hasPermissionGroup as aE, type SubOrganization as aa, type SubOrganizationListOptions as ab, type SubTenant as ac, type SubTenantListOptions as ad, type SubjectApprovals as ae, type SubjectSecurity as af, type Tenant as ag, type TenantInvite as ah, type TenantInviteAccepted as ai, type TenantInviteInput as aj, type TenantInviteIssued as ak, type TenantInvitePreview as al, type TenantInviteStatus as am, type TenantMember as an, type TenantOrder as ao, type TenantOrderField as ap, type TenantParent as aq, type TwoFactorChallenge as ar, type TwoFactorMethod as as, type TwoFactorStatus as at, type User as au, type ValidateResult as av, type VerifyTwoFactorInput as aw, type WebAuthnAssertion as ax, type WebAuthnCeremonyStart as ay, type WebAuthnCredential 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 };
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 };
package/dist/index.cjs CHANGED
@@ -519,6 +519,38 @@ function memberQuery(options = {}) {
519
519
  var ORDER_FIELDS = ["name", "createdAt", "updatedAt"];
520
520
  var MAX_FILTERS = 10;
521
521
  var MAX_FILTER_LENGTH = 512;
522
+ var MAX_PERMISSIONS = 10;
523
+ var MAX_PERMISSION_LENGTH = 256;
524
+ function permissionQuery(options = {}) {
525
+ const { permission, permissionMatch } = options;
526
+ const query = {};
527
+ if (permissionMatch !== void 0) {
528
+ if (permissionMatch !== "all" && permissionMatch !== "any")
529
+ throw new RangeError('Authyon: permissionMatch must be "all" or "any".');
530
+ query.permissionMatch = permissionMatch;
531
+ }
532
+ if (permission === void 0) return query;
533
+ if (!Array.isArray(permission)) throw new RangeError("Authyon: permission must be an array.");
534
+ const values = permission.map((p) => typeof p === "string" ? p.trim() : "");
535
+ if (values.some((p) => p.length === 0))
536
+ throw new RangeError("Authyon: a permission value may not be empty.");
537
+ if (values.length > MAX_PERMISSIONS)
538
+ throw new RangeError(`Authyon: at most ${MAX_PERMISSIONS} permission values per request.`);
539
+ for (const p of values) {
540
+ if (p.length > MAX_PERMISSION_LENGTH)
541
+ throw new RangeError(
542
+ `Authyon: a permission holds at most ${MAX_PERMISSION_LENGTH} characters.`
543
+ );
544
+ if (p.includes("*"))
545
+ throw new RangeError(`Authyon: name a concrete permission, not a wildcard (got "${p}").`);
546
+ }
547
+ if (values.length > 0) query.permission = values;
548
+ return query;
549
+ }
550
+ function tenantListQuery(options = {}) {
551
+ const { permission, permissionMatch, ...page } = options;
552
+ return { ...memberQuery(page), ...permissionQuery({ permission, permissionMatch }) };
553
+ }
522
554
  function orderByParam(order) {
523
555
  if (order === void 0) return void 0;
524
556
  const field = typeof order === "string" ? order : order?.field;
@@ -530,8 +562,11 @@ function orderByParam(order) {
530
562
  return `${field}:${direction}`;
531
563
  }
532
564
  function subTenantQuery(options = {}) {
533
- const { filter, orderBy, ...page } = options;
534
- const query = { ...memberQuery(page) };
565
+ const { filter, orderBy, permission, permissionMatch, ...page } = options;
566
+ const query = {
567
+ ...memberQuery(page),
568
+ ...permissionQuery({ permission, permissionMatch })
569
+ };
535
570
  if (filter !== void 0) {
536
571
  if (!Array.isArray(filter)) throw new RangeError("Authyon: filter must be an array.");
537
572
  const present = filter.filter((f) => typeof f === "string" && f.trim().length > 0);
@@ -678,11 +713,17 @@ var AuthyonClient = class {
678
713
  *
679
714
  * Also lists the tenants below them that the user may switch into
680
715
  * without being a member, marked `inherited` — only the ones that actually
681
- * carry `subtenants:tree:switch`, so the switcher never offers an
716
+ * carry `subtenants:tree:switch`, so the switcher never offers a
682
717
  * tenant the switch would then refuse. `depth` indents the list into
683
718
  * the tree it describes.
719
+ *
720
+ * `search`, `skip`/`take` and the permission filter (`permission`,
721
+ * `permissionMatch`) narrow it — see `TenantListParams`. The answer stays
722
+ * a plain array. A bad option raises `RangeError` before any request.
723
+ * APIs older than 2026-11-27 ignored every option and always answered the
724
+ * whole list.
684
725
  */
685
- list: (params = {}) => this.request(appendQuery("/auth/tenants", params), { bearer: true }),
726
+ list: (params = {}) => this.request(appendQuery("/auth/tenants", tenantListQuery(params)), { bearer: true }),
686
727
  /**
687
728
  * POST /auth/tenants — creates a tenant owned by the signed-in
688
729
  * user (only available when self-service tenant creation is
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-BPJ5VdSC.cjs';
2
- export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as AcceptTenantInviteInput, i as Activity, j as Approval, k as ApprovalAssurance, l as ApprovalPayload, m as ApprovalStatus, n as ApprovalWebAuthnOptions, o as AuthEvent, p as AuthState, q as AuthStateListener, r as AuthenticatorSetup, s as AuthyonAbility, t as AuthyonAbilityBuilder, u as AuthyonAbilityOptions, v as AuthyonClientOptions, w as AuthyonPermissionSource, x as AuthyonSessionController, C as ConfirmApprovalInput, y as CreateOrganizationInput, z as CreateTenantInput, F as FetchHttpAdapter, B as HttpAdapterRequest, D as HttpLogEvent, E as HttpLogger, I as IntrospectResult, G as InviteMemberInput, L as LoggingHttpAdapter, J as LoginInput, K as LoginResult, M as MemberListOptions, O as Organization, N as OrganizationInvite, P as OrganizationInviteAccepted, Q as OrganizationInviteInput, R as OrganizationInviteIssued, S as OrganizationInvitePreview, U as OrganizationInviteStatus, V as OrganizationMember, W as Paged, X as PaginationOptions, Y as PasswordResetCompleted, Z as PasswordResetPreview, _ as PasswordResetRequestOptions, $ as PermissionGroup, a0 as RegisterInput, a1 as Role, a2 as SecurityMethods, a3 as Session, a4 as SessionControllerOptions, a5 as SessionInfo, a6 as SessionSnapshot, a7 as SessionSnapshotListener, a8 as SessionStatus, a9 as SsoProvider, aa as SubOrganization, ab as SubOrganizationListOptions, ac as SubTenant, ad as SubTenantListOptions, ae as SubjectApprovals, af as SubjectSecurity, ag as Tenant, ah as TenantInvite, ai as TenantInviteAccepted, aj as TenantInviteInput, ak as TenantInviteIssued, al as TenantInvitePreview, am as TenantInviteStatus, an as TenantMember, ao as TenantOrder, ap as TenantOrderField, aq as TenantParent, ar as TwoFactorChallenge, as as TwoFactorMethod, at as TwoFactorStatus, au as User, av as ValidateResult, aw as VerifyTwoFactorInput, ax as WebAuthnAssertion, ay as WebAuthnCeremonyStart, az as WebAuthnCredential, aA as createAuthyonAbility, aB as createAuthyonRules, aC as createClient, aD as hasPermission, aE as hasPermissionGroup } from './ability-BPJ5VdSC.cjs';
1
+ import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-DBh_yZ5o.cjs';
2
+ export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as AcceptTenantInviteInput, i as Activity, j as Approval, k as ApprovalAssurance, l as ApprovalPayload, m as ApprovalStatus, n as ApprovalWebAuthnOptions, o as AuthEvent, p as AuthState, q as AuthStateListener, r as AuthenticatorSetup, s as AuthyonAbility, t as AuthyonAbilityBuilder, u as AuthyonAbilityOptions, v as AuthyonClientOptions, w as AuthyonPermissionSource, x as AuthyonSessionController, C as ConfirmApprovalInput, y as CreateOrganizationInput, z as CreateTenantInput, F as FetchHttpAdapter, B as HttpAdapterRequest, D as HttpLogEvent, E as HttpLogger, I as IntrospectResult, G as InviteMemberInput, L as LoggingHttpAdapter, J as LoginInput, K as LoginResult, M as MemberListOptions, O as Organization, N as OrganizationInvite, P as OrganizationInviteAccepted, Q as OrganizationInviteInput, R as OrganizationInviteIssued, S as OrganizationInvitePreview, U as OrganizationInviteStatus, V as OrganizationMember, W as Paged, X as PaginationOptions, Y as PasswordResetCompleted, Z as PasswordResetPreview, _ as PasswordResetRequestOptions, $ as PermissionFilterOptions, a0 as PermissionGroup, a1 as RegisterInput, a2 as Role, a3 as SecurityMethods, a4 as Session, a5 as SessionControllerOptions, a6 as SessionInfo, a7 as SessionSnapshot, a8 as SessionSnapshotListener, a9 as SessionStatus, aa as SsoProvider, ab as SubOrganization, ac as SubOrganizationListOptions, ad as SubTenant, ae as SubTenantListOptions, af as SubjectApprovals, ag as SubjectSecurity, ah as Tenant, ai as TenantInvite, aj as TenantInviteAccepted, ak as TenantInviteInput, al as TenantInviteIssued, am as TenantInvitePreview, an as TenantInviteStatus, ao as TenantListParams, ap as TenantMember, aq as TenantOrder, ar as TenantOrderField, as as TenantParent, at as TwoFactorChallenge, au as TwoFactorMethod, av as TwoFactorStatus, aw as User, ax as ValidateResult, ay as VerifyTwoFactorInput, az as WebAuthnAssertion, aA as WebAuthnCeremonyStart, aB as WebAuthnCredential, aC as createAuthyonAbility, aD as createAuthyonRules, aE as createClient, aF as hasPermission, aG as hasPermissionGroup } from './ability-DBh_yZ5o.cjs';
3
3
 
4
4
  declare const ErrorCodes: {
5
5
  readonly Unknown: "unknown";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-BPJ5VdSC.js';
2
- export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as AcceptTenantInviteInput, i as Activity, j as Approval, k as ApprovalAssurance, l as ApprovalPayload, m as ApprovalStatus, n as ApprovalWebAuthnOptions, o as AuthEvent, p as AuthState, q as AuthStateListener, r as AuthenticatorSetup, s as AuthyonAbility, t as AuthyonAbilityBuilder, u as AuthyonAbilityOptions, v as AuthyonClientOptions, w as AuthyonPermissionSource, x as AuthyonSessionController, C as ConfirmApprovalInput, y as CreateOrganizationInput, z as CreateTenantInput, F as FetchHttpAdapter, B as HttpAdapterRequest, D as HttpLogEvent, E as HttpLogger, I as IntrospectResult, G as InviteMemberInput, L as LoggingHttpAdapter, J as LoginInput, K as LoginResult, M as MemberListOptions, O as Organization, N as OrganizationInvite, P as OrganizationInviteAccepted, Q as OrganizationInviteInput, R as OrganizationInviteIssued, S as OrganizationInvitePreview, U as OrganizationInviteStatus, V as OrganizationMember, W as Paged, X as PaginationOptions, Y as PasswordResetCompleted, Z as PasswordResetPreview, _ as PasswordResetRequestOptions, $ as PermissionGroup, a0 as RegisterInput, a1 as Role, a2 as SecurityMethods, a3 as Session, a4 as SessionControllerOptions, a5 as SessionInfo, a6 as SessionSnapshot, a7 as SessionSnapshotListener, a8 as SessionStatus, a9 as SsoProvider, aa as SubOrganization, ab as SubOrganizationListOptions, ac as SubTenant, ad as SubTenantListOptions, ae as SubjectApprovals, af as SubjectSecurity, ag as Tenant, ah as TenantInvite, ai as TenantInviteAccepted, aj as TenantInviteInput, ak as TenantInviteIssued, al as TenantInvitePreview, am as TenantInviteStatus, an as TenantMember, ao as TenantOrder, ap as TenantOrderField, aq as TenantParent, ar as TwoFactorChallenge, as as TwoFactorMethod, at as TwoFactorStatus, au as User, av as ValidateResult, aw as VerifyTwoFactorInput, ax as WebAuthnAssertion, ay as WebAuthnCeremonyStart, az as WebAuthnCredential, aA as createAuthyonAbility, aB as createAuthyonRules, aC as createClient, aD as hasPermission, aE as hasPermissionGroup } from './ability-BPJ5VdSC.js';
1
+ import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-DBh_yZ5o.js';
2
+ export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as AcceptTenantInviteInput, i as Activity, j as Approval, k as ApprovalAssurance, l as ApprovalPayload, m as ApprovalStatus, n as ApprovalWebAuthnOptions, o as AuthEvent, p as AuthState, q as AuthStateListener, r as AuthenticatorSetup, s as AuthyonAbility, t as AuthyonAbilityBuilder, u as AuthyonAbilityOptions, v as AuthyonClientOptions, w as AuthyonPermissionSource, x as AuthyonSessionController, C as ConfirmApprovalInput, y as CreateOrganizationInput, z as CreateTenantInput, F as FetchHttpAdapter, B as HttpAdapterRequest, D as HttpLogEvent, E as HttpLogger, I as IntrospectResult, G as InviteMemberInput, L as LoggingHttpAdapter, J as LoginInput, K as LoginResult, M as MemberListOptions, O as Organization, N as OrganizationInvite, P as OrganizationInviteAccepted, Q as OrganizationInviteInput, R as OrganizationInviteIssued, S as OrganizationInvitePreview, U as OrganizationInviteStatus, V as OrganizationMember, W as Paged, X as PaginationOptions, Y as PasswordResetCompleted, Z as PasswordResetPreview, _ as PasswordResetRequestOptions, $ as PermissionFilterOptions, a0 as PermissionGroup, a1 as RegisterInput, a2 as Role, a3 as SecurityMethods, a4 as Session, a5 as SessionControllerOptions, a6 as SessionInfo, a7 as SessionSnapshot, a8 as SessionSnapshotListener, a9 as SessionStatus, aa as SsoProvider, ab as SubOrganization, ac as SubOrganizationListOptions, ad as SubTenant, ae as SubTenantListOptions, af as SubjectApprovals, ag as SubjectSecurity, ah as Tenant, ai as TenantInvite, aj as TenantInviteAccepted, ak as TenantInviteInput, al as TenantInviteIssued, am as TenantInvitePreview, an as TenantInviteStatus, ao as TenantListParams, ap as TenantMember, aq as TenantOrder, ar as TenantOrderField, as as TenantParent, at as TwoFactorChallenge, au as TwoFactorMethod, av as TwoFactorStatus, aw as User, ax as ValidateResult, ay as VerifyTwoFactorInput, az as WebAuthnAssertion, aA as WebAuthnCeremonyStart, aB as WebAuthnCredential, aC as createAuthyonAbility, aD as createAuthyonRules, aE as createClient, aF as hasPermission, aG as hasPermissionGroup } from './ability-DBh_yZ5o.js';
3
3
 
4
4
  declare const ErrorCodes: {
5
5
  readonly Unknown: "unknown";
package/dist/index.js CHANGED
@@ -481,6 +481,38 @@ function memberQuery(options = {}) {
481
481
  var ORDER_FIELDS = ["name", "createdAt", "updatedAt"];
482
482
  var MAX_FILTERS = 10;
483
483
  var MAX_FILTER_LENGTH = 512;
484
+ var MAX_PERMISSIONS = 10;
485
+ var MAX_PERMISSION_LENGTH = 256;
486
+ function permissionQuery(options = {}) {
487
+ const { permission, permissionMatch } = options;
488
+ const query = {};
489
+ if (permissionMatch !== void 0) {
490
+ if (permissionMatch !== "all" && permissionMatch !== "any")
491
+ throw new RangeError('Authyon: permissionMatch must be "all" or "any".');
492
+ query.permissionMatch = permissionMatch;
493
+ }
494
+ if (permission === void 0) return query;
495
+ if (!Array.isArray(permission)) throw new RangeError("Authyon: permission must be an array.");
496
+ const values = permission.map((p) => typeof p === "string" ? p.trim() : "");
497
+ if (values.some((p) => p.length === 0))
498
+ throw new RangeError("Authyon: a permission value may not be empty.");
499
+ if (values.length > MAX_PERMISSIONS)
500
+ throw new RangeError(`Authyon: at most ${MAX_PERMISSIONS} permission values per request.`);
501
+ for (const p of values) {
502
+ if (p.length > MAX_PERMISSION_LENGTH)
503
+ throw new RangeError(
504
+ `Authyon: a permission holds at most ${MAX_PERMISSION_LENGTH} characters.`
505
+ );
506
+ if (p.includes("*"))
507
+ throw new RangeError(`Authyon: name a concrete permission, not a wildcard (got "${p}").`);
508
+ }
509
+ if (values.length > 0) query.permission = values;
510
+ return query;
511
+ }
512
+ function tenantListQuery(options = {}) {
513
+ const { permission, permissionMatch, ...page } = options;
514
+ return { ...memberQuery(page), ...permissionQuery({ permission, permissionMatch }) };
515
+ }
484
516
  function orderByParam(order) {
485
517
  if (order === void 0) return void 0;
486
518
  const field = typeof order === "string" ? order : order?.field;
@@ -492,8 +524,11 @@ function orderByParam(order) {
492
524
  return `${field}:${direction}`;
493
525
  }
494
526
  function subTenantQuery(options = {}) {
495
- const { filter, orderBy, ...page } = options;
496
- const query = { ...memberQuery(page) };
527
+ const { filter, orderBy, permission, permissionMatch, ...page } = options;
528
+ const query = {
529
+ ...memberQuery(page),
530
+ ...permissionQuery({ permission, permissionMatch })
531
+ };
497
532
  if (filter !== void 0) {
498
533
  if (!Array.isArray(filter)) throw new RangeError("Authyon: filter must be an array.");
499
534
  const present = filter.filter((f) => typeof f === "string" && f.trim().length > 0);
@@ -640,11 +675,17 @@ var AuthyonClient = class {
640
675
  *
641
676
  * Also lists the tenants below them that the user may switch into
642
677
  * without being a member, marked `inherited` — only the ones that actually
643
- * carry `subtenants:tree:switch`, so the switcher never offers an
678
+ * carry `subtenants:tree:switch`, so the switcher never offers a
644
679
  * tenant the switch would then refuse. `depth` indents the list into
645
680
  * the tree it describes.
681
+ *
682
+ * `search`, `skip`/`take` and the permission filter (`permission`,
683
+ * `permissionMatch`) narrow it — see `TenantListParams`. The answer stays
684
+ * a plain array. A bad option raises `RangeError` before any request.
685
+ * APIs older than 2026-11-27 ignored every option and always answered the
686
+ * whole list.
646
687
  */
647
- list: (params = {}) => this.request(appendQuery("/auth/tenants", params), { bearer: true }),
688
+ list: (params = {}) => this.request(appendQuery("/auth/tenants", tenantListQuery(params)), { bearer: true }),
648
689
  /**
649
690
  * POST /auth/tenants — creates a tenant owned by the signed-in
650
691
  * user (only available when self-service tenant creation is
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { au as User, a4 as SessionControllerOptions, A as AuthyonClient, a6 as SessionSnapshot, a3 as Session, f as AbilitySubject, u as AuthyonAbilityOptions, s as AuthyonAbility } from '../ability-BPJ5VdSC.cjs';
4
- export { x as AuthyonSessionController, a7 as SessionSnapshotListener, a8 as SessionStatus } from '../ability-BPJ5VdSC.cjs';
3
+ import { aw as User, a5 as SessionControllerOptions, A as AuthyonClient, a7 as SessionSnapshot, a4 as Session, f as AbilitySubject, u as AuthyonAbilityOptions, s as AuthyonAbility } from '../ability-DBh_yZ5o.cjs';
4
+ export { x as AuthyonSessionController, a8 as SessionSnapshotListener, a9 as SessionStatus } from '../ability-DBh_yZ5o.cjs';
5
5
 
6
6
  interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
7
7
  client: AuthyonClient;
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { au as User, a4 as SessionControllerOptions, A as AuthyonClient, a6 as SessionSnapshot, a3 as Session, f as AbilitySubject, u as AuthyonAbilityOptions, s as AuthyonAbility } from '../ability-BPJ5VdSC.js';
4
- export { x as AuthyonSessionController, a7 as SessionSnapshotListener, a8 as SessionStatus } from '../ability-BPJ5VdSC.js';
3
+ import { aw as User, a5 as SessionControllerOptions, A as AuthyonClient, a7 as SessionSnapshot, a4 as Session, f as AbilitySubject, u as AuthyonAbilityOptions, s as AuthyonAbility } from '../ability-DBh_yZ5o.js';
4
+ export { x as AuthyonSessionController, a8 as SessionSnapshotListener, a9 as SessionStatus } from '../ability-DBh_yZ5o.js';
5
5
 
6
6
  interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
7
7
  client: AuthyonClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authyon/auth",
3
- "version": "0.2.0-beta.31",
3
+ "version": "0.2.0-beta.32",
4
4
  "description": "Authyon SDK for browsers — auth, sessions, multi-tenant and 2FA for vanilla JS/TS.",
5
5
  "license": "MIT",
6
6
  "type": "module",