@authyon/server 0.2.0-beta.1 → 0.2.0-beta.3
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 +171 -1
- package/dist/index.cjs +368 -28
- package/dist/index.d.cts +305 -66
- package/dist/index.d.ts +305 -66
- package/dist/index.js +365 -28
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { JSONWebKeySet, JWTPayload, JWSHeaderParameters } from 'jose';
|
|
2
2
|
|
|
3
|
-
interface ClientRequestContext {
|
|
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
3
|
interface HttpAdapterRequest {
|
|
11
4
|
url: string;
|
|
12
5
|
method: string;
|
|
@@ -118,6 +111,8 @@ interface User {
|
|
|
118
111
|
id: string;
|
|
119
112
|
email: string;
|
|
120
113
|
username?: string;
|
|
114
|
+
/** Environment-level roles from the database-validated user profile. */
|
|
115
|
+
roles?: string[];
|
|
121
116
|
permissions?: string[];
|
|
122
117
|
}
|
|
123
118
|
interface RoleGrant {
|
|
@@ -278,9 +273,36 @@ type LoginActivity = AuditEvent;
|
|
|
278
273
|
/**
|
|
279
274
|
* Envelope every `skip`/`take`-paginated list endpoint returns, confirmed
|
|
280
275
|
* live for `/env/users`, `/env/audit` and `/env/audit/login-activity`.
|
|
281
|
-
* Endpoints without `skip`/`take` params
|
|
282
|
-
* bare array instead.
|
|
276
|
+
* Endpoints without `skip`/`take` params return a bare array instead.
|
|
283
277
|
*/
|
|
278
|
+
/** Tenant credential metadata. Listing never returns the secret. */
|
|
279
|
+
interface TenantCredentialSummary {
|
|
280
|
+
id: string;
|
|
281
|
+
clientId: string;
|
|
282
|
+
description: string | null;
|
|
283
|
+
createdAt: string;
|
|
284
|
+
lastUsedAt: string | null;
|
|
285
|
+
revokedAt: string | null;
|
|
286
|
+
expiresAt: string | null;
|
|
287
|
+
isActive: boolean;
|
|
288
|
+
permissions: string[];
|
|
289
|
+
}
|
|
290
|
+
/** Input for a tenant machine credential. Requires at least one explicit permission. */
|
|
291
|
+
interface CreateTenantCredentialInput {
|
|
292
|
+
description: string;
|
|
293
|
+
/** Number of days until the tenant credential expires. Omit for no automatic expiration. */
|
|
294
|
+
lifetimeDays?: number | null;
|
|
295
|
+
permissions: string[];
|
|
296
|
+
}
|
|
297
|
+
/** The plaintext secret is returned only when the credential is issued. */
|
|
298
|
+
interface TenantCredentialIssued {
|
|
299
|
+
credentialId: string;
|
|
300
|
+
clientId: string;
|
|
301
|
+
clientSecret: string;
|
|
302
|
+
createdAt: string;
|
|
303
|
+
expiresAt: string | null;
|
|
304
|
+
permissions: string[];
|
|
305
|
+
}
|
|
284
306
|
/** OAuth 2.0 client-credentials pair minted in the Authyon console. */
|
|
285
307
|
interface ClientCredentials {
|
|
286
308
|
clientId: string;
|
|
@@ -333,6 +355,252 @@ interface AuthyonServerClientOptions {
|
|
|
333
355
|
fetch?: typeof fetch;
|
|
334
356
|
}
|
|
335
357
|
|
|
358
|
+
/** A token of the requested authentication plane, or a provider called for each request. */
|
|
359
|
+
type AccessTokenSource = string | (() => string | Promise<string>);
|
|
360
|
+
interface CredentialListOptions extends PaginationOptions {
|
|
361
|
+
search?: string;
|
|
362
|
+
}
|
|
363
|
+
/** scopes is an alias for permissions. Always supply an explicit, nonempty set. */
|
|
364
|
+
type CredentialPermissionsInput = {
|
|
365
|
+
permissions: readonly string[];
|
|
366
|
+
scopes?: never;
|
|
367
|
+
} | {
|
|
368
|
+
scopes: readonly string[];
|
|
369
|
+
permissions?: never;
|
|
370
|
+
};
|
|
371
|
+
type CreateCredentialInput = CredentialPermissionsInput & {
|
|
372
|
+
description?: string;
|
|
373
|
+
lifetimeDays?: number | null;
|
|
374
|
+
};
|
|
375
|
+
interface CredentialScope {
|
|
376
|
+
workspaceId: string;
|
|
377
|
+
environmentId: string;
|
|
378
|
+
tenantId?: string;
|
|
379
|
+
}
|
|
380
|
+
interface TenantManagementScope extends CredentialScope {
|
|
381
|
+
tenantId: string;
|
|
382
|
+
}
|
|
383
|
+
interface CredentialCreator {
|
|
384
|
+
id: string | null;
|
|
385
|
+
type: string;
|
|
386
|
+
displayName: string | null;
|
|
387
|
+
}
|
|
388
|
+
interface CredentialDetail extends TenantCredentialSummary {
|
|
389
|
+
createdBy: CredentialCreator | null;
|
|
390
|
+
updatedAt: string | null;
|
|
391
|
+
secretRotatedAt: string | null;
|
|
392
|
+
expiresAt: string | null;
|
|
393
|
+
ageSeconds: number;
|
|
394
|
+
/** Null while active; elapsed lifetime at revocation otherwise. */
|
|
395
|
+
lifetimeSeconds: number | null;
|
|
396
|
+
accessTokenLifetimeSeconds: number;
|
|
397
|
+
}
|
|
398
|
+
type WorkspaceRole = "admin" | "auditor";
|
|
399
|
+
interface WorkspaceMember {
|
|
400
|
+
memberId: string | null;
|
|
401
|
+
userId: string;
|
|
402
|
+
email: string;
|
|
403
|
+
name: string;
|
|
404
|
+
role: string;
|
|
405
|
+
isOwner: boolean;
|
|
406
|
+
isSelf: boolean;
|
|
407
|
+
invitedByName: string | null;
|
|
408
|
+
joinedAt: string;
|
|
409
|
+
lastLoginAt: string | null;
|
|
410
|
+
}
|
|
411
|
+
interface WorkspaceInvite {
|
|
412
|
+
id: string;
|
|
413
|
+
email: string;
|
|
414
|
+
role: string;
|
|
415
|
+
invitedByName: string | null;
|
|
416
|
+
createdAt: string;
|
|
417
|
+
expiresAt: string;
|
|
418
|
+
}
|
|
419
|
+
interface WorkspaceTeam {
|
|
420
|
+
workspaceId: string;
|
|
421
|
+
workspaceName: string;
|
|
422
|
+
callerRole: string;
|
|
423
|
+
canManage: boolean;
|
|
424
|
+
members: WorkspaceMember[];
|
|
425
|
+
pendingInvites: WorkspaceInvite[];
|
|
426
|
+
}
|
|
427
|
+
interface InviteWorkspaceMemberInput {
|
|
428
|
+
email: string;
|
|
429
|
+
role: WorkspaceRole;
|
|
430
|
+
}
|
|
431
|
+
interface WorkspaceInviteIssued {
|
|
432
|
+
inviteId: string;
|
|
433
|
+
email: string;
|
|
434
|
+
role: string;
|
|
435
|
+
/** Sensitive bearer link returned at issuance. Do not log or persist in public storage. */
|
|
436
|
+
acceptUrl: string;
|
|
437
|
+
expiresAt: string;
|
|
438
|
+
}
|
|
439
|
+
interface WorkspaceInvitePreview {
|
|
440
|
+
workspaceName: string;
|
|
441
|
+
email: string;
|
|
442
|
+
role: string;
|
|
443
|
+
expiresAt: string;
|
|
444
|
+
requiresRegistration: boolean;
|
|
445
|
+
}
|
|
446
|
+
interface WorkspaceInviteAccepted {
|
|
447
|
+
workspaceId: string;
|
|
448
|
+
workspaceName: string;
|
|
449
|
+
role: string;
|
|
450
|
+
accountCreated: boolean;
|
|
451
|
+
}
|
|
452
|
+
interface AcceptWorkspaceInviteInput {
|
|
453
|
+
name?: string;
|
|
454
|
+
password?: string;
|
|
455
|
+
}
|
|
456
|
+
interface InviteTenantMemberInput {
|
|
457
|
+
email: string;
|
|
458
|
+
roles?: string[];
|
|
459
|
+
}
|
|
460
|
+
interface TenantMember {
|
|
461
|
+
userId: string;
|
|
462
|
+
email: string;
|
|
463
|
+
username: string;
|
|
464
|
+
roles: string[];
|
|
465
|
+
createdAt: string;
|
|
466
|
+
lastLoginAt: string | null;
|
|
467
|
+
}
|
|
468
|
+
type TenantMemberPage = Paged<TenantMember>;
|
|
469
|
+
|
|
470
|
+
type QueryParams = object;
|
|
471
|
+
|
|
472
|
+
declare const ErrorCodes: {
|
|
473
|
+
readonly Unknown: "unknown";
|
|
474
|
+
readonly NetworkError: "request.network_error";
|
|
475
|
+
readonly Timeout: "request.timeout";
|
|
476
|
+
readonly SessionMalformed: "session.malformed";
|
|
477
|
+
readonly NotAuthenticated: "auth.not_authenticated";
|
|
478
|
+
readonly InvalidToken: "auth.invalid_token";
|
|
479
|
+
readonly MissingToken: "auth.missing_token";
|
|
480
|
+
readonly EmailTaken: "user.email_taken";
|
|
481
|
+
readonly PasswordWeak: "user.password_weak";
|
|
482
|
+
readonly PasswordPwned: "user.password_pwned";
|
|
483
|
+
readonly RateLimited: "rate_limited";
|
|
484
|
+
};
|
|
485
|
+
type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
486
|
+
type AuthyonErrorCategory = "network" | "timeout" | "authentication" | "authorization" | "validation" | "not_found" | "conflict" | "rate_limit" | "server" | "unknown";
|
|
487
|
+
type AuthyonErrorAction = "retry" | "reauthenticate" | "request_access" | "fix_input" | "not_found" | "resolve_conflict" | "contact_support";
|
|
488
|
+
interface AuthyonErrorInterpretation {
|
|
489
|
+
category: AuthyonErrorCategory;
|
|
490
|
+
action: AuthyonErrorAction;
|
|
491
|
+
retryable: boolean;
|
|
492
|
+
retryAfter?: number;
|
|
493
|
+
requestId?: string;
|
|
494
|
+
}
|
|
495
|
+
/** Shared RFC 7807 error implementation used by both public SDKs. */
|
|
496
|
+
declare class AuthyonError extends Error {
|
|
497
|
+
readonly status: number;
|
|
498
|
+
readonly code: string;
|
|
499
|
+
readonly title: string;
|
|
500
|
+
readonly detail?: string;
|
|
501
|
+
readonly requestId?: string;
|
|
502
|
+
readonly retryAfter?: number;
|
|
503
|
+
readonly cause?: unknown;
|
|
504
|
+
constructor(status: number, body: Partial<{
|
|
505
|
+
title: string;
|
|
506
|
+
detail: string;
|
|
507
|
+
code: string;
|
|
508
|
+
}>, options?: {
|
|
509
|
+
requestId?: string;
|
|
510
|
+
retryAfter?: number;
|
|
511
|
+
cause?: unknown;
|
|
512
|
+
});
|
|
513
|
+
is(code: string): boolean;
|
|
514
|
+
isAny(...codes: readonly string[]): boolean;
|
|
515
|
+
hasPrefix(prefix: string): boolean;
|
|
516
|
+
isStatus(...statuses: readonly number[]): boolean;
|
|
517
|
+
/** Stable interpretation for UI decisions, retries, telemetry and support flows. */
|
|
518
|
+
interpret(): AuthyonErrorInterpretation;
|
|
519
|
+
get category(): AuthyonErrorCategory;
|
|
520
|
+
get retryable(): boolean;
|
|
521
|
+
toJSON(): Record<string, unknown>;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
525
|
+
interface JsonRequestOptions {
|
|
526
|
+
method?: HttpMethod;
|
|
527
|
+
body?: unknown;
|
|
528
|
+
query?: QueryParams;
|
|
529
|
+
headers?: Record<string, string>;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
type ManagementRequest = <T>(path: string, options?: JsonRequestOptions) => Promise<T>;
|
|
533
|
+
|
|
534
|
+
/** Platform user administration. Never falls back to an environment machine token. */
|
|
535
|
+
declare class PlatformScopedClient {
|
|
536
|
+
#private;
|
|
537
|
+
/** @hidden */
|
|
538
|
+
constructor(request: ManagementRequest, token: AccessTokenSource);
|
|
539
|
+
readonly credentials: {
|
|
540
|
+
list: (scope: CredentialScope, options?: CredentialListOptions) => Promise<Paged<TenantCredentialSummary>>;
|
|
541
|
+
get: (scope: CredentialScope, credentialId: string) => Promise<CredentialDetail>;
|
|
542
|
+
create: (scope: CredentialScope, input: CreateCredentialInput) => Promise<TenantCredentialIssued>;
|
|
543
|
+
updatePermissions: (scope: CredentialScope, credentialId: string, input: CredentialPermissionsInput) => Promise<void>;
|
|
544
|
+
updateScopes: (scope: CredentialScope, credentialId: string, scopes: readonly string[]) => Promise<void>;
|
|
545
|
+
/** Returns a new secret once. API may require an explicit step-up first. */
|
|
546
|
+
rotate: (scope: CredentialScope, credentialId: string) => Promise<TenantCredentialIssued>;
|
|
547
|
+
revoke: (scope: CredentialScope, credentialId: string) => Promise<void>;
|
|
548
|
+
};
|
|
549
|
+
readonly workspaces: {
|
|
550
|
+
team: (workspaceId: string) => Promise<WorkspaceTeam>;
|
|
551
|
+
members: {
|
|
552
|
+
invite: (workspaceId: string, input: InviteWorkspaceMemberInput) => Promise<WorkspaceInviteIssued>;
|
|
553
|
+
/** memberId comes from team.members; it is not the platform userId. */
|
|
554
|
+
remove: (workspaceId: string, memberId: string) => Promise<void>;
|
|
555
|
+
changeRole: (workspaceId: string, memberId: string, role: WorkspaceRole) => Promise<void>;
|
|
556
|
+
};
|
|
557
|
+
invites: {
|
|
558
|
+
create: (workspaceId: string, input: InviteWorkspaceMemberInput) => Promise<WorkspaceInviteIssued>;
|
|
559
|
+
revoke: (workspaceId: string, inviteId: string) => Promise<void>;
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
readonly tenants: {
|
|
563
|
+
members: {
|
|
564
|
+
list: (scope: TenantManagementScope, options?: PaginationOptions) => Promise<EnvironmentUser[]>;
|
|
565
|
+
add: (scope: TenantManagementScope, userId: string, roles?: string[]) => Promise<void>;
|
|
566
|
+
remove: (scope: TenantManagementScope, userId: string) => Promise<void>;
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
readonly auth: {
|
|
570
|
+
/** Explicitly confirms the current platform session; passwords are not retained. */
|
|
571
|
+
stepUp: (currentPassword: string) => Promise<void>;
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
/** End-user operations require a user token and the environment publishable key. */
|
|
575
|
+
declare class UserScopedClient {
|
|
576
|
+
#private;
|
|
577
|
+
/** @hidden */
|
|
578
|
+
constructor(request: ManagementRequest, token: AccessTokenSource);
|
|
579
|
+
readonly tenants: {
|
|
580
|
+
members: {
|
|
581
|
+
list: (tenantId: string, options?: PaginationOptions) => Promise<TenantMemberPage>;
|
|
582
|
+
/** Adds an existing environment user by email; does not send an invitation email. */
|
|
583
|
+
invite: (tenantId: string, input: InviteTenantMemberInput) => Promise<TenantMember>;
|
|
584
|
+
remove: (tenantId: string, userId: string) => Promise<void>;
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
/** Anonymous invite endpoints: the invitation token itself authorizes these requests. */
|
|
589
|
+
declare class WorkspaceInvitesClient {
|
|
590
|
+
#private;
|
|
591
|
+
/** @hidden */
|
|
592
|
+
constructor(request: ManagementRequest);
|
|
593
|
+
preview(token: string): Promise<WorkspaceInvitePreview>;
|
|
594
|
+
accept(token: string, input?: AcceptWorkspaceInviteInput): Promise<WorkspaceInviteAccepted>;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
interface ClientRequestContext {
|
|
598
|
+
/** Real end-user IP, resolved only from infrastructure trusted by the application. */
|
|
599
|
+
clientIp?: string;
|
|
600
|
+
}
|
|
601
|
+
/** Rejects header injection and values that are not a single IPv4 or IPv6 address. */
|
|
602
|
+
declare function normalizeClientIp(value: string): string;
|
|
603
|
+
|
|
336
604
|
type SafeJwtAlgorithm = "RS256" | "PS256" | "ES256" | "EdDSA";
|
|
337
605
|
interface AuthyonJwtClaims extends JWTPayload {
|
|
338
606
|
sub: string;
|
|
@@ -397,9 +665,9 @@ declare class JwksTokenVerifier {
|
|
|
397
665
|
* server.
|
|
398
666
|
*/
|
|
399
667
|
declare class AuthyonServerClient {
|
|
668
|
+
#private;
|
|
400
669
|
private readonly envKey?;
|
|
401
670
|
private readonly clientId?;
|
|
402
|
-
private readonly clientSecret?;
|
|
403
671
|
private readonly transport;
|
|
404
672
|
private readonly http;
|
|
405
673
|
private readonly environmentTokenProvider;
|
|
@@ -434,6 +702,11 @@ declare class AuthyonServerClient {
|
|
|
434
702
|
* "the token's tenant" rather than one you pass by id.
|
|
435
703
|
*/
|
|
436
704
|
tenant(credentials: ClientCredentials): TenantScopedClient;
|
|
705
|
+
/** Uses only the supplied platform-user access token. */
|
|
706
|
+
platform(token: AccessTokenSource): PlatformScopedClient;
|
|
707
|
+
/** Uses an end-user token; the configured environment key selects the environment. */
|
|
708
|
+
user(token: AccessTokenSource): UserScopedClient;
|
|
709
|
+
readonly workspaceInvites: WorkspaceInvitesClient;
|
|
437
710
|
readonly environment: {
|
|
438
711
|
users: {
|
|
439
712
|
/** GET /env/users — paginated list of users in the environment. */
|
|
@@ -476,8 +749,24 @@ declare class AuthyonServerClient {
|
|
|
476
749
|
removeTenant: (userId: string, tenantId: string) => Promise<void>;
|
|
477
750
|
};
|
|
478
751
|
tenants: {
|
|
479
|
-
|
|
480
|
-
|
|
752
|
+
credentials: {
|
|
753
|
+
/** GET /env/tenants/{tenantId}/credentials. Returns metadata only, including revoked credentials. */
|
|
754
|
+
list: (tenantId: string) => Promise<TenantCredentialSummary[]>;
|
|
755
|
+
/** Paginated searchable listing. Prefer this over loading every credential. */
|
|
756
|
+
listPage: (tenantId: string, options?: CredentialListOptions) => Promise<Paged<TenantCredentialSummary>>;
|
|
757
|
+
get: (tenantId: string, credentialId: string) => Promise<CredentialDetail>;
|
|
758
|
+
/** Explicit scopes/permissions; only issuance returns the client secret. */
|
|
759
|
+
create: (tenantId: string, input: CreateTenantCredentialInput | CreateCredentialInput) => Promise<TenantCredentialIssued>;
|
|
760
|
+
/** Returns a new secret once while keeping the same client id. */
|
|
761
|
+
rotate: (tenantId: string, credentialId: string) => Promise<TenantCredentialIssued>;
|
|
762
|
+
updatePermissions: (tenantId: string, credentialId: string, input: CredentialPermissionsInput) => Promise<void>;
|
|
763
|
+
updateScopes: (tenantId: string, credentialId: string, scopes: readonly string[]) => Promise<void>;
|
|
764
|
+
revoke: (tenantId: string, credentialId: string) => Promise<void>;
|
|
765
|
+
};
|
|
766
|
+
/** GET /env/tenants — paginated, searchable list of tenants in the environment. */
|
|
767
|
+
list: (params?: {
|
|
768
|
+
search?: string;
|
|
769
|
+
} & PaginationOptions) => Promise<Paged<Organization>>;
|
|
481
770
|
/** POST /env/tenants — create a tenant in the environment. */
|
|
482
771
|
create: (input: CreateOrganizationInput) => Promise<Organization>;
|
|
483
772
|
/** GET /env/tenants/{tenantId} — fetch a tenant by id. */
|
|
@@ -624,7 +913,7 @@ declare function createClient(options?: AuthyonServerClientOptions): AuthyonServ
|
|
|
624
913
|
|
|
625
914
|
/** Builds a server client while keeping environment credentials grouped. */
|
|
626
915
|
declare class AuthyonServerClientBuilder {
|
|
627
|
-
private
|
|
916
|
+
#private;
|
|
628
917
|
withEnvironmentKey(envKey: string): this;
|
|
629
918
|
withEnvironmentCredentials(clientId: string, clientSecret: string): this;
|
|
630
919
|
withBaseUrl(baseUrl: string, allowInsecureHttp?: boolean): this;
|
|
@@ -634,58 +923,6 @@ declare class AuthyonServerClientBuilder {
|
|
|
634
923
|
build(): AuthyonServerClient;
|
|
635
924
|
}
|
|
636
925
|
|
|
637
|
-
declare const ErrorCodes: {
|
|
638
|
-
readonly Unknown: "unknown";
|
|
639
|
-
readonly NetworkError: "request.network_error";
|
|
640
|
-
readonly Timeout: "request.timeout";
|
|
641
|
-
readonly SessionMalformed: "session.malformed";
|
|
642
|
-
readonly NotAuthenticated: "auth.not_authenticated";
|
|
643
|
-
readonly InvalidToken: "auth.invalid_token";
|
|
644
|
-
readonly MissingToken: "auth.missing_token";
|
|
645
|
-
readonly EmailTaken: "user.email_taken";
|
|
646
|
-
readonly PasswordWeak: "user.password_weak";
|
|
647
|
-
readonly PasswordPwned: "user.password_pwned";
|
|
648
|
-
readonly RateLimited: "rate_limited";
|
|
649
|
-
};
|
|
650
|
-
type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
651
|
-
type AuthyonErrorCategory = "network" | "timeout" | "authentication" | "authorization" | "validation" | "not_found" | "conflict" | "rate_limit" | "server" | "unknown";
|
|
652
|
-
type AuthyonErrorAction = "retry" | "reauthenticate" | "request_access" | "fix_input" | "not_found" | "resolve_conflict" | "contact_support";
|
|
653
|
-
interface AuthyonErrorInterpretation {
|
|
654
|
-
category: AuthyonErrorCategory;
|
|
655
|
-
action: AuthyonErrorAction;
|
|
656
|
-
retryable: boolean;
|
|
657
|
-
retryAfter?: number;
|
|
658
|
-
requestId?: string;
|
|
659
|
-
}
|
|
660
|
-
/** Shared RFC 7807 error implementation used by both public SDKs. */
|
|
661
|
-
declare class AuthyonError extends Error {
|
|
662
|
-
readonly status: number;
|
|
663
|
-
readonly code: string;
|
|
664
|
-
readonly title: string;
|
|
665
|
-
readonly detail?: string;
|
|
666
|
-
readonly requestId?: string;
|
|
667
|
-
readonly retryAfter?: number;
|
|
668
|
-
readonly cause?: unknown;
|
|
669
|
-
constructor(status: number, body: Partial<{
|
|
670
|
-
title: string;
|
|
671
|
-
detail: string;
|
|
672
|
-
code: string;
|
|
673
|
-
}>, options?: {
|
|
674
|
-
requestId?: string;
|
|
675
|
-
retryAfter?: number;
|
|
676
|
-
cause?: unknown;
|
|
677
|
-
});
|
|
678
|
-
is(code: string): boolean;
|
|
679
|
-
isAny(...codes: readonly string[]): boolean;
|
|
680
|
-
hasPrefix(prefix: string): boolean;
|
|
681
|
-
isStatus(...statuses: readonly number[]): boolean;
|
|
682
|
-
/** Stable interpretation for UI decisions, retries, telemetry and support flows. */
|
|
683
|
-
interpret(): AuthyonErrorInterpretation;
|
|
684
|
-
get category(): AuthyonErrorCategory;
|
|
685
|
-
get retryable(): boolean;
|
|
686
|
-
toJSON(): Record<string, unknown>;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
926
|
type AbilitySubject = string | Record<string, unknown>;
|
|
690
927
|
type AbilityConditions = Record<string, unknown>;
|
|
691
928
|
interface AbilityRule {
|
|
@@ -733,6 +970,8 @@ declare class AuthyonAbilityBuilder {
|
|
|
733
970
|
}
|
|
734
971
|
/** Creates an ability from Authyon permissions, OAuth scope and optional role rules. */
|
|
735
972
|
declare function createAuthyonAbility(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AuthyonAbility;
|
|
973
|
+
/** Checks an Authyon permission string using the same wildcard rules as an ability. */
|
|
974
|
+
declare function hasPermission(source: AuthyonPermissionSource | readonly string[], requiredPermission: string): boolean;
|
|
736
975
|
/** Converts Authyon's `subject:action` permission strings to authorization rules. */
|
|
737
976
|
declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
|
|
738
977
|
|
|
@@ -798,4 +1037,4 @@ declare function createExpressAuthorizationMiddleware(client: AuthyonServerClien
|
|
|
798
1037
|
/** Converts an authorization error into a Fetch Response suitable for Next.js. */
|
|
799
1038
|
declare function createAuthorizationErrorResponse(error: unknown): Response;
|
|
800
1039
|
|
|
801
|
-
export { type AbilityConditions, type AbilityEvent, type AbilityListener, type AbilityRequirement, type AbilityRule, type AbilitySubject, type AuditEvent, type AuthorizationContext, AuthorizationError, type AuthorizationOptions, AuthyonAbility, AuthyonAbilityBuilder, type AuthyonAbilityOptions, AuthyonError, type AuthyonErrorAction, type AuthyonErrorCategory, type AuthyonErrorInterpretation, type AuthyonJwksDiscoveryOptions, type AuthyonJwtClaims, type AuthyonPermissionSource, AuthyonServerClient, AuthyonServerClientBuilder, type AuthyonServerClientOptions, type ClientCredentials, type ClientRequestContext, type CreateOrganizationInput, type CreatePermissionInput, type CreateUserInput, type EnvironmentUser, ErrorCodes, type ExpressAuthorizationMiddlewareOptions, type ExpressNext, type ExpressRequestLike, type ExpressResponseLike, FetchHttpAdapter, type HttpAdapter, type HttpAdapterRequest, type HttpLogEvent, type HttpLogger, type HttpLoggerOptions, type IntrospectResult, type JsonWebKeySet, JwksTokenVerifier, type JwksTokenVerifierOptions, type KnownErrorCode, LoggingHttpAdapter, type LoginActivity, type OpenIdConfiguration, type Organization, type Paged, type PaginationOptions, type Permission, type PermissionsByRole, type RequestAuthorizationOptions, type ReservedPermissions, type Role, type RoleGrant, type RoleInput, type RoleList, type RolePermissions, type SafeJwtAlgorithm, type TenantMembership, TenantScopedClient, type TokenResult, TokenVerificationError, type TokenVerificationErrorCode, type UpdateOrganizationInput, type User, type ValidateResult, type VerifiedAccessToken, authorizeRequest, authorizeToken, createAuthorizationErrorResponse, createAuthyonAbility, createAuthyonRules, createClient, createExpressAuthorizationMiddleware, normalizeClientIp };
|
|
1040
|
+
export { type AbilityConditions, type AbilityEvent, type AbilityListener, type AbilityRequirement, type AbilityRule, type AbilitySubject, type AcceptWorkspaceInviteInput, type AccessTokenSource, type AuditEvent, type AuthorizationContext, AuthorizationError, type AuthorizationOptions, AuthyonAbility, AuthyonAbilityBuilder, type AuthyonAbilityOptions, AuthyonError, type AuthyonErrorAction, type AuthyonErrorCategory, type AuthyonErrorInterpretation, type AuthyonJwksDiscoveryOptions, type AuthyonJwtClaims, type AuthyonPermissionSource, AuthyonServerClient, AuthyonServerClientBuilder, type AuthyonServerClientOptions, type ClientCredentials, type ClientRequestContext, type CreateCredentialInput, type CreateOrganizationInput, type CreatePermissionInput, type CreateTenantCredentialInput, type CreateUserInput, type CredentialCreator, type CredentialDetail, type CredentialListOptions, type CredentialPermissionsInput, type CredentialScope, type EnvironmentUser, ErrorCodes, type ExpressAuthorizationMiddlewareOptions, type ExpressNext, type ExpressRequestLike, type ExpressResponseLike, FetchHttpAdapter, type HttpAdapter, type HttpAdapterRequest, type HttpLogEvent, type HttpLogger, type HttpLoggerOptions, type IntrospectResult, type InviteTenantMemberInput, type InviteWorkspaceMemberInput, type JsonWebKeySet, JwksTokenVerifier, type JwksTokenVerifierOptions, type KnownErrorCode, LoggingHttpAdapter, type LoginActivity, type OpenIdConfiguration, type Organization, type Paged, type PaginationOptions, type Permission, type PermissionsByRole, PlatformScopedClient, type RequestAuthorizationOptions, type ReservedPermissions, type Role, type RoleGrant, type RoleInput, type RoleList, type RolePermissions, type SafeJwtAlgorithm, type TenantCredentialIssued, type TenantCredentialSummary, type TenantManagementScope, type TenantMember, type TenantMemberPage, type TenantMembership, TenantScopedClient, type TokenResult, TokenVerificationError, type TokenVerificationErrorCode, type UpdateOrganizationInput, type User, UserScopedClient, type ValidateResult, type VerifiedAccessToken, type WorkspaceInvite, type WorkspaceInviteAccepted, type WorkspaceInviteIssued, type WorkspaceInvitePreview, WorkspaceInvitesClient, type WorkspaceMember, type WorkspaceRole, type WorkspaceTeam, authorizeRequest, authorizeToken, createAuthorizationErrorResponse, createAuthyonAbility, createAuthyonRules, createClient, createExpressAuthorizationMiddleware, hasPermission, normalizeClientIp };
|