@authyon/server 0.2.0-beta.5 → 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 +13 -0
- package/dist/{authorization-NQe6R3am.d.cts → authorization-BGURVMFT.d.cts} +10 -1
- package/dist/{authorization-NQe6R3am.d.ts → authorization-BGURVMFT.d.ts} +10 -1
- package/dist/index.cjs +24 -4
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +24 -4
- package/dist/next.d.cts +1 -1
- package/dist/next.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -198,6 +198,19 @@ await acme.roles.create({ name: "viewer", permissions: ["reports:read"] });
|
|
|
198
198
|
vem do backend depois da checagem de revogação, rotação de secret e tenant
|
|
199
199
|
desabilitado; não confie só na claim `scope` quando precisar do estado atual.
|
|
200
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
|
+
|
|
201
214
|
## Descoberta
|
|
202
215
|
|
|
203
216
|
```ts
|
|
@@ -352,6 +352,12 @@ interface AuthyonServerClientOptions {
|
|
|
352
352
|
*/
|
|
353
353
|
clientId?: string;
|
|
354
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;
|
|
355
361
|
/** API origin. Defaults to `https://api.authyon.com`. */
|
|
356
362
|
baseUrl?: string;
|
|
357
363
|
/** Allow an HTTP `baseUrl`. Intended only for explicitly trusted local development. */
|
|
@@ -627,6 +633,7 @@ declare class AuthyonServerClient {
|
|
|
627
633
|
#private;
|
|
628
634
|
private readonly envKey?;
|
|
629
635
|
private readonly clientId?;
|
|
636
|
+
private readonly clientIp?;
|
|
630
637
|
private readonly transport;
|
|
631
638
|
private readonly http;
|
|
632
639
|
private readonly environmentTokenProvider;
|
|
@@ -653,6 +660,8 @@ declare class AuthyonServerClient {
|
|
|
653
660
|
readonly tenantAuth: {
|
|
654
661
|
/** POST /tenant/oauth/token — exchanges a tenant's client credentials for a scoped access token. */
|
|
655
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>;
|
|
656
665
|
};
|
|
657
666
|
/**
|
|
658
667
|
* Scopes a client to a single tenant's OAuth credentials — mints and
|
|
@@ -824,7 +833,7 @@ declare class TenantScopedClient {
|
|
|
824
833
|
private getAccessToken;
|
|
825
834
|
private request;
|
|
826
835
|
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
827
|
-
validate(): Promise<TenantClientValidationResult>;
|
|
836
|
+
validate(context?: ClientRequestContext): Promise<TenantClientValidationResult>;
|
|
828
837
|
readonly members: {
|
|
829
838
|
/**
|
|
830
839
|
* GET /tenant/members — members of the token's tenant.
|
|
@@ -352,6 +352,12 @@ interface AuthyonServerClientOptions {
|
|
|
352
352
|
*/
|
|
353
353
|
clientId?: string;
|
|
354
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;
|
|
355
361
|
/** API origin. Defaults to `https://api.authyon.com`. */
|
|
356
362
|
baseUrl?: string;
|
|
357
363
|
/** Allow an HTTP `baseUrl`. Intended only for explicitly trusted local development. */
|
|
@@ -627,6 +633,7 @@ declare class AuthyonServerClient {
|
|
|
627
633
|
#private;
|
|
628
634
|
private readonly envKey?;
|
|
629
635
|
private readonly clientId?;
|
|
636
|
+
private readonly clientIp?;
|
|
630
637
|
private readonly transport;
|
|
631
638
|
private readonly http;
|
|
632
639
|
private readonly environmentTokenProvider;
|
|
@@ -653,6 +660,8 @@ declare class AuthyonServerClient {
|
|
|
653
660
|
readonly tenantAuth: {
|
|
654
661
|
/** POST /tenant/oauth/token — exchanges a tenant's client credentials for a scoped access token. */
|
|
655
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>;
|
|
656
665
|
};
|
|
657
666
|
/**
|
|
658
667
|
* Scopes a client to a single tenant's OAuth credentials — mints and
|
|
@@ -824,7 +833,7 @@ declare class TenantScopedClient {
|
|
|
824
833
|
private getAccessToken;
|
|
825
834
|
private request;
|
|
826
835
|
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
827
|
-
validate(): Promise<TenantClientValidationResult>;
|
|
836
|
+
validate(context?: ClientRequestContext): Promise<TenantClientValidationResult>;
|
|
828
837
|
readonly members: {
|
|
829
838
|
/**
|
|
830
839
|
* GET /tenant/members — members of the token's tenant.
|
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
|
}
|
|
@@ -1296,8 +1312,8 @@ var TenantScopedClient = class {
|
|
|
1296
1312
|
return this.server._requestAsTenant(await this.getAccessToken(), path, options);
|
|
1297
1313
|
}
|
|
1298
1314
|
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
1299
|
-
validate() {
|
|
1300
|
-
return this.
|
|
1315
|
+
async validate(context) {
|
|
1316
|
+
return this.server.tenantAuth.validate(await this.getAccessToken(), context);
|
|
1301
1317
|
}
|
|
1302
1318
|
};
|
|
1303
1319
|
function createClient(options = {}) {
|
|
@@ -1319,6 +1335,10 @@ var AuthyonServerClientBuilder = class {
|
|
|
1319
1335
|
__privateGet(this, _options).clientSecret = clientSecret;
|
|
1320
1336
|
return this;
|
|
1321
1337
|
}
|
|
1338
|
+
withClientIp(clientIp) {
|
|
1339
|
+
__privateGet(this, _options).clientIp = clientIp;
|
|
1340
|
+
return this;
|
|
1341
|
+
}
|
|
1322
1342
|
withBaseUrl(baseUrl, allowInsecureHttp = false) {
|
|
1323
1343
|
__privateGet(this, _options).baseUrl = baseUrl;
|
|
1324
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 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-
|
|
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 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-
|
|
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
|
}
|
|
@@ -1103,8 +1119,8 @@ var TenantScopedClient = class {
|
|
|
1103
1119
|
return this.server._requestAsTenant(await this.getAccessToken(), path, options);
|
|
1104
1120
|
}
|
|
1105
1121
|
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
1106
|
-
validate() {
|
|
1107
|
-
return this.
|
|
1122
|
+
async validate(context) {
|
|
1123
|
+
return this.server.tenantAuth.validate(await this.getAccessToken(), context);
|
|
1108
1124
|
}
|
|
1109
1125
|
};
|
|
1110
1126
|
function createClient(options = {}) {
|
|
@@ -1126,6 +1142,10 @@ var AuthyonServerClientBuilder = class {
|
|
|
1126
1142
|
__privateGet(this, _options).clientSecret = clientSecret;
|
|
1127
1143
|
return this;
|
|
1128
1144
|
}
|
|
1145
|
+
withClientIp(clientIp) {
|
|
1146
|
+
__privateGet(this, _options).clientIp = clientIp;
|
|
1147
|
+
return this;
|
|
1148
|
+
}
|
|
1129
1149
|
withBaseUrl(baseUrl, allowInsecureHttp = false) {
|
|
1130
1150
|
__privateGet(this, _options).baseUrl = baseUrl;
|
|
1131
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