@authyon/server 0.2.0-beta.1 → 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/README.md +201 -1
- package/dist/authorization-CeP_GqT7.d.cts +129 -0
- package/dist/authorization-D_A6L9Ie.d.ts +129 -0
- package/dist/authyonServerClient-D-DxoL30.d.cts +898 -0
- package/dist/authyonServerClient-D-DxoL30.d.ts +898 -0
- package/dist/bff.cjs +1126 -0
- package/dist/bff.d.cts +142 -0
- package/dist/bff.d.ts +142 -0
- package/dist/bff.js +791 -0
- package/dist/chunk-56H66KLG.js +323 -0
- package/dist/chunk-77J4NURK.js +13 -0
- package/dist/chunk-NKWQMYB3.js +485 -0
- package/dist/index.cjs +412 -30
- package/dist/index.d.cts +16 -746
- package/dist/index.d.ts +16 -746
- package/dist/index.js +392 -770
- package/dist/next.cjs +328 -0
- package/dist/next.d.cts +27 -0
- package/dist/next.d.ts +27 -0
- package/dist/next.js +48 -0
- package/package.json +28 -5
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
import { JSONWebKeySet, JWTPayload, JWSHeaderParameters } from 'jose';
|
|
2
|
+
|
|
3
|
+
interface HttpAdapterRequest {
|
|
4
|
+
url: string;
|
|
5
|
+
method: string;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
body?: BodyInit | null;
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/** Transport contract accepted by both Authyon clients. */
|
|
11
|
+
interface HttpAdapter {
|
|
12
|
+
request(request: HttpAdapterRequest): Promise<Response>;
|
|
13
|
+
}
|
|
14
|
+
type HttpLogEvent = {
|
|
15
|
+
type: "request";
|
|
16
|
+
method: string;
|
|
17
|
+
url: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
} | {
|
|
20
|
+
type: "response";
|
|
21
|
+
method: string;
|
|
22
|
+
url: string;
|
|
23
|
+
status: number;
|
|
24
|
+
durationMs: number;
|
|
25
|
+
requestId?: string;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
} | {
|
|
28
|
+
type: "error";
|
|
29
|
+
method: string;
|
|
30
|
+
url: string;
|
|
31
|
+
errorName: string;
|
|
32
|
+
durationMs: number;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
};
|
|
35
|
+
/** Receives sanitized HTTP lifecycle events. Headers, bodies and query values are never exposed. */
|
|
36
|
+
type HttpLogger = (event: HttpLogEvent) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Mutable logging configuration. Change `enabled` at runtime to enable or disable logging
|
|
39
|
+
* without recreating the Authyon client.
|
|
40
|
+
*/
|
|
41
|
+
interface HttpLoggerOptions {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
logger?: HttpLogger;
|
|
44
|
+
}
|
|
45
|
+
/** Default adapter backed by the platform's Fetch API. */
|
|
46
|
+
declare class FetchHttpAdapter implements HttpAdapter {
|
|
47
|
+
private readonly fetchImpl;
|
|
48
|
+
constructor(fetchImpl?: typeof fetch);
|
|
49
|
+
request(request: HttpAdapterRequest): Promise<Response>;
|
|
50
|
+
}
|
|
51
|
+
/** Adds safe, configurable lifecycle logging to any HTTP adapter. */
|
|
52
|
+
declare class LoggingHttpAdapter implements HttpAdapter {
|
|
53
|
+
private readonly adapter;
|
|
54
|
+
private readonly options;
|
|
55
|
+
constructor(adapter: HttpAdapter, options: HttpLoggerOptions);
|
|
56
|
+
request(request: HttpAdapterRequest): Promise<Response>;
|
|
57
|
+
private log;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface PaginationOptions {
|
|
61
|
+
skip?: number;
|
|
62
|
+
take?: number;
|
|
63
|
+
}
|
|
64
|
+
interface Paged<T> {
|
|
65
|
+
data: T[];
|
|
66
|
+
perPage?: number;
|
|
67
|
+
pageSize: number;
|
|
68
|
+
total: number;
|
|
69
|
+
pages: number;
|
|
70
|
+
hasNext: boolean;
|
|
71
|
+
hasPrev: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface IntrospectResult {
|
|
74
|
+
active: boolean;
|
|
75
|
+
sub?: string;
|
|
76
|
+
username?: string | null;
|
|
77
|
+
email?: string | null;
|
|
78
|
+
roles?: string[] | null;
|
|
79
|
+
permissions?: string[];
|
|
80
|
+
client_id?: string;
|
|
81
|
+
scope?: string;
|
|
82
|
+
exp?: number;
|
|
83
|
+
iat?: number;
|
|
84
|
+
jti?: string;
|
|
85
|
+
token_type?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** GET/POST /env/tenants — confirmed against the live API. */
|
|
89
|
+
interface Organization {
|
|
90
|
+
id: string;
|
|
91
|
+
slug: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
description?: string | null;
|
|
94
|
+
environmentId?: string;
|
|
95
|
+
workspaceId?: string;
|
|
96
|
+
isDisabled?: boolean;
|
|
97
|
+
memberCount?: number;
|
|
98
|
+
createdAt?: string;
|
|
99
|
+
updatedAt?: string;
|
|
100
|
+
/** JSON-encoded values for the tenant's configured custom fields. */
|
|
101
|
+
customFields?: string;
|
|
102
|
+
/** JSON-encoded metadata that may be exposed to tenant members. */
|
|
103
|
+
publicMetadata?: string;
|
|
104
|
+
/** JSON-encoded metadata available only through administrative APIs. */
|
|
105
|
+
privateMetadata?: string;
|
|
106
|
+
}
|
|
107
|
+
/** One of a user's tenant memberships, as embedded in `EnvironmentUser.tenantMemberships`. */
|
|
108
|
+
interface TenantMembership {
|
|
109
|
+
tenantId: string;
|
|
110
|
+
tenantSlug: string;
|
|
111
|
+
tenantName: string;
|
|
112
|
+
tenantDisabled: boolean;
|
|
113
|
+
roles: string[];
|
|
114
|
+
}
|
|
115
|
+
/** Lightweight user shape returned by `introspect()`/`validate()`. */
|
|
116
|
+
interface User {
|
|
117
|
+
id: string;
|
|
118
|
+
email: string;
|
|
119
|
+
username?: string;
|
|
120
|
+
/** Environment-level roles from the database-validated user profile. */
|
|
121
|
+
roles?: string[];
|
|
122
|
+
permissions?: string[];
|
|
123
|
+
}
|
|
124
|
+
interface RoleGrant {
|
|
125
|
+
role: string;
|
|
126
|
+
expiresAt?: string | null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Full user record from the EnvironmentManagement plane
|
|
130
|
+
* (`environment.users.get()` / `.list()`), confirmed against the live API.
|
|
131
|
+
* `get()` returns every field below; `list()` returns a subset (no
|
|
132
|
+
* `failedLoginAttempts`, `lockedOutUntil`, `roleGrants`,
|
|
133
|
+
* `directPermissions`, `effectivePermissions`, `refreshTokens`,
|
|
134
|
+
* `tenantMemberships`, `totpConfirmedAt`, `emailOtpEnabledAt`,
|
|
135
|
+
* `remainingRecoveryCodes`, `disableReason`, `suspension`, `deleteReason`,
|
|
136
|
+
* `customFields` — and `suspendedUntil` instead of `suspension`).
|
|
137
|
+
*/
|
|
138
|
+
interface EnvironmentUser {
|
|
139
|
+
id: string;
|
|
140
|
+
email: string;
|
|
141
|
+
username?: string;
|
|
142
|
+
firstName?: string | null;
|
|
143
|
+
lastName?: string | null;
|
|
144
|
+
emailConfirmed: boolean;
|
|
145
|
+
isDisabled: boolean;
|
|
146
|
+
createdAt: string;
|
|
147
|
+
lastLoginAt?: string | null;
|
|
148
|
+
failedLoginAttempts?: number;
|
|
149
|
+
lockedOutUntil?: string | null;
|
|
150
|
+
roles: string[];
|
|
151
|
+
roleGrants?: RoleGrant[];
|
|
152
|
+
directPermissions?: string[];
|
|
153
|
+
effectivePermissions?: string[];
|
|
154
|
+
/** Confirmed shape unknown — empty in every response seen so far. */
|
|
155
|
+
refreshTokens?: unknown[];
|
|
156
|
+
tenantIds: string[];
|
|
157
|
+
tenantMemberships?: TenantMembership[];
|
|
158
|
+
/** Flattened role names across all tenant memberships (list() only). */
|
|
159
|
+
tenantRoles?: string[];
|
|
160
|
+
twoFactorMethods: string[];
|
|
161
|
+
totpConfirmedAt?: string | null;
|
|
162
|
+
emailOtpEnabledAt?: string | null;
|
|
163
|
+
remainingRecoveryCodes?: number;
|
|
164
|
+
disableReason?: string | null;
|
|
165
|
+
suspension?: unknown | null;
|
|
166
|
+
suspendedUntil?: string | null;
|
|
167
|
+
deletedAt?: string | null;
|
|
168
|
+
deleteReason?: string | null;
|
|
169
|
+
/** JSON-encoded string. */
|
|
170
|
+
customFields?: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* POST /auth/validate — confirmed against the live API. The wire shape is
|
|
174
|
+
* `{ valid, reason, profile }`, not `{ user, organization }` as the
|
|
175
|
+
* OpenAPI schema (which didn't document response bodies) suggested.
|
|
176
|
+
* `profile` is `null` for machine tokens (there's no user behind them) and
|
|
177
|
+
* for tokens that fail validation.
|
|
178
|
+
*/
|
|
179
|
+
interface ValidateResult {
|
|
180
|
+
valid: boolean;
|
|
181
|
+
reason?: string | null;
|
|
182
|
+
user: User | null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A role available within an environment or one of its tenants. Confirmed
|
|
186
|
+
* live: system roles carry no `id`/`description` (only `name` +
|
|
187
|
+
* `permissions`) — both are only populated for custom roles you create.
|
|
188
|
+
*/
|
|
189
|
+
interface Role {
|
|
190
|
+
id?: string | null;
|
|
191
|
+
name: string;
|
|
192
|
+
description?: string | null;
|
|
193
|
+
permissions: string[];
|
|
194
|
+
}
|
|
195
|
+
interface RoleInput {
|
|
196
|
+
name: string;
|
|
197
|
+
description?: string;
|
|
198
|
+
permissions?: string[];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* GET /env/roles and GET /tenant/roles group results by origin instead of
|
|
202
|
+
* returning a flat array — confirmed live for the environment endpoint.
|
|
203
|
+
*/
|
|
204
|
+
interface RoleList {
|
|
205
|
+
custom: Role[];
|
|
206
|
+
system: Role[];
|
|
207
|
+
}
|
|
208
|
+
/** A permission entry as it appears nested under a role in `PermissionsByRole`. */
|
|
209
|
+
interface Permission {
|
|
210
|
+
value: string;
|
|
211
|
+
description?: string | null;
|
|
212
|
+
/** Confirmed live: `null` for the built-in catalog: no separate id per entry. */
|
|
213
|
+
catalogId?: string | null;
|
|
214
|
+
}
|
|
215
|
+
/** A role entry as returned by GET /env/permissions, with its permissions nested. */
|
|
216
|
+
interface RolePermissions {
|
|
217
|
+
roleId: string | null;
|
|
218
|
+
name: string;
|
|
219
|
+
description?: string | null;
|
|
220
|
+
isSystem: boolean;
|
|
221
|
+
permissions: Permission[];
|
|
222
|
+
}
|
|
223
|
+
/** GET /env/permissions — confirmed live: grouped by role, plus any orphaned entries. */
|
|
224
|
+
interface PermissionsByRole {
|
|
225
|
+
roles: RolePermissions[];
|
|
226
|
+
orphans: Permission[];
|
|
227
|
+
}
|
|
228
|
+
/** GET /permissions/reserved — confirmed live: wrapped, not a bare string array. */
|
|
229
|
+
interface ReservedPermissions {
|
|
230
|
+
namespace: string;
|
|
231
|
+
items: string[];
|
|
232
|
+
}
|
|
233
|
+
interface CreatePermissionInput {
|
|
234
|
+
value: string;
|
|
235
|
+
description?: string;
|
|
236
|
+
/** Attach the new permission to this role immediately. */
|
|
237
|
+
attachToRoleId?: string;
|
|
238
|
+
}
|
|
239
|
+
interface CreateOrganizationInput {
|
|
240
|
+
name: string;
|
|
241
|
+
slug: string;
|
|
242
|
+
description?: string;
|
|
243
|
+
customFields?: Record<string, unknown>;
|
|
244
|
+
publicMetadata?: Record<string, unknown>;
|
|
245
|
+
privateMetadata?: Record<string, unknown>;
|
|
246
|
+
}
|
|
247
|
+
interface UpdateOrganizationInput {
|
|
248
|
+
name: string;
|
|
249
|
+
description?: string;
|
|
250
|
+
customFields?: Record<string, unknown>;
|
|
251
|
+
}
|
|
252
|
+
interface CreateUserInput {
|
|
253
|
+
email: string;
|
|
254
|
+
username: string;
|
|
255
|
+
password: string;
|
|
256
|
+
emailConfirmed?: boolean;
|
|
257
|
+
roles?: string[];
|
|
258
|
+
/** Tenants (organizations) to add the user to on creation. */
|
|
259
|
+
tenantIds?: string[];
|
|
260
|
+
}
|
|
261
|
+
/** GET /env/audit — one audit-trail entry, confirmed against the live API. */
|
|
262
|
+
interface AuditEvent {
|
|
263
|
+
id: string;
|
|
264
|
+
occurredAt: string;
|
|
265
|
+
eventType: string;
|
|
266
|
+
/** JSON-encoded string — `JSON.parse` it for the event-specific payload. */
|
|
267
|
+
payloadJson?: string;
|
|
268
|
+
workspaceId?: string;
|
|
269
|
+
environmentId?: string;
|
|
270
|
+
actorUserId?: string | null;
|
|
271
|
+
actorType?: string;
|
|
272
|
+
actorIp?: string;
|
|
273
|
+
userAgent?: string;
|
|
274
|
+
tenantId?: string | null;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* GET /env/audit/login-activity. Not confirmed with a populated example
|
|
278
|
+
* live (the test environment had none) — assumed to share `AuditEvent`'s
|
|
279
|
+
* shape, since login activity is the same underlying audit-event stream
|
|
280
|
+
* filtered to sign-in events.
|
|
281
|
+
*/
|
|
282
|
+
type LoginActivity = AuditEvent;
|
|
283
|
+
/**
|
|
284
|
+
* Envelope every `skip`/`take`-paginated list endpoint returns, confirmed
|
|
285
|
+
* live for `/env/users`, `/env/audit` and `/env/audit/login-activity`.
|
|
286
|
+
* Endpoints without `skip`/`take` params return a bare array instead.
|
|
287
|
+
*/
|
|
288
|
+
/** Tenant credential metadata. Listing never returns the secret. */
|
|
289
|
+
interface TenantCredentialSummary {
|
|
290
|
+
id: string;
|
|
291
|
+
clientId: string;
|
|
292
|
+
description: string | null;
|
|
293
|
+
createdAt: string;
|
|
294
|
+
lastUsedAt: string | null;
|
|
295
|
+
revokedAt: string | null;
|
|
296
|
+
expiresAt: string | null;
|
|
297
|
+
isActive: boolean;
|
|
298
|
+
permissions: string[];
|
|
299
|
+
}
|
|
300
|
+
/** Input for a tenant machine credential. Requires at least one explicit permission. */
|
|
301
|
+
interface CreateTenantCredentialInput {
|
|
302
|
+
description: string;
|
|
303
|
+
/** Number of days until the tenant credential expires. Omit for no automatic expiration. */
|
|
304
|
+
lifetimeDays?: number | null;
|
|
305
|
+
permissions: string[];
|
|
306
|
+
}
|
|
307
|
+
/** The plaintext secret is returned only when the credential is issued. */
|
|
308
|
+
interface TenantCredentialIssued {
|
|
309
|
+
credentialId: string;
|
|
310
|
+
clientId: string;
|
|
311
|
+
clientSecret: string;
|
|
312
|
+
createdAt: string;
|
|
313
|
+
expiresAt: string | null;
|
|
314
|
+
permissions: string[];
|
|
315
|
+
}
|
|
316
|
+
/** OAuth 2.0 client-credentials pair minted in the Authyon console. */
|
|
317
|
+
interface ClientCredentials {
|
|
318
|
+
clientId: string;
|
|
319
|
+
clientSecret: string;
|
|
320
|
+
}
|
|
321
|
+
/** Standard OAuth 2.0 client-credentials token response. */
|
|
322
|
+
interface TokenResult {
|
|
323
|
+
access_token: string;
|
|
324
|
+
token_type: string;
|
|
325
|
+
expires_in: number;
|
|
326
|
+
scope?: string;
|
|
327
|
+
}
|
|
328
|
+
/** POST /tenant/auth/validate — validates the current tenant-client bearer. */
|
|
329
|
+
interface TenantClientValidationResult {
|
|
330
|
+
valid: boolean;
|
|
331
|
+
reason?: string | null;
|
|
332
|
+
tenantId: string;
|
|
333
|
+
workspaceId: string;
|
|
334
|
+
environmentId: string;
|
|
335
|
+
credentialId: string;
|
|
336
|
+
clientId: string;
|
|
337
|
+
permissions: string[];
|
|
338
|
+
}
|
|
339
|
+
interface JsonWebKeySet {
|
|
340
|
+
keys: Record<string, unknown>[];
|
|
341
|
+
}
|
|
342
|
+
interface OpenIdConfiguration {
|
|
343
|
+
issuer: string;
|
|
344
|
+
jwks_uri: string;
|
|
345
|
+
authorization_endpoint?: string;
|
|
346
|
+
token_endpoint?: string;
|
|
347
|
+
[key: string]: unknown;
|
|
348
|
+
}
|
|
349
|
+
interface AuthyonServerClientOptions {
|
|
350
|
+
/**
|
|
351
|
+
* Publishable environment key (`pk_live_...` / `pk_test_...`), sent as
|
|
352
|
+
* `X-Authyon-Environment`. Required on **every** call — it selects the
|
|
353
|
+
* environment (Test / Live) that a request applies to, independently of
|
|
354
|
+
* whichever bearer token authenticates it.
|
|
355
|
+
*/
|
|
356
|
+
envKey?: string;
|
|
357
|
+
/**
|
|
358
|
+
* Environment-level OAuth client credentials (`ec_...` / secret), minted
|
|
359
|
+
* in the console. Required for everything under `environment.*` and
|
|
360
|
+
* `permissions.*` — the SDK exchanges them for a short-lived access token
|
|
361
|
+
* via `POST /env/oauth/token` and refreshes it transparently.
|
|
362
|
+
*/
|
|
363
|
+
clientId?: string;
|
|
364
|
+
clientSecret?: string;
|
|
365
|
+
/**
|
|
366
|
+
* Originating end-user IP to forward on every API call as `X-Forwarded-For`.
|
|
367
|
+
* Only set this from infrastructure you trust; the SDK rejects comma-separated
|
|
368
|
+
* or whitespace-containing values to avoid forwarded-header injection.
|
|
369
|
+
*/
|
|
370
|
+
clientIp?: string;
|
|
371
|
+
/** API origin. Defaults to `https://api.authyon.com`. */
|
|
372
|
+
baseUrl?: string;
|
|
373
|
+
/** Allow an HTTP `baseUrl`. Intended only for explicitly trusted local development. */
|
|
374
|
+
allowInsecureHttp?: boolean;
|
|
375
|
+
/** Maximum duration of each HTTP request. Defaults to 15 seconds; set to `0` to disable. */
|
|
376
|
+
timeoutMs?: number;
|
|
377
|
+
/** Custom HTTP adapter for tracing, mocks or an alternative HTTP stack. */
|
|
378
|
+
httpAdapter?: HttpAdapter;
|
|
379
|
+
/** Safe HTTP lifecycle logging. Disabled unless this option is provided with `enabled: true`. */
|
|
380
|
+
httpLogger?: HttpLoggerOptions;
|
|
381
|
+
/** @deprecated Prefer `httpAdapter: new FetchHttpAdapter(customFetch)`. */
|
|
382
|
+
fetch?: typeof fetch;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** A token of the requested authentication plane, or a provider called for each request. */
|
|
386
|
+
type AccessTokenSource = string | (() => string | Promise<string>);
|
|
387
|
+
interface CredentialListOptions extends PaginationOptions {
|
|
388
|
+
search?: string;
|
|
389
|
+
}
|
|
390
|
+
/** scopes is an alias for permissions. Always supply an explicit, nonempty set. */
|
|
391
|
+
type CredentialPermissionsInput = {
|
|
392
|
+
permissions: readonly string[];
|
|
393
|
+
scopes?: never;
|
|
394
|
+
} | {
|
|
395
|
+
scopes: readonly string[];
|
|
396
|
+
permissions?: never;
|
|
397
|
+
};
|
|
398
|
+
type CreateCredentialInput = CredentialPermissionsInput & {
|
|
399
|
+
description?: string;
|
|
400
|
+
lifetimeDays?: number | null;
|
|
401
|
+
};
|
|
402
|
+
interface CredentialScope {
|
|
403
|
+
workspaceId: string;
|
|
404
|
+
environmentId: string;
|
|
405
|
+
tenantId?: string;
|
|
406
|
+
}
|
|
407
|
+
interface TenantManagementScope extends CredentialScope {
|
|
408
|
+
tenantId: string;
|
|
409
|
+
}
|
|
410
|
+
interface CredentialCreator {
|
|
411
|
+
id: string | null;
|
|
412
|
+
type: string;
|
|
413
|
+
displayName: string | null;
|
|
414
|
+
}
|
|
415
|
+
interface CredentialDetail extends TenantCredentialSummary {
|
|
416
|
+
createdBy: CredentialCreator | null;
|
|
417
|
+
updatedAt: string | null;
|
|
418
|
+
secretRotatedAt: string | null;
|
|
419
|
+
expiresAt: string | null;
|
|
420
|
+
ageSeconds: number;
|
|
421
|
+
/** Null while active; elapsed lifetime at revocation otherwise. */
|
|
422
|
+
lifetimeSeconds: number | null;
|
|
423
|
+
accessTokenLifetimeSeconds: number;
|
|
424
|
+
}
|
|
425
|
+
type WorkspaceRole = "admin" | "auditor";
|
|
426
|
+
interface WorkspaceMember {
|
|
427
|
+
memberId: string | null;
|
|
428
|
+
userId: string;
|
|
429
|
+
email: string;
|
|
430
|
+
name: string;
|
|
431
|
+
role: string;
|
|
432
|
+
isOwner: boolean;
|
|
433
|
+
isSelf: boolean;
|
|
434
|
+
invitedByName: string | null;
|
|
435
|
+
joinedAt: string;
|
|
436
|
+
lastLoginAt: string | null;
|
|
437
|
+
}
|
|
438
|
+
interface WorkspaceInvite {
|
|
439
|
+
id: string;
|
|
440
|
+
email: string;
|
|
441
|
+
role: string;
|
|
442
|
+
invitedByName: string | null;
|
|
443
|
+
createdAt: string;
|
|
444
|
+
expiresAt: string;
|
|
445
|
+
}
|
|
446
|
+
interface WorkspaceTeam {
|
|
447
|
+
workspaceId: string;
|
|
448
|
+
workspaceName: string;
|
|
449
|
+
callerRole: string;
|
|
450
|
+
canManage: boolean;
|
|
451
|
+
members: WorkspaceMember[];
|
|
452
|
+
pendingInvites: WorkspaceInvite[];
|
|
453
|
+
}
|
|
454
|
+
interface InviteWorkspaceMemberInput {
|
|
455
|
+
email: string;
|
|
456
|
+
role: WorkspaceRole;
|
|
457
|
+
}
|
|
458
|
+
interface WorkspaceInviteIssued {
|
|
459
|
+
inviteId: string;
|
|
460
|
+
email: string;
|
|
461
|
+
role: string;
|
|
462
|
+
/** Sensitive bearer link returned at issuance. Do not log or persist in public storage. */
|
|
463
|
+
acceptUrl: string;
|
|
464
|
+
expiresAt: string;
|
|
465
|
+
}
|
|
466
|
+
interface WorkspaceInvitePreview {
|
|
467
|
+
workspaceName: string;
|
|
468
|
+
email: string;
|
|
469
|
+
role: string;
|
|
470
|
+
expiresAt: string;
|
|
471
|
+
requiresRegistration: boolean;
|
|
472
|
+
}
|
|
473
|
+
interface WorkspaceInviteAccepted {
|
|
474
|
+
workspaceId: string;
|
|
475
|
+
workspaceName: string;
|
|
476
|
+
role: string;
|
|
477
|
+
accountCreated: boolean;
|
|
478
|
+
}
|
|
479
|
+
interface AcceptWorkspaceInviteInput {
|
|
480
|
+
name?: string;
|
|
481
|
+
password?: string;
|
|
482
|
+
}
|
|
483
|
+
interface InviteTenantMemberInput {
|
|
484
|
+
email: string;
|
|
485
|
+
roles?: string[];
|
|
486
|
+
}
|
|
487
|
+
interface TenantMember {
|
|
488
|
+
userId: string;
|
|
489
|
+
email: string;
|
|
490
|
+
username: string;
|
|
491
|
+
roles: string[];
|
|
492
|
+
createdAt: string;
|
|
493
|
+
lastLoginAt: string | null;
|
|
494
|
+
}
|
|
495
|
+
type TenantMemberPage = Paged<TenantMember>;
|
|
496
|
+
|
|
497
|
+
type QueryParams = object;
|
|
498
|
+
|
|
499
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
500
|
+
interface JsonRequestOptions {
|
|
501
|
+
method?: HttpMethod;
|
|
502
|
+
body?: unknown;
|
|
503
|
+
query?: QueryParams;
|
|
504
|
+
headers?: Record<string, string>;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
type ManagementRequest = <T>(path: string, options?: JsonRequestOptions) => Promise<T>;
|
|
508
|
+
|
|
509
|
+
/** Platform user administration. Never falls back to an environment machine token. */
|
|
510
|
+
declare class PlatformScopedClient {
|
|
511
|
+
#private;
|
|
512
|
+
/** @hidden */
|
|
513
|
+
constructor(request: ManagementRequest, token: AccessTokenSource);
|
|
514
|
+
readonly credentials: {
|
|
515
|
+
list: (scope: CredentialScope, options?: CredentialListOptions) => Promise<Paged<TenantCredentialSummary>>;
|
|
516
|
+
get: (scope: CredentialScope, credentialId: string) => Promise<CredentialDetail>;
|
|
517
|
+
create: (scope: CredentialScope, input: CreateCredentialInput) => Promise<TenantCredentialIssued>;
|
|
518
|
+
updatePermissions: (scope: CredentialScope, credentialId: string, input: CredentialPermissionsInput) => Promise<void>;
|
|
519
|
+
updateScopes: (scope: CredentialScope, credentialId: string, scopes: readonly string[]) => Promise<void>;
|
|
520
|
+
/** Returns a new secret once. API may require an explicit step-up first. */
|
|
521
|
+
rotate: (scope: CredentialScope, credentialId: string) => Promise<TenantCredentialIssued>;
|
|
522
|
+
revoke: (scope: CredentialScope, credentialId: string) => Promise<void>;
|
|
523
|
+
};
|
|
524
|
+
readonly workspaces: {
|
|
525
|
+
team: (workspaceId: string) => Promise<WorkspaceTeam>;
|
|
526
|
+
members: {
|
|
527
|
+
invite: (workspaceId: string, input: InviteWorkspaceMemberInput) => Promise<WorkspaceInviteIssued>;
|
|
528
|
+
/** memberId comes from team.members; it is not the platform userId. */
|
|
529
|
+
remove: (workspaceId: string, memberId: string) => Promise<void>;
|
|
530
|
+
changeRole: (workspaceId: string, memberId: string, role: WorkspaceRole) => Promise<void>;
|
|
531
|
+
};
|
|
532
|
+
invites: {
|
|
533
|
+
create: (workspaceId: string, input: InviteWorkspaceMemberInput) => Promise<WorkspaceInviteIssued>;
|
|
534
|
+
revoke: (workspaceId: string, inviteId: string) => Promise<void>;
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
readonly tenants: {
|
|
538
|
+
members: {
|
|
539
|
+
list: (scope: TenantManagementScope, options?: PaginationOptions) => Promise<EnvironmentUser[]>;
|
|
540
|
+
add: (scope: TenantManagementScope, userId: string, roles?: string[]) => Promise<void>;
|
|
541
|
+
remove: (scope: TenantManagementScope, userId: string) => Promise<void>;
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
readonly auth: {
|
|
545
|
+
/** Explicitly confirms the current platform session; passwords are not retained. */
|
|
546
|
+
stepUp: (currentPassword: string) => Promise<void>;
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
/** End-user operations require a user token and the environment publishable key. */
|
|
550
|
+
declare class UserScopedClient {
|
|
551
|
+
#private;
|
|
552
|
+
/** @hidden */
|
|
553
|
+
constructor(request: ManagementRequest, token: AccessTokenSource);
|
|
554
|
+
readonly tenants: {
|
|
555
|
+
members: {
|
|
556
|
+
list: (tenantId: string, options?: PaginationOptions) => Promise<TenantMemberPage>;
|
|
557
|
+
/** Adds an existing environment user by email; does not send an invitation email. */
|
|
558
|
+
invite: (tenantId: string, input: InviteTenantMemberInput) => Promise<TenantMember>;
|
|
559
|
+
remove: (tenantId: string, userId: string) => Promise<void>;
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
/** Anonymous invite endpoints: the invitation token itself authorizes these requests. */
|
|
564
|
+
declare class WorkspaceInvitesClient {
|
|
565
|
+
#private;
|
|
566
|
+
/** @hidden */
|
|
567
|
+
constructor(request: ManagementRequest);
|
|
568
|
+
preview(token: string): Promise<WorkspaceInvitePreview>;
|
|
569
|
+
accept(token: string, input?: AcceptWorkspaceInviteInput): Promise<WorkspaceInviteAccepted>;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
interface ClientRequestContext {
|
|
573
|
+
/** Real end-user IP, resolved only from infrastructure trusted by the application. */
|
|
574
|
+
clientIp?: string;
|
|
575
|
+
}
|
|
576
|
+
/** Rejects header injection and values that are not a single IPv4 or IPv6 address. */
|
|
577
|
+
declare function normalizeClientIp(value: string): string;
|
|
578
|
+
|
|
579
|
+
type SafeJwtAlgorithm = "RS256" | "PS256" | "ES256" | "EdDSA";
|
|
580
|
+
interface AuthyonJwtClaims extends JWTPayload {
|
|
581
|
+
sub: string;
|
|
582
|
+
iss: string;
|
|
583
|
+
aud: string | string[];
|
|
584
|
+
exp: number;
|
|
585
|
+
iat: number;
|
|
586
|
+
email?: string;
|
|
587
|
+
username?: string;
|
|
588
|
+
roles?: string[];
|
|
589
|
+
permissions?: string[];
|
|
590
|
+
scope?: string;
|
|
591
|
+
}
|
|
592
|
+
interface VerifiedAccessToken {
|
|
593
|
+
claims: AuthyonJwtClaims;
|
|
594
|
+
protectedHeader: JWSHeaderParameters;
|
|
595
|
+
}
|
|
596
|
+
interface JwksTokenVerifierOptions {
|
|
597
|
+
/** Exact trusted issuer from Authyon OpenID discovery. */
|
|
598
|
+
issuer: string;
|
|
599
|
+
/** Audience assigned to the API consuming this token. */
|
|
600
|
+
audience: string | string[];
|
|
601
|
+
/** Trusted HTTPS JWKS endpoint. Never derive this value from the token header. */
|
|
602
|
+
jwksUri?: string;
|
|
603
|
+
/** Static trusted keys for pinned or offline verification. */
|
|
604
|
+
jwks?: JSONWebKeySet;
|
|
605
|
+
algorithms?: readonly SafeJwtAlgorithm[];
|
|
606
|
+
acceptedTokenTypes?: readonly string[];
|
|
607
|
+
clockToleranceSeconds?: number;
|
|
608
|
+
maxTokenAgeSeconds?: number;
|
|
609
|
+
jwksTimeoutMs?: number;
|
|
610
|
+
jwksCacheMs?: number;
|
|
611
|
+
jwksCooldownMs?: number;
|
|
612
|
+
}
|
|
613
|
+
interface AuthyonJwksDiscoveryOptions extends Omit<JwksTokenVerifierOptions, "issuer" | "jwksUri" | "jwks"> {
|
|
614
|
+
/** Optional pin; discovery fails if Authyon advertises a different issuer. */
|
|
615
|
+
issuer?: string;
|
|
616
|
+
/** Override the client environment key used by the discovery endpoint. */
|
|
617
|
+
publishableKey?: string;
|
|
618
|
+
}
|
|
619
|
+
type TokenVerificationErrorCode = "token.invalid" | "token.expired" | "token.not_active" | "token.invalid_claims" | "token.invalid_signature" | "token.key_unavailable";
|
|
620
|
+
declare class TokenVerificationError extends Error {
|
|
621
|
+
readonly code: TokenVerificationErrorCode;
|
|
622
|
+
constructor(code: TokenVerificationErrorCode, options?: {
|
|
623
|
+
cause?: unknown;
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
/** Secure, cached JWT signature and claims verifier backed by a trusted remote JWKS. */
|
|
627
|
+
declare class JwksTokenVerifier {
|
|
628
|
+
private readonly options;
|
|
629
|
+
private readonly verifyKey;
|
|
630
|
+
private readonly algorithms;
|
|
631
|
+
private readonly acceptedTokenTypes;
|
|
632
|
+
constructor(options: JwksTokenVerifierOptions);
|
|
633
|
+
verifyAccessToken(token: string): Promise<VerifiedAccessToken>;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Server-side Authyon client: environment/tenant administration (OAuth
|
|
638
|
+
* client-credentials) plus access-token verification (publishable key).
|
|
639
|
+
* Never import this in browser code — client secrets must stay on your
|
|
640
|
+
* server.
|
|
641
|
+
*/
|
|
642
|
+
declare class AuthyonServerClient {
|
|
643
|
+
#private;
|
|
644
|
+
private readonly envKey?;
|
|
645
|
+
private readonly clientId?;
|
|
646
|
+
private readonly clientIp?;
|
|
647
|
+
private readonly transport;
|
|
648
|
+
private readonly http;
|
|
649
|
+
private readonly environmentTokenProvider;
|
|
650
|
+
constructor(options?: AuthyonServerClientOptions);
|
|
651
|
+
private request;
|
|
652
|
+
/** Mints (and caches) an environment access token from `clientId`/`clientSecret`. */
|
|
653
|
+
private getEnvironmentAccessToken;
|
|
654
|
+
readonly discovery: {
|
|
655
|
+
/** GET /.well-known/jwks.json — the environment's public signing keys. */
|
|
656
|
+
jwks: (publishableKey?: string) => Promise<JsonWebKeySet>;
|
|
657
|
+
/** GET /.well-known/openid-configuration — OIDC discovery document. */
|
|
658
|
+
openidConfiguration: (publishableKey?: string) => Promise<OpenIdConfiguration>;
|
|
659
|
+
};
|
|
660
|
+
/** Discovers Authyon's trusted issuer/JWKS and creates a cached local access-token verifier. */
|
|
661
|
+
createJwksTokenVerifier(options: AuthyonJwksDiscoveryOptions): Promise<JwksTokenVerifier>;
|
|
662
|
+
/** POST /auth/introspect — lightweight token introspection (RFC 7662). */
|
|
663
|
+
introspect(token: string, context?: ClientRequestContext): Promise<IntrospectResult>;
|
|
664
|
+
/** POST /auth/validate — recommended: cross-checks DB state, catches revocation immediately. */
|
|
665
|
+
validate(token: string, context?: ClientRequestContext): Promise<ValidateResult>;
|
|
666
|
+
readonly environmentAuth: {
|
|
667
|
+
/** POST /env/oauth/token — exchanges environment client credentials for an access token. */
|
|
668
|
+
token: (credentials: ClientCredentials) => Promise<TokenResult>;
|
|
669
|
+
};
|
|
670
|
+
readonly tenantAuth: {
|
|
671
|
+
/** POST /tenant/oauth/token — exchanges a tenant's client credentials for a scoped access token. */
|
|
672
|
+
token: (credentials: ClientCredentials) => Promise<TokenResult>;
|
|
673
|
+
/** POST /tenant/auth/validate — validates an already-minted tenant-client bearer token. */
|
|
674
|
+
validate: (accessToken: string, context?: ClientRequestContext) => Promise<TenantClientValidationResult>;
|
|
675
|
+
};
|
|
676
|
+
/**
|
|
677
|
+
* Scopes a client to a single tenant's OAuth credentials — mints and
|
|
678
|
+
* caches its access token independently of the environment plane. Use
|
|
679
|
+
* this for the `TenantManagement` endpoints (`/tenant/...`), which act on
|
|
680
|
+
* "the token's tenant" rather than one you pass by id.
|
|
681
|
+
*/
|
|
682
|
+
tenant(credentials: ClientCredentials): TenantScopedClient;
|
|
683
|
+
/** Uses only the supplied platform-user access token. */
|
|
684
|
+
platform(token: AccessTokenSource): PlatformScopedClient;
|
|
685
|
+
/** Uses an end-user token; the configured environment key selects the environment. */
|
|
686
|
+
user(token: AccessTokenSource): UserScopedClient;
|
|
687
|
+
readonly workspaceInvites: WorkspaceInvitesClient;
|
|
688
|
+
readonly environment: {
|
|
689
|
+
users: {
|
|
690
|
+
/** GET /env/users — paginated list of users in the environment. */
|
|
691
|
+
list: (params?: {
|
|
692
|
+
search?: string;
|
|
693
|
+
} & PaginationOptions) => Promise<Paged<EnvironmentUser>>;
|
|
694
|
+
/** POST /env/users — create a user in the environment; returns only the new id. */
|
|
695
|
+
create: (input: CreateUserInput) => Promise<{
|
|
696
|
+
id: string;
|
|
697
|
+
}>;
|
|
698
|
+
/** GET /env/users/{userId} — fetch an environment user by id. */
|
|
699
|
+
get: (userId: string) => Promise<EnvironmentUser>;
|
|
700
|
+
/** POST /env/users/{userId}/roles — grant a role to an environment user. */
|
|
701
|
+
assignRole: (userId: string, role: string) => Promise<void>;
|
|
702
|
+
/** DELETE /env/users/{userId}/roles/{role} — revoke a role from an environment user. */
|
|
703
|
+
removeRole: (userId: string, role: string) => Promise<void>;
|
|
704
|
+
/** POST /env/users/{userId}/permissions — grant a direct permission to an environment user. */
|
|
705
|
+
grantPermission: (userId: string, permission: string) => Promise<void>;
|
|
706
|
+
/** DELETE /env/users/{userId}/permissions/{permission} — revoke a direct permission. */
|
|
707
|
+
revokePermission: (userId: string, permission: string) => Promise<void>;
|
|
708
|
+
/** POST /env/users/{userId}/unlock — clears an environment user's lockout. */
|
|
709
|
+
unlock: (userId: string, reason?: string) => Promise<void>;
|
|
710
|
+
/** POST /env/users/{userId}/password — sets a new password for the user. */
|
|
711
|
+
setPassword: (userId: string, newPassword: string, reason?: string) => Promise<void>;
|
|
712
|
+
/** POST /env/users/{userId}/sessions/revoke-all — revokes every session the user has. */
|
|
713
|
+
revokeSessions: (userId: string, reason?: string) => Promise<void>;
|
|
714
|
+
/** DELETE /env/users/{userId}/sessions/{sessionId} — revokes a single session. */
|
|
715
|
+
revokeSession: (userId: string, sessionId: string, reason?: string) => Promise<void>;
|
|
716
|
+
/** POST /env/users/{userId}/disable — bans the user indefinitely; revokes live sessions. */
|
|
717
|
+
disable: (userId: string, reason?: string) => Promise<void>;
|
|
718
|
+
/** POST /env/users/{userId}/enable — lifts a ban. */
|
|
719
|
+
enable: (userId: string, reason?: string) => Promise<void>;
|
|
720
|
+
/** POST /env/users/{userId}/suspend — blocks the user temporarily; clears itself after `durationMinutes`. */
|
|
721
|
+
suspend: (userId: string, durationMinutes: number, reason?: string) => Promise<void>;
|
|
722
|
+
/** POST /env/users/{userId}/unsuspend — lifts a suspension early. */
|
|
723
|
+
unsuspend: (userId: string, reason?: string) => Promise<void>;
|
|
724
|
+
/** POST /env/users/{userId}/tenants — adds an environment user to a tenant. */
|
|
725
|
+
assignTenant: (userId: string, tenantId: string, roles?: string[]) => Promise<void>;
|
|
726
|
+
/** DELETE /env/users/{userId}/tenants/{tenantId} — removes an environment user from a tenant. */
|
|
727
|
+
removeTenant: (userId: string, tenantId: string) => Promise<void>;
|
|
728
|
+
};
|
|
729
|
+
tenants: {
|
|
730
|
+
credentials: {
|
|
731
|
+
/** GET /env/tenants/{tenantId}/credentials. Returns metadata only, including revoked credentials. */
|
|
732
|
+
list: (tenantId: string) => Promise<TenantCredentialSummary[]>;
|
|
733
|
+
/** Paginated searchable listing. Prefer this over loading every credential. */
|
|
734
|
+
listPage: (tenantId: string, options?: CredentialListOptions) => Promise<Paged<TenantCredentialSummary>>;
|
|
735
|
+
get: (tenantId: string, credentialId: string) => Promise<CredentialDetail>;
|
|
736
|
+
/** Explicit scopes/permissions; only issuance returns the client secret. */
|
|
737
|
+
create: (tenantId: string, input: CreateTenantCredentialInput | CreateCredentialInput) => Promise<TenantCredentialIssued>;
|
|
738
|
+
/** Returns a new secret once while keeping the same client id. */
|
|
739
|
+
rotate: (tenantId: string, credentialId: string) => Promise<TenantCredentialIssued>;
|
|
740
|
+
updatePermissions: (tenantId: string, credentialId: string, input: CredentialPermissionsInput) => Promise<void>;
|
|
741
|
+
updateScopes: (tenantId: string, credentialId: string, scopes: readonly string[]) => Promise<void>;
|
|
742
|
+
revoke: (tenantId: string, credentialId: string) => Promise<void>;
|
|
743
|
+
};
|
|
744
|
+
/** GET /env/tenants — paginated, searchable list of tenants in the environment. */
|
|
745
|
+
list: (params?: {
|
|
746
|
+
search?: string;
|
|
747
|
+
} & PaginationOptions) => Promise<Paged<Organization>>;
|
|
748
|
+
/** POST /env/tenants — create a tenant in the environment. */
|
|
749
|
+
create: (input: CreateOrganizationInput) => Promise<Organization>;
|
|
750
|
+
/** GET /env/tenants/{tenantId} — fetch a tenant by id. */
|
|
751
|
+
get: (tenantId: string) => Promise<Organization>;
|
|
752
|
+
/** PUT /env/tenants/{tenantId} — update a tenant. */
|
|
753
|
+
update: (tenantId: string, input: UpdateOrganizationInput) => Promise<Organization>;
|
|
754
|
+
/** PUT /env/tenants/{tenantId}/metadata - replace public and private metadata. */
|
|
755
|
+
updateMetadata: (tenantId: string, input: Pick<CreateOrganizationInput, "publicMetadata" | "privateMetadata">) => Promise<void>;
|
|
756
|
+
/** POST /env/tenants/{tenantId}/disable — disable without removing tenant data. */
|
|
757
|
+
disable: (tenantId: string) => Promise<void>;
|
|
758
|
+
/** DELETE /env/tenants/{tenantId} — logically delete (disable) a tenant. */
|
|
759
|
+
delete: (tenantId: string) => Promise<void>;
|
|
760
|
+
members: {
|
|
761
|
+
/**
|
|
762
|
+
* GET /env/tenants/{tenantId}/members — a tenant's members as full
|
|
763
|
+
* user records. Confirmed live: a bare array (unlike
|
|
764
|
+
* `environment.users.list()`, this one does NOT paginate despite
|
|
765
|
+
* accepting `skip`/`take`), with the same shape
|
|
766
|
+
* `environment.users.list()` items have.
|
|
767
|
+
*/
|
|
768
|
+
list: (tenantId: string, params?: PaginationOptions) => Promise<EnvironmentUser[]>;
|
|
769
|
+
/** POST /env/tenants/{tenantId}/members — add a member to a tenant. */
|
|
770
|
+
add: (tenantId: string, userId: string, roles?: string[]) => Promise<void>;
|
|
771
|
+
/** DELETE /env/tenants/{tenantId}/members/{userId} — remove a member from a tenant. */
|
|
772
|
+
remove: (tenantId: string, userId: string) => Promise<void>;
|
|
773
|
+
/** POST /env/tenants/{tenantId}/members/{userId}/roles — grant a tenant role to a member. */
|
|
774
|
+
assignRole: (tenantId: string, userId: string, role: string) => Promise<void>;
|
|
775
|
+
/** DELETE .../members/{userId}/roles/{role} — revoke a tenant role from a member. */
|
|
776
|
+
removeRole: (tenantId: string, userId: string, role: string) => Promise<void>;
|
|
777
|
+
/** POST .../members/{userId}/permissions — grant a permission to a tenant member. */
|
|
778
|
+
grantPermission: (tenantId: string, userId: string, permission: string) => Promise<void>;
|
|
779
|
+
/** DELETE .../members/{userId}/permissions/{permission} — revoke a permission from a tenant member. */
|
|
780
|
+
revokePermission: (tenantId: string, userId: string, permission: string) => Promise<void>;
|
|
781
|
+
};
|
|
782
|
+
roles: {
|
|
783
|
+
/** GET /env/tenants/{tenantId}/roles — list a tenant's roles. */
|
|
784
|
+
list: (tenantId: string) => Promise<Role[]>;
|
|
785
|
+
/** POST /env/tenants/{tenantId}/roles — create a tenant role. */
|
|
786
|
+
create: (tenantId: string, input: RoleInput) => Promise<Role>;
|
|
787
|
+
/** GET /env/tenants/{tenantId}/roles/{roleId} — fetch a tenant role by id. */
|
|
788
|
+
get: (tenantId: string, roleId: string) => Promise<Role>;
|
|
789
|
+
/** PUT /env/tenants/{tenantId}/roles/{roleId} — update a tenant role. */
|
|
790
|
+
update: (tenantId: string, roleId: string, input: RoleInput) => Promise<Role>;
|
|
791
|
+
/** DELETE /env/tenants/{tenantId}/roles/{roleId} — delete a tenant role. */
|
|
792
|
+
delete: (tenantId: string, roleId: string) => Promise<void>;
|
|
793
|
+
};
|
|
794
|
+
};
|
|
795
|
+
roles: {
|
|
796
|
+
/** GET /env/roles — environment-level roles, grouped into custom and system-defined. */
|
|
797
|
+
list: () => Promise<RoleList>;
|
|
798
|
+
/** POST /env/roles — create an environment-level role. */
|
|
799
|
+
create: (input: RoleInput) => Promise<Role>;
|
|
800
|
+
/** PUT /env/roles/{roleId} — update an environment-level role. */
|
|
801
|
+
update: (roleId: string, input: RoleInput) => Promise<Role>;
|
|
802
|
+
/** DELETE /env/roles/{roleId} — delete an environment-level role. */
|
|
803
|
+
delete: (roleId: string) => Promise<void>;
|
|
804
|
+
};
|
|
805
|
+
permissions: {
|
|
806
|
+
/** GET /env/permissions — environment-level permissions, grouped by the role they're attached to. */
|
|
807
|
+
list: () => Promise<PermissionsByRole>;
|
|
808
|
+
/** POST /env/permissions — create an environment-level permission. */
|
|
809
|
+
create: (input: CreatePermissionInput) => Promise<Permission>;
|
|
810
|
+
/** PUT /env/permissions/{permissionId} — update an environment-level permission. */
|
|
811
|
+
update: (permissionId: string, description?: string) => Promise<Permission>;
|
|
812
|
+
/** DELETE /env/permissions/{permissionId} — delete an environment-level permission. */
|
|
813
|
+
delete: (permissionId: string) => Promise<void>;
|
|
814
|
+
/** GET /permissions/reserved — reserved permission names you can't redefine. */
|
|
815
|
+
reserved: () => Promise<ReservedPermissions>;
|
|
816
|
+
};
|
|
817
|
+
audit: {
|
|
818
|
+
/** GET /env/audit — paginated list of the environment's audit events. */
|
|
819
|
+
list: (params?: PaginationOptions) => Promise<Paged<AuditEvent>>;
|
|
820
|
+
/** GET /env/audit/login-activity — paginated login activity in the environment. */
|
|
821
|
+
loginActivity: (params?: PaginationOptions) => Promise<Paged<LoginActivity>>;
|
|
822
|
+
};
|
|
823
|
+
};
|
|
824
|
+
readonly permissions: {
|
|
825
|
+
/** POST /users/{userId}/permissions — grant a permission directly to a user. */
|
|
826
|
+
grant: (userId: string, permission: string) => Promise<void>;
|
|
827
|
+
/** DELETE /users/{userId}/permissions/{permission} — revoke a permission from a user. */
|
|
828
|
+
revoke: (userId: string, permission: string) => Promise<void>;
|
|
829
|
+
};
|
|
830
|
+
/** @internal used by {@link TenantScopedClient} to share the base URL/fetch/error handling. */
|
|
831
|
+
_requestAsTenant<T>(accessToken: string, path: string, options?: {
|
|
832
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
833
|
+
body?: unknown;
|
|
834
|
+
query?: object;
|
|
835
|
+
headers?: Record<string, string>;
|
|
836
|
+
}): Promise<T>;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Client scoped to a single tenant's OAuth credentials — every call acts on
|
|
840
|
+
* "the token's tenant" (`TenantManagement` endpoints), so there's no
|
|
841
|
+
* `tenantId` parameter to pass.
|
|
842
|
+
*/
|
|
843
|
+
declare class TenantScopedClient {
|
|
844
|
+
private readonly server;
|
|
845
|
+
private readonly tokenProvider;
|
|
846
|
+
constructor(server: AuthyonServerClient, credentials: ClientCredentials);
|
|
847
|
+
private getAccessToken;
|
|
848
|
+
private request;
|
|
849
|
+
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
850
|
+
validate(context?: ClientRequestContext): Promise<TenantClientValidationResult>;
|
|
851
|
+
readonly members: {
|
|
852
|
+
/**
|
|
853
|
+
* GET /tenant/members — members of the token's tenant.
|
|
854
|
+
*
|
|
855
|
+
* ⚠️ Inferred, not confirmed live (no tenant client credentials
|
|
856
|
+
* available to exchange for a scoped token) — assumed to share
|
|
857
|
+
* `/env/tenants/{id}/members`'s confirmed shape (bare array of full
|
|
858
|
+
* user records), since both are the "admin" member listing as opposed
|
|
859
|
+
* to `/auth/tenants/{id}/members`'s paginated, lightweight one.
|
|
860
|
+
*/
|
|
861
|
+
list: (params?: PaginationOptions) => Promise<EnvironmentUser[]>;
|
|
862
|
+
/** POST /tenant/members — add a member to the token's tenant. */
|
|
863
|
+
add: (userId: string, roles?: string[]) => Promise<void>;
|
|
864
|
+
/** DELETE /tenant/members/{userId} — remove a member from the token's tenant. */
|
|
865
|
+
remove: (userId: string) => Promise<void>;
|
|
866
|
+
/** POST /tenant/members/{userId}/roles — grant a role to a member of the tenant. */
|
|
867
|
+
assignRole: (userId: string, role: string) => Promise<void>;
|
|
868
|
+
/** DELETE /tenant/members/{userId}/roles/{role} — revoke a role from a member of the tenant. */
|
|
869
|
+
removeRole: (userId: string, role: string) => Promise<void>;
|
|
870
|
+
/** POST /tenant/members/{userId}/permissions — grant a permission to a member of the tenant. */
|
|
871
|
+
grantPermission: (userId: string, permission: string) => Promise<void>;
|
|
872
|
+
/** DELETE .../permissions/{permission} — revoke a permission from a member of the tenant. */
|
|
873
|
+
revokePermission: (userId: string, permission: string) => Promise<void>;
|
|
874
|
+
};
|
|
875
|
+
readonly roles: {
|
|
876
|
+
/**
|
|
877
|
+
* GET /tenant/roles — roles in the token's tenant, grouped into custom
|
|
878
|
+
* and system-defined.
|
|
879
|
+
*
|
|
880
|
+
* ⚠️ Inferred, not confirmed live (the test environment had no tenants
|
|
881
|
+
* to exchange a scoped token for) — assumed to share `/env/roles`'
|
|
882
|
+
* grouped shape, since both operate on the same underlying role model.
|
|
883
|
+
*/
|
|
884
|
+
list: () => Promise<RoleList>;
|
|
885
|
+
/** POST /tenant/roles — create a role in the tenant. */
|
|
886
|
+
create: (input: RoleInput) => Promise<Role>;
|
|
887
|
+
/** GET /tenant/roles/{roleId} — fetch a tenant role by id. */
|
|
888
|
+
get: (roleId: string) => Promise<Role>;
|
|
889
|
+
/** PUT /tenant/roles/{roleId} — update a role in the tenant. */
|
|
890
|
+
update: (roleId: string, input: RoleInput) => Promise<Role>;
|
|
891
|
+
/** DELETE /tenant/roles/{roleId} — delete a role in the tenant. */
|
|
892
|
+
delete: (roleId: string) => Promise<void>;
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
/** Convenience factory: `const authyon = createClient({ clientId, clientSecret })`. */
|
|
896
|
+
declare function createClient(options?: AuthyonServerClientOptions): AuthyonServerClient;
|
|
897
|
+
|
|
898
|
+
export { type TenantMemberPage as $, AuthyonServerClient as A, type Organization as B, type ClientCredentials as C, type PaginationOptions as D, type EnvironmentUser as E, FetchHttpAdapter as F, type Permission as G, type HttpAdapter as H, type IntrospectResult as I, type JsonWebKeySet as J, type PermissionsByRole as K, LoggingHttpAdapter as L, PlatformScopedClient as M, type Role as N, type OpenIdConfiguration as O, type Paged as P, type RoleGrant as Q, type ReservedPermissions as R, type RoleInput as S, type RoleList as T, type RolePermissions as U, type SafeJwtAlgorithm as V, type TenantClientValidationResult as W, type TenantCredentialIssued as X, type TenantCredentialSummary as Y, type TenantManagementScope as Z, type TenantMember as _, type HttpLoggerOptions as a, type TenantMembership as a0, TenantScopedClient as a1, type TokenResult as a2, TokenVerificationError as a3, type TokenVerificationErrorCode as a4, type UpdateOrganizationInput as a5, type User as a6, UserScopedClient as a7, type ValidateResult as a8, type VerifiedAccessToken as a9, type WorkspaceInvite as aa, type WorkspaceInviteAccepted as ab, type WorkspaceInviteIssued as ac, type WorkspaceInvitePreview as ad, WorkspaceInvitesClient as ae, type WorkspaceMember as af, type WorkspaceRole as ag, type WorkspaceTeam as ah, createClient as ai, normalizeClientIp as aj, type AcceptWorkspaceInviteInput as b, type AccessTokenSource as c, type AuditEvent as d, type AuthyonJwksDiscoveryOptions as e, type AuthyonJwtClaims as f, type AuthyonServerClientOptions as g, type ClientRequestContext as h, type CreateCredentialInput as i, type CreateOrganizationInput as j, type CreatePermissionInput as k, type CreateTenantCredentialInput as l, type CreateUserInput as m, type CredentialCreator as n, type CredentialDetail as o, type CredentialListOptions as p, type CredentialPermissionsInput as q, type CredentialScope as r, type HttpAdapterRequest as s, type HttpLogEvent as t, type HttpLogger as u, type InviteTenantMemberInput as v, type InviteWorkspaceMemberInput as w, JwksTokenVerifier as x, type JwksTokenVerifierOptions as y, type LoginActivity as z };
|