@authyon/server 0.2.0-beta.0 → 0.2.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,519 +1,71 @@
1
- /** GET/POST /env/tenants — confirmed against the live API. */
2
- interface Organization {
3
- id: string;
4
- slug: string;
5
- name?: string;
6
- description?: string | null;
7
- environmentId?: string;
8
- workspaceId?: string;
9
- isDisabled?: boolean;
10
- memberCount?: number;
11
- createdAt?: string;
12
- updatedAt?: string;
13
- }
14
- /** One of a user's tenant memberships, as embedded in `EnvironmentUser.tenantMemberships`. */
15
- interface TenantMembership {
16
- tenantId: string;
17
- tenantSlug: string;
18
- tenantName: string;
19
- tenantDisabled: boolean;
20
- roles: string[];
21
- }
22
- /** Lightweight user shape returned by `introspect()`/`validate()`. */
23
- interface User {
24
- id: string;
25
- email: string;
26
- username?: string;
27
- permissions?: string[];
28
- }
29
- interface RoleGrant {
30
- role: string;
31
- expiresAt?: string | null;
32
- }
33
- /**
34
- * Full user record from the EnvironmentManagement plane
35
- * (`environment.users.get()` / `.list()`), confirmed against the live API.
36
- * `get()` returns every field below; `list()` returns a subset (no
37
- * `failedLoginAttempts`, `lockedOutUntil`, `roleGrants`,
38
- * `directPermissions`, `effectivePermissions`, `refreshTokens`,
39
- * `tenantMemberships`, `totpConfirmedAt`, `emailOtpEnabledAt`,
40
- * `remainingRecoveryCodes`, `disableReason`, `suspension`, `deleteReason`,
41
- * `customFields` — and `suspendedUntil` instead of `suspension`).
42
- */
43
- interface EnvironmentUser {
44
- id: string;
45
- email: string;
46
- username?: string;
47
- firstName?: string | null;
48
- lastName?: string | null;
49
- emailConfirmed: boolean;
50
- isDisabled: boolean;
51
- createdAt: string;
52
- lastLoginAt?: string | null;
53
- failedLoginAttempts?: number;
54
- lockedOutUntil?: string | null;
55
- roles: string[];
56
- roleGrants?: RoleGrant[];
57
- directPermissions?: string[];
58
- effectivePermissions?: string[];
59
- /** Confirmed shape unknown — empty in every response seen so far. */
60
- refreshTokens?: unknown[];
61
- tenantIds: string[];
62
- tenantMemberships?: TenantMembership[];
63
- /** Flattened role names across all tenant memberships (list() only). */
64
- tenantRoles?: string[];
65
- twoFactorMethods: string[];
66
- totpConfirmedAt?: string | null;
67
- emailOtpEnabledAt?: string | null;
68
- remainingRecoveryCodes?: number;
69
- disableReason?: string | null;
70
- suspension?: unknown | null;
71
- suspendedUntil?: string | null;
72
- deletedAt?: string | null;
73
- deleteReason?: string | null;
74
- /** JSON-encoded string. */
75
- customFields?: string;
76
- }
77
- /** POST /auth/introspect (RFC 7662) — confirmed against the live API. */
78
- interface IntrospectResult {
79
- active: boolean;
80
- sub?: string;
81
- username?: string | null;
82
- email?: string | null;
83
- roles?: string[] | null;
84
- permissions?: string[];
85
- client_id?: string;
86
- scope?: string;
87
- exp?: number;
88
- iat?: number;
89
- jti?: string;
90
- token_type?: string;
91
- }
92
- /**
93
- * POST /auth/validate — confirmed against the live API. The wire shape is
94
- * `{ valid, reason, profile }`, not `{ user, organization }` as the
95
- * OpenAPI schema (which didn't document response bodies) suggested.
96
- * `profile` is `null` for machine tokens (there's no user behind them) and
97
- * for tokens that fail validation.
98
- */
99
- interface ValidateResult {
100
- valid: boolean;
101
- reason?: string | null;
102
- user: User | null;
103
- }
104
- /**
105
- * A role available within an environment or one of its tenants. Confirmed
106
- * live: system roles carry no `id`/`description` (only `name` +
107
- * `permissions`) — both are only populated for custom roles you create.
108
- */
109
- interface Role {
110
- id?: string | null;
111
- name: string;
112
- description?: string | null;
113
- permissions: string[];
114
- }
115
- interface RoleInput {
116
- name: string;
117
- description?: string;
118
- permissions?: string[];
119
- }
120
- /**
121
- * GET /env/roles and GET /tenant/roles group results by origin instead of
122
- * returning a flat array — confirmed live for the environment endpoint.
123
- */
124
- interface RoleList {
125
- custom: Role[];
126
- system: Role[];
127
- }
128
- /** A permission entry as it appears nested under a role in `PermissionsByRole`. */
129
- interface Permission {
130
- value: string;
131
- description?: string | null;
132
- /** Confirmed live: `null` for the built-in catalog: no separate id per entry. */
133
- catalogId?: string | null;
134
- }
135
- /** A role entry as returned by GET /env/permissions, with its permissions nested. */
136
- interface RolePermissions {
137
- roleId: string | null;
138
- name: string;
139
- description?: string | null;
140
- isSystem: boolean;
141
- permissions: Permission[];
142
- }
143
- /** GET /env/permissions — confirmed live: grouped by role, plus any orphaned entries. */
144
- interface PermissionsByRole {
145
- roles: RolePermissions[];
146
- orphans: Permission[];
147
- }
148
- /** GET /permissions/reserved — confirmed live: wrapped, not a bare string array. */
149
- interface ReservedPermissions {
150
- namespace: string;
151
- items: string[];
152
- }
153
- interface CreatePermissionInput {
154
- value: string;
155
- description?: string;
156
- /** Attach the new permission to this role immediately. */
157
- attachToRoleId?: string;
158
- }
159
- interface CreateOrganizationInput {
160
- name: string;
161
- slug: string;
162
- description?: string;
163
- }
164
- interface UpdateOrganizationInput {
165
- name: string;
166
- description?: string;
167
- }
168
- interface CreateUserInput {
169
- email: string;
170
- username: string;
171
- password: string;
172
- emailConfirmed?: boolean;
173
- roles?: string[];
174
- /** Tenants (organizations) to add the user to on creation. */
175
- tenantIds?: string[];
176
- }
177
- /** GET /env/audit — one audit-trail entry, confirmed against the live API. */
178
- interface AuditEvent {
179
- id: string;
180
- occurredAt: string;
181
- eventType: string;
182
- /** JSON-encoded string — `JSON.parse` it for the event-specific payload. */
183
- payloadJson?: string;
184
- workspaceId?: string;
185
- environmentId?: string;
186
- actorUserId?: string | null;
187
- actorType?: string;
188
- actorIp?: string;
189
- userAgent?: string;
190
- tenantId?: string | null;
191
- }
192
- /**
193
- * GET /env/audit/login-activity. Not confirmed with a populated example
194
- * live (the test environment had none) — assumed to share `AuditEvent`'s
195
- * shape, since login activity is the same underlying audit-event stream
196
- * filtered to sign-in events.
197
- */
198
- type LoginActivity = AuditEvent;
199
- /**
200
- * Envelope every `skip`/`take`-paginated list endpoint returns, confirmed
201
- * live for `/env/users`, `/env/audit` and `/env/audit/login-activity`.
202
- * Endpoints without `skip`/`take` params (e.g. `/env/tenants`) return a
203
- * bare array instead.
204
- */
205
- interface Page<T> {
206
- data: T[];
207
- /** Item count actually returned for this page. */
208
- perPage?: number;
209
- pageSize: number;
210
- total: number;
211
- pages: number;
212
- hasNext: boolean;
213
- hasPrev: boolean;
214
- }
215
- /** Pagination options accepted by list endpoints. */
216
- interface PageParams {
217
- skip?: number;
218
- take?: number;
219
- }
220
- /** OAuth 2.0 client-credentials pair minted in the Authyon console. */
221
- interface ClientCredentials {
222
- clientId: string;
223
- clientSecret: string;
224
- }
225
- /** Standard OAuth 2.0 client-credentials token response. */
226
- interface TokenResult {
227
- access_token: string;
228
- token_type: string;
229
- expires_in: number;
230
- scope?: string;
231
- }
232
- interface JsonWebKeySet {
233
- keys: Record<string, unknown>[];
234
- }
235
- interface OpenIdConfiguration {
236
- issuer: string;
237
- jwks_uri: string;
238
- authorization_endpoint?: string;
239
- token_endpoint?: string;
240
- [key: string]: unknown;
241
- }
242
- interface AuthyonServerClientOptions {
243
- /**
244
- * Publishable environment key (`pk_live_...` / `pk_test_...`), sent as
245
- * `X-Authyon-Environment`. Required on **every** call — it selects the
246
- * environment (Test / Live) that a request applies to, independently of
247
- * whichever bearer token authenticates it.
248
- */
249
- envKey?: string;
250
- /**
251
- * Environment-level OAuth client credentials (`ec_...` / secret), minted
252
- * in the console. Required for everything under `environment.*` and
253
- * `permissions.*` — the SDK exchanges them for a short-lived access token
254
- * via `POST /env/oauth/token` and refreshes it transparently.
255
- */
256
- clientId?: string;
257
- clientSecret?: string;
258
- /** API origin. Defaults to `https://api.authyon.com`. */
259
- baseUrl?: string;
260
- /** Custom fetch implementation (useful for tests / edge runtimes). */
261
- fetch?: typeof fetch;
262
- }
263
-
264
- interface RequestOptions {
265
- method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
266
- body?: unknown;
267
- query?: object;
268
- headers?: Record<string, string>;
269
- /** Attach the cached environment access token, minting one first if needed. */
270
- envBearer?: boolean;
271
- }
272
- /**
273
- * Server-side Authyon client: environment/tenant administration (OAuth
274
- * client-credentials) plus access-token verification (publishable key).
275
- * Never import this in browser code — client secrets must stay on your
276
- * server.
277
- */
278
- declare class AuthyonServerClient {
279
- private readonly envKey?;
280
- private readonly clientId?;
281
- private readonly clientSecret?;
282
- private readonly baseUrl;
283
- private readonly fetchImpl;
284
- private environmentToken;
285
- private environmentTokenInFlight;
286
- constructor(options?: AuthyonServerClientOptions);
287
- private request;
288
- /** Mints (and caches) an environment access token from `clientId`/`clientSecret`. */
289
- private getEnvironmentAccessToken;
290
- readonly discovery: {
291
- /** GET /.well-known/jwks.json — the environment's public signing keys. */
292
- jwks: (publishableKey?: string) => Promise<JsonWebKeySet>;
293
- /** GET /.well-known/openid-configuration — OIDC discovery document. */
294
- openidConfiguration: (publishableKey?: string) => Promise<OpenIdConfiguration>;
295
- };
296
- /** POST /auth/introspect — lightweight token introspection (RFC 7662). */
297
- introspect(token: string): Promise<IntrospectResult>;
298
- /** POST /auth/validate — recommended: cross-checks DB state, catches revocation immediately. */
299
- validate(token: string): Promise<ValidateResult>;
300
- readonly environmentAuth: {
301
- /** POST /env/oauth/token — exchanges environment client credentials for an access token. */
302
- token: (credentials: ClientCredentials) => Promise<TokenResult>;
303
- };
304
- readonly tenantAuth: {
305
- /** POST /tenant/oauth/token — exchanges a tenant's client credentials for a scoped access token. */
306
- token: (credentials: ClientCredentials) => Promise<TokenResult>;
307
- };
308
- /**
309
- * Scopes a client to a single tenant's OAuth credentials — mints and
310
- * caches its access token independently of the environment plane. Use
311
- * this for the `TenantManagement` endpoints (`/tenant/...`), which act on
312
- * "the token's tenant" rather than one you pass by id.
313
- */
314
- tenant(credentials: ClientCredentials): TenantScopedClient;
315
- readonly environment: {
316
- users: {
317
- /** GET /env/users — paginated list of users in the environment. */
318
- list: (params?: {
319
- search?: string;
320
- } & PageParams) => Promise<Page<EnvironmentUser>>;
321
- /** POST /env/users — create a user in the environment; returns only the new id. */
322
- create: (input: CreateUserInput) => Promise<{
323
- id: string;
324
- }>;
325
- /** GET /env/users/{userId} — fetch an environment user by id. */
326
- get: (userId: string) => Promise<EnvironmentUser>;
327
- /** POST /env/users/{userId}/roles — grant a role to an environment user. */
328
- assignRole: (userId: string, role: string) => Promise<void>;
329
- /** DELETE /env/users/{userId}/roles/{role} — revoke a role from an environment user. */
330
- removeRole: (userId: string, role: string) => Promise<void>;
331
- /** POST /env/users/{userId}/permissions — grant a direct permission to an environment user. */
332
- grantPermission: (userId: string, permission: string) => Promise<void>;
333
- /** DELETE /env/users/{userId}/permissions/{permission} — revoke a direct permission. */
334
- revokePermission: (userId: string, permission: string) => Promise<void>;
335
- /** POST /env/users/{userId}/unlock — clears an environment user's lockout. */
336
- unlock: (userId: string, reason?: string) => Promise<void>;
337
- /** POST /env/users/{userId}/password — sets a new password for the user. */
338
- setPassword: (userId: string, newPassword: string, reason?: string) => Promise<void>;
339
- /** POST /env/users/{userId}/sessions/revoke-all — revokes every session the user has. */
340
- revokeSessions: (userId: string, reason?: string) => Promise<void>;
341
- /** DELETE /env/users/{userId}/sessions/{sessionId} — revokes a single session. */
342
- revokeSession: (userId: string, sessionId: string, reason?: string) => Promise<void>;
343
- /** POST /env/users/{userId}/disable — bans the user indefinitely; revokes live sessions. */
344
- disable: (userId: string, reason?: string) => Promise<void>;
345
- /** POST /env/users/{userId}/enable — lifts a ban. */
346
- enable: (userId: string, reason?: string) => Promise<void>;
347
- /** POST /env/users/{userId}/suspend — blocks the user temporarily; clears itself after `durationMinutes`. */
348
- suspend: (userId: string, durationMinutes: number, reason?: string) => Promise<void>;
349
- /** POST /env/users/{userId}/unsuspend — lifts a suspension early. */
350
- unsuspend: (userId: string, reason?: string) => Promise<void>;
351
- /** POST /env/users/{userId}/tenants — adds an environment user to a tenant. */
352
- assignTenant: (userId: string, tenantId: string, roles?: string[]) => Promise<void>;
353
- /** DELETE /env/users/{userId}/tenants/{tenantId} — removes an environment user from a tenant. */
354
- removeTenant: (userId: string, tenantId: string) => Promise<void>;
355
- };
356
- tenants: {
357
- /** GET /env/tenants — list tenants in the environment. */
358
- list: () => Promise<Organization[]>;
359
- /** POST /env/tenants — create a tenant in the environment. */
360
- create: (input: CreateOrganizationInput) => Promise<Organization>;
361
- /** GET /env/tenants/{tenantId} — fetch a tenant by id. */
362
- get: (tenantId: string) => Promise<Organization>;
363
- /** PUT /env/tenants/{tenantId} — update a tenant. */
364
- update: (tenantId: string, input: UpdateOrganizationInput) => Promise<Organization>;
365
- /** DELETE /env/tenants/{tenantId} — delete a tenant. */
366
- delete: (tenantId: string) => Promise<void>;
367
- members: {
368
- /**
369
- * GET /env/tenants/{tenantId}/members — a tenant's members as full
370
- * user records. Confirmed live: a bare array (unlike
371
- * `environment.users.list()`, this one does NOT paginate despite
372
- * accepting `skip`/`take`), with the same shape
373
- * `environment.users.list()` items have.
374
- */
375
- list: (tenantId: string, params?: PageParams) => Promise<EnvironmentUser[]>;
376
- /** POST /env/tenants/{tenantId}/members — add a member to a tenant. */
377
- add: (tenantId: string, userId: string, roles?: string[]) => Promise<void>;
378
- /** DELETE /env/tenants/{tenantId}/members/{userId} — remove a member from a tenant. */
379
- remove: (tenantId: string, userId: string) => Promise<void>;
380
- /** POST /env/tenants/{tenantId}/members/{userId}/roles — grant a tenant role to a member. */
381
- assignRole: (tenantId: string, userId: string, role: string) => Promise<void>;
382
- /** DELETE .../members/{userId}/roles/{role} — revoke a tenant role from a member. */
383
- removeRole: (tenantId: string, userId: string, role: string) => Promise<void>;
384
- /** POST .../members/{userId}/permissions — grant a permission to a tenant member. */
385
- grantPermission: (tenantId: string, userId: string, permission: string) => Promise<void>;
386
- /** DELETE .../members/{userId}/permissions/{permission} — revoke a permission from a tenant member. */
387
- revokePermission: (tenantId: string, userId: string, permission: string) => Promise<void>;
388
- };
389
- roles: {
390
- /** GET /env/tenants/{tenantId}/roles — list a tenant's roles. */
391
- list: (tenantId: string) => Promise<Role[]>;
392
- /** POST /env/tenants/{tenantId}/roles — create a tenant role. */
393
- create: (tenantId: string, input: RoleInput) => Promise<Role>;
394
- /** GET /env/tenants/{tenantId}/roles/{roleId} — fetch a tenant role by id. */
395
- get: (tenantId: string, roleId: string) => Promise<Role>;
396
- /** PUT /env/tenants/{tenantId}/roles/{roleId} — update a tenant role. */
397
- update: (tenantId: string, roleId: string, input: RoleInput) => Promise<Role>;
398
- /** DELETE /env/tenants/{tenantId}/roles/{roleId} — delete a tenant role. */
399
- delete: (tenantId: string, roleId: string) => Promise<void>;
400
- };
401
- };
402
- roles: {
403
- /** GET /env/roles — environment-level roles, grouped into custom and system-defined. */
404
- list: () => Promise<RoleList>;
405
- /** POST /env/roles — create an environment-level role. */
406
- create: (input: RoleInput) => Promise<Role>;
407
- /** PUT /env/roles/{roleId} — update an environment-level role. */
408
- update: (roleId: string, input: RoleInput) => Promise<Role>;
409
- /** DELETE /env/roles/{roleId} — delete an environment-level role. */
410
- delete: (roleId: string) => Promise<void>;
411
- };
412
- permissions: {
413
- /** GET /env/permissions — environment-level permissions, grouped by the role they're attached to. */
414
- list: () => Promise<PermissionsByRole>;
415
- /** POST /env/permissions — create an environment-level permission. */
416
- create: (input: CreatePermissionInput) => Promise<Permission>;
417
- /** PUT /env/permissions/{permissionId} — update an environment-level permission. */
418
- update: (permissionId: string, description?: string) => Promise<Permission>;
419
- /** DELETE /env/permissions/{permissionId} — delete an environment-level permission. */
420
- delete: (permissionId: string) => Promise<void>;
421
- /** GET /permissions/reserved — reserved permission names you can't redefine. */
422
- reserved: () => Promise<ReservedPermissions>;
423
- };
424
- audit: {
425
- /** GET /env/audit — paginated list of the environment's audit events. */
426
- list: (params?: PageParams) => Promise<Page<AuditEvent>>;
427
- /** GET /env/audit/login-activity — paginated login activity in the environment. */
428
- loginActivity: (params?: PageParams) => Promise<Page<LoginActivity>>;
429
- };
430
- };
431
- readonly permissions: {
432
- /** POST /users/{userId}/permissions — grant a permission directly to a user. */
433
- grant: (userId: string, permission: string) => Promise<void>;
434
- /** DELETE /users/{userId}/permissions/{permission} — revoke a permission from a user. */
435
- revoke: (userId: string, permission: string) => Promise<void>;
436
- };
437
- /** @internal used by {@link TenantScopedClient} to share the base URL/fetch/error handling. */
438
- _requestAsTenant<T>(accessToken: string, path: string, options?: RequestOptions): Promise<T>;
439
- }
440
- /**
441
- * Client scoped to a single tenant's OAuth credentials — every call acts on
442
- * "the token's tenant" (`TenantManagement` endpoints), so there's no
443
- * `tenantId` parameter to pass.
444
- */
445
- declare class TenantScopedClient {
446
- private readonly server;
447
- private readonly credentials;
448
- private token;
449
- private tokenInFlight;
450
- constructor(server: AuthyonServerClient, credentials: ClientCredentials);
451
- private getAccessToken;
452
- private request;
453
- readonly members: {
454
- /**
455
- * GET /tenant/members — members of the token's tenant.
456
- *
457
- * ⚠️ Inferred, not confirmed live (no tenant client credentials
458
- * available to exchange for a scoped token) — assumed to share
459
- * `/env/tenants/{id}/members`'s confirmed shape (bare array of full
460
- * user records), since both are the "admin" member listing as opposed
461
- * to `/auth/tenants/{id}/members`'s paginated, lightweight one.
462
- */
463
- list: (params?: PageParams) => Promise<EnvironmentUser[]>;
464
- /** POST /tenant/members — add a member to the token's tenant. */
465
- add: (userId: string, roles?: string[]) => Promise<void>;
466
- /** DELETE /tenant/members/{userId} — remove a member from the token's tenant. */
467
- remove: (userId: string) => Promise<void>;
468
- /** POST /tenant/members/{userId}/roles — grant a role to a member of the tenant. */
469
- assignRole: (userId: string, role: string) => Promise<void>;
470
- /** DELETE /tenant/members/{userId}/roles/{role} — revoke a role from a member of the tenant. */
471
- removeRole: (userId: string, role: string) => Promise<void>;
472
- /** POST /tenant/members/{userId}/permissions — grant a permission to a member of the tenant. */
473
- grantPermission: (userId: string, permission: string) => Promise<void>;
474
- /** DELETE .../permissions/{permission} — revoke a permission from a member of the tenant. */
475
- revokePermission: (userId: string, permission: string) => Promise<void>;
476
- };
477
- readonly roles: {
478
- /**
479
- * GET /tenant/roles — roles in the token's tenant, grouped into custom
480
- * and system-defined.
481
- *
482
- * ⚠️ Inferred, not confirmed live (the test environment had no tenants
483
- * to exchange a scoped token for) — assumed to share `/env/roles`'
484
- * grouped shape, since both operate on the same underlying role model.
485
- */
486
- list: () => Promise<RoleList>;
487
- /** POST /tenant/roles — create a role in the tenant. */
488
- create: (input: RoleInput) => Promise<Role>;
489
- /** GET /tenant/roles/{roleId} — fetch a tenant role by id. */
490
- get: (roleId: string) => Promise<Role>;
491
- /** PUT /tenant/roles/{roleId} — update a role in the tenant. */
492
- update: (roleId: string, input: RoleInput) => Promise<Role>;
493
- /** DELETE /tenant/roles/{roleId} — delete a role in the tenant. */
494
- delete: (roleId: string) => Promise<void>;
495
- };
496
- }
497
- /** Convenience factory: `const authyon = createClient({ clientId, clientSecret })`. */
498
- declare function createClient(options?: AuthyonServerClientOptions): AuthyonServerClient;
1
+ import { H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonServerClient } from './authyonServerClient-D-DxoL30.js';
2
+ export { b as AcceptWorkspaceInviteInput, c as AccessTokenSource, d as AuditEvent, e as AuthyonJwksDiscoveryOptions, f as AuthyonJwtClaims, g as AuthyonServerClientOptions, C as ClientCredentials, h as ClientRequestContext, i as CreateCredentialInput, j as CreateOrganizationInput, k as CreatePermissionInput, l as CreateTenantCredentialInput, m as CreateUserInput, n as CredentialCreator, o as CredentialDetail, p as CredentialListOptions, q as CredentialPermissionsInput, r as CredentialScope, E as EnvironmentUser, F as FetchHttpAdapter, s as HttpAdapterRequest, t as HttpLogEvent, u as HttpLogger, I as IntrospectResult, v as InviteTenantMemberInput, w as InviteWorkspaceMemberInput, J as JsonWebKeySet, x as JwksTokenVerifier, y as JwksTokenVerifierOptions, L as LoggingHttpAdapter, z as LoginActivity, O as OpenIdConfiguration, B as Organization, P as Paged, D as PaginationOptions, G as Permission, K as PermissionsByRole, M as PlatformScopedClient, R as ReservedPermissions, N as Role, Q as RoleGrant, S as RoleInput, T as RoleList, U as RolePermissions, V as SafeJwtAlgorithm, W as TenantClientValidationResult, X as TenantCredentialIssued, Y as TenantCredentialSummary, Z as TenantManagementScope, _ as TenantMember, $ as TenantMemberPage, a0 as TenantMembership, a1 as TenantScopedClient, a2 as TokenResult, a3 as TokenVerificationError, a4 as TokenVerificationErrorCode, a5 as UpdateOrganizationInput, a6 as User, a7 as UserScopedClient, a8 as ValidateResult, a9 as VerifiedAccessToken, aa as WorkspaceInvite, ab as WorkspaceInviteAccepted, ac as WorkspaceInviteIssued, ad as WorkspaceInvitePreview, ae as WorkspaceInvitesClient, af as WorkspaceMember, ag as WorkspaceRole, ah as WorkspaceTeam, ai as createClient, aj as normalizeClientIp } from './authyonServerClient-D-DxoL30.js';
3
+ export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRequirement, f as AbilityRule, A as AbilitySubject, g as AuthorizationContext, a as AuthorizationError, h as AuthorizationOptions, i as AuthyonAbility, j as AuthyonAbilityBuilder, k as AuthyonAbilityOptions, l as AuthyonPermissionSource, E as ExpressAuthorizationMiddlewareOptions, m as ExpressNext, n as ExpressRequestLike, o as ExpressResponseLike, P as PermissionGroup, R as RequestAuthorizationOptions, p as authorizeRequest, q as authorizeToken, r as createAuthorizationErrorResponse, s as createAuthyonAbility, t as createAuthyonRules, u as createExpressAuthorizationMiddleware, v as hasPermission, w as hasPermissionGroup } from './authorization-D_A6L9Ie.js';
4
+ import 'jose';
499
5
 
