@authyon/auth 0.2.0-beta.28 → 0.2.0-beta.30
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 +27 -0
- package/dist/{ability-SmIMPYUn.d.cts → ability-CmJEviJj.d.cts} +151 -5
- package/dist/{ability-SmIMPYUn.d.ts → ability-CmJEviJj.d.ts} +151 -5
- package/dist/index.cjs +185 -6
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +180 -5
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -240,6 +240,8 @@ Métodos de sessão/auth ficam soltos no client; os que giram em torno de um rec
|
|
|
240
240
|
| `organization.members.invite(organizationId, params)` | `POST /auth/tenants/{id}/members` |
|
|
241
241
|
| `organization.members.remove(organizationId, userId)` | `DELETE /auth/tenants/{id}/members/{userId}` |
|
|
242
242
|
| `organization.roles.list(organizationId)` | `GET /auth/tenants/{id}/roles` |
|
|
243
|
+
| `organization.subOrganizations.list(organizationId, params?)` | `GET /auth/tenants/{id}/subtenants` |
|
|
244
|
+
| `organization.subOrganizations.listCurrent(params?)` | `GET /auth/tenants/subtenants` (tenant ativo) |
|
|
243
245
|
| `organization.invites.list(organizationId)` | `GET /auth/tenants/{id}/invites` |
|
|
244
246
|
| `organization.invites.create(organizationId, params)` | `POST /auth/tenants/{id}/invites` |
|
|
245
247
|
| `organization.invites.resend(organizationId, inviteId, params?)` | `POST /auth/tenants/{id}/invites/{inviteId}/resend` |
|
|
@@ -266,6 +268,31 @@ usuário já pertence (precisa de `subtenants:tree:create` lá). `organization.r
|
|
|
266
268
|
`tenants:settings:manage` — o valor antes escrito `tenants:manage`, que a API não
|
|
267
269
|
armazenava. Ver o [guia de hierarquia](../../docs/tenantHierarchy.md).
|
|
268
270
|
|
|
271
|
+
Para navegar pelos sub-tenants (e não só pelos que aceitam troca), use
|
|
272
|
+
`organization.subOrganizations.list(id, params)` ou `.listCurrent(params)`, que usa o
|
|
273
|
+
tenant ativo da sessão. Um nível por chamada, paginado (`skip`, `take` de 1 a 100), com
|
|
274
|
+
`search` (nome, slug, descrição e metadados públicos), `filter` só no escopo `public` —
|
|
275
|
+
monte com `tenantFilter`, exportado também por este pacote — e `orderBy` (`name`,
|
|
276
|
+
`createdAt` ou `updatedAt`, `asc` ou `desc`). Cada linha traz `childCount`, então dá
|
|
277
|
+
para expandir a árvore só onde há filhos. Exige `subtenants:tree:read`, inclusive no
|
|
278
|
+
próprio tenant.
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
import { tenantFilter } from "@authyon/auth";
|
|
282
|
+
|
|
283
|
+
const { data, total, hasNext } = await authyon.organization.subOrganizations.listCurrent({
|
|
284
|
+
filter: [tenantFilter.eq("public.region", "sul")],
|
|
285
|
+
orderBy: { field: "name", direction: "asc" },
|
|
286
|
+
take: 50,
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
`organization.get()` passa a trazer `myPermissions` — as permissões das rotas de
|
|
291
|
+
organização que o usuário pode usar ali. Use esse campo, e não `myRoles`, para decidir que
|
|
292
|
+
ações mostrar: quem cria o tenant recebe permissões diretas e nenhum papel. Cada membro de
|
|
293
|
+
`organization.members.list()` traz `status` (`active`, `suspended` ou `disabled`) e
|
|
294
|
+
`emailConfirmed`.
|
|
295
|
+
|
|
269
296
|
### `authyon.twoFactor`
|
|
270
297
|
|
|
271
298
|
| Método | Endpoint |
|
|
@@ -164,6 +164,15 @@ interface PaginationOptions {
|
|
|
164
164
|
skip?: number;
|
|
165
165
|
take?: number;
|
|
166
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Options for a member listing. Always newest member first.
|
|
169
|
+
* `search` keeps members whose email, username or name ("first last")
|
|
170
|
+
* contains it, case-insensitively; `%` and `_` count as text. At most 100
|
|
171
|
+
* characters; blank lists everyone.
|
|
172
|
+
*/
|
|
173
|
+
interface MemberListOptions extends PaginationOptions {
|
|
174
|
+
search?: string;
|
|
175
|
+
}
|
|
167
176
|
/**
|
|
168
177
|
* The envelope every paged endpoint answers with.
|
|
169
178
|
*
|
|
@@ -197,6 +206,66 @@ interface IntrospectResult {
|
|
|
197
206
|
jti?: string;
|
|
198
207
|
token_type?: string;
|
|
199
208
|
}
|
|
209
|
+
/** Fields a tenant listing can order by. */
|
|
210
|
+
type TenantOrderField = "name" | "createdAt" | "updatedAt";
|
|
211
|
+
/**
|
|
212
|
+
* A server-side order: a field as a bare name (ascending) or with a direction.
|
|
213
|
+
* Ties always break on the id, so a row cannot move across a page boundary
|
|
214
|
+
* between two calls.
|
|
215
|
+
*/
|
|
216
|
+
type TenantOrder = TenantOrderField | {
|
|
217
|
+
field: TenantOrderField;
|
|
218
|
+
direction?: "asc" | "desc";
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Options for a sub-tenant listing on the end-user routes
|
|
222
|
+
* (`/auth/tenants/{id}/subtenants` and `/auth/tenants/subtenants`).
|
|
223
|
+
*
|
|
224
|
+
* The same knobs as the environment's tenant list, cut down to what a member
|
|
225
|
+
* is shown:
|
|
226
|
+
*
|
|
227
|
+
* - `search`: one substring, case-insensitive, over the name, the slug, the
|
|
228
|
+
* description and the public metadata. Never the private metadata. At most
|
|
229
|
+
* 100 characters; blank lists everything.
|
|
230
|
+
* - `filter`: structured conditions, ANDed, at most 10 — build them with
|
|
231
|
+
* `tenantFilter`. Only the `public` scope: a `private.*` or `custom.*`
|
|
232
|
+
* filter would let a member test values they cannot read, so it raises
|
|
233
|
+
* `RangeError` here (and is a 400 `tenant.filter.invalid` on the API).
|
|
234
|
+
* - `orderBy`: `name` (the default, ascending), `createdAt` or `updatedAt`.
|
|
235
|
+
*
|
|
236
|
+
* There is no `status`: only active sub-tenants are listed, since everything
|
|
237
|
+
* below a disabled one is closed to reads from above.
|
|
238
|
+
*/
|
|
239
|
+
interface SubTenantListOptions extends PaginationOptions {
|
|
240
|
+
search?: string;
|
|
241
|
+
filter?: string[];
|
|
242
|
+
orderBy?: TenantOrder;
|
|
243
|
+
}
|
|
244
|
+
/** The tenant another one hangs from: enough to name it in a breadcrumb. */
|
|
245
|
+
interface TenantParent {
|
|
246
|
+
id: string;
|
|
247
|
+
slug: string;
|
|
248
|
+
name: string;
|
|
249
|
+
}
|
|
250
|
+
/** One direct sub-tenant, as the end-user sub-tenant listings return it. */
|
|
251
|
+
interface SubTenant {
|
|
252
|
+
id: string;
|
|
253
|
+
slug: string;
|
|
254
|
+
name: string;
|
|
255
|
+
description: string | null;
|
|
256
|
+
/** Distance from the root: `1` for a child of a root. */
|
|
257
|
+
depth: number;
|
|
258
|
+
/** Its own direct sub-tenants. Ask for the next level only where this is above zero. */
|
|
259
|
+
childCount: number;
|
|
260
|
+
/** Whether the user also belongs to it directly. */
|
|
261
|
+
isMember: boolean;
|
|
262
|
+
createdAt: string;
|
|
263
|
+
updatedAt: string;
|
|
264
|
+
/** JSON-encoded metadata visible to members. */
|
|
265
|
+
publicMetadata: string;
|
|
266
|
+
/** The tenant it hangs from — the same on every row of a page, carried so a row stands on its own. */
|
|
267
|
+
parent: TenantParent;
|
|
268
|
+
}
|
|
200
269
|
|
|
201
270
|
/**
|
|
202
271
|
* Organization membership (the Authyon API calls this a "tenant" on the
|
|
@@ -223,7 +292,46 @@ interface Organization {
|
|
|
223
292
|
inherited?: boolean;
|
|
224
293
|
/** Distance from the root: `0` at a root organization. Indent the switcher by it. */
|
|
225
294
|
depth?: number;
|
|
295
|
+
/**
|
|
296
|
+
* The parent's id, `null` for a root. Only `organization.list()` fills it —
|
|
297
|
+
* with `depth`, it nests the switcher's flat list into a tree. `get`,
|
|
298
|
+
* `create` and `rename` send `parent` instead. Absent from an API older than
|
|
299
|
+
* 2026-11-26.
|
|
300
|
+
*/
|
|
301
|
+
parentTenantId?: string | null;
|
|
302
|
+
/**
|
|
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`;
|
|
305
|
+
* absent from an API older than 2026-11-26.
|
|
306
|
+
*/
|
|
307
|
+
parent?: TenantParent | null;
|
|
308
|
+
/**
|
|
309
|
+
* A disabled organization still reads, but every change to it is refused
|
|
310
|
+
* with `tenant.disabled`. Filled by `get`, `create` and `rename`; absent from
|
|
311
|
+
* an API older than 2026-11-26.
|
|
312
|
+
*/
|
|
313
|
+
isDisabled?: boolean;
|
|
314
|
+
/** Roles the user holds in it; empty when they reach it from an ancestor. Filled by `get`, `create` and `rename`. */
|
|
315
|
+
myRoles?: string[];
|
|
316
|
+
/**
|
|
317
|
+
* The organization-route permissions the user can use on it, as concrete
|
|
318
|
+
* values: `tenants:*` on their own organization, `subtenants:tree:*` from
|
|
319
|
+
* above. This, not `myRoles`, is what decides which actions to offer — the
|
|
320
|
+
* creator holds direct grants and no role. Filled by `get`, `create` and
|
|
321
|
+
* `rename`; absent from an API older than 2026-11-26.
|
|
322
|
+
*/
|
|
323
|
+
myPermissions?: string[];
|
|
324
|
+
/** How many members it has. Filled by `get`, `create` and `rename`. */
|
|
325
|
+
memberCount?: number;
|
|
226
326
|
}
|
|
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;
|
|
227
335
|
/** POST /auth/tenants — creates an organization owned by the signed-in user. */
|
|
228
336
|
interface CreateOrganizationInput {
|
|
229
337
|
name?: string;
|
|
@@ -252,6 +360,13 @@ interface OrganizationMember {
|
|
|
252
360
|
roles?: string[];
|
|
253
361
|
createdAt?: string;
|
|
254
362
|
lastLoginAt?: string | null;
|
|
363
|
+
/**
|
|
364
|
+
* Account status: `"active"`, `"suspended"` (a temporary hold is in force) or
|
|
365
|
+
* `"disabled"`. Absent from an API older than 2026-11-26.
|
|
366
|
+
*/
|
|
367
|
+
status?: "active" | "suspended" | "disabled";
|
|
368
|
+
/** Whether the member confirmed their e-mail. Absent from an API older than 2026-11-26. */
|
|
369
|
+
emailConfirmed?: boolean;
|
|
255
370
|
}
|
|
256
371
|
/** POST /auth/tenants/{tenantId}/members — invites a member by e-mail. */
|
|
257
372
|
interface InviteMemberInput {
|
|
@@ -490,6 +605,8 @@ interface Activity {
|
|
|
490
605
|
interface Role {
|
|
491
606
|
id: string;
|
|
492
607
|
name: string;
|
|
608
|
+
/** Label to show instead of `name`, when the operator set one. Absent from an API older than 2026-11-26. */
|
|
609
|
+
displayName?: string | null;
|
|
493
610
|
description?: string;
|
|
494
611
|
permissions?: string[];
|
|
495
612
|
}
|
|
@@ -773,11 +890,12 @@ declare class AuthyonClient {
|
|
|
773
890
|
members: {
|
|
774
891
|
/**
|
|
775
892
|
* GET /auth/tenants/{organizationId}/members — paginated list of an
|
|
776
|
-
* organization's members
|
|
777
|
-
*
|
|
778
|
-
*
|
|
893
|
+
* organization's members, newest first, in the `Paged<T>` envelope every
|
|
894
|
+
* other `skip`/`take` endpoint returns. `search` matches email, username
|
|
895
|
+
* or name; at most 100 characters, and `take` 1-100, checked before any
|
|
896
|
+
* request.
|
|
779
897
|
*/
|
|
780
|
-
list: (organizationId: string, params?:
|
|
898
|
+
list: (organizationId: string, params?: MemberListOptions) => Promise<Paged<OrganizationMember>>;
|
|
781
899
|
/**
|
|
782
900
|
* POST /auth/tenants/{organizationId}/members — add an existing
|
|
783
901
|
* environment user by e-mail (no e-mail is sent). To invite an address
|
|
@@ -825,6 +943,34 @@ declare class AuthyonClient {
|
|
|
825
943
|
*/
|
|
826
944
|
accept: (params: AcceptOrganizationInviteInput) => Promise<OrganizationInviteAccepted>;
|
|
827
945
|
};
|
|
946
|
+
/**
|
|
947
|
+
* The direct, active sub-organizations of an organization. One level per
|
|
948
|
+
* call: each row's `childCount` says where the next call is worth making,
|
|
949
|
+
* which is what a lazily expanded tree asks for.
|
|
950
|
+
*
|
|
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
|
|
953
|
+
* reading below it. Paged like every other `skip`/`take` listing, with
|
|
954
|
+
* `search` (name, slug, description and public metadata), `filter` (public
|
|
955
|
+
* scope only — build them with `tenantFilter`) and `orderBy`
|
|
956
|
+
* (`name` | `createdAt` | `updatedAt`, ascending or descending). A bad
|
|
957
|
+
* option raises `RangeError` before any request.
|
|
958
|
+
*
|
|
959
|
+
* Not the same list as `organization.list()`, which is the switcher's and
|
|
960
|
+
* only brings what `subtenants:tree:switch` lets the user enter. Requires
|
|
961
|
+
* the Authyon API of 2026-11-26 or newer.
|
|
962
|
+
*/
|
|
963
|
+
subOrganizations: {
|
|
964
|
+
/** GET /auth/tenants/{organizationId}/subtenants. */
|
|
965
|
+
list: (organizationId: string, params?: SubOrganizationListOptions) => Promise<Paged<SubOrganization>>;
|
|
966
|
+
/**
|
|
967
|
+
* GET /auth/tenants/subtenants — the same, for the organization the
|
|
968
|
+
* session is scoped to (`organization.current()`, the token's
|
|
969
|
+
* `tenant_id`). Same permission rule; answers `tenant.no_active_tenant`
|
|
970
|
+
* when the session never switched into one.
|
|
971
|
+
*/
|
|
972
|
+
listCurrent: (params?: SubOrganizationListOptions) => Promise<Paged<SubOrganization>>;
|
|
973
|
+
};
|
|
828
974
|
roles: {
|
|
829
975
|
/** GET /auth/tenants/{organizationId}/roles — roles available in the organization. */
|
|
830
976
|
list: (organizationId: string) => Promise<Role[]>;
|
|
@@ -1021,4 +1167,4 @@ declare function hasPermissionGroup(source: AuthyonPermissionSource | readonly s
|
|
|
1021
1167
|
/** Converts Authyon's `subject:action` permission strings to authorization rules. */
|
|
1022
1168
|
declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
|
|
1023
1169
|
|
|
1024
|
-
export { type
|
|
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 };
|
|
@@ -164,6 +164,15 @@ interface PaginationOptions {
|
|
|
164
164
|
skip?: number;
|
|
165
165
|
take?: number;
|
|
166
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Options for a member listing. Always newest member first.
|
|
169
|
+
* `search` keeps members whose email, username or name ("first last")
|
|
170
|
+
* contains it, case-insensitively; `%` and `_` count as text. At most 100
|
|
171
|
+
* characters; blank lists everyone.
|
|
172
|
+
*/
|
|
173
|
+
interface MemberListOptions extends PaginationOptions {
|
|
174
|
+
search?: string;
|
|
175
|
+
}
|
|
167
176
|
/**
|
|
168
177
|
* The envelope every paged endpoint answers with.
|
|
169
178
|
*
|
|
@@ -197,6 +206,66 @@ interface IntrospectResult {
|
|
|
197
206
|
jti?: string;
|
|
198
207
|
token_type?: string;
|
|
199
208
|
}
|
|
209
|
+
/** Fields a tenant listing can order by. */
|
|
210
|
+
type TenantOrderField = "name" | "createdAt" | "updatedAt";
|
|
211
|
+
/**
|
|
212
|
+
* A server-side order: a field as a bare name (ascending) or with a direction.
|
|
213
|
+
* Ties always break on the id, so a row cannot move across a page boundary
|
|
214
|
+
* between two calls.
|
|
215
|
+
*/
|
|
216
|
+
type TenantOrder = TenantOrderField | {
|
|
217
|
+
field: TenantOrderField;
|
|
218
|
+
direction?: "asc" | "desc";
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Options for a sub-tenant listing on the end-user routes
|
|
222
|
+
* (`/auth/tenants/{id}/subtenants` and `/auth/tenants/subtenants`).
|
|
223
|
+
*
|
|
224
|
+
* The same knobs as the environment's tenant list, cut down to what a member
|
|
225
|
+
* is shown:
|
|
226
|
+
*
|
|
227
|
+
* - `search`: one substring, case-insensitive, over the name, the slug, the
|
|
228
|
+
* description and the public metadata. Never the private metadata. At most
|
|
229
|
+
* 100 characters; blank lists everything.
|
|
230
|
+
* - `filter`: structured conditions, ANDed, at most 10 — build them with
|
|
231
|
+
* `tenantFilter`. Only the `public` scope: a `private.*` or `custom.*`
|
|
232
|
+
* filter would let a member test values they cannot read, so it raises
|
|
233
|
+
* `RangeError` here (and is a 400 `tenant.filter.invalid` on the API).
|
|
234
|
+
* - `orderBy`: `name` (the default, ascending), `createdAt` or `updatedAt`.
|
|
235
|
+
*
|
|
236
|
+
* There is no `status`: only active sub-tenants are listed, since everything
|
|
237
|
+
* below a disabled one is closed to reads from above.
|
|
238
|
+
*/
|
|
239
|
+
interface SubTenantListOptions extends PaginationOptions {
|
|
240
|
+
search?: string;
|
|
241
|
+
filter?: string[];
|
|
242
|
+
orderBy?: TenantOrder;
|
|
243
|
+
}
|
|
244
|
+
/** The tenant another one hangs from: enough to name it in a breadcrumb. */
|
|
245
|
+
interface TenantParent {
|
|
246
|
+
id: string;
|
|
247
|
+
slug: string;
|
|
248
|
+
name: string;
|
|
249
|
+
}
|
|
250
|
+
/** One direct sub-tenant, as the end-user sub-tenant listings return it. */
|
|
251
|
+
interface SubTenant {
|
|
252
|
+
id: string;
|
|
253
|
+
slug: string;
|
|
254
|
+
name: string;
|
|
255
|
+
description: string | null;
|
|
256
|
+
/** Distance from the root: `1` for a child of a root. */
|
|
257
|
+
depth: number;
|
|
258
|
+
/** Its own direct sub-tenants. Ask for the next level only where this is above zero. */
|
|
259
|
+
childCount: number;
|
|
260
|
+
/** Whether the user also belongs to it directly. */
|
|
261
|
+
isMember: boolean;
|
|
262
|
+
createdAt: string;
|
|
263
|
+
updatedAt: string;
|
|
264
|
+
/** JSON-encoded metadata visible to members. */
|
|
265
|
+
publicMetadata: string;
|
|
266
|
+
/** The tenant it hangs from — the same on every row of a page, carried so a row stands on its own. */
|
|
267
|
+
parent: TenantParent;
|
|
268
|
+
}
|
|
200
269
|
|
|
201
270
|
/**
|
|
202
271
|
* Organization membership (the Authyon API calls this a "tenant" on the
|
|
@@ -223,7 +292,46 @@ interface Organization {
|
|
|
223
292
|
inherited?: boolean;
|
|
224
293
|
/** Distance from the root: `0` at a root organization. Indent the switcher by it. */
|
|
225
294
|
depth?: number;
|
|
295
|
+
/**
|
|
296
|
+
* The parent's id, `null` for a root. Only `organization.list()` fills it —
|
|
297
|
+
* with `depth`, it nests the switcher's flat list into a tree. `get`,
|
|
298
|
+
* `create` and `rename` send `parent` instead. Absent from an API older than
|
|
299
|
+
* 2026-11-26.
|
|
300
|
+
*/
|
|
301
|
+
parentTenantId?: string | null;
|
|
302
|
+
/**
|
|
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`;
|
|
305
|
+
* absent from an API older than 2026-11-26.
|
|
306
|
+
*/
|
|
307
|
+
parent?: TenantParent | null;
|
|
308
|
+
/**
|
|
309
|
+
* A disabled organization still reads, but every change to it is refused
|
|
310
|
+
* with `tenant.disabled`. Filled by `get`, `create` and `rename`; absent from
|
|
311
|
+
* an API older than 2026-11-26.
|
|
312
|
+
*/
|
|
313
|
+
isDisabled?: boolean;
|
|
314
|
+
/** Roles the user holds in it; empty when they reach it from an ancestor. Filled by `get`, `create` and `rename`. */
|
|
315
|
+
myRoles?: string[];
|
|
316
|
+
/**
|
|
317
|
+
* The organization-route permissions the user can use on it, as concrete
|
|
318
|
+
* values: `tenants:*` on their own organization, `subtenants:tree:*` from
|
|
319
|
+
* above. This, not `myRoles`, is what decides which actions to offer — the
|
|
320
|
+
* creator holds direct grants and no role. Filled by `get`, `create` and
|
|
321
|
+
* `rename`; absent from an API older than 2026-11-26.
|
|
322
|
+
*/
|
|
323
|
+
myPermissions?: string[];
|
|
324
|
+
/** How many members it has. Filled by `get`, `create` and `rename`. */
|
|
325
|
+
memberCount?: number;
|
|
226
326
|
}
|
|
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;
|
|
227
335
|
/** POST /auth/tenants — creates an organization owned by the signed-in user. */
|
|
228
336
|
interface CreateOrganizationInput {
|
|
229
337
|
name?: string;
|
|
@@ -252,6 +360,13 @@ interface OrganizationMember {
|
|
|
252
360
|
roles?: string[];
|
|
253
361
|
createdAt?: string;
|
|
254
362
|
lastLoginAt?: string | null;
|
|
363
|
+
/**
|
|
364
|
+
* Account status: `"active"`, `"suspended"` (a temporary hold is in force) or
|
|
365
|
+
* `"disabled"`. Absent from an API older than 2026-11-26.
|
|
366
|
+
*/
|
|
367
|
+
status?: "active" | "suspended" | "disabled";
|
|
368
|
+
/** Whether the member confirmed their e-mail. Absent from an API older than 2026-11-26. */
|
|
369
|
+
emailConfirmed?: boolean;
|
|
255
370
|
}
|
|
256
371
|
/** POST /auth/tenants/{tenantId}/members — invites a member by e-mail. */
|
|
257
372
|
interface InviteMemberInput {
|
|
@@ -490,6 +605,8 @@ interface Activity {
|
|
|
490
605
|
interface Role {
|
|
491
606
|
id: string;
|
|
492
607
|
name: string;
|
|
608
|
+
/** Label to show instead of `name`, when the operator set one. Absent from an API older than 2026-11-26. */
|
|
609
|
+
displayName?: string | null;
|
|
493
610
|
description?: string;
|
|
494
611
|
permissions?: string[];
|
|
495
612
|
}
|
|
@@ -773,11 +890,12 @@ declare class AuthyonClient {
|
|
|
773
890
|
members: {
|
|
774
891
|
/**
|
|
775
892
|
* GET /auth/tenants/{organizationId}/members — paginated list of an
|
|
776
|
-
* organization's members
|
|
777
|
-
*
|
|
778
|
-
*
|
|
893
|
+
* organization's members, newest first, in the `Paged<T>` envelope every
|
|
894
|
+
* other `skip`/`take` endpoint returns. `search` matches email, username
|
|
895
|
+
* or name; at most 100 characters, and `take` 1-100, checked before any
|
|
896
|
+
* request.
|
|
779
897
|
*/
|
|
780
|
-
list: (organizationId: string, params?:
|
|
898
|
+
list: (organizationId: string, params?: MemberListOptions) => Promise<Paged<OrganizationMember>>;
|
|
781
899
|
/**
|
|
782
900
|
* POST /auth/tenants/{organizationId}/members — add an existing
|
|
783
901
|
* environment user by e-mail (no e-mail is sent). To invite an address
|
|
@@ -825,6 +943,34 @@ declare class AuthyonClient {
|
|
|
825
943
|
*/
|
|
826
944
|
accept: (params: AcceptOrganizationInviteInput) => Promise<OrganizationInviteAccepted>;
|
|
827
945
|
};
|
|
946
|
+
/**
|
|
947
|
+
* The direct, active sub-organizations of an organization. One level per
|
|
948
|
+
* call: each row's `childCount` says where the next call is worth making,
|
|
949
|
+
* which is what a lazily expanded tree asks for.
|
|
950
|
+
*
|
|
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
|
|
953
|
+
* reading below it. Paged like every other `skip`/`take` listing, with
|
|
954
|
+
* `search` (name, slug, description and public metadata), `filter` (public
|
|
955
|
+
* scope only — build them with `tenantFilter`) and `orderBy`
|
|
956
|
+
* (`name` | `createdAt` | `updatedAt`, ascending or descending). A bad
|
|
957
|
+
* option raises `RangeError` before any request.
|
|
958
|
+
*
|
|
959
|
+
* Not the same list as `organization.list()`, which is the switcher's and
|
|
960
|
+
* only brings what `subtenants:tree:switch` lets the user enter. Requires
|
|
961
|
+
* the Authyon API of 2026-11-26 or newer.
|
|
962
|
+
*/
|
|
963
|
+
subOrganizations: {
|
|
964
|
+
/** GET /auth/tenants/{organizationId}/subtenants. */
|
|
965
|
+
list: (organizationId: string, params?: SubOrganizationListOptions) => Promise<Paged<SubOrganization>>;
|
|
966
|
+
/**
|
|
967
|
+
* GET /auth/tenants/subtenants — the same, for the organization the
|
|
968
|
+
* session is scoped to (`organization.current()`, the token's
|
|
969
|
+
* `tenant_id`). Same permission rule; answers `tenant.no_active_tenant`
|
|
970
|
+
* when the session never switched into one.
|
|
971
|
+
*/
|
|
972
|
+
listCurrent: (params?: SubOrganizationListOptions) => Promise<Paged<SubOrganization>>;
|
|
973
|
+
};
|
|
828
974
|
roles: {
|
|
829
975
|
/** GET /auth/tenants/{organizationId}/roles — roles available in the organization. */
|
|
830
976
|
list: (organizationId: string) => Promise<Role[]>;
|
|
@@ -1021,4 +1167,4 @@ declare function hasPermissionGroup(source: AuthyonPermissionSource | readonly s
|
|
|
1021
1167
|
/** Converts Authyon's `subject:action` permission strings to authorization rules. */
|
|
1022
1168
|
declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
|
|
1023
1169
|
|
|
1024
|
-
export { type
|
|
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 };
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,9 @@ __export(index_exports, {
|
|
|
30
30
|
FetchHttpAdapter: () => FetchHttpAdapter,
|
|
31
31
|
LoggingHttpAdapter: () => LoggingHttpAdapter,
|
|
32
32
|
SubtenantPermissions: () => SubtenantPermissions,
|
|
33
|
+
TENANT_FILTER_MAX_DEPTH: () => TENANT_FILTER_MAX_DEPTH,
|
|
34
|
+
TENANT_FILTER_MAX_VALUES: () => TENANT_FILTER_MAX_VALUES,
|
|
35
|
+
TENANT_FILTER_MAX_VALUE_LENGTH: () => TENANT_FILTER_MAX_VALUE_LENGTH,
|
|
33
36
|
TenantPermissions: () => TenantPermissions,
|
|
34
37
|
createAuthyonAbility: () => createAuthyonAbility,
|
|
35
38
|
createAuthyonRules: () => createAuthyonRules,
|
|
@@ -38,7 +41,8 @@ __export(index_exports, {
|
|
|
38
41
|
createLocalStorage: () => createLocalStorage,
|
|
39
42
|
createMemoryStorage: () => createMemoryStorage,
|
|
40
43
|
hasPermission: () => hasPermission,
|
|
41
|
-
hasPermissionGroup: () => hasPermissionGroup
|
|
44
|
+
hasPermissionGroup: () => hasPermissionGroup,
|
|
45
|
+
tenantFilter: () => tenantFilter
|
|
42
46
|
});
|
|
43
47
|
module.exports = __toCommonJS(index_exports);
|
|
44
48
|
|
|
@@ -499,6 +503,57 @@ function invalidClientIp() {
|
|
|
499
503
|
return new Error("Authyon: `clientIp` must be a single valid IPv4 or IPv6 address");
|
|
500
504
|
}
|
|
501
505
|
|
|
506
|
+
// ../../internal/core/http/memberQuery.ts
|
|
507
|
+
function memberQuery(options = {}) {
|
|
508
|
+
const { skip, take, search } = options;
|
|
509
|
+
if (skip !== void 0 && (!Number.isInteger(skip) || skip < 0 || skip > 2147483647))
|
|
510
|
+
throw new RangeError("Authyon: invalid skip.");
|
|
511
|
+
if (take !== void 0 && (!Number.isInteger(take) || take < 1 || take > 100))
|
|
512
|
+
throw new RangeError("Authyon: take must be between 1 and 100.");
|
|
513
|
+
if (search !== void 0 && (typeof search !== "string" || search.trim().length > 100))
|
|
514
|
+
throw new RangeError("Authyon: search must contain at most 100 characters.");
|
|
515
|
+
return { search: search?.trim() || void 0, skip, take };
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// ../../internal/core/http/subTenantQuery.ts
|
|
519
|
+
var ORDER_FIELDS = ["name", "createdAt", "updatedAt"];
|
|
520
|
+
var MAX_FILTERS = 10;
|
|
521
|
+
var MAX_FILTER_LENGTH = 512;
|
|
522
|
+
function orderByParam(order) {
|
|
523
|
+
if (order === void 0) return void 0;
|
|
524
|
+
const field = typeof order === "string" ? order : order?.field;
|
|
525
|
+
const direction = typeof order === "string" ? "asc" : order.direction ?? "asc";
|
|
526
|
+
if (!ORDER_FIELDS.includes(field))
|
|
527
|
+
throw new RangeError(`Authyon: orderBy must be one of ${ORDER_FIELDS.join(", ")}.`);
|
|
528
|
+
if (direction !== "asc" && direction !== "desc")
|
|
529
|
+
throw new RangeError('Authyon: orderBy direction must be "asc" or "desc".');
|
|
530
|
+
return `${field}:${direction}`;
|
|
531
|
+
}
|
|
532
|
+
function subTenantQuery(options = {}) {
|
|
533
|
+
const { filter, orderBy, ...page } = options;
|
|
534
|
+
const query = { ...memberQuery(page) };
|
|
535
|
+
if (filter !== void 0) {
|
|
536
|
+
if (!Array.isArray(filter)) throw new RangeError("Authyon: filter must be an array.");
|
|
537
|
+
const present = filter.filter((f) => typeof f === "string" && f.trim().length > 0);
|
|
538
|
+
if (present.length !== filter.length)
|
|
539
|
+
throw new RangeError("Authyon: a filter may not be empty \u2014 build it with tenantFilter.");
|
|
540
|
+
if (present.length > MAX_FILTERS)
|
|
541
|
+
throw new RangeError(`Authyon: at most ${MAX_FILTERS} filters per request.`);
|
|
542
|
+
for (const f of present) {
|
|
543
|
+
if (f.length > MAX_FILTER_LENGTH)
|
|
544
|
+
throw new RangeError(`Authyon: a filter may hold at most ${MAX_FILTER_LENGTH} characters.`);
|
|
545
|
+
if (!f.startsWith("public."))
|
|
546
|
+
throw new RangeError(
|
|
547
|
+
`Authyon: sub-tenant listings only filter on the public scope (got "${f.split(":")[0]}").`
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
if (present.length > 0) query.filter = present;
|
|
551
|
+
}
|
|
552
|
+
const order = orderByParam(orderBy);
|
|
553
|
+
if (order !== void 0) query.orderBy = order;
|
|
554
|
+
return query;
|
|
555
|
+
}
|
|
556
|
+
|
|
502
557
|
// src/client/authyonClient.ts
|
|
503
558
|
var FALLBACK_EXPIRES_IN = 1800;
|
|
504
559
|
function readTokens(raw) {
|
|
@@ -672,12 +727,16 @@ var AuthyonClient = class {
|
|
|
672
727
|
members: {
|
|
673
728
|
/**
|
|
674
729
|
* GET /auth/tenants/{organizationId}/members — paginated list of an
|
|
675
|
-
* organization's members
|
|
676
|
-
*
|
|
677
|
-
*
|
|
730
|
+
* organization's members, newest first, in the `Paged<T>` envelope every
|
|
731
|
+
* other `skip`/`take` endpoint returns. `search` matches email, username
|
|
732
|
+
* or name; at most 100 characters, and `take` 1-100, checked before any
|
|
733
|
+
* request.
|
|
678
734
|
*/
|
|
679
735
|
list: (organizationId, params = {}) => this.request(
|
|
680
|
-
appendQuery(
|
|
736
|
+
appendQuery(
|
|
737
|
+
`/auth/tenants/${encodeURIComponent(organizationId)}/members`,
|
|
738
|
+
memberQuery(params)
|
|
739
|
+
),
|
|
681
740
|
{ bearer: true }
|
|
682
741
|
),
|
|
683
742
|
/**
|
|
@@ -749,6 +808,42 @@ var AuthyonClient = class {
|
|
|
749
808
|
*/
|
|
750
809
|
accept: (params) => this.request("/auth/tenant-invites/accept", { method: "POST", body: params })
|
|
751
810
|
},
|
|
811
|
+
/**
|
|
812
|
+
* The direct, active sub-organizations of an organization. One level per
|
|
813
|
+
* call: each row's `childCount` says where the next call is worth making,
|
|
814
|
+
* which is what a lazily expanded tree asks for.
|
|
815
|
+
*
|
|
816
|
+
* Needs `subtenants:tree:read` on the organization or on one above it —
|
|
817
|
+
* even on the user's own organization, since listing the children is
|
|
818
|
+
* reading below it. Paged like every other `skip`/`take` listing, with
|
|
819
|
+
* `search` (name, slug, description and public metadata), `filter` (public
|
|
820
|
+
* scope only — build them with `tenantFilter`) and `orderBy`
|
|
821
|
+
* (`name` | `createdAt` | `updatedAt`, ascending or descending). A bad
|
|
822
|
+
* option raises `RangeError` before any request.
|
|
823
|
+
*
|
|
824
|
+
* Not the same list as `organization.list()`, which is the switcher's and
|
|
825
|
+
* only brings what `subtenants:tree:switch` lets the user enter. Requires
|
|
826
|
+
* the Authyon API of 2026-11-26 or newer.
|
|
827
|
+
*/
|
|
828
|
+
subOrganizations: {
|
|
829
|
+
/** GET /auth/tenants/{organizationId}/subtenants. */
|
|
830
|
+
list: (organizationId, params = {}) => this.request(
|
|
831
|
+
appendQuery(
|
|
832
|
+
`/auth/tenants/${encodeURIComponent(organizationId)}/subtenants`,
|
|
833
|
+
subTenantQuery(params)
|
|
834
|
+
),
|
|
835
|
+
{ bearer: true }
|
|
836
|
+
),
|
|
837
|
+
/**
|
|
838
|
+
* GET /auth/tenants/subtenants — the same, for the organization the
|
|
839
|
+
* session is scoped to (`organization.current()`, the token's
|
|
840
|
+
* `tenant_id`). Same permission rule; answers `tenant.no_active_tenant`
|
|
841
|
+
* when the session never switched into one.
|
|
842
|
+
*/
|
|
843
|
+
listCurrent: (params = {}) => this.request(appendQuery("/auth/tenants/subtenants", subTenantQuery(params)), {
|
|
844
|
+
bearer: true
|
|
845
|
+
})
|
|
846
|
+
},
|
|
752
847
|
roles: {
|
|
753
848
|
/** GET /auth/tenants/{organizationId}/roles — roles available in the organization. */
|
|
754
849
|
list: (organizationId) => this.request(`/auth/tenants/${encodeURIComponent(organizationId)}/roles`, {
|
|
@@ -1150,6 +1245,86 @@ var AuthyonClientBuilder = class {
|
|
|
1150
1245
|
}
|
|
1151
1246
|
};
|
|
1152
1247
|
|
|
1248
|
+
// ../../internal/core/http/tenantFilters.ts
|
|
1249
|
+
var TENANT_FILTER_MAX_VALUES = 25;
|
|
1250
|
+
var TENANT_FILTER_MAX_VALUE_LENGTH = 200;
|
|
1251
|
+
var TENANT_FILTER_MAX_DEPTH = 3;
|
|
1252
|
+
var SCOPES = ["public", "private", "custom"];
|
|
1253
|
+
var KEY_SEGMENT = /^[A-Za-z0-9_-]{1,64}$/;
|
|
1254
|
+
function assertPath(path2) {
|
|
1255
|
+
if (typeof path2 !== "string" || path2.length === 0) {
|
|
1256
|
+
throw new RangeError("Authyon: a filter path is required, e.g. public.kind.");
|
|
1257
|
+
}
|
|
1258
|
+
const [scope, ...keys] = path2.split(".");
|
|
1259
|
+
if (!SCOPES.includes(scope)) {
|
|
1260
|
+
throw new RangeError(
|
|
1261
|
+
`Authyon: unknown filter scope "${scope}" \u2014 use ${SCOPES.join(", ")} (e.g. public.kind).`
|
|
1262
|
+
);
|
|
1263
|
+
}
|
|
1264
|
+
if (keys.length === 0) {
|
|
1265
|
+
throw new RangeError(`Authyon: filter path "${path2}" needs a key after the scope.`);
|
|
1266
|
+
}
|
|
1267
|
+
if (keys.length > TENANT_FILTER_MAX_DEPTH) {
|
|
1268
|
+
throw new RangeError(
|
|
1269
|
+
`Authyon: filter path "${path2}" goes deeper than ${TENANT_FILTER_MAX_DEPTH} levels.`
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
for (const key of keys) {
|
|
1273
|
+
if (!KEY_SEGMENT.test(key)) {
|
|
1274
|
+
throw new RangeError(
|
|
1275
|
+
`Authyon: invalid filter key "${key}" \u2014 letters, digits, "_" and "-", up to 64 characters.`
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
return path2;
|
|
1280
|
+
}
|
|
1281
|
+
function assertValue(value, forIn) {
|
|
1282
|
+
if (value === void 0 || value === null) {
|
|
1283
|
+
throw new RangeError("Authyon: a filter value is required.");
|
|
1284
|
+
}
|
|
1285
|
+
const text = String(value);
|
|
1286
|
+
if (text.length === 0) {
|
|
1287
|
+
throw new RangeError("Authyon: a filter value may not be empty.");
|
|
1288
|
+
}
|
|
1289
|
+
if (text.length > TENANT_FILTER_MAX_VALUE_LENGTH) {
|
|
1290
|
+
throw new RangeError(
|
|
1291
|
+
`Authyon: a filter value may hold at most ${TENANT_FILTER_MAX_VALUE_LENGTH} characters.`
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
if (text.includes(",")) {
|
|
1295
|
+
throw new RangeError(
|
|
1296
|
+
forIn ? "Authyon: an `in` value may not contain a comma \u2014 pass separate values instead." : "Authyon: a filter value may not contain a comma."
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
return text;
|
|
1300
|
+
}
|
|
1301
|
+
var tenantFilter = {
|
|
1302
|
+
/** `public.kind:eq:reseller` — the key equals this value. */
|
|
1303
|
+
eq(path2, value) {
|
|
1304
|
+
return `${assertPath(path2)}:eq:${assertValue(value, false)}`;
|
|
1305
|
+
},
|
|
1306
|
+
/** `public.kind:in:reseller,partner` — the key equals any of these (SQL IN). */
|
|
1307
|
+
in(path2, values) {
|
|
1308
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
1309
|
+
throw new RangeError("Authyon: `in` needs at least one value.");
|
|
1310
|
+
}
|
|
1311
|
+
if (values.length > TENANT_FILTER_MAX_VALUES) {
|
|
1312
|
+
throw new RangeError(`Authyon: \`in\` takes at most ${TENANT_FILTER_MAX_VALUES} values.`);
|
|
1313
|
+
}
|
|
1314
|
+
const unique = [...new Set(values.map((value) => assertValue(value, true)))];
|
|
1315
|
+
return `${assertPath(path2)}:in:${unique.join(",")}`;
|
|
1316
|
+
},
|
|
1317
|
+
/** `public.notes:like:nacional` — the key contains this text, case-insensitive.
|
|
1318
|
+
* The server escapes the LIKE metacharacters, so `100%` means `100%`. */
|
|
1319
|
+
like(path2, text) {
|
|
1320
|
+
return `${assertPath(path2)}:like:${assertValue(text, false)}`;
|
|
1321
|
+
},
|
|
1322
|
+
/** `custom.cnpj:exists` — the key is present, whatever its value. */
|
|
1323
|
+
exists(path2) {
|
|
1324
|
+
return `${assertPath(path2)}:exists`;
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
|
|
1153
1328
|
// src/session/sessionController.ts
|
|
1154
1329
|
var SERVER_SNAPSHOT = {
|
|
1155
1330
|
// The server cannot inspect browser storage. Reporting unauthenticated here
|
|
@@ -1553,6 +1728,9 @@ var SubtenantPermissions = {
|
|
|
1553
1728
|
FetchHttpAdapter,
|
|
1554
1729
|
LoggingHttpAdapter,
|
|
1555
1730
|
SubtenantPermissions,
|
|
1731
|
+
TENANT_FILTER_MAX_DEPTH,
|
|
1732
|
+
TENANT_FILTER_MAX_VALUES,
|
|
1733
|
+
TENANT_FILTER_MAX_VALUE_LENGTH,
|
|
1556
1734
|
TenantPermissions,
|
|
1557
1735
|
createAuthyonAbility,
|
|
1558
1736
|
createAuthyonRules,
|
|
@@ -1561,5 +1739,6 @@ var SubtenantPermissions = {
|
|
|
1561
1739
|
createLocalStorage,
|
|
1562
1740
|
createMemoryStorage,
|
|
1563
1741
|
hasPermission,
|
|
1564
|
-
hasPermissionGroup
|
|
1742
|
+
hasPermissionGroup,
|
|
1743
|
+
tenantFilter
|
|
1565
1744
|
});
|
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-
|
|
2
|
-
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted,
|
|
1
|
+
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-CmJEviJj.cjs';
|
|
2
|
+
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, M as MemberListOptions, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted, N as OrganizationInviteInput, P as OrganizationInviteIssued, Q as OrganizationInvitePreview, R as OrganizationInviteStatus, S as OrganizationMember, U as Paged, V as PaginationOptions, W as PasswordResetCompleted, X as PasswordResetPreview, Y as PasswordResetRequestOptions, Z as PermissionGroup, _ as RegisterInput, $ as Role, a0 as SecurityMethods, a1 as Session, a2 as SessionControllerOptions, a3 as SessionInfo, a4 as SessionSnapshot, a5 as SessionSnapshotListener, a6 as SessionStatus, a7 as SsoProvider, a8 as SubOrganization, a9 as SubOrganizationListOptions, aa as SubTenant, ab as SubTenantListOptions, ac as SubjectApprovals, ad as SubjectSecurity, ae as TenantOrder, af as TenantOrderField, ag as TenantParent, ah as TwoFactorChallenge, ai as TwoFactorMethod, aj as TwoFactorStatus, ak as User, al as ValidateResult, am as VerifyTwoFactorInput, an as WebAuthnAssertion, ao as WebAuthnCeremonyStart, ap as WebAuthnCredential, aq as createAuthyonAbility, ar as createAuthyonRules, as as createClient, at as hasPermission, au as hasPermissionGroup } from './ability-CmJEviJj.cjs';
|
|
3
3
|
|
|
4
4
|
declare const ErrorCodes: {
|
|
5
5
|
readonly Unknown: "unknown";
|
|
@@ -93,6 +93,43 @@ declare class AuthyonClientBuilder {
|
|
|
93
93
|
build(): AuthyonClient;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Builders for the tenant list's structured filters.
|
|
98
|
+
*
|
|
99
|
+
* The wire form of one filter is `<scope>.<key>:<op>[:<value>]`, repeated once
|
|
100
|
+
* per condition: `?filter=public.kind:in:reseller,partner&filter=custom.cnpj:eq:000`.
|
|
101
|
+
* Repeating the parameter ANDs the conditions and the comma inside `in` is the
|
|
102
|
+
* OR, which is the whole reason to filter server-side — the conditions are part
|
|
103
|
+
* of the SQL statement, so `total`, `pages` and `hasNext` describe the filtered
|
|
104
|
+
* set. A filter applied to a page after it arrives cannot do that.
|
|
105
|
+
*
|
|
106
|
+
* Scopes map to the three JSON documents a tenant carries: `public` →
|
|
107
|
+
* `publicMetadata`, `private` → `privateMetadata`, `custom` → `customFields`
|
|
108
|
+
* (the one the free-text `search` never covered).
|
|
109
|
+
*
|
|
110
|
+
* The rules below mirror the server's parser, so a typo raises `RangeError`
|
|
111
|
+
* here instead of coming back as a 400 `tenant.filter.invalid`.
|
|
112
|
+
*/
|
|
113
|
+
/** One `filter` parameter, ready to send. */
|
|
114
|
+
type TenantFilterExpression = string;
|
|
115
|
+
/** Values the filters accept; numbers and booleans are compared as text, the
|
|
116
|
+
* way `jsonb ->> key` returns them. */
|
|
117
|
+
type TenantFilterValue = string | number | boolean;
|
|
118
|
+
declare const TENANT_FILTER_MAX_VALUES = 25;
|
|
119
|
+
declare const TENANT_FILTER_MAX_VALUE_LENGTH = 200;
|
|
120
|
+
declare const TENANT_FILTER_MAX_DEPTH = 3;
|
|
121
|
+
declare const tenantFilter: {
|
|
122
|
+
/** `public.kind:eq:reseller` — the key equals this value. */
|
|
123
|
+
eq(path: string, value: TenantFilterValue): TenantFilterExpression;
|
|
124
|
+
/** `public.kind:in:reseller,partner` — the key equals any of these (SQL IN). */
|
|
125
|
+
in(path: string, values: readonly TenantFilterValue[]): TenantFilterExpression;
|
|
126
|
+
/** `public.notes:like:nacional` — the key contains this text, case-insensitive.
|
|
127
|
+
* The server escapes the LIKE metacharacters, so `100%` means `100%`. */
|
|
128
|
+
like(path: string, text: string): TenantFilterExpression;
|
|
129
|
+
/** `custom.cnpj:exists` — the key is present, whatever its value. */
|
|
130
|
+
exists(path: string): TenantFilterExpression;
|
|
131
|
+
};
|
|
132
|
+
|
|
96
133
|
/** Keeps the session in memory only (lost on page reload). */
|
|
97
134
|
declare function createMemoryStorage(): TokenStorage;
|
|
98
135
|
/** Persists the session in `localStorage` under a namespaced key. */
|
|
@@ -149,4 +186,4 @@ declare const SubtenantPermissions: {
|
|
|
149
186
|
type TenantPermission = (typeof TenantPermissions)[keyof typeof TenantPermissions];
|
|
150
187
|
type SubtenantPermission = (typeof SubtenantPermissions)[keyof typeof SubtenantPermissions];
|
|
151
188
|
|
|
152
|
-
export { AuthyonClient, AuthyonClientBuilder, AuthyonError, type AuthyonErrorAction, type AuthyonErrorBody, type AuthyonErrorCategory, type AuthyonErrorInterpretation, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode, type SubtenantPermission, SubtenantPermissions, type TenantPermission, TenantPermissions, TokenStorage, createDefaultStorage, createLocalStorage, createMemoryStorage };
|
|
189
|
+
export { AuthyonClient, AuthyonClientBuilder, AuthyonError, type AuthyonErrorAction, type AuthyonErrorBody, type AuthyonErrorCategory, type AuthyonErrorInterpretation, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode, type SubtenantPermission, SubtenantPermissions, TENANT_FILTER_MAX_DEPTH, TENANT_FILTER_MAX_VALUES, TENANT_FILTER_MAX_VALUE_LENGTH, type TenantFilterExpression, type TenantFilterValue, type TenantPermission, TenantPermissions, TokenStorage, createDefaultStorage, createLocalStorage, createMemoryStorage, tenantFilter };
|
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-
|
|
2
|
-
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted,
|
|
1
|
+
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-CmJEviJj.js';
|
|
2
|
+
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, M as MemberListOptions, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted, N as OrganizationInviteInput, P as OrganizationInviteIssued, Q as OrganizationInvitePreview, R as OrganizationInviteStatus, S as OrganizationMember, U as Paged, V as PaginationOptions, W as PasswordResetCompleted, X as PasswordResetPreview, Y as PasswordResetRequestOptions, Z as PermissionGroup, _ as RegisterInput, $ as Role, a0 as SecurityMethods, a1 as Session, a2 as SessionControllerOptions, a3 as SessionInfo, a4 as SessionSnapshot, a5 as SessionSnapshotListener, a6 as SessionStatus, a7 as SsoProvider, a8 as SubOrganization, a9 as SubOrganizationListOptions, aa as SubTenant, ab as SubTenantListOptions, ac as SubjectApprovals, ad as SubjectSecurity, ae as TenantOrder, af as TenantOrderField, ag as TenantParent, ah as TwoFactorChallenge, ai as TwoFactorMethod, aj as TwoFactorStatus, ak as User, al as ValidateResult, am as VerifyTwoFactorInput, an as WebAuthnAssertion, ao as WebAuthnCeremonyStart, ap as WebAuthnCredential, aq as createAuthyonAbility, ar as createAuthyonRules, as as createClient, at as hasPermission, au as hasPermissionGroup } from './ability-CmJEviJj.js';
|
|
3
3
|
|
|
4
4
|
declare const ErrorCodes: {
|
|
5
5
|
readonly Unknown: "unknown";
|
|
@@ -93,6 +93,43 @@ declare class AuthyonClientBuilder {
|
|
|
93
93
|
build(): AuthyonClient;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Builders for the tenant list's structured filters.
|
|
98
|
+
*
|
|
99
|
+
* The wire form of one filter is `<scope>.<key>:<op>[:<value>]`, repeated once
|
|
100
|
+
* per condition: `?filter=public.kind:in:reseller,partner&filter=custom.cnpj:eq:000`.
|
|
101
|
+
* Repeating the parameter ANDs the conditions and the comma inside `in` is the
|
|
102
|
+
* OR, which is the whole reason to filter server-side — the conditions are part
|
|
103
|
+
* of the SQL statement, so `total`, `pages` and `hasNext` describe the filtered
|
|
104
|
+
* set. A filter applied to a page after it arrives cannot do that.
|
|
105
|
+
*
|
|
106
|
+
* Scopes map to the three JSON documents a tenant carries: `public` →
|
|
107
|
+
* `publicMetadata`, `private` → `privateMetadata`, `custom` → `customFields`
|
|
108
|
+
* (the one the free-text `search` never covered).
|
|
109
|
+
*
|
|
110
|
+
* The rules below mirror the server's parser, so a typo raises `RangeError`
|
|
111
|
+
* here instead of coming back as a 400 `tenant.filter.invalid`.
|
|
112
|
+
*/
|
|
113
|
+
/** One `filter` parameter, ready to send. */
|
|
114
|
+
type TenantFilterExpression = string;
|
|
115
|
+
/** Values the filters accept; numbers and booleans are compared as text, the
|
|
116
|
+
* way `jsonb ->> key` returns them. */
|
|
117
|
+
type TenantFilterValue = string | number | boolean;
|
|
118
|
+
declare const TENANT_FILTER_MAX_VALUES = 25;
|
|
119
|
+
declare const TENANT_FILTER_MAX_VALUE_LENGTH = 200;
|
|
120
|
+
declare const TENANT_FILTER_MAX_DEPTH = 3;
|
|
121
|
+
declare const tenantFilter: {
|
|
122
|
+
/** `public.kind:eq:reseller` — the key equals this value. */
|
|
123
|
+
eq(path: string, value: TenantFilterValue): TenantFilterExpression;
|
|
124
|
+
/** `public.kind:in:reseller,partner` — the key equals any of these (SQL IN). */
|
|
125
|
+
in(path: string, values: readonly TenantFilterValue[]): TenantFilterExpression;
|
|
126
|
+
/** `public.notes:like:nacional` — the key contains this text, case-insensitive.
|
|
127
|
+
* The server escapes the LIKE metacharacters, so `100%` means `100%`. */
|
|
128
|
+
like(path: string, text: string): TenantFilterExpression;
|
|
129
|
+
/** `custom.cnpj:exists` — the key is present, whatever its value. */
|
|
130
|
+
exists(path: string): TenantFilterExpression;
|
|
131
|
+
};
|
|
132
|
+
|
|
96
133
|
/** Keeps the session in memory only (lost on page reload). */
|
|
97
134
|
declare function createMemoryStorage(): TokenStorage;
|
|
98
135
|
/** Persists the session in `localStorage` under a namespaced key. */
|
|
@@ -149,4 +186,4 @@ declare const SubtenantPermissions: {
|
|
|
149
186
|
type TenantPermission = (typeof TenantPermissions)[keyof typeof TenantPermissions];
|
|
150
187
|
type SubtenantPermission = (typeof SubtenantPermissions)[keyof typeof SubtenantPermissions];
|
|
151
188
|
|
|
152
|
-
export { AuthyonClient, AuthyonClientBuilder, AuthyonError, type AuthyonErrorAction, type AuthyonErrorBody, type AuthyonErrorCategory, type AuthyonErrorInterpretation, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode, type SubtenantPermission, SubtenantPermissions, type TenantPermission, TenantPermissions, TokenStorage, createDefaultStorage, createLocalStorage, createMemoryStorage };
|
|
189
|
+
export { AuthyonClient, AuthyonClientBuilder, AuthyonError, type AuthyonErrorAction, type AuthyonErrorBody, type AuthyonErrorCategory, type AuthyonErrorInterpretation, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode, type SubtenantPermission, SubtenantPermissions, TENANT_FILTER_MAX_DEPTH, TENANT_FILTER_MAX_VALUES, TENANT_FILTER_MAX_VALUE_LENGTH, type TenantFilterExpression, type TenantFilterValue, type TenantPermission, TenantPermissions, TokenStorage, createDefaultStorage, createLocalStorage, createMemoryStorage, tenantFilter };
|
package/dist/index.js
CHANGED
|
@@ -465,6 +465,57 @@ function invalidClientIp() {
|
|
|
465
465
|
return new Error("Authyon: `clientIp` must be a single valid IPv4 or IPv6 address");
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
+
// ../../internal/core/http/memberQuery.ts
|
|
469
|
+
function memberQuery(options = {}) {
|
|
470
|
+
const { skip, take, search } = options;
|
|
471
|
+
if (skip !== void 0 && (!Number.isInteger(skip) || skip < 0 || skip > 2147483647))
|
|
472
|
+
throw new RangeError("Authyon: invalid skip.");
|
|
473
|
+
if (take !== void 0 && (!Number.isInteger(take) || take < 1 || take > 100))
|
|
474
|
+
throw new RangeError("Authyon: take must be between 1 and 100.");
|
|
475
|
+
if (search !== void 0 && (typeof search !== "string" || search.trim().length > 100))
|
|
476
|
+
throw new RangeError("Authyon: search must contain at most 100 characters.");
|
|
477
|
+
return { search: search?.trim() || void 0, skip, take };
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// ../../internal/core/http/subTenantQuery.ts
|
|
481
|
+
var ORDER_FIELDS = ["name", "createdAt", "updatedAt"];
|
|
482
|
+
var MAX_FILTERS = 10;
|
|
483
|
+
var MAX_FILTER_LENGTH = 512;
|
|
484
|
+
function orderByParam(order) {
|
|
485
|
+
if (order === void 0) return void 0;
|
|
486
|
+
const field = typeof order === "string" ? order : order?.field;
|
|
487
|
+
const direction = typeof order === "string" ? "asc" : order.direction ?? "asc";
|
|
488
|
+
if (!ORDER_FIELDS.includes(field))
|
|
489
|
+
throw new RangeError(`Authyon: orderBy must be one of ${ORDER_FIELDS.join(", ")}.`);
|
|
490
|
+
if (direction !== "asc" && direction !== "desc")
|
|
491
|
+
throw new RangeError('Authyon: orderBy direction must be "asc" or "desc".');
|
|
492
|
+
return `${field}:${direction}`;
|
|
493
|
+
}
|
|
494
|
+
function subTenantQuery(options = {}) {
|
|
495
|
+
const { filter, orderBy, ...page } = options;
|
|
496
|
+
const query = { ...memberQuery(page) };
|
|
497
|
+
if (filter !== void 0) {
|
|
498
|
+
if (!Array.isArray(filter)) throw new RangeError("Authyon: filter must be an array.");
|
|
499
|
+
const present = filter.filter((f) => typeof f === "string" && f.trim().length > 0);
|
|
500
|
+
if (present.length !== filter.length)
|
|
501
|
+
throw new RangeError("Authyon: a filter may not be empty \u2014 build it with tenantFilter.");
|
|
502
|
+
if (present.length > MAX_FILTERS)
|
|
503
|
+
throw new RangeError(`Authyon: at most ${MAX_FILTERS} filters per request.`);
|
|
504
|
+
for (const f of present) {
|
|
505
|
+
if (f.length > MAX_FILTER_LENGTH)
|
|
506
|
+
throw new RangeError(`Authyon: a filter may hold at most ${MAX_FILTER_LENGTH} characters.`);
|
|
507
|
+
if (!f.startsWith("public."))
|
|
508
|
+
throw new RangeError(
|
|
509
|
+
`Authyon: sub-tenant listings only filter on the public scope (got "${f.split(":")[0]}").`
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
if (present.length > 0) query.filter = present;
|
|
513
|
+
}
|
|
514
|
+
const order = orderByParam(orderBy);
|
|
515
|
+
if (order !== void 0) query.orderBy = order;
|
|
516
|
+
return query;
|
|
517
|
+
}
|
|
518
|
+
|
|
468
519
|
// src/client/authyonClient.ts
|
|
469
520
|
var FALLBACK_EXPIRES_IN = 1800;
|
|
470
521
|
function readTokens(raw) {
|
|
@@ -638,12 +689,16 @@ var AuthyonClient = class {
|
|
|
638
689
|
members: {
|
|
639
690
|
/**
|
|
640
691
|
* GET /auth/tenants/{organizationId}/members — paginated list of an
|
|
641
|
-
* organization's members
|
|
642
|
-
*
|
|
643
|
-
*
|
|
692
|
+
* organization's members, newest first, in the `Paged<T>` envelope every
|
|
693
|
+
* other `skip`/`take` endpoint returns. `search` matches email, username
|
|
694
|
+
* or name; at most 100 characters, and `take` 1-100, checked before any
|
|
695
|
+
* request.
|
|
644
696
|
*/
|
|
645
697
|
list: (organizationId, params = {}) => this.request(
|
|
646
|
-
appendQuery(
|
|
698
|
+
appendQuery(
|
|
699
|
+
`/auth/tenants/${encodeURIComponent(organizationId)}/members`,
|
|
700
|
+
memberQuery(params)
|
|
701
|
+
),
|
|
647
702
|
{ bearer: true }
|
|
648
703
|
),
|
|
649
704
|
/**
|
|
@@ -715,6 +770,42 @@ var AuthyonClient = class {
|
|
|
715
770
|
*/
|
|
716
771
|
accept: (params) => this.request("/auth/tenant-invites/accept", { method: "POST", body: params })
|
|
717
772
|
},
|
|
773
|
+
/**
|
|
774
|
+
* The direct, active sub-organizations of an organization. One level per
|
|
775
|
+
* call: each row's `childCount` says where the next call is worth making,
|
|
776
|
+
* which is what a lazily expanded tree asks for.
|
|
777
|
+
*
|
|
778
|
+
* Needs `subtenants:tree:read` on the organization or on one above it —
|
|
779
|
+
* even on the user's own organization, since listing the children is
|
|
780
|
+
* reading below it. Paged like every other `skip`/`take` listing, with
|
|
781
|
+
* `search` (name, slug, description and public metadata), `filter` (public
|
|
782
|
+
* scope only — build them with `tenantFilter`) and `orderBy`
|
|
783
|
+
* (`name` | `createdAt` | `updatedAt`, ascending or descending). A bad
|
|
784
|
+
* option raises `RangeError` before any request.
|
|
785
|
+
*
|
|
786
|
+
* Not the same list as `organization.list()`, which is the switcher's and
|
|
787
|
+
* only brings what `subtenants:tree:switch` lets the user enter. Requires
|
|
788
|
+
* the Authyon API of 2026-11-26 or newer.
|
|
789
|
+
*/
|
|
790
|
+
subOrganizations: {
|
|
791
|
+
/** GET /auth/tenants/{organizationId}/subtenants. */
|
|
792
|
+
list: (organizationId, params = {}) => this.request(
|
|
793
|
+
appendQuery(
|
|
794
|
+
`/auth/tenants/${encodeURIComponent(organizationId)}/subtenants`,
|
|
795
|
+
subTenantQuery(params)
|
|
796
|
+
),
|
|
797
|
+
{ bearer: true }
|
|
798
|
+
),
|
|
799
|
+
/**
|
|
800
|
+
* GET /auth/tenants/subtenants — the same, for the organization the
|
|
801
|
+
* session is scoped to (`organization.current()`, the token's
|
|
802
|
+
* `tenant_id`). Same permission rule; answers `tenant.no_active_tenant`
|
|
803
|
+
* when the session never switched into one.
|
|
804
|
+
*/
|
|
805
|
+
listCurrent: (params = {}) => this.request(appendQuery("/auth/tenants/subtenants", subTenantQuery(params)), {
|
|
806
|
+
bearer: true
|
|
807
|
+
})
|
|
808
|
+
},
|
|
718
809
|
roles: {
|
|
719
810
|
/** GET /auth/tenants/{organizationId}/roles — roles available in the organization. */
|
|
720
811
|
list: (organizationId) => this.request(`/auth/tenants/${encodeURIComponent(organizationId)}/roles`, {
|
|
@@ -1116,6 +1207,86 @@ var AuthyonClientBuilder = class {
|
|
|
1116
1207
|
}
|
|
1117
1208
|
};
|
|
1118
1209
|
|
|
1210
|
+
// ../../internal/core/http/tenantFilters.ts
|
|
1211
|
+
var TENANT_FILTER_MAX_VALUES = 25;
|
|
1212
|
+
var TENANT_FILTER_MAX_VALUE_LENGTH = 200;
|
|
1213
|
+
var TENANT_FILTER_MAX_DEPTH = 3;
|
|
1214
|
+
var SCOPES = ["public", "private", "custom"];
|
|
1215
|
+
var KEY_SEGMENT = /^[A-Za-z0-9_-]{1,64}$/;
|
|
1216
|
+
function assertPath(path2) {
|
|
1217
|
+
if (typeof path2 !== "string" || path2.length === 0) {
|
|
1218
|
+
throw new RangeError("Authyon: a filter path is required, e.g. public.kind.");
|
|
1219
|
+
}
|
|
1220
|
+
const [scope, ...keys] = path2.split(".");
|
|
1221
|
+
if (!SCOPES.includes(scope)) {
|
|
1222
|
+
throw new RangeError(
|
|
1223
|
+
`Authyon: unknown filter scope "${scope}" \u2014 use ${SCOPES.join(", ")} (e.g. public.kind).`
|
|
1224
|
+
);
|
|
1225
|
+
}
|
|
1226
|
+
if (keys.length === 0) {
|
|
1227
|
+
throw new RangeError(`Authyon: filter path "${path2}" needs a key after the scope.`);
|
|
1228
|
+
}
|
|
1229
|
+
if (keys.length > TENANT_FILTER_MAX_DEPTH) {
|
|
1230
|
+
throw new RangeError(
|
|
1231
|
+
`Authyon: filter path "${path2}" goes deeper than ${TENANT_FILTER_MAX_DEPTH} levels.`
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
for (const key of keys) {
|
|
1235
|
+
if (!KEY_SEGMENT.test(key)) {
|
|
1236
|
+
throw new RangeError(
|
|
1237
|
+
`Authyon: invalid filter key "${key}" \u2014 letters, digits, "_" and "-", up to 64 characters.`
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
return path2;
|
|
1242
|
+
}
|
|
1243
|
+
function assertValue(value, forIn) {
|
|
1244
|
+
if (value === void 0 || value === null) {
|
|
1245
|
+
throw new RangeError("Authyon: a filter value is required.");
|
|
1246
|
+
}
|
|
1247
|
+
const text = String(value);
|
|
1248
|
+
if (text.length === 0) {
|
|
1249
|
+
throw new RangeError("Authyon: a filter value may not be empty.");
|
|
1250
|
+
}
|
|
1251
|
+
if (text.length > TENANT_FILTER_MAX_VALUE_LENGTH) {
|
|
1252
|
+
throw new RangeError(
|
|
1253
|
+
`Authyon: a filter value may hold at most ${TENANT_FILTER_MAX_VALUE_LENGTH} characters.`
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
if (text.includes(",")) {
|
|
1257
|
+
throw new RangeError(
|
|
1258
|
+
forIn ? "Authyon: an `in` value may not contain a comma \u2014 pass separate values instead." : "Authyon: a filter value may not contain a comma."
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
return text;
|
|
1262
|
+
}
|
|
1263
|
+
var tenantFilter = {
|
|
1264
|
+
/** `public.kind:eq:reseller` — the key equals this value. */
|
|
1265
|
+
eq(path2, value) {
|
|
1266
|
+
return `${assertPath(path2)}:eq:${assertValue(value, false)}`;
|
|
1267
|
+
},
|
|
1268
|
+
/** `public.kind:in:reseller,partner` — the key equals any of these (SQL IN). */
|
|
1269
|
+
in(path2, values) {
|
|
1270
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
1271
|
+
throw new RangeError("Authyon: `in` needs at least one value.");
|
|
1272
|
+
}
|
|
1273
|
+
if (values.length > TENANT_FILTER_MAX_VALUES) {
|
|
1274
|
+
throw new RangeError(`Authyon: \`in\` takes at most ${TENANT_FILTER_MAX_VALUES} values.`);
|
|
1275
|
+
}
|
|
1276
|
+
const unique = [...new Set(values.map((value) => assertValue(value, true)))];
|
|
1277
|
+
return `${assertPath(path2)}:in:${unique.join(",")}`;
|
|
1278
|
+
},
|
|
1279
|
+
/** `public.notes:like:nacional` — the key contains this text, case-insensitive.
|
|
1280
|
+
* The server escapes the LIKE metacharacters, so `100%` means `100%`. */
|
|
1281
|
+
like(path2, text) {
|
|
1282
|
+
return `${assertPath(path2)}:like:${assertValue(text, false)}`;
|
|
1283
|
+
},
|
|
1284
|
+
/** `custom.cnpj:exists` — the key is present, whatever its value. */
|
|
1285
|
+
exists(path2) {
|
|
1286
|
+
return `${assertPath(path2)}:exists`;
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1119
1290
|
// ../../internal/core/authorization/tenantPermissions.ts
|
|
1120
1291
|
var TenantPermissions = {
|
|
1121
1292
|
/** Rename the tenant and change its settings. */
|
|
@@ -1152,6 +1323,9 @@ export {
|
|
|
1152
1323
|
FetchHttpAdapter,
|
|
1153
1324
|
LoggingHttpAdapter,
|
|
1154
1325
|
SubtenantPermissions,
|
|
1326
|
+
TENANT_FILTER_MAX_DEPTH,
|
|
1327
|
+
TENANT_FILTER_MAX_VALUES,
|
|
1328
|
+
TENANT_FILTER_MAX_VALUE_LENGTH,
|
|
1155
1329
|
TenantPermissions,
|
|
1156
1330
|
createAuthyonAbility,
|
|
1157
1331
|
createAuthyonRules,
|
|
@@ -1160,5 +1334,6 @@ export {
|
|
|
1160
1334
|
createLocalStorage,
|
|
1161
1335
|
createMemoryStorage,
|
|
1162
1336
|
hasPermission,
|
|
1163
|
-
hasPermissionGroup
|
|
1337
|
+
hasPermissionGroup,
|
|
1338
|
+
tenantFilter
|
|
1164
1339
|
};
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { w as AuthyonSessionController,
|
|
3
|
+
import { ak as User, a2 as SessionControllerOptions, A as AuthyonClient, a4 as SessionSnapshot, a1 as Session, f as AbilitySubject, t as AuthyonAbilityOptions, r as AuthyonAbility } from '../ability-CmJEviJj.cjs';
|
|
4
|
+
export { w as AuthyonSessionController, a5 as SessionSnapshotListener, a6 as SessionStatus } from '../ability-CmJEviJj.cjs';
|
|
5
5
|
|
|
6
6
|
interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
|
|
7
7
|
client: AuthyonClient;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { w as AuthyonSessionController,
|
|
3
|
+
import { ak as User, a2 as SessionControllerOptions, A as AuthyonClient, a4 as SessionSnapshot, a1 as Session, f as AbilitySubject, t as AuthyonAbilityOptions, r as AuthyonAbility } from '../ability-CmJEviJj.js';
|
|
4
|
+
export { w as AuthyonSessionController, a5 as SessionSnapshotListener, a6 as SessionStatus } from '../ability-CmJEviJj.js';
|
|
5
5
|
|
|
6
6
|
interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
|
|
7
7
|
client: AuthyonClient;
|