@authyon/server 0.2.0-beta.2 → 0.2.0-beta.4
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 +166 -1
- package/dist/authorization-Cwl7YFEZ.d.cts +976 -0
- package/dist/authorization-Cwl7YFEZ.d.ts +976 -0
- package/dist/chunk-24IFDJ73.js +490 -0
- package/dist/index.cjs +348 -26
- package/dist/index.d.cts +14 -751
- package/dist/index.d.ts +14 -751
- package/dist/index.js +357 -488
- package/dist/next.cjs +328 -0
- package/dist/next.d.cts +26 -0
- package/dist/next.d.ts +26 -0
- package/dist/next.js +47 -0
- package/package.json +20 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,641 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/** Real end-user IP, resolved only from infrastructure trusted by the application. */
|
|
5
|
-
clientIp?: string;
|
|
6
|
-
}
|
|
7
|
-
/** Rejects header injection and values that are not a single IPv4 or IPv6 address. */
|
|
8
|
-
declare function normalizeClientIp(value: string): string;
|
|
9
|
-
|
|
10
|
-
interface HttpAdapterRequest {
|
|
11
|
-
url: string;
|
|
12
|
-
method: string;
|
|
13
|
-
headers: Record<string, string>;
|
|
14
|
-
body?: BodyInit | null;
|
|
15
|
-
signal: AbortSignal;
|
|
16
|
-
}
|
|
17
|
-
/** Transport contract accepted by both Authyon clients. */
|
|
18
|
-
interface HttpAdapter {
|
|
19
|
-
request(request: HttpAdapterRequest): Promise<Response>;
|
|
20
|
-
}
|
|
21
|
-
type HttpLogEvent = {
|
|
22
|
-
type: "request";
|
|
23
|
-
method: string;
|
|
24
|
-
url: string;
|
|
25
|
-
timestamp: number;
|
|
26
|
-
} | {
|
|
27
|
-
type: "response";
|
|
28
|
-
method: string;
|
|
29
|
-
url: string;
|
|
30
|
-
status: number;
|
|
31
|
-
durationMs: number;
|
|
32
|
-
requestId?: string;
|
|
33
|
-
timestamp: number;
|
|
34
|
-
} | {
|
|
35
|
-
type: "error";
|
|
36
|
-
method: string;
|
|
37
|
-
url: string;
|
|
38
|
-
errorName: string;
|
|
39
|
-
durationMs: number;
|
|
40
|
-
timestamp: number;
|
|
41
|
-
};
|
|
42
|
-
/** Receives sanitized HTTP lifecycle events. Headers, bodies and query values are never exposed. */
|
|
43
|
-
type HttpLogger = (event: HttpLogEvent) => void;
|
|
44
|
-
/**
|
|
45
|
-
* Mutable logging configuration. Change `enabled` at runtime to enable or disable logging
|
|
46
|
-
* without recreating the Authyon client.
|
|
47
|
-
*/
|
|
48
|
-
interface HttpLoggerOptions {
|
|
49
|
-
enabled: boolean;
|
|
50
|
-
logger?: HttpLogger;
|
|
51
|
-
}
|
|
52
|
-
/** Default adapter backed by the platform's Fetch API. */
|
|
53
|
-
declare class FetchHttpAdapter implements HttpAdapter {
|
|
54
|
-
private readonly fetchImpl;
|
|
55
|
-
constructor(fetchImpl?: typeof fetch);
|
|
56
|
-
request(request: HttpAdapterRequest): Promise<Response>;
|
|
57
|
-
}
|
|
58
|
-
/** Adds safe, configurable lifecycle logging to any HTTP adapter. */
|
|
59
|
-
declare class LoggingHttpAdapter implements HttpAdapter {
|
|
60
|
-
private readonly adapter;
|
|
61
|
-
private readonly options;
|
|
62
|
-
constructor(adapter: HttpAdapter, options: HttpLoggerOptions);
|
|
63
|
-
request(request: HttpAdapterRequest): Promise<Response>;
|
|
64
|
-
private log;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface PaginationOptions {
|
|
68
|
-
skip?: number;
|
|
69
|
-
take?: number;
|
|
70
|
-
}
|
|
71
|
-
interface Paged<T> {
|
|
72
|
-
data: T[];
|
|
73
|
-
perPage?: number;
|
|
74
|
-
pageSize: number;
|
|
75
|
-
total: number;
|
|
76
|
-
pages: number;
|
|
77
|
-
hasNext: boolean;
|
|
78
|
-
hasPrev: boolean;
|
|
79
|
-
}
|
|
80
|
-
interface IntrospectResult {
|
|
81
|
-
active: boolean;
|
|
82
|
-
sub?: string;
|
|
83
|
-
username?: string | null;
|
|
84
|
-
email?: string | null;
|
|
85
|
-
roles?: string[] | null;
|
|
86
|
-
permissions?: string[];
|
|
87
|
-
client_id?: string;
|
|
88
|
-
scope?: string;
|
|
89
|
-
exp?: number;
|
|
90
|
-
iat?: number;
|
|
91
|
-
jti?: string;
|
|
92
|
-
token_type?: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** GET/POST /env/tenants — confirmed against the live API. */
|
|
96
|
-
interface Organization {
|
|
97
|
-
id: string;
|
|
98
|
-
slug: string;
|
|
99
|
-
name?: string;
|
|
100
|
-
description?: string | null;
|
|
101
|
-
environmentId?: string;
|
|
102
|
-
workspaceId?: string;
|
|
103
|
-
isDisabled?: boolean;
|
|
104
|
-
memberCount?: number;
|
|
105
|
-
createdAt?: string;
|
|
106
|
-
updatedAt?: string;
|
|
107
|
-
}
|
|
108
|
-
/** One of a user's tenant memberships, as embedded in `EnvironmentUser.tenantMemberships`. */
|
|
109
|
-
interface TenantMembership {
|
|
110
|
-
tenantId: string;
|
|
111
|
-
tenantSlug: string;
|
|
112
|
-
tenantName: string;
|
|
113
|
-
tenantDisabled: boolean;
|
|
114
|
-
roles: string[];
|
|
115
|
-
}
|
|
116
|
-
/** Lightweight user shape returned by `introspect()`/`validate()`. */
|
|
117
|
-
interface User {
|
|
118
|
-
id: string;
|
|
119
|
-
email: string;
|
|
120
|
-
username?: string;
|
|
121
|
-
/** Environment-level roles from the database-validated user profile. */
|
|
122
|
-
roles?: string[];
|
|
123
|
-
permissions?: string[];
|
|
124
|
-
}
|
|
125
|
-
interface RoleGrant {
|
|
126
|
-
role: string;
|
|
127
|
-
expiresAt?: string | null;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Full user record from the EnvironmentManagement plane
|
|
131
|
-
* (`environment.users.get()` / `.list()`), confirmed against the live API.
|
|
132
|
-
* `get()` returns every field below; `list()` returns a subset (no
|
|
133
|
-
* `failedLoginAttempts`, `lockedOutUntil`, `roleGrants`,
|
|
134
|
-
* `directPermissions`, `effectivePermissions`, `refreshTokens`,
|
|
135
|
-
* `tenantMemberships`, `totpConfirmedAt`, `emailOtpEnabledAt`,
|
|
136
|
-
* `remainingRecoveryCodes`, `disableReason`, `suspension`, `deleteReason`,
|
|
137
|
-
* `customFields` — and `suspendedUntil` instead of `suspension`).
|
|
138
|
-
*/
|
|
139
|
-
interface EnvironmentUser {
|
|
140
|
-
id: string;
|
|
141
|
-
email: string;
|
|
142
|
-
username?: string;
|
|
143
|
-
firstName?: string | null;
|
|
144
|
-
lastName?: string | null;
|
|
145
|
-
emailConfirmed: boolean;
|
|
146
|
-
isDisabled: boolean;
|
|
147
|
-
createdAt: string;
|
|
148
|
-
lastLoginAt?: string | null;
|
|
149
|
-
failedLoginAttempts?: number;
|
|
150
|
-
lockedOutUntil?: string | null;
|
|
151
|
-
roles: string[];
|
|
152
|
-
roleGrants?: RoleGrant[];
|
|
153
|
-
directPermissions?: string[];
|
|
154
|
-
effectivePermissions?: string[];
|
|
155
|
-
/** Confirmed shape unknown — empty in every response seen so far. */
|
|
156
|
-
refreshTokens?: unknown[];
|
|
157
|
-
tenantIds: string[];
|
|
158
|
-
tenantMemberships?: TenantMembership[];
|
|
159
|
-
/** Flattened role names across all tenant memberships (list() only). */
|
|
160
|
-
tenantRoles?: string[];
|
|
161
|
-
twoFactorMethods: string[];
|
|
162
|
-
totpConfirmedAt?: string | null;
|
|
163
|
-
emailOtpEnabledAt?: string | null;
|
|
164
|
-
remainingRecoveryCodes?: number;
|
|
165
|
-
disableReason?: string | null;
|
|
166
|
-
suspension?: unknown | null;
|
|
167
|
-
suspendedUntil?: string | null;
|
|
168
|
-
deletedAt?: string | null;
|
|
169
|
-
deleteReason?: string | null;
|
|
170
|
-
/** JSON-encoded string. */
|
|
171
|
-
customFields?: string;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* POST /auth/validate — confirmed against the live API. The wire shape is
|
|
175
|
-
* `{ valid, reason, profile }`, not `{ user, organization }` as the
|
|
176
|
-
* OpenAPI schema (which didn't document response bodies) suggested.
|
|
177
|
-
* `profile` is `null` for machine tokens (there's no user behind them) and
|
|
178
|
-
* for tokens that fail validation.
|
|
179
|
-
*/
|
|
180
|
-
interface ValidateResult {
|
|
181
|
-
valid: boolean;
|
|
182
|
-
reason?: string | null;
|
|
183
|
-
user: User | null;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* A role available within an environment or one of its tenants. Confirmed
|
|
187
|
-
* live: system roles carry no `id`/`description` (only `name` +
|
|
188
|
-
* `permissions`) — both are only populated for custom roles you create.
|
|
189
|
-
*/
|
|
190
|
-
interface Role {
|
|
191
|
-
id?: string | null;
|
|
192
|
-
name: string;
|
|
193
|
-
description?: string | null;
|
|
194
|
-
permissions: string[];
|
|
195
|
-
}
|
|
196
|
-
interface RoleInput {
|
|
197
|
-
name: string;
|
|
198
|
-
description?: string;
|
|
199
|
-
permissions?: string[];
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* GET /env/roles and GET /tenant/roles group results by origin instead of
|
|
203
|
-
* returning a flat array — confirmed live for the environment endpoint.
|
|
204
|
-
*/
|
|
205
|
-
interface RoleList {
|
|
206
|
-
custom: Role[];
|
|
207
|
-
system: Role[];
|
|
208
|
-
}
|
|
209
|
-
/** A permission entry as it appears nested under a role in `PermissionsByRole`. */
|
|
210
|
-
interface Permission {
|
|
211
|
-
value: string;
|
|
212
|
-
description?: string | null;
|
|
213
|
-
/** Confirmed live: `null` for the built-in catalog: no separate id per entry. */
|
|
214
|
-
catalogId?: string | null;
|
|
215
|
-
}
|
|
216
|
-
/** A role entry as returned by GET /env/permissions, with its permissions nested. */
|
|
217
|
-
interface RolePermissions {
|
|
218
|
-
roleId: string | null;
|
|
219
|
-
name: string;
|
|
220
|
-
description?: string | null;
|
|
221
|
-
isSystem: boolean;
|
|
222
|
-
permissions: Permission[];
|
|
223
|
-
}
|
|
224
|
-
/** GET /env/permissions — confirmed live: grouped by role, plus any orphaned entries. */
|
|
225
|
-
interface PermissionsByRole {
|
|
226
|
-
roles: RolePermissions[];
|
|
227
|
-
orphans: Permission[];
|
|
228
|
-
}
|
|
229
|
-
/** GET /permissions/reserved — confirmed live: wrapped, not a bare string array. */
|
|
230
|
-
interface ReservedPermissions {
|
|
231
|
-
namespace: string;
|
|
232
|
-
items: string[];
|
|
233
|
-
}
|
|
234
|
-
interface CreatePermissionInput {
|
|
235
|
-
value: string;
|
|
236
|
-
description?: string;
|
|
237
|
-
/** Attach the new permission to this role immediately. */
|
|
238
|
-
attachToRoleId?: string;
|
|
239
|
-
}
|
|
240
|
-
interface CreateOrganizationInput {
|
|
241
|
-
name: string;
|
|
242
|
-
slug: string;
|
|
243
|
-
description?: string;
|
|
244
|
-
}
|
|
245
|
-
interface UpdateOrganizationInput {
|
|
246
|
-
name: string;
|
|
247
|
-
description?: string;
|
|
248
|
-
}
|
|
249
|
-
interface CreateUserInput {
|
|
250
|
-
email: string;
|
|
251
|
-
username: string;
|
|
252
|
-
password: string;
|
|
253
|
-
emailConfirmed?: boolean;
|
|
254
|
-
roles?: string[];
|
|
255
|
-
/** Tenants (organizations) to add the user to on creation. */
|
|
256
|
-
tenantIds?: string[];
|
|
257
|
-
}
|
|
258
|
-
/** GET /env/audit — one audit-trail entry, confirmed against the live API. */
|
|
259
|
-
interface AuditEvent {
|
|
260
|
-
id: string;
|
|
261
|
-
occurredAt: string;
|
|
262
|
-
eventType: string;
|
|
263
|
-
/** JSON-encoded string — `JSON.parse` it for the event-specific payload. */
|
|
264
|
-
payloadJson?: string;
|
|
265
|
-
workspaceId?: string;
|
|
266
|
-
environmentId?: string;
|
|
267
|
-
actorUserId?: string | null;
|
|
268
|
-
actorType?: string;
|
|
269
|
-
actorIp?: string;
|
|
270
|
-
userAgent?: string;
|
|
271
|
-
tenantId?: string | null;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* GET /env/audit/login-activity. Not confirmed with a populated example
|
|
275
|
-
* live (the test environment had none) — assumed to share `AuditEvent`'s
|
|
276
|
-
* shape, since login activity is the same underlying audit-event stream
|
|
277
|
-
* filtered to sign-in events.
|
|
278
|
-
*/
|
|
279
|
-
type LoginActivity = AuditEvent;
|
|
280
|
-
/**
|
|
281
|
-
* Envelope every `skip`/`take`-paginated list endpoint returns, confirmed
|
|
282
|
-
* live for `/env/users`, `/env/audit` and `/env/audit/login-activity`.
|
|
283
|
-
* Endpoints without `skip`/`take` params return a bare array instead.
|
|
284
|
-
*/
|
|
285
|
-
/** OAuth 2.0 client-credentials pair minted in the Authyon console. */
|
|
286
|
-
interface ClientCredentials {
|
|
287
|
-
clientId: string;
|
|
288
|
-
clientSecret: string;
|
|
289
|
-
}
|
|
290
|
-
/** Standard OAuth 2.0 client-credentials token response. */
|
|
291
|
-
interface TokenResult {
|
|
292
|
-
access_token: string;
|
|
293
|
-
token_type: string;
|
|
294
|
-
expires_in: number;
|
|
295
|
-
scope?: string;
|
|
296
|
-
}
|
|
297
|
-
interface JsonWebKeySet {
|
|
298
|
-
keys: Record<string, unknown>[];
|
|
299
|
-
}
|
|
300
|
-
interface OpenIdConfiguration {
|
|
301
|
-
issuer: string;
|
|
302
|
-
jwks_uri: string;
|
|
303
|
-
authorization_endpoint?: string;
|
|
304
|
-
token_endpoint?: string;
|
|
305
|
-
[key: string]: unknown;
|
|
306
|
-
}
|
|
307
|
-
interface AuthyonServerClientOptions {
|
|
308
|
-
/**
|
|
309
|
-
* Publishable environment key (`pk_live_...` / `pk_test_...`), sent as
|
|
310
|
-
* `X-Authyon-Environment`. Required on **every** call — it selects the
|
|
311
|
-
* environment (Test / Live) that a request applies to, independently of
|
|
312
|
-
* whichever bearer token authenticates it.
|
|
313
|
-
*/
|
|
314
|
-
envKey?: string;
|
|
315
|
-
/**
|
|
316
|
-
* Environment-level OAuth client credentials (`ec_...` / secret), minted
|
|
317
|
-
* in the console. Required for everything under `environment.*` and
|
|
318
|
-
* `permissions.*` — the SDK exchanges them for a short-lived access token
|
|
319
|
-
* via `POST /env/oauth/token` and refreshes it transparently.
|
|
320
|
-
*/
|
|
321
|
-
clientId?: string;
|
|
322
|
-
clientSecret?: string;
|
|
323
|
-
/** API origin. Defaults to `https://api.authyon.com`. */
|
|
324
|
-
baseUrl?: string;
|
|
325
|
-
/** Allow an HTTP `baseUrl`. Intended only for explicitly trusted local development. */
|
|
326
|
-
allowInsecureHttp?: boolean;
|
|
327
|
-
/** Maximum duration of each HTTP request. Defaults to 15 seconds; set to `0` to disable. */
|
|
328
|
-
timeoutMs?: number;
|
|
329
|
-
/** Custom HTTP adapter for tracing, mocks or an alternative HTTP stack. */
|
|
330
|
-
httpAdapter?: HttpAdapter;
|
|
331
|
-
/** Safe HTTP lifecycle logging. Disabled unless this option is provided with `enabled: true`. */
|
|
332
|
-
httpLogger?: HttpLoggerOptions;
|
|
333
|
-
/** @deprecated Prefer `httpAdapter: new FetchHttpAdapter(customFetch)`. */
|
|
334
|
-
fetch?: typeof fetch;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
type SafeJwtAlgorithm = "RS256" | "PS256" | "ES256" | "EdDSA";
|
|
338
|
-
interface AuthyonJwtClaims extends JWTPayload {
|
|
339
|
-
sub: string;
|
|
340
|
-
iss: string;
|
|
341
|
-
aud: string | string[];
|
|
342
|
-
exp: number;
|
|
343
|
-
iat: number;
|
|
344
|
-
email?: string;
|
|
345
|
-
username?: string;
|
|
346
|
-
roles?: string[];
|
|
347
|
-
permissions?: string[];
|
|
348
|
-
scope?: string;
|
|
349
|
-
}
|
|
350
|
-
interface VerifiedAccessToken {
|
|
351
|
-
claims: AuthyonJwtClaims;
|
|
352
|
-
protectedHeader: JWSHeaderParameters;
|
|
353
|
-
}
|
|
354
|
-
interface JwksTokenVerifierOptions {
|
|
355
|
-
/** Exact trusted issuer from Authyon OpenID discovery. */
|
|
356
|
-
issuer: string;
|
|
357
|
-
/** Audience assigned to the API consuming this token. */
|
|
358
|
-
audience: string | string[];
|
|
359
|
-
/** Trusted HTTPS JWKS endpoint. Never derive this value from the token header. */
|
|
360
|
-
jwksUri?: string;
|
|
361
|
-
/** Static trusted keys for pinned or offline verification. */
|
|
362
|
-
jwks?: JSONWebKeySet;
|
|
363
|
-
algorithms?: readonly SafeJwtAlgorithm[];
|
|
364
|
-
acceptedTokenTypes?: readonly string[];
|
|
365
|
-
clockToleranceSeconds?: number;
|
|
366
|
-
maxTokenAgeSeconds?: number;
|
|
367
|
-
jwksTimeoutMs?: number;
|
|
368
|
-
jwksCacheMs?: number;
|
|
369
|
-
jwksCooldownMs?: number;
|
|
370
|
-
}
|
|
371
|
-
interface AuthyonJwksDiscoveryOptions extends Omit<JwksTokenVerifierOptions, "issuer" | "jwksUri" | "jwks"> {
|
|
372
|
-
/** Optional pin; discovery fails if Authyon advertises a different issuer. */
|
|
373
|
-
issuer?: string;
|
|
374
|
-
/** Override the client environment key used by the discovery endpoint. */
|
|
375
|
-
publishableKey?: string;
|
|
376
|
-
}
|
|
377
|
-
type TokenVerificationErrorCode = "token.invalid" | "token.expired" | "token.not_active" | "token.invalid_claims" | "token.invalid_signature" | "token.key_unavailable";
|
|
378
|
-
declare class TokenVerificationError extends Error {
|
|
379
|
-
readonly code: TokenVerificationErrorCode;
|
|
380
|
-
constructor(code: TokenVerificationErrorCode, options?: {
|
|
381
|
-
cause?: unknown;
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
/** Secure, cached JWT signature and claims verifier backed by a trusted remote JWKS. */
|
|
385
|
-
declare class JwksTokenVerifier {
|
|
386
|
-
private readonly options;
|
|
387
|
-
private readonly verifyKey;
|
|
388
|
-
private readonly algorithms;
|
|
389
|
-
private readonly acceptedTokenTypes;
|
|
390
|
-
constructor(options: JwksTokenVerifierOptions);
|
|
391
|
-
verifyAccessToken(token: string): Promise<VerifiedAccessToken>;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Server-side Authyon client: environment/tenant administration (OAuth
|
|
396
|
-
* client-credentials) plus access-token verification (publishable key).
|
|
397
|
-
* Never import this in browser code — client secrets must stay on your
|
|
398
|
-
* server.
|
|
399
|
-
*/
|
|
400
|
-
declare class AuthyonServerClient {
|
|
401
|
-
private readonly envKey?;
|
|
402
|
-
private readonly clientId?;
|
|
403
|
-
private readonly clientSecret?;
|
|
404
|
-
private readonly transport;
|
|
405
|
-
private readonly http;
|
|
406
|
-
private readonly environmentTokenProvider;
|
|
407
|
-
constructor(options?: AuthyonServerClientOptions);
|
|
408
|
-
private request;
|
|
409
|
-
/** Mints (and caches) an environment access token from `clientId`/`clientSecret`. */
|
|
410
|
-
private getEnvironmentAccessToken;
|
|
411
|
-
readonly discovery: {
|
|
412
|
-
/** GET /.well-known/jwks.json — the environment's public signing keys. */
|
|
413
|
-
jwks: (publishableKey?: string) => Promise<JsonWebKeySet>;
|
|
414
|
-
/** GET /.well-known/openid-configuration — OIDC discovery document. */
|
|
415
|
-
openidConfiguration: (publishableKey?: string) => Promise<OpenIdConfiguration>;
|
|
416
|
-
};
|
|
417
|
-
/** Discovers Authyon's trusted issuer/JWKS and creates a cached local access-token verifier. */
|
|
418
|
-
createJwksTokenVerifier(options: AuthyonJwksDiscoveryOptions): Promise<JwksTokenVerifier>;
|
|
419
|
-
/** POST /auth/introspect — lightweight token introspection (RFC 7662). */
|
|
420
|
-
introspect(token: string, context?: ClientRequestContext): Promise<IntrospectResult>;
|
|
421
|
-
/** POST /auth/validate — recommended: cross-checks DB state, catches revocation immediately. */
|
|
422
|
-
validate(token: string, context?: ClientRequestContext): Promise<ValidateResult>;
|
|
423
|
-
readonly environmentAuth: {
|
|
424
|
-
/** POST /env/oauth/token — exchanges environment client credentials for an access token. */
|
|
425
|
-
token: (credentials: ClientCredentials) => Promise<TokenResult>;
|
|
426
|
-
};
|
|
427
|
-
readonly tenantAuth: {
|
|
428
|
-
/** POST /tenant/oauth/token — exchanges a tenant's client credentials for a scoped access token. */
|
|
429
|
-
token: (credentials: ClientCredentials) => Promise<TokenResult>;
|
|
430
|
-
};
|
|
431
|
-
/**
|
|
432
|
-
* Scopes a client to a single tenant's OAuth credentials — mints and
|
|
433
|
-
* caches its access token independently of the environment plane. Use
|
|
434
|
-
* this for the `TenantManagement` endpoints (`/tenant/...`), which act on
|
|
435
|
-
* "the token's tenant" rather than one you pass by id.
|
|
436
|
-
*/
|
|
437
|
-
tenant(credentials: ClientCredentials): TenantScopedClient;
|
|
438
|
-
readonly environment: {
|
|
439
|
-
users: {
|
|
440
|
-
/** GET /env/users — paginated list of users in the environment. */
|
|
441
|
-
list: (params?: {
|
|
442
|
-
search?: string;
|
|
443
|
-
} & PaginationOptions) => Promise<Paged<EnvironmentUser>>;
|
|
444
|
-
/** POST /env/users — create a user in the environment; returns only the new id. */
|
|
445
|
-
create: (input: CreateUserInput) => Promise<{
|
|
446
|
-
id: string;
|
|
447
|
-
}>;
|
|
448
|
-
/** GET /env/users/{userId} — fetch an environment user by id. */
|
|
449
|
-
get: (userId: string) => Promise<EnvironmentUser>;
|
|
450
|
-
/** POST /env/users/{userId}/roles — grant a role to an environment user. */
|
|
451
|
-
assignRole: (userId: string, role: string) => Promise<void>;
|
|
452
|
-
/** DELETE /env/users/{userId}/roles/{role} — revoke a role from an environment user. */
|
|
453
|
-
removeRole: (userId: string, role: string) => Promise<void>;
|
|
454
|
-
/** POST /env/users/{userId}/permissions — grant a direct permission to an environment user. */
|
|
455
|
-
grantPermission: (userId: string, permission: string) => Promise<void>;
|
|
456
|
-
/** DELETE /env/users/{userId}/permissions/{permission} — revoke a direct permission. */
|
|
457
|
-
revokePermission: (userId: string, permission: string) => Promise<void>;
|
|
458
|
-
/** POST /env/users/{userId}/unlock — clears an environment user's lockout. */
|
|
459
|
-
unlock: (userId: string, reason?: string) => Promise<void>;
|
|
460
|
-
/** POST /env/users/{userId}/password — sets a new password for the user. */
|
|
461
|
-
setPassword: (userId: string, newPassword: string, reason?: string) => Promise<void>;
|
|
462
|
-
/** POST /env/users/{userId}/sessions/revoke-all — revokes every session the user has. */
|
|
463
|
-
revokeSessions: (userId: string, reason?: string) => Promise<void>;
|
|
464
|
-
/** DELETE /env/users/{userId}/sessions/{sessionId} — revokes a single session. */
|
|
465
|
-
revokeSession: (userId: string, sessionId: string, reason?: string) => Promise<void>;
|
|
466
|
-
/** POST /env/users/{userId}/disable — bans the user indefinitely; revokes live sessions. */
|
|
467
|
-
disable: (userId: string, reason?: string) => Promise<void>;
|
|
468
|
-
/** POST /env/users/{userId}/enable — lifts a ban. */
|
|
469
|
-
enable: (userId: string, reason?: string) => Promise<void>;
|
|
470
|
-
/** POST /env/users/{userId}/suspend — blocks the user temporarily; clears itself after `durationMinutes`. */
|
|
471
|
-
suspend: (userId: string, durationMinutes: number, reason?: string) => Promise<void>;
|
|
472
|
-
/** POST /env/users/{userId}/unsuspend — lifts a suspension early. */
|
|
473
|
-
unsuspend: (userId: string, reason?: string) => Promise<void>;
|
|
474
|
-
/** POST /env/users/{userId}/tenants — adds an environment user to a tenant. */
|
|
475
|
-
assignTenant: (userId: string, tenantId: string, roles?: string[]) => Promise<void>;
|
|
476
|
-
/** DELETE /env/users/{userId}/tenants/{tenantId} — removes an environment user from a tenant. */
|
|
477
|
-
removeTenant: (userId: string, tenantId: string) => Promise<void>;
|
|
478
|
-
};
|
|
479
|
-
tenants: {
|
|
480
|
-
/** GET /env/tenants — paginated, searchable list of tenants in the environment. */
|
|
481
|
-
list: (params?: {
|
|
482
|
-
search?: string;
|
|
483
|
-
} & PaginationOptions) => Promise<Paged<Organization>>;
|
|
484
|
-
/** POST /env/tenants — create a tenant in the environment. */
|
|
485
|
-
create: (input: CreateOrganizationInput) => Promise<Organization>;
|
|
486
|
-
/** GET /env/tenants/{tenantId} — fetch a tenant by id. */
|
|
487
|
-
get: (tenantId: string) => Promise<Organization>;
|
|
488
|
-
/** PUT /env/tenants/{tenantId} — update a tenant. */
|
|
489
|
-
update: (tenantId: string, input: UpdateOrganizationInput) => Promise<Organization>;
|
|
490
|
-
/** DELETE /env/tenants/{tenantId} — delete a tenant. */
|
|
491
|
-
delete: (tenantId: string) => Promise<void>;
|
|
492
|
-
members: {
|
|
493
|
-
/**
|
|
494
|
-
* GET /env/tenants/{tenantId}/members — a tenant's members as full
|
|
495
|
-
* user records. Confirmed live: a bare array (unlike
|
|
496
|
-
* `environment.users.list()`, this one does NOT paginate despite
|
|
497
|
-
* accepting `skip`/`take`), with the same shape
|
|
498
|
-
* `environment.users.list()` items have.
|
|
499
|
-
*/
|
|
500
|
-
list: (tenantId: string, params?: PaginationOptions) => Promise<EnvironmentUser[]>;
|
|
501
|
-
/** POST /env/tenants/{tenantId}/members — add a member to a tenant. */
|
|
502
|
-
add: (tenantId: string, userId: string, roles?: string[]) => Promise<void>;
|
|
503
|
-
/** DELETE /env/tenants/{tenantId}/members/{userId} — remove a member from a tenant. */
|
|
504
|
-
remove: (tenantId: string, userId: string) => Promise<void>;
|
|
505
|
-
/** POST /env/tenants/{tenantId}/members/{userId}/roles — grant a tenant role to a member. */
|
|
506
|
-
assignRole: (tenantId: string, userId: string, role: string) => Promise<void>;
|
|
507
|
-
/** DELETE .../members/{userId}/roles/{role} — revoke a tenant role from a member. */
|
|
508
|
-
removeRole: (tenantId: string, userId: string, role: string) => Promise<void>;
|
|
509
|
-
/** POST .../members/{userId}/permissions — grant a permission to a tenant member. */
|
|
510
|
-
grantPermission: (tenantId: string, userId: string, permission: string) => Promise<void>;
|
|
511
|
-
/** DELETE .../members/{userId}/permissions/{permission} — revoke a permission from a tenant member. */
|
|
512
|
-
revokePermission: (tenantId: string, userId: string, permission: string) => Promise<void>;
|
|
513
|
-
};
|
|
514
|
-
roles: {
|
|
515
|
-
/** GET /env/tenants/{tenantId}/roles — list a tenant's roles. */
|
|
516
|
-
list: (tenantId: string) => Promise<Role[]>;
|
|
517
|
-
/** POST /env/tenants/{tenantId}/roles — create a tenant role. */
|
|
518
|
-
create: (tenantId: string, input: RoleInput) => Promise<Role>;
|
|
519
|
-
/** GET /env/tenants/{tenantId}/roles/{roleId} — fetch a tenant role by id. */
|
|
520
|
-
get: (tenantId: string, roleId: string) => Promise<Role>;
|
|
521
|
-
/** PUT /env/tenants/{tenantId}/roles/{roleId} — update a tenant role. */
|
|
522
|
-
update: (tenantId: string, roleId: string, input: RoleInput) => Promise<Role>;
|
|
523
|
-
/** DELETE /env/tenants/{tenantId}/roles/{roleId} — delete a tenant role. */
|
|
524
|
-
delete: (tenantId: string, roleId: string) => Promise<void>;
|
|
525
|
-
};
|
|
526
|
-
};
|
|
527
|
-
roles: {
|
|
528
|
-
/** GET /env/roles — environment-level roles, grouped into custom and system-defined. */
|
|
529
|
-
list: () => Promise<RoleList>;
|
|
530
|
-
/** POST /env/roles — create an environment-level role. */
|
|
531
|
-
create: (input: RoleInput) => Promise<Role>;
|
|
532
|
-
/** PUT /env/roles/{roleId} — update an environment-level role. */
|
|
533
|
-
update: (roleId: string, input: RoleInput) => Promise<Role>;
|
|
534
|
-
/** DELETE /env/roles/{roleId} — delete an environment-level role. */
|
|
535
|
-
delete: (roleId: string) => Promise<void>;
|
|
536
|
-
};
|
|
537
|
-
permissions: {
|
|
538
|
-
/** GET /env/permissions — environment-level permissions, grouped by the role they're attached to. */
|
|
539
|
-
list: () => Promise<PermissionsByRole>;
|
|
540
|
-
/** POST /env/permissions — create an environment-level permission. */
|
|
541
|
-
create: (input: CreatePermissionInput) => Promise<Permission>;
|
|
542
|
-
/** PUT /env/permissions/{permissionId} — update an environment-level permission. */
|
|
543
|
-
update: (permissionId: string, description?: string) => Promise<Permission>;
|
|
544
|
-
/** DELETE /env/permissions/{permissionId} — delete an environment-level permission. */
|
|
545
|
-
delete: (permissionId: string) => Promise<void>;
|
|
546
|
-
/** GET /permissions/reserved — reserved permission names you can't redefine. */
|
|
547
|
-
reserved: () => Promise<ReservedPermissions>;
|
|
548
|
-
};
|
|
549
|
-
audit: {
|
|
550
|
-
/** GET /env/audit — paginated list of the environment's audit events. */
|
|
551
|
-
list: (params?: PaginationOptions) => Promise<Paged<AuditEvent>>;
|
|
552
|
-
/** GET /env/audit/login-activity — paginated login activity in the environment. */
|
|
553
|
-
loginActivity: (params?: PaginationOptions) => Promise<Paged<LoginActivity>>;
|
|
554
|
-
};
|
|
555
|
-
};
|
|
556
|
-
readonly permissions: {
|
|
557
|
-
/** POST /users/{userId}/permissions — grant a permission directly to a user. */
|
|
558
|
-
grant: (userId: string, permission: string) => Promise<void>;
|
|
559
|
-
/** DELETE /users/{userId}/permissions/{permission} — revoke a permission from a user. */
|
|
560
|
-
revoke: (userId: string, permission: string) => Promise<void>;
|
|
561
|
-
};
|
|
562
|
-
/** @internal used by {@link TenantScopedClient} to share the base URL/fetch/error handling. */
|
|
563
|
-
_requestAsTenant<T>(accessToken: string, path: string, options?: {
|
|
564
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
565
|
-
body?: unknown;
|
|
566
|
-
query?: object;
|
|
567
|
-
headers?: Record<string, string>;
|
|
568
|
-
}): Promise<T>;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* Client scoped to a single tenant's OAuth credentials — every call acts on
|
|
572
|
-
* "the token's tenant" (`TenantManagement` endpoints), so there's no
|
|
573
|
-
* `tenantId` parameter to pass.
|
|
574
|
-
*/
|
|
575
|
-
declare class TenantScopedClient {
|
|
576
|
-
private readonly server;
|
|
577
|
-
private readonly tokenProvider;
|
|
578
|
-
constructor(server: AuthyonServerClient, credentials: ClientCredentials);
|
|
579
|
-
private getAccessToken;
|
|
580
|
-
private request;
|
|
581
|
-
readonly members: {
|
|
582
|
-
/**
|
|
583
|
-
* GET /tenant/members — members of the token's tenant.
|
|
584
|
-
*
|
|
585
|
-
* ⚠️ Inferred, not confirmed live (no tenant client credentials
|
|
586
|
-
* available to exchange for a scoped token) — assumed to share
|
|
587
|
-
* `/env/tenants/{id}/members`'s confirmed shape (bare array of full
|
|
588
|
-
* user records), since both are the "admin" member listing as opposed
|
|
589
|
-
* to `/auth/tenants/{id}/members`'s paginated, lightweight one.
|
|
590
|
-
*/
|
|
591
|
-
list: (params?: PaginationOptions) => Promise<EnvironmentUser[]>;
|
|
592
|
-
/** POST /tenant/members — add a member to the token's tenant. */
|
|
593
|
-
add: (userId: string, roles?: string[]) => Promise<void>;
|
|
594
|
-
/** DELETE /tenant/members/{userId} — remove a member from the token's tenant. */
|
|
595
|
-
remove: (userId: string) => Promise<void>;
|
|
596
|
-
/** POST /tenant/members/{userId}/roles — grant a role to a member of the tenant. */
|
|
597
|
-
assignRole: (userId: string, role: string) => Promise<void>;
|
|
598
|
-
/** DELETE /tenant/members/{userId}/roles/{role} — revoke a role from a member of the tenant. */
|
|
599
|
-
removeRole: (userId: string, role: string) => Promise<void>;
|
|
600
|
-
/** POST /tenant/members/{userId}/permissions — grant a permission to a member of the tenant. */
|
|
601
|
-
grantPermission: (userId: string, permission: string) => Promise<void>;
|
|
602
|
-
/** DELETE .../permissions/{permission} — revoke a permission from a member of the tenant. */
|
|
603
|
-
revokePermission: (userId: string, permission: string) => Promise<void>;
|
|
604
|
-
};
|
|
605
|
-
readonly roles: {
|
|
606
|
-
/**
|
|
607
|
-
* GET /tenant/roles — roles in the token's tenant, grouped into custom
|
|
608
|
-
* and system-defined.
|
|
609
|
-
*
|
|
610
|
-
* ⚠️ Inferred, not confirmed live (the test environment had no tenants
|
|
611
|
-
* to exchange a scoped token for) — assumed to share `/env/roles`'
|
|
612
|
-
* grouped shape, since both operate on the same underlying role model.
|
|
613
|
-
*/
|
|
614
|
-
list: () => Promise<RoleList>;
|
|
615
|
-
/** POST /tenant/roles — create a role in the tenant. */
|
|
616
|
-
create: (input: RoleInput) => Promise<Role>;
|
|
617
|
-
/** GET /tenant/roles/{roleId} — fetch a tenant role by id. */
|
|
618
|
-
get: (roleId: string) => Promise<Role>;
|
|
619
|
-
/** PUT /tenant/roles/{roleId} — update a role in the tenant. */
|
|
620
|
-
update: (roleId: string, input: RoleInput) => Promise<Role>;
|
|
621
|
-
/** DELETE /tenant/roles/{roleId} — delete a role in the tenant. */
|
|
622
|
-
delete: (roleId: string) => Promise<void>;
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
/** Convenience factory: `const authyon = createClient({ clientId, clientSecret })`. */
|
|
626
|
-
declare function createClient(options?: AuthyonServerClientOptions): AuthyonServerClient;
|
|
627
|
-
|
|
628
|
-
/** Builds a server client while keeping environment credentials grouped. */
|
|
629
|
-
declare class AuthyonServerClientBuilder {
|
|
630
|
-
private readonly options;
|
|
631
|
-
withEnvironmentKey(envKey: string): this;
|
|
632
|
-
withEnvironmentCredentials(clientId: string, clientSecret: string): this;
|
|
633
|
-
withBaseUrl(baseUrl: string, allowInsecureHttp?: boolean): this;
|
|
634
|
-
withTimeout(timeoutMs: number): this;
|
|
635
|
-
withHttpAdapter(httpAdapter: HttpAdapter): this;
|
|
636
|
-
withHttpLogger(httpLogger: HttpLoggerOptions): this;
|
|
637
|
-
build(): AuthyonServerClient;
|
|
638
|
-
}
|
|
1
|
+
import { H as HttpAdapter, c as HttpLoggerOptions, A as AuthyonServerClient } from './authorization-Cwl7YFEZ.cjs';
|
|
2
|
+
export { d as AbilityConditions, e as AbilityEvent, f as AbilityListener, g as AbilityRequirement, h as AbilityRule, a as AbilitySubject, i as AcceptWorkspaceInviteInput, j as AccessTokenSource, k as AuditEvent, l as AuthorizationContext, b as AuthorizationError, m as AuthorizationOptions, n as AuthyonAbility, o as AuthyonAbilityBuilder, p as AuthyonAbilityOptions, q as AuthyonJwksDiscoveryOptions, r as AuthyonJwtClaims, s as AuthyonPermissionSource, t as AuthyonServerClientOptions, C as ClientCredentials, u as ClientRequestContext, v as CreateCredentialInput, w as CreateOrganizationInput, x as CreatePermissionInput, y as CreateTenantCredentialInput, z as CreateUserInput, B as CredentialCreator, D as CredentialDetail, E as CredentialListOptions, F as CredentialPermissionsInput, G as CredentialScope, I as EnvironmentUser, J as ExpressAuthorizationMiddlewareOptions, K as ExpressNext, L as ExpressRequestLike, M as ExpressResponseLike, N as FetchHttpAdapter, O as HttpAdapterRequest, P as HttpLogEvent, Q as HttpLogger, S as IntrospectResult, T as InviteTenantMemberInput, U as InviteWorkspaceMemberInput, V as JsonWebKeySet, W as JwksTokenVerifier, X as JwksTokenVerifierOptions, Y as LoggingHttpAdapter, Z as LoginActivity, _ as OpenIdConfiguration, $ as Organization, a0 as Paged, a1 as PaginationOptions, a2 as Permission, a3 as PermissionsByRole, a4 as PlatformScopedClient, R as RequestAuthorizationOptions, a5 as ReservedPermissions, a6 as Role, a7 as RoleGrant, a8 as RoleInput, a9 as RoleList, aa as RolePermissions, ab as SafeJwtAlgorithm, ac as TenantCredentialIssued, ad as TenantCredentialSummary, ae as TenantManagementScope, af as TenantMember, ag as TenantMemberPage, ah as TenantMembership, ai as TenantScopedClient, aj as TokenResult, ak as TokenVerificationError, al as TokenVerificationErrorCode, am as UpdateOrganizationInput, an as User, ao as UserScopedClient, ap as ValidateResult, aq as VerifiedAccessToken, ar as WorkspaceInvite, as as WorkspaceInviteAccepted, at as WorkspaceInviteIssued, au as WorkspaceInvitePreview, av as WorkspaceInvitesClient, aw as WorkspaceMember, ax as WorkspaceRole, ay as WorkspaceTeam, az as authorizeRequest, aA as authorizeToken, aB as createAuthorizationErrorResponse, aC as createAuthyonAbility, aD as createAuthyonRules, aE as createClient, aF as createExpressAuthorizationMiddleware, aG as hasPermission, aH as normalizeClientIp } from './authorization-Cwl7YFEZ.cjs';
|
|
3
|
+
import 'jose';
|
|
639
4
|
|
|
640
5
|
declare const ErrorCodes: {
|
|
641
6
|
readonly Unknown: "unknown";
|
|
@@ -689,118 +54,16 @@ declare class AuthyonError extends Error {
|
|
|
689
54
|
toJSON(): Record<string, unknown>;
|
|
690
55
|
}
|
|
691
56
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
interface AuthyonPermissionSource {
|
|
703
|
-
permissions?: readonly string[] | null;
|
|
704
|
-
roles?: readonly string[] | null;
|
|
705
|
-
/** OAuth scopes are also accepted and interpreted as Authyon permissions. */
|
|
706
|
-
scope?: string | null;
|
|
707
|
-
}
|
|
708
|
-
interface AuthyonAbilityOptions {
|
|
709
|
-
rules?: readonly AbilityRule[];
|
|
710
|
-
/** Rules added when the source contains a matching Authyon role. */
|
|
711
|
-
roleRules?: Readonly<Record<string, readonly AbilityRule[]>>;
|
|
712
|
-
roles?: readonly string[] | null;
|
|
713
|
-
detectSubjectType?: (subject: Record<string, unknown>) => string;
|
|
714
|
-
}
|
|
715
|
-
type AbilityEvent = "updated";
|
|
716
|
-
type AbilityListener = (rules: readonly AbilityRule[]) => void;
|
|
717
|
-
/** Isomorphic, deny-by-default authorization engine backed by Authyon permissions. */
|
|
718
|
-
declare class AuthyonAbility {
|
|
719
|
-
private readonly detectSubjectType;
|
|
720
|
-
private currentRules;
|
|
721
|
-
private readonly listeners;
|
|
722
|
-
constructor(rules?: readonly AbilityRule[], detectSubjectType?: (subject: Record<string, unknown>) => string);
|
|
723
|
-
get rules(): readonly AbilityRule[];
|
|
724
|
-
can(action: string, subject: AbilitySubject, field?: string): boolean;
|
|
725
|
-
cannot(action: string, subject: AbilitySubject, field?: string): boolean;
|
|
726
|
-
rulesFor(action: string, subject: string): readonly AbilityRule[];
|
|
727
|
-
update(rules: readonly AbilityRule[]): void;
|
|
728
|
-
on(event: AbilityEvent, listener: AbilityListener): () => void;
|
|
729
|
-
}
|
|
730
|
-
/** Fluent rule builder with CASL-like `can` and `cannot` methods. */
|
|
731
|
-
declare class AuthyonAbilityBuilder {
|
|
732
|
-
readonly rules: AbilityRule[];
|
|
733
|
-
can(action: string | string[], subject: string | string[], conditions?: AbilityConditions, fields?: string[]): this;
|
|
734
|
-
cannot(action: string | string[], subject: string | string[], conditions?: AbilityConditions, fields?: string[], reason?: string): this;
|
|
735
|
-
build(options?: Pick<AuthyonAbilityOptions, "detectSubjectType">): AuthyonAbility;
|
|
736
|
-
}
|
|
737
|
-
/** Creates an ability from Authyon permissions, OAuth scope and optional role rules. */
|
|
738
|
-
declare function createAuthyonAbility(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AuthyonAbility;
|
|
739
|
-
/** Checks an Authyon permission string using the same wildcard rules as an ability. */
|
|
740
|
-
declare function hasPermission(source: AuthyonPermissionSource | readonly string[], requiredPermission: string): boolean;
|
|
741
|
-
/** Converts Authyon's `subject:action` permission strings to authorization rules. */
|
|
742
|
-
declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
|
|
743
|
-
|
|
744
|
-
interface AbilityRequirement {
|
|
745
|
-
action: string;
|
|
746
|
-
subject: AbilitySubject;
|
|
747
|
-
field?: string;
|
|
748
|
-
}
|
|
749
|
-
interface AuthorizationContext {
|
|
750
|
-
token: string;
|
|
751
|
-
userId?: string;
|
|
752
|
-
ability: AuthyonAbility;
|
|
753
|
-
permissions: readonly string[];
|
|
754
|
-
roles: readonly string[];
|
|
755
|
-
}
|
|
756
|
-
interface AuthorizationOptions extends AuthyonAbilityOptions {
|
|
757
|
-
requirement?: AbilityRequirement;
|
|
758
|
-
/** Uses database-backed validation by default; introspection can be selected when desired. */
|
|
759
|
-
verification?: "validate" | "introspect" | "jwks";
|
|
760
|
-
/** Required for local JWKS verification. Create once and reuse its key cache. */
|
|
761
|
-
jwksVerifier?: JwksTokenVerifier;
|
|
762
|
-
/** Real end-user IP, obtained from trusted application infrastructure. */
|
|
763
|
-
clientIp?: string;
|
|
764
|
-
}
|
|
765
|
-
declare class AuthorizationError extends Error {
|
|
766
|
-
readonly status: 401 | 403 | 503;
|
|
767
|
-
readonly code: "authorization.unauthenticated" | "authorization.forbidden" | "authorization.unavailable";
|
|
768
|
-
constructor(status: 401 | 403 | 503, code: "authorization.unauthenticated" | "authorization.forbidden" | "authorization.unavailable", message: string);
|
|
769
|
-
}
|
|
770
|
-
/** Validates a bearer token and creates an Authyon-backed ability for server runtimes. */
|
|
771
|
-
declare function authorizeToken(client: AuthyonServerClient, token: string, options?: AuthorizationOptions): Promise<AuthorizationContext>;
|
|
772
|
-
/** Works with Web Request objects used by Next.js Route Handlers and other Fetch runtimes. */
|
|
773
|
-
declare function authorizeRequest(client: AuthyonServerClient, request: Pick<Request, "headers">, options?: RequestAuthorizationOptions): Promise<AuthorizationContext>;
|
|
774
|
-
interface RequestAuthorizationOptions extends AuthorizationOptions {
|
|
775
|
-
/** Platform-aware resolver. Only read headers that your trusted proxy overwrites. */
|
|
776
|
-
resolveClientIp?: (request: Pick<Request, "headers">) => string | undefined;
|
|
777
|
-
}
|
|
778
|
-
interface ExpressRequestLike {
|
|
779
|
-
headers: Record<string, string | string[] | undefined>;
|
|
780
|
-
ip?: string;
|
|
781
|
-
socket?: {
|
|
782
|
-
remoteAddress?: string;
|
|
783
|
-
};
|
|
784
|
-
authyon?: AuthorizationContext;
|
|
785
|
-
}
|
|
786
|
-
interface ExpressResponseLike {
|
|
787
|
-
status(code: number): ExpressResponseLike;
|
|
788
|
-
json(body: unknown): unknown;
|
|
789
|
-
}
|
|
790
|
-
type ExpressNext = (error?: unknown) => void;
|
|
791
|
-
interface ExpressAuthorizationMiddlewareOptions extends AuthorizationOptions {
|
|
792
|
-
/** Property assigned to the request. Defaults to `authyon`. */
|
|
793
|
-
requestProperty?: string;
|
|
794
|
-
/** Pass authorization errors to Express error middleware instead of writing a JSON response. */
|
|
795
|
-
passErrorsToNext?: boolean;
|
|
796
|
-
/** Trust Express's proxy-aware `request.ip`. Disabled by default. */
|
|
797
|
-
trustProxy?: boolean;
|
|
798
|
-
/** Overrides all built-in IP resolution; return only a trusted, single client IP. */
|
|
799
|
-
resolveClientIp?: (request: ExpressRequestLike) => string | undefined;
|
|
57
|
+
/** Builds a server client while keeping environment credentials grouped. */
|
|
58
|
+
declare class AuthyonServerClientBuilder {
|
|
59
|
+
#private;
|
|
60
|
+
withEnvironmentKey(envKey: string): this;
|
|
61
|
+
withEnvironmentCredentials(clientId: string, clientSecret: string): this;
|
|
62
|
+
withBaseUrl(baseUrl: string, allowInsecureHttp?: boolean): this;
|
|
63
|
+
withTimeout(timeoutMs: number): this;
|
|
64
|
+
withHttpAdapter(httpAdapter: HttpAdapter): this;
|
|
65
|
+
withHttpLogger(httpLogger: HttpLoggerOptions): this;
|
|
66
|
+
build(): AuthyonServerClient;
|
|
800
67
|
}
|
|
801
|
-
/** Dependency-free middleware compatible with Express and similar Connect frameworks. */
|
|
802
|
-
declare function createExpressAuthorizationMiddleware(client: AuthyonServerClient, options?: ExpressAuthorizationMiddlewareOptions): (request: ExpressRequestLike & Record<string, unknown>, response: ExpressResponseLike, next: ExpressNext) => Promise<void>;
|
|
803
|
-
/** Converts an authorization error into a Fetch Response suitable for Next.js. */
|
|
804
|
-
declare function createAuthorizationErrorResponse(error: unknown): Response;
|
|
805
68
|
|
|
806
|
-
export {
|
|
69
|
+
export { AuthyonError, type AuthyonErrorAction, type AuthyonErrorCategory, type AuthyonErrorInterpretation, AuthyonServerClient, AuthyonServerClientBuilder, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode };
|