500
- /**
501
- * Error thrown for any non-2xx Authyon API response.
502
- *
503
- * The API uses RFC 7807 problem+json: `{ title, status, detail, code }`.
504
- * Match on the machine-readable `code` (e.g. `user.email_taken`), never on `title`.
505
- */
6
+ declare const ErrorCodes: {
7
+ readonly Unknown: "unknown";
8
+ readonly NetworkError: "request.network_error";
9
+ readonly Timeout: "request.timeout";
10
+ readonly SessionMalformed: "session.malformed";
11
+ readonly NotAuthenticated: "auth.not_authenticated";
12
+ readonly InvalidToken: "auth.invalid_token";
13
+ readonly MissingToken: "auth.missing_token";
14
+ readonly EmailTaken: "user.email_taken";
15
+ readonly PasswordWeak: "user.password_weak";
16
+ readonly PasswordPwned: "user.password_pwned";
17
+ readonly RateLimited: "rate_limited";
18
+ };
19
+ type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
20
+ type AuthyonErrorCategory = "network" | "timeout" | "authentication" | "authorization" | "validation" | "not_found" | "conflict" | "rate_limit" | "server" | "unknown";
21
+ type AuthyonErrorAction = "retry" | "reauthenticate" | "request_access" | "fix_input" | "not_found" | "resolve_conflict" | "contact_support";
22
+ interface AuthyonErrorInterpretation {
23
+ category: AuthyonErrorCategory;
24
+ action: AuthyonErrorAction;
25
+ retryable: boolean;
26
+ retryAfter?: number;
27
+ requestId?: string;
28
+ }
29
+ /** Shared RFC 7807 error implementation used by both public SDKs. */
506
30
  declare class AuthyonError extends Error {
507
31
  readonly status: number;
508
32
  readonly code: string;
509
33
  readonly title: string;
510
34
  readonly detail?: string;
35
+ readonly requestId?: string;
36
+ readonly retryAfter?: number;
37
+ readonly cause?: unknown;
511
38
  constructor(status: number, body: Partial<{
512
39
  title: string;
513
40
  detail: string;
514
41
  code: string;
515
- }>);
42
+ }>, options?: {
43
+ requestId?: string;
44
+ retryAfter?: number;
45
+ cause?: unknown;
46
+ });
516
47
  is(code: string): boolean;
