@authyon/server 0.2.0-beta.4 → 0.2.0-beta.6
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 +19 -0
- package/dist/{authorization-Cwl7YFEZ.d.cts → authorization-BGURVMFT.d.cts} +23 -1
- package/dist/{authorization-Cwl7YFEZ.d.ts → authorization-BGURVMFT.d.ts} +23 -1
- package/dist/index.cjs +26 -2
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +26 -2
- package/dist/next.d.cts +1 -1
- package/dist/next.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -187,11 +187,30 @@ As credenciais de um tenant são próprias dele — use `authyon.tenant(credenti
|
|
|
187
187
|
```ts
|
|
188
188
|
const acme = authyon.tenant({ clientId: acmeClientId, clientSecret: acmeClientSecret });
|
|
189
189
|
|
|
190
|
+
const identity = await acme.validate(); // POST /tenant/auth/validate
|
|
190
191
|
await acme.members.list();
|
|
191
192
|
await acme.members.add(userId, ["member"]);
|
|
192
193
|
await acme.roles.create({ name: "viewer", permissions: ["reports:read"] });
|
|
193
194
|
```
|
|
194
195
|
|
|
196
|
+
`validate()` confirma o bearer tenant-client atual e devolve `tenantId`,
|
|
197
|
+
`credentialId`, `clientId` e as permissões vigentes da credencial. A resposta
|
|
198
|
+
vem do backend depois da checagem de revogação, rotação de secret e tenant
|
|
199
|
+
desabilitado; não confie só na claim `scope` quando precisar do estado atual.
|
|
200
|
+
|
|
201
|
+
Em middleware, quando você já recebeu o bearer tenant-client na requisição, não
|
|
202
|
+
use `clientId`/`clientSecret`; valide o token diretamente:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
const validation = await authyon.tenantAuth.validate(tenantBearerToken, {
|
|
206
|
+
clientIp: "203.0.113.10",
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
if (!validation.valid) {
|
|
210
|
+
// responda 401
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
195
214
|
## Descoberta
|
|
196
215
|
|
|
197
216
|
```ts
|
|
@@ -315,6 +315,17 @@ interface TokenResult {
|
|
|
315
315
|
expires_in: number;
|
|
316
316
|
scope?: string;
|
|
317
317
|
}
|
|
318
|
+
/** POST /tenant/auth/validate — validates the current tenant-client bearer. */
|
|
319
|
+
interface TenantClientValidationResult {
|
|
320
|
+
valid: boolean;
|
|
321
|
+
reason?: string | null;
|
|
322
|
+
tenantId: string;
|
|
323
|
+
workspaceId: string;
|
|
324
|
+
environmentId: string;
|
|
325
|
+
credentialId: string;
|
|
326
|
+
clientId: string;
|
|
327
|
+
permissions: string[];
|
|
328
|
+
}
|
|
318
329
|
interface JsonWebKeySet {
|
|
319
330
|
keys: Record<string, unknown>[];
|
|
320
331
|
}
|
|
@@ -341,6 +352,12 @@ interface AuthyonServerClientOptions {
|
|
|
341
352
|
*/
|
|
342
353
|
clientId?: string;
|
|
343
354
|
clientSecret?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Originating end-user IP to forward on every API call as `X-Forwarded-For`.
|
|
357
|
+
* Only set this from infrastructure you trust; the SDK rejects comma-separated
|
|
358
|
+
* or whitespace-containing values to avoid forwarded-header injection.
|
|
359
|
+
*/
|
|
360
|
+
clientIp?: string;
|
|
344
361
|
/** API origin. Defaults to `https://api.authyon.com`. */
|
|
345
362
|
baseUrl?: string;
|
|
346
363
|
/** Allow an HTTP `baseUrl`. Intended only for explicitly trusted local development. */
|
|
@@ -616,6 +633,7 @@ declare class AuthyonServerClient {
|
|
|
616
633
|
#private;
|
|
617
634
|
private readonly envKey?;
|
|
618
635
|
private readonly clientId?;
|
|
636
|
+
private readonly clientIp?;
|
|
619
637
|
private readonly transport;
|
|
620
638
|
private readonly http;
|
|
621
639
|
private readonly environmentTokenProvider;
|
|
@@ -642,6 +660,8 @@ declare class AuthyonServerClient {
|
|
|
642
660
|
readonly tenantAuth: {
|
|
643
661
|
/** POST /tenant/oauth/token — exchanges a tenant's client credentials for a scoped access token. */
|
|
644
662
|
token: (credentials: ClientCredentials) => Promise<TokenResult>;
|
|
663
|
+
/** POST /tenant/auth/validate — validates an already-minted tenant-client bearer token. */
|
|
664
|
+
validate: (accessToken: string, context?: ClientRequestContext) => Promise<TenantClientValidationResult>;
|
|
645
665
|
};
|
|
646
666
|
/**
|
|
647
667
|
* Scopes a client to a single tenant's OAuth credentials — mints and
|
|
@@ -812,6 +832,8 @@ declare class TenantScopedClient {
|
|
|
812
832
|
constructor(server: AuthyonServerClient, credentials: ClientCredentials);
|
|
813
833
|
private getAccessToken;
|
|
814
834
|
private request;
|
|
835
|
+
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
836
|
+
validate(context?: ClientRequestContext): Promise<TenantClientValidationResult>;
|
|
815
837
|
readonly members: {
|
|
816
838
|
/**
|
|
817
839
|
* GET /tenant/members — members of the token's tenant.
|
|
@@ -973,4 +995,4 @@ declare function createExpressAuthorizationMiddleware(client: AuthyonServerClien
|
|
|
973
995
|
/** Converts an authorization error into a Fetch Response suitable for Next.js. */
|
|
974
996
|
declare function createAuthorizationErrorResponse(error: unknown): Response;
|
|
975
997
|
|
|
976
|
-
export { type Organization as $, AuthyonServerClient as A, type CredentialCreator as B, type ClientCredentials as C, type CredentialDetail as D, type CredentialListOptions as E, type CredentialPermissionsInput as F, type CredentialScope as G, type HttpAdapter as H, type EnvironmentUser as I, type ExpressAuthorizationMiddlewareOptions as J, type ExpressNext as K, type ExpressRequestLike as L, type ExpressResponseLike as M, FetchHttpAdapter as N, type HttpAdapterRequest as O, type HttpLogEvent as P, type HttpLogger as Q, type RequestAuthorizationOptions as R, type IntrospectResult as S, type InviteTenantMemberInput as T, type InviteWorkspaceMemberInput as U, type JsonWebKeySet as V, JwksTokenVerifier as W, type JwksTokenVerifierOptions as X, LoggingHttpAdapter as Y, type LoginActivity as Z, type OpenIdConfiguration as _, type AbilitySubject as a, type Paged as a0, type PaginationOptions as a1, type Permission as a2, type PermissionsByRole as a3, PlatformScopedClient as a4, type ReservedPermissions as a5, type Role as a6, type RoleGrant as a7, type RoleInput as a8, type RoleList as a9,
|
|
998
|
+
export { type Organization as $, AuthyonServerClient as A, type CredentialCreator as B, type ClientCredentials as C, type CredentialDetail as D, type CredentialListOptions as E, type CredentialPermissionsInput as F, type CredentialScope as G, type HttpAdapter as H, type EnvironmentUser as I, type ExpressAuthorizationMiddlewareOptions as J, type ExpressNext as K, type ExpressRequestLike as L, type ExpressResponseLike as M, FetchHttpAdapter as N, type HttpAdapterRequest as O, type HttpLogEvent as P, type HttpLogger as Q, type RequestAuthorizationOptions as R, type IntrospectResult as S, type InviteTenantMemberInput as T, type InviteWorkspaceMemberInput as U, type JsonWebKeySet as V, JwksTokenVerifier as W, type JwksTokenVerifierOptions as X, LoggingHttpAdapter as Y, type LoginActivity as Z, type OpenIdConfiguration as _, type AbilitySubject as a, type Paged as a0, type PaginationOptions as a1, type Permission as a2, type PermissionsByRole as a3, PlatformScopedClient as a4, type ReservedPermissions as a5, type Role as a6, type RoleGrant as a7, type RoleInput as a8, type RoleList as a9, authorizeRequest as aA, authorizeToken as aB, createAuthorizationErrorResponse as aC, createAuthyonAbility as aD, createAuthyonRules as aE, createClient as aF, createExpressAuthorizationMiddleware as aG, hasPermission as aH, normalizeClientIp as aI, type RolePermissions as aa, type SafeJwtAlgorithm as ab, type TenantClientValidationResult as ac, type TenantCredentialIssued as ad, type TenantCredentialSummary as ae, type TenantManagementScope as af, type TenantMember as ag, type TenantMemberPage as ah, type TenantMembership as ai, TenantScopedClient as aj, type TokenResult as ak, TokenVerificationError as al, type TokenVerificationErrorCode as am, type UpdateOrganizationInput as an, type User as ao, UserScopedClient as ap, type ValidateResult as aq, type VerifiedAccessToken as ar, type WorkspaceInvite as as, type WorkspaceInviteAccepted as at, type WorkspaceInviteIssued as au, type WorkspaceInvitePreview as av, WorkspaceInvitesClient as aw, type WorkspaceMember as ax, type WorkspaceRole as ay, type WorkspaceTeam as az, AuthorizationError as b, type HttpLoggerOptions as c, type AbilityConditions as d, type AbilityEvent as e, type AbilityListener as f, type AbilityRequirement as g, type AbilityRule as h, type AcceptWorkspaceInviteInput as i, type AccessTokenSource as j, type AuditEvent as k, type AuthorizationContext as l, type AuthorizationOptions as m, AuthyonAbility as n, AuthyonAbilityBuilder as o, type AuthyonAbilityOptions as p, type AuthyonJwksDiscoveryOptions as q, type AuthyonJwtClaims as r, type AuthyonPermissionSource as s, type AuthyonServerClientOptions as t, type ClientRequestContext as u, type CreateCredentialInput as v, type CreateOrganizationInput as w, type CreatePermissionInput as x, type CreateTenantCredentialInput as y, type CreateUserInput as z };
|
|
@@ -315,6 +315,17 @@ interface TokenResult {
|
|
|
315
315
|
expires_in: number;
|
|
316
316
|
scope?: string;
|
|
317
317
|
}
|
|
318
|
+
/** POST /tenant/auth/validate — validates the current tenant-client bearer. */
|
|
319
|
+
interface TenantClientValidationResult {
|
|
320
|
+
valid: boolean;
|
|
321
|
+
reason?: string | null;
|
|
322
|
+
tenantId: string;
|
|
323
|
+
workspaceId: string;
|
|
324
|
+
environmentId: string;
|
|
325
|
+
credentialId: string;
|
|
326
|
+
clientId: string;
|
|
327
|
+
permissions: string[];
|
|
328
|
+
}
|
|
318
329
|
interface JsonWebKeySet {
|
|
319
330
|
keys: Record<string, unknown>[];
|
|
320
331
|
}
|
|
@@ -341,6 +352,12 @@ interface AuthyonServerClientOptions {
|
|
|
341
352
|
*/
|
|
342
353
|
clientId?: string;
|
|
343
354
|
clientSecret?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Originating end-user IP to forward on every API call as `X-Forwarded-For`.
|
|
357
|
+
* Only set this from infrastructure you trust; the SDK rejects comma-separated
|
|
358
|
+
* or whitespace-containing values to avoid forwarded-header injection.
|
|
359
|
+
*/
|
|
360
|
+
clientIp?: string;
|
|
344
361
|
/** API origin. Defaults to `https://api.authyon.com`. */
|
|
345
362
|
baseUrl?: string;
|
|
346
363
|
/** Allow an HTTP `baseUrl`. Intended only for explicitly trusted local development. */
|
|
@@ -616,6 +633,7 @@ declare class AuthyonServerClient {
|
|
|
616
633
|
#private;
|
|
617
634
|
private readonly envKey?;
|
|
618
635
|
private readonly clientId?;
|
|
636
|
+
private readonly clientIp?;
|
|
619
637
|
private readonly transport;
|
|
620
638
|
private readonly http;
|
|
621
639
|
private readonly environmentTokenProvider;
|
|
@@ -642,6 +660,8 @@ declare class AuthyonServerClient {
|
|
|
642
660
|
readonly tenantAuth: {
|
|
643
661
|
/** POST /tenant/oauth/token — exchanges a tenant's client credentials for a scoped access token. */
|
|
644
662
|
token: (credentials: ClientCredentials) => Promise<TokenResult>;
|
|
663
|
+
/** POST /tenant/auth/validate — validates an already-minted tenant-client bearer token. */
|
|
664
|
+
validate: (accessToken: string, context?: ClientRequestContext) => Promise<TenantClientValidationResult>;
|
|
645
665
|
};
|
|
646
666
|
/**
|
|
647
667
|
* Scopes a client to a single tenant's OAuth credentials — mints and
|
|
@@ -812,6 +832,8 @@ declare class TenantScopedClient {
|
|
|
812
832
|
constructor(server: AuthyonServerClient, credentials: ClientCredentials);
|
|
813
833
|
private getAccessToken;
|
|
814
834
|
private request;
|
|
835
|
+
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
836
|
+
validate(context?: ClientRequestContext): Promise<TenantClientValidationResult>;
|
|
815
837
|
readonly members: {
|
|
816
838
|
/**
|
|
817
839
|
* GET /tenant/members — members of the token's tenant.
|
|
@@ -973,4 +995,4 @@ declare function createExpressAuthorizationMiddleware(client: AuthyonServerClien
|
|
|
973
995
|
/** Converts an authorization error into a Fetch Response suitable for Next.js. */
|
|
974
996
|
declare function createAuthorizationErrorResponse(error: unknown): Response;
|
|
975
997
|
|
|
976
|
-
export { type Organization as $, AuthyonServerClient as A, type CredentialCreator as B, type ClientCredentials as C, type CredentialDetail as D, type CredentialListOptions as E, type CredentialPermissionsInput as F, type CredentialScope as G, type HttpAdapter as H, type EnvironmentUser as I, type ExpressAuthorizationMiddlewareOptions as J, type ExpressNext as K, type ExpressRequestLike as L, type ExpressResponseLike as M, FetchHttpAdapter as N, type HttpAdapterRequest as O, type HttpLogEvent as P, type HttpLogger as Q, type RequestAuthorizationOptions as R, type IntrospectResult as S, type InviteTenantMemberInput as T, type InviteWorkspaceMemberInput as U, type JsonWebKeySet as V, JwksTokenVerifier as W, type JwksTokenVerifierOptions as X, LoggingHttpAdapter as Y, type LoginActivity as Z, type OpenIdConfiguration as _, type AbilitySubject as a, type Paged as a0, type PaginationOptions as a1, type Permission as a2, type PermissionsByRole as a3, PlatformScopedClient as a4, type ReservedPermissions as a5, type Role as a6, type RoleGrant as a7, type RoleInput as a8, type RoleList as a9,
|
|
998
|
+
export { type Organization as $, AuthyonServerClient as A, type CredentialCreator as B, type ClientCredentials as C, type CredentialDetail as D, type CredentialListOptions as E, type CredentialPermissionsInput as F, type CredentialScope as G, type HttpAdapter as H, type EnvironmentUser as I, type ExpressAuthorizationMiddlewareOptions as J, type ExpressNext as K, type ExpressRequestLike as L, type ExpressResponseLike as M, FetchHttpAdapter as N, type HttpAdapterRequest as O, type HttpLogEvent as P, type HttpLogger as Q, type RequestAuthorizationOptions as R, type IntrospectResult as S, type InviteTenantMemberInput as T, type InviteWorkspaceMemberInput as U, type JsonWebKeySet as V, JwksTokenVerifier as W, type JwksTokenVerifierOptions as X, LoggingHttpAdapter as Y, type LoginActivity as Z, type OpenIdConfiguration as _, type AbilitySubject as a, type Paged as a0, type PaginationOptions as a1, type Permission as a2, type PermissionsByRole as a3, PlatformScopedClient as a4, type ReservedPermissions as a5, type Role as a6, type RoleGrant as a7, type RoleInput as a8, type RoleList as a9, authorizeRequest as aA, authorizeToken as aB, createAuthorizationErrorResponse as aC, createAuthyonAbility as aD, createAuthyonRules as aE, createClient as aF, createExpressAuthorizationMiddleware as aG, hasPermission as aH, normalizeClientIp as aI, type RolePermissions as aa, type SafeJwtAlgorithm as ab, type TenantClientValidationResult as ac, type TenantCredentialIssued as ad, type TenantCredentialSummary as ae, type TenantManagementScope as af, type TenantMember as ag, type TenantMemberPage as ah, type TenantMembership as ai, TenantScopedClient as aj, type TokenResult as ak, TokenVerificationError as al, type TokenVerificationErrorCode as am, type UpdateOrganizationInput as an, type User as ao, UserScopedClient as ap, type ValidateResult as aq, type VerifiedAccessToken as ar, type WorkspaceInvite as as, type WorkspaceInviteAccepted as at, type WorkspaceInviteIssued as au, type WorkspaceInvitePreview as av, WorkspaceInvitesClient as aw, type WorkspaceMember as ax, type WorkspaceRole as ay, type WorkspaceTeam as az, AuthorizationError as b, type HttpLoggerOptions as c, type AbilityConditions as d, type AbilityEvent as e, type AbilityListener as f, type AbilityRequirement as g, type AbilityRule as h, type AcceptWorkspaceInviteInput as i, type AccessTokenSource as j, type AuditEvent as k, type AuthorizationContext as l, type AuthorizationOptions as m, AuthyonAbility as n, AuthyonAbilityBuilder as o, type AuthyonAbilityOptions as p, type AuthyonJwksDiscoveryOptions as q, type AuthyonJwtClaims as r, type AuthyonPermissionSource as s, type AuthyonServerClientOptions as t, type ClientRequestContext as u, type CreateCredentialInput as v, type CreateOrganizationInput as w, type CreatePermissionInput as x, type CreateTenantCredentialInput as y, type CreateUserInput as z };
|
package/dist/index.cjs
CHANGED
|
@@ -835,6 +835,14 @@ var AuthyonServerClient = class {
|
|
|
835
835
|
client_id: credentials.clientId,
|
|
836
836
|
client_secret: credentials.clientSecret
|
|
837
837
|
}
|
|
838
|
+
}),
|
|
839
|
+
/** POST /tenant/auth/validate — validates an already-minted tenant-client bearer token. */
|
|
840
|
+
validate: (accessToken, context) => this.request("/tenant/auth/validate", {
|
|
841
|
+
method: "POST",
|
|
842
|
+
headers: {
|
|
843
|
+
...clientIpHeaders(context),
|
|
844
|
+
Authorization: `Bearer ${accessToken}`
|
|
845
|
+
}
|
|
838
846
|
})
|
|
839
847
|
};
|
|
840
848
|
this.workspaceInvites = new WorkspaceInvitesClient(
|
|
@@ -953,7 +961,11 @@ var AuthyonServerClient = class {
|
|
|
953
961
|
create: (tenantId, input) => this.request(`/env/tenants/${segment(tenantId)}/credentials`, {
|
|
954
962
|
method: "POST",
|
|
955
963
|
envBearer: true,
|
|
956
|
-
body: {
|
|
964
|
+
body: {
|
|
965
|
+
description: input.description,
|
|
966
|
+
...lifetimeBody(input),
|
|
967
|
+
...permissionsBody(input)
|
|
968
|
+
}
|
|
957
969
|
}),
|
|
958
970
|
/** Returns a new secret once while keeping the same client id. */
|
|
959
971
|
rotate: (tenantId, credentialId) => this.request(
|
|
@@ -1119,6 +1131,7 @@ var AuthyonServerClient = class {
|
|
|
1119
1131
|
this.envKey = options.envKey;
|
|
1120
1132
|
this.clientId = options.clientId;
|
|
1121
1133
|
__privateSet(this, _clientSecret, options.clientSecret);
|
|
1134
|
+
this.clientIp = options.clientIp;
|
|
1122
1135
|
this.transport = createSharedTransport({
|
|
1123
1136
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
1124
1137
|
allowInsecureHttp: options.allowInsecureHttp,
|
|
@@ -1145,7 +1158,10 @@ var AuthyonServerClient = class {
|
|
|
1145
1158
|
});
|
|
1146
1159
|
}
|
|
1147
1160
|
async request(path, options = {}) {
|
|
1148
|
-
const headers = {
|
|
1161
|
+
const headers = {
|
|
1162
|
+
...clientIpHeaders({ clientIp: this.clientIp }),
|
|
1163
|
+
...options.headers
|
|
1164
|
+
};
|
|
1149
1165
|
if (options.envBearer) {
|
|
1150
1166
|
headers.Authorization = `Bearer ${await this.getEnvironmentAccessToken()}`;
|
|
1151
1167
|
}
|
|
@@ -1295,6 +1311,10 @@ var TenantScopedClient = class {
|
|
|
1295
1311
|
async request(path, options = {}) {
|
|
1296
1312
|
return this.server._requestAsTenant(await this.getAccessToken(), path, options);
|
|
1297
1313
|
}
|
|
1314
|
+
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
1315
|
+
async validate(context) {
|
|
1316
|
+
return this.server.tenantAuth.validate(await this.getAccessToken(), context);
|
|
1317
|
+
}
|
|
1298
1318
|
};
|
|
1299
1319
|
function createClient(options = {}) {
|
|
1300
1320
|
return new AuthyonServerClient(options);
|
|
@@ -1315,6 +1335,10 @@ var AuthyonServerClientBuilder = class {
|
|
|
1315
1335
|
__privateGet(this, _options).clientSecret = clientSecret;
|
|
1316
1336
|
return this;
|
|
1317
1337
|
}
|
|
1338
|
+
withClientIp(clientIp) {
|
|
1339
|
+
__privateGet(this, _options).clientIp = clientIp;
|
|
1340
|
+
return this;
|
|
1341
|
+
}
|
|
1318
1342
|
withBaseUrl(baseUrl, allowInsecureHttp = false) {
|
|
1319
1343
|
__privateGet(this, _options).baseUrl = baseUrl;
|
|
1320
1344
|
__privateGet(this, _options).allowInsecureHttp = allowInsecureHttp;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HttpAdapter, c as HttpLoggerOptions, A as AuthyonServerClient } from './authorization-
|
|
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
|
|
1
|
+
import { H as HttpAdapter, c as HttpLoggerOptions, A as AuthyonServerClient } from './authorization-BGURVMFT.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 TenantClientValidationResult, ad as TenantCredentialIssued, ae as TenantCredentialSummary, af as TenantManagementScope, ag as TenantMember, ah as TenantMemberPage, ai as TenantMembership, aj as TenantScopedClient, ak as TokenResult, al as TokenVerificationError, am as TokenVerificationErrorCode, an as UpdateOrganizationInput, ao as User, ap as UserScopedClient, aq as ValidateResult, ar as VerifiedAccessToken, as as WorkspaceInvite, at as WorkspaceInviteAccepted, au as WorkspaceInviteIssued, av as WorkspaceInvitePreview, aw as WorkspaceInvitesClient, ax as WorkspaceMember, ay as WorkspaceRole, az as WorkspaceTeam, aA as authorizeRequest, aB as authorizeToken, aC as createAuthorizationErrorResponse, aD as createAuthyonAbility, aE as createAuthyonRules, aF as createClient, aG as createExpressAuthorizationMiddleware, aH as hasPermission, aI as normalizeClientIp } from './authorization-BGURVMFT.cjs';
|
|
3
3
|
import 'jose';
|
|
4
4
|
|
|
5
5
|
declare const ErrorCodes: {
|
|
@@ -59,6 +59,7 @@ declare class AuthyonServerClientBuilder {
|
|
|
59
59
|
#private;
|
|
60
60
|
withEnvironmentKey(envKey: string): this;
|
|
61
61
|
withEnvironmentCredentials(clientId: string, clientSecret: string): this;
|
|
62
|
+
withClientIp(clientIp: string): this;
|
|
62
63
|
withBaseUrl(baseUrl: string, allowInsecureHttp?: boolean): this;
|
|
63
64
|
withTimeout(timeoutMs: number): this;
|
|
64
65
|
withHttpAdapter(httpAdapter: HttpAdapter): this;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HttpAdapter, c as HttpLoggerOptions, A as AuthyonServerClient } from './authorization-
|
|
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
|
|
1
|
+
import { H as HttpAdapter, c as HttpLoggerOptions, A as AuthyonServerClient } from './authorization-BGURVMFT.js';
|
|
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 TenantClientValidationResult, ad as TenantCredentialIssued, ae as TenantCredentialSummary, af as TenantManagementScope, ag as TenantMember, ah as TenantMemberPage, ai as TenantMembership, aj as TenantScopedClient, ak as TokenResult, al as TokenVerificationError, am as TokenVerificationErrorCode, an as UpdateOrganizationInput, ao as User, ap as UserScopedClient, aq as ValidateResult, ar as VerifiedAccessToken, as as WorkspaceInvite, at as WorkspaceInviteAccepted, au as WorkspaceInviteIssued, av as WorkspaceInvitePreview, aw as WorkspaceInvitesClient, ax as WorkspaceMember, ay as WorkspaceRole, az as WorkspaceTeam, aA as authorizeRequest, aB as authorizeToken, aC as createAuthorizationErrorResponse, aD as createAuthyonAbility, aE as createAuthyonRules, aF as createClient, aG as createExpressAuthorizationMiddleware, aH as hasPermission, aI as normalizeClientIp } from './authorization-BGURVMFT.js';
|
|
3
3
|
import 'jose';
|
|
4
4
|
|
|
5
5
|
declare const ErrorCodes: {
|
|
@@ -59,6 +59,7 @@ declare class AuthyonServerClientBuilder {
|
|
|
59
59
|
#private;
|
|
60
60
|
withEnvironmentKey(envKey: string): this;
|
|
61
61
|
withEnvironmentCredentials(clientId: string, clientSecret: string): this;
|
|
62
|
+
withClientIp(clientIp: string): this;
|
|
62
63
|
withBaseUrl(baseUrl: string, allowInsecureHttp?: boolean): this;
|
|
63
64
|
withTimeout(timeoutMs: number): this;
|
|
64
65
|
withHttpAdapter(httpAdapter: HttpAdapter): this;
|
package/dist/index.js
CHANGED
|
@@ -642,6 +642,14 @@ var AuthyonServerClient = class {
|
|
|
642
642
|
client_id: credentials.clientId,
|
|
643
643
|
client_secret: credentials.clientSecret
|
|
644
644
|
}
|
|
645
|
+
}),
|
|
646
|
+
/** POST /tenant/auth/validate — validates an already-minted tenant-client bearer token. */
|
|
647
|
+
validate: (accessToken, context) => this.request("/tenant/auth/validate", {
|
|
648
|
+
method: "POST",
|
|
649
|
+
headers: {
|
|
650
|
+
...clientIpHeaders(context),
|
|
651
|
+
Authorization: `Bearer ${accessToken}`
|
|
652
|
+
}
|
|
645
653
|
})
|
|
646
654
|
};
|
|
647
655
|
this.workspaceInvites = new WorkspaceInvitesClient(
|
|
@@ -760,7 +768,11 @@ var AuthyonServerClient = class {
|
|
|
760
768
|
create: (tenantId, input) => this.request(`/env/tenants/${segment(tenantId)}/credentials`, {
|
|
761
769
|
method: "POST",
|
|
762
770
|
envBearer: true,
|
|
763
|
-
body: {
|
|
771
|
+
body: {
|
|
772
|
+
description: input.description,
|
|
773
|
+
...lifetimeBody(input),
|
|
774
|
+
...permissionsBody(input)
|
|
775
|
+
}
|
|
764
776
|
}),
|
|
765
777
|
/** Returns a new secret once while keeping the same client id. */
|
|
766
778
|
rotate: (tenantId, credentialId) => this.request(
|
|
@@ -926,6 +938,7 @@ var AuthyonServerClient = class {
|
|
|
926
938
|
this.envKey = options.envKey;
|
|
927
939
|
this.clientId = options.clientId;
|
|
928
940
|
__privateSet(this, _clientSecret, options.clientSecret);
|
|
941
|
+
this.clientIp = options.clientIp;
|
|
929
942
|
this.transport = createSharedTransport({
|
|
930
943
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
931
944
|
allowInsecureHttp: options.allowInsecureHttp,
|
|
@@ -952,7 +965,10 @@ var AuthyonServerClient = class {
|
|
|
952
965
|
});
|
|
953
966
|
}
|
|
954
967
|
async request(path, options = {}) {
|
|
955
|
-
const headers = {
|
|
968
|
+
const headers = {
|
|
969
|
+
...clientIpHeaders({ clientIp: this.clientIp }),
|
|
970
|
+
...options.headers
|
|
971
|
+
};
|
|
956
972
|
if (options.envBearer) {
|
|
957
973
|
headers.Authorization = `Bearer ${await this.getEnvironmentAccessToken()}`;
|
|
958
974
|
}
|
|
@@ -1102,6 +1118,10 @@ var TenantScopedClient = class {
|
|
|
1102
1118
|
async request(path, options = {}) {
|
|
1103
1119
|
return this.server._requestAsTenant(await this.getAccessToken(), path, options);
|
|
1104
1120
|
}
|
|
1121
|
+
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
1122
|
+
async validate(context) {
|
|
1123
|
+
return this.server.tenantAuth.validate(await this.getAccessToken(), context);
|
|
1124
|
+
}
|
|
1105
1125
|
};
|
|
1106
1126
|
function createClient(options = {}) {
|
|
1107
1127
|
return new AuthyonServerClient(options);
|
|
@@ -1122,6 +1142,10 @@ var AuthyonServerClientBuilder = class {
|
|
|
1122
1142
|
__privateGet(this, _options).clientSecret = clientSecret;
|
|
1123
1143
|
return this;
|
|
1124
1144
|
}
|
|
1145
|
+
withClientIp(clientIp) {
|
|
1146
|
+
__privateGet(this, _options).clientIp = clientIp;
|
|
1147
|
+
return this;
|
|
1148
|
+
}
|
|
1125
1149
|
withBaseUrl(baseUrl, allowInsecureHttp = false) {
|
|
1126
1150
|
__privateGet(this, _options).baseUrl = baseUrl;
|
|
1127
1151
|
__privateGet(this, _options).allowInsecureHttp = allowInsecureHttp;
|
package/dist/next.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { R as RequestAuthorizationOptions, A as AuthyonServerClient, a as AbilitySubject, b as AuthorizationError } from './authorization-
|
|
2
|
+
import { R as RequestAuthorizationOptions, A as AuthyonServerClient, a as AbilitySubject, b as AuthorizationError } from './authorization-BGURVMFT.cjs';
|
|
3
3
|
import 'jose';
|
|
4
4
|
|
|
5
5
|
interface ServerPermissionGuardFallbackContext {
|
package/dist/next.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { R as RequestAuthorizationOptions, A as AuthyonServerClient, a as AbilitySubject, b as AuthorizationError } from './authorization-
|
|
2
|
+
import { R as RequestAuthorizationOptions, A as AuthyonServerClient, a as AbilitySubject, b as AuthorizationError } from './authorization-BGURVMFT.js';
|
|
3
3
|
import 'jose';
|
|
4
4
|
|
|
5
5
|
interface ServerPermissionGuardFallbackContext {
|
package/package.json
CHANGED