48
+ isAny(...codes: readonly string[]): boolean;
49
+ hasPrefix(prefix: string): boolean;
50
+ isStatus(...statuses: readonly number[]): boolean;
51
+ /** Stable interpretation for UI decisions, retries, telemetry and support flows. */
52
+ interpret(): AuthyonErrorInterpretation;
53
+ get category(): AuthyonErrorCategory;
54
+ get retryable(): boolean;
55
+ toJSON(): Record<string, unknown>;
56
+ }
57
+
58
+ /** Builds a server client while keeping environment credentials grouped. */
59
+ declare class AuthyonServerClientBuilder {
60
+ #private;
61
+ withEnvironmentKey(envKey: string): this;
62
+ withEnvironmentCredentials(clientId: string, clientSecret: string): this;
63
+ withClientIp(clientIp: string): this;
64
+ withBaseUrl(baseUrl: string, allowInsecureHttp?: boolean): this;
65
+ withTimeout(timeoutMs: number): this;
66
+ withHttpAdapter(httpAdapter: HttpAdapter): this;
67
+ withHttpLogger(httpLogger: HttpLoggerOptions): this;
68
+ build(): AuthyonServerClient;
517
69
  }
518
70
 
519
- export { type AuditEvent, AuthyonError, AuthyonServerClient, type AuthyonServerClientOptions, type ClientCredentials, type CreateOrganizationInput, type CreatePermissionInput, type CreateUserInput, type EnvironmentUser, type IntrospectResult, type JsonWebKeySet, type LoginActivity, type OpenIdConfiguration, type Organization, type Page, type PageParams, type Permission, type PermissionsByRole, type ReservedPermissions, type Role, type RoleGrant, type RoleInput, type RoleList, type RolePermissions, type TenantMembership, TenantScopedClient, type TokenResult, type UpdateOrganizationInput, type User, type ValidateResult, createClient };
71
+ export { AuthyonError, type AuthyonErrorAction, type AuthyonErrorCategory, type AuthyonErrorInterpretation, AuthyonServerClient, AuthyonServerClientBuilder, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode };