@authyon/server 0.2.0-beta.12 → 0.2.0-beta.15
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 +51 -62
- package/dist/{authorization-DWlLfYQJ.d.cts → authorization-B82XXf3B.d.cts} +1 -1
- package/dist/{authorization-wrZ5ull7.d.ts → authorization-WlwcTBwG.d.ts} +1 -1
- package/dist/{authyonServerClient-t82mwTws.d.cts → authyonServerClient-DQzhfaja.d.cts} +163 -115
- package/dist/{authyonServerClient-t82mwTws.d.ts → authyonServerClient-DQzhfaja.d.ts} +163 -115
- package/dist/bff.cjs +36 -6
- package/dist/bff.d.cts +1 -1
- package/dist/bff.d.ts +1 -1
- package/dist/bff.js +1 -1
- package/dist/{chunk-56H66KLG.js → chunk-WPPEV5BA.js} +36 -6
- package/dist/index.cjs +142 -147
- package/dist/index.d.cts +34 -9
- package/dist/index.d.ts +34 -9
- package/dist/index.js +92 -125
- package/dist/next.d.cts +2 -2
- package/dist/next.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonServerClient } from './authyonServerClient-
|
|
2
|
-
export { b as
|
|
3
|
-
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRequirement, f as AbilityRule, A as AbilitySubject, g as AuthorizationContext, a as AuthorizationError, h as AuthorizationOptions, i as AuthyonAbility, j as AuthyonAbilityBuilder, k as AuthyonAbilityOptions, l as AuthyonPermissionSource, E as ExpressAuthorizationMiddlewareOptions, m as ExpressNext, n as ExpressRequestLike, o as ExpressResponseLike, P as PermissionGroup, R as RequestAuthorizationOptions, p as authorizeRequest, q as authorizeToken, r as createAuthorizationErrorResponse, s as createAuthyonAbility, t as createAuthyonRules, u as createExpressAuthorizationMiddleware, v as hasPermission, w as hasPermissionGroup } from './authorization-
|
|
1
|
+
import { H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonServerClient } from './authyonServerClient-DQzhfaja.js';
|
|
2
|
+
export { b as AccessTokenSource, c as Approval, d as ApprovalAssurance, e as ApprovalPayload, f as ApprovalStatus, g as ApprovalWebAuthnOptions, h as AuditEvent, i as AuthyonJwksDiscoveryOptions, j as AuthyonJwtClaims, k as AuthyonServerClientOptions, C as ClientCredentials, l as ClientRequestContext, m as ConfirmApprovalInput, n as ConsumedApproval, o as CreateApprovalInput, p as CreateCredentialInput, q as CreateOrganizationInput, r as CreatePermissionInput, s as CreateTenantCredentialInput, t as CreateUserInput, u as CredentialCreator, v as CredentialDetail, w as CredentialListOptions, x as CredentialPermissionsInput, E as EnvironmentUser, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteTenantMemberInput, J as JsonWebKeySet, G as JwksTokenVerifier, K as JwksTokenVerifierOptions, L as LoggingHttpAdapter, M as LoginActivity, O as OpenIdConfiguration, N as Organization, P as OtpCheckResult, Q as Paged, R as PaginationOptions, S as Permission, T as PermissionsByRole, U as ReservedPermissions, V as Role, W as RoleGrant, X as RoleInput, Y as RoleList, Z as RolePermissions, _ as SafeJwtAlgorithm, $ as SubjectApprovals, a0 as SubjectSecurity, a1 as TenantClientValidationResult, a2 as TenantCredentialIssued, a3 as TenantCredentialSummary, a4 as TenantMember, a5 as TenantMemberPage, a6 as TenantMembership, a7 as TenantScopedClient, a8 as TokenResult, a9 as TokenVerificationError, aa as TokenVerificationErrorCode, ab as UpdateOrganizationInput, ac as User, ad as UserScopedClient, ae as ValidateResult, af as VerifiedAccessToken, ag as createClient, ah as normalizeClientIp } from './authyonServerClient-DQzhfaja.js';
|
|
3
|
+
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRequirement, f as AbilityRule, A as AbilitySubject, g as AuthorizationContext, a as AuthorizationError, h as AuthorizationOptions, i as AuthyonAbility, j as AuthyonAbilityBuilder, k as AuthyonAbilityOptions, l as AuthyonPermissionSource, E as ExpressAuthorizationMiddlewareOptions, m as ExpressNext, n as ExpressRequestLike, o as ExpressResponseLike, P as PermissionGroup, R as RequestAuthorizationOptions, p as authorizeRequest, q as authorizeToken, r as createAuthorizationErrorResponse, s as createAuthyonAbility, t as createAuthyonRules, u as createExpressAuthorizationMiddleware, v as hasPermission, w as hasPermissionGroup } from './authorization-WlwcTBwG.js';
|
|
4
4
|
import 'jose';
|
|
5
5
|
|
|
6
6
|
declare const ErrorCodes: {
|
|
@@ -15,6 +15,21 @@ declare const ErrorCodes: {
|
|
|
15
15
|
readonly PasswordWeak: "user.password_weak";
|
|
16
16
|
readonly PasswordPwned: "user.password_pwned";
|
|
17
17
|
readonly RateLimited: "rate_limited";
|
|
18
|
+
readonly StepUpRequired: "step_up_required";
|
|
19
|
+
readonly InvalidSecondFactorCode: "invalid_code";
|
|
20
|
+
readonly VerificationAttemptsExhausted: "verification_attempts_exhausted";
|
|
21
|
+
readonly MethodNotEnrolled: "method_not_enrolled";
|
|
22
|
+
readonly InvalidApprovalState: "invalid_authorization_state";
|
|
23
|
+
readonly PayloadMismatch: "payload_mismatch";
|
|
24
|
+
readonly ApprovalNotConsumable: "authorization_not_consumable";
|
|
25
|
+
readonly IdempotencyConflict: "idempotency_conflict";
|
|
26
|
+
readonly UserDisabled: "user_disabled";
|
|
27
|
+
readonly UserNotFound: "user_not_found";
|
|
28
|
+
readonly TemporarilyUnavailable: "temporarily_unavailable";
|
|
29
|
+
readonly InsufficientScope: "insufficient_scope";
|
|
30
|
+
readonly ApprovalNotFound: "authorization_not_found";
|
|
31
|
+
readonly SessionRevoked: "session_revoked";
|
|
32
|
+
readonly TwoFactorTooManyFailures: "user.2fa.too_many_failures";
|
|
18
33
|
};
|
|
19
34
|
type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
20
35
|
type AuthyonErrorCategory = "network" | "timeout" | "authentication" | "authorization" | "validation" | "not_found" | "conflict" | "rate_limit" | "server" | "unknown";
|
|
@@ -26,6 +41,14 @@ interface AuthyonErrorInterpretation {
|
|
|
26
41
|
retryAfter?: number;
|
|
27
42
|
requestId?: string;
|
|
28
43
|
}
|
|
44
|
+
/** Error body as sent by the API: RFC 7807, or OAuth-style `error`/`error_description`. */
|
|
45
|
+
type AuthyonErrorBody = Partial<{
|
|
46
|
+
title: string;
|
|
47
|
+
detail: string;
|
|
48
|
+
code: string;
|
|
49
|
+
error: string;
|
|
50
|
+
error_description: string;
|
|
51
|
+
}> & Record<string, unknown>;
|
|
29
52
|
/** Shared RFC 7807 error implementation used by both public SDKs. */
|
|
30
53
|
declare class AuthyonError extends Error {
|
|
31
54
|
readonly status: number;
|
|
@@ -35,11 +58,13 @@ declare class AuthyonError extends Error {
|
|
|
35
58
|
readonly requestId?: string;
|
|
36
59
|
readonly retryAfter?: number;
|
|
37
60
|
readonly cause?: unknown;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Extra fields from the error body beyond code/title/detail — e.g.
|
|
63
|
+
* `attemptsRemaining` on `invalid_code` or `requiredMethods` on
|
|
64
|
+
* `step_up_required`. Not included in {@link toJSON}.
|
|
65
|
+
*/
|
|
66
|
+
readonly extensions: Readonly<Record<string, unknown>>;
|
|
67
|
+
constructor(status: number, body: AuthyonErrorBody, options?: {
|
|
43
68
|
requestId?: string;
|
|
44
69
|
retryAfter?: number;
|
|
45
70
|
cause?: unknown;
|
|
@@ -68,4 +93,4 @@ declare class AuthyonServerClientBuilder {
|
|
|
68
93
|
build(): AuthyonServerClient;
|
|
69
94
|
}
|
|
70
95
|
|
|
71
|
-
export { AuthyonError, type AuthyonErrorAction, type AuthyonErrorCategory, type AuthyonErrorInterpretation, AuthyonServerClient, AuthyonServerClientBuilder, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode };
|
|
96
|
+
export { AuthyonError, type AuthyonErrorAction, type AuthyonErrorBody, type AuthyonErrorCategory, type AuthyonErrorInterpretation, AuthyonServerClient, AuthyonServerClientBuilder, ErrorCodes, HttpAdapter, HttpLoggerOptions, type KnownErrorCode };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
JsonHttpClient,
|
|
8
8
|
LoggingHttpAdapter,
|
|
9
9
|
createSharedTransport
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WPPEV5BA.js";
|
|
11
11
|
import {
|
|
12
12
|
AuthorizationError,
|
|
13
13
|
AuthyonAbility,
|
|
@@ -102,9 +102,9 @@ function credentialDetail(value) {
|
|
|
102
102
|
accessTokenLifetimeSeconds: value.accessTokenLifetimeSeconds
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
async function credentialPage(request,
|
|
105
|
+
async function credentialPage(request, path2, options = {}) {
|
|
106
106
|
const query = credentialQuery(options);
|
|
107
|
-
const page = await request(
|
|
107
|
+
const page = await request(path2, { query });
|
|
108
108
|
if (!page || !Array.isArray(page.data))
|
|
109
109
|
throw new TypeError("Authyon: expected a paginated credential response.");
|
|
110
110
|
return {
|
|
@@ -117,13 +117,13 @@ async function credentialPage(request, path, options = {}) {
|
|
|
117
117
|
hasPrev: page.hasPrev
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
async function allCredentials(request,
|
|
120
|
+
async function allCredentials(request, path2) {
|
|
121
121
|
const result = [];
|
|
122
122
|
const seen = /* @__PURE__ */ new Set();
|
|
123
123
|
let skip = 0;
|
|
124
124
|
for (let iteration = 0; iteration < 1e3; iteration++) {
|
|
125
125
|
const page = await request(
|
|
126
|
-
|
|
126
|
+
path2,
|
|
127
127
|
iteration === 0 ? {} : { query: { skip, take: 100 } }
|
|
128
128
|
);
|
|
129
129
|
if (Array.isArray(page)) {
|
|
@@ -146,134 +146,58 @@ async function allCredentials(request, path) {
|
|
|
146
146
|
throw new Error("Authyon: use listPage for more than 1000 credential pages.");
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
// ../../internal/core/security/approvals.ts
|
|
150
|
+
function path(id, suffix = "") {
|
|
151
|
+
if (typeof id !== "string" || !id.trim())
|
|
152
|
+
throw new TypeError("Authyon: an approval id is required.");
|
|
153
|
+
return `/auth/authorizations/${encodeURIComponent(id)}${suffix}`;
|
|
154
|
+
}
|
|
155
|
+
function subjectSecurity(request) {
|
|
156
|
+
return {
|
|
157
|
+
approvals: {
|
|
158
|
+
get: (id) => request(path(id)),
|
|
159
|
+
webauthnOptions: (id) => request(path(id, "/webauthn/options"), { method: "POST" }),
|
|
160
|
+
confirm: (id, input) => request(path(id, "/confirm"), { method: "POST", body: input }),
|
|
161
|
+
reject: (id) => request(path(id, "/reject"), { method: "POST" })
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
149
166
|
// src/client/scopedManagementClient.ts
|
|
150
167
|
function scopedRequest(request, source) {
|
|
151
|
-
return async (
|
|
168
|
+
return async (path2, options = {}) => {
|
|
152
169
|
const token = typeof source === "function" ? await source() : source;
|
|
153
170
|
if (typeof token !== "string" || !token.trim() || /\s/u.test(token))
|
|
154
171
|
throw new TypeError("Authyon: a valid access token is required.");
|
|
155
|
-
return request(
|
|
172
|
+
return request(path2, {
|
|
156
173
|
...options,
|
|
157
174
|
headers: { ...options.headers, Authorization: `Bearer ${token}` }
|
|
158
175
|
});
|
|
159
176
|
};
|
|
160
177
|
}
|
|
161
|
-
function environmentPath(scope) {
|
|
162
|
-
return `/platform/workspaces/${segment(scope.workspaceId)}/environments/${segment(scope.environmentId)}`;
|
|
163
|
-
}
|
|
164
|
-
function tenantPath(scope) {
|
|
165
|
-
return `${environmentPath(scope)}/tenants/${segment(scope.tenantId)}`;
|
|
166
|
-
}
|
|
167
|
-
function credentialPath(scope) {
|
|
168
|
-
return `${scope.tenantId === void 0 ? environmentPath(scope) : tenantPath(scope)}/credentials`;
|
|
169
|
-
}
|
|
170
|
-
function workspacePath(id) {
|
|
171
|
-
return `/platform/workspaces/${segment(id)}`;
|
|
172
|
-
}
|
|
173
|
-
function workspaceRole(role) {
|
|
174
|
-
if (role !== "admin" && role !== "auditor")
|
|
175
|
-
throw new TypeError("Authyon: workspace role must be admin or auditor.");
|
|
176
|
-
return role;
|
|
177
|
-
}
|
|
178
178
|
var _request;
|
|
179
|
-
var PlatformScopedClient = class {
|
|
180
|
-
/** @hidden */
|
|
181
|
-
constructor(request, token) {
|
|
182
|
-
__privateAdd(this, _request);
|
|
183
|
-
this.credentials = {
|
|
184
|
-
list: (scope, options = {}) => credentialPage(__privateGet(this, _request), credentialPath(scope), options),
|
|
185
|
-
get: async (scope, credentialId) => credentialDetail(await __privateGet(this, _request).call(this, `${credentialPath(scope)}/${segment(credentialId)}`)),
|
|
186
|
-
create: (scope, input) => __privateGet(this, _request).call(this, credentialPath(scope), {
|
|
187
|
-
method: "POST",
|
|
188
|
-
body: { description: input.description, ...lifetimeBody(input), ...permissionsBody(input) }
|
|
189
|
-
}),
|
|
190
|
-
updatePermissions: (scope, credentialId, input) => __privateGet(this, _request).call(this, `${credentialPath(scope)}/${segment(credentialId)}/permissions`, {
|
|
191
|
-
method: "PUT",
|
|
192
|
-
body: permissionsBody(input)
|
|
193
|
-
}),
|
|
194
|
-
updateScopes: (scope, credentialId, scopes) => this.credentials.updatePermissions(scope, credentialId, { scopes }),
|
|
195
|
-
/** Returns a new secret once. API may require an explicit step-up first. */
|
|
196
|
-
rotate: (scope, credentialId) => __privateGet(this, _request).call(this, `${credentialPath(scope)}/${segment(credentialId)}/rotate`, { method: "POST" }),
|
|
197
|
-
revoke: (scope, credentialId) => __privateGet(this, _request).call(this, `${credentialPath(scope)}/${segment(credentialId)}`, { method: "DELETE" })
|
|
198
|
-
};
|
|
199
|
-
this.workspaces = {
|
|
200
|
-
team: (workspaceId) => __privateGet(this, _request).call(this, `${workspacePath(workspaceId)}/team`),
|
|
201
|
-
members: {
|
|
202
|
-
invite: (workspaceId, input) => __privateGet(this, _request).call(this, `${workspacePath(workspaceId)}/invites`, {
|
|
203
|
-
method: "POST",
|
|
204
|
-
body: { email: input.email, role: workspaceRole(input.role) }
|
|
205
|
-
}),
|
|
206
|
-
/** memberId comes from team.members; it is not the platform userId. */
|
|
207
|
-
remove: (workspaceId, memberId) => __privateGet(this, _request).call(this, `${workspacePath(workspaceId)}/members/${segment(memberId)}`, {
|
|
208
|
-
method: "DELETE"
|
|
209
|
-
}),
|
|
210
|
-
changeRole: (workspaceId, memberId, role) => __privateGet(this, _request).call(this, `${workspacePath(workspaceId)}/members/${segment(memberId)}`, {
|
|
211
|
-
method: "PATCH",
|
|
212
|
-
body: { role: workspaceRole(role) }
|
|
213
|
-
})
|
|
214
|
-
},
|
|
215
|
-
invites: {
|
|
216
|
-
create: (workspaceId, input) => this.workspaces.members.invite(workspaceId, input),
|
|
217
|
-
revoke: (workspaceId, inviteId) => __privateGet(this, _request).call(this, `${workspacePath(workspaceId)}/invites/${segment(inviteId)}`, {
|
|
218
|
-
method: "DELETE"
|
|
219
|
-
})
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
this.tenants = {
|
|
223
|
-
members: {
|
|
224
|
-
list: (scope, options = {}) => __privateGet(this, _request).call(this, `${tenantPath(scope)}/members`, { query: options }),
|
|
225
|
-
add: (scope, userId, roles) => __privateGet(this, _request).call(this, `${tenantPath(scope)}/members`, { method: "POST", body: { userId, roles } }),
|
|
226
|
-
remove: (scope, userId) => __privateGet(this, _request).call(this, `${tenantPath(scope)}/members/${segment(userId)}`, { method: "DELETE" })
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
this.auth = {
|
|
230
|
-
/** Explicitly confirms the current platform session; passwords are not retained. */
|
|
231
|
-
stepUp: (currentPassword) => __privateGet(this, _request).call(this, "/platform/auth/step-up", { method: "POST", body: { currentPassword } })
|
|
232
|
-
};
|
|
233
|
-
__privateSet(this, _request, scopedRequest(request, token));
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
_request = new WeakMap();
|
|
237
|
-
var _request2;
|
|
238
179
|
var UserScopedClient = class {
|
|
239
180
|
/** @hidden */
|
|
240
181
|
constructor(request, token) {
|
|
241
|
-
__privateAdd(this,
|
|
182
|
+
__privateAdd(this, _request);
|
|
242
183
|
this.tenants = {
|
|
243
184
|
members: {
|
|
244
|
-
list: (tenantId, options = {}) => __privateGet(this,
|
|
185
|
+
list: (tenantId, options = {}) => __privateGet(this, _request).call(this, `/auth/tenants/${segment(tenantId)}/members`, { query: options }),
|
|
245
186
|
/** Adds an existing environment user by email; does not send an invitation email. */
|
|
246
|
-
invite: (tenantId, input) => __privateGet(this,
|
|
187
|
+
invite: (tenantId, input) => __privateGet(this, _request).call(this, `/auth/tenants/${segment(tenantId)}/members`, {
|
|
247
188
|
method: "POST",
|
|
248
189
|
body: { email: input.email, roles: input.roles }
|
|
249
190
|
}),
|
|
250
|
-
remove: (tenantId, userId) => __privateGet(this,
|
|
191
|
+
remove: (tenantId, userId) => __privateGet(this, _request).call(this, `/auth/tenants/${segment(tenantId)}/members/${segment(userId)}`, {
|
|
251
192
|
method: "DELETE"
|
|
252
193
|
})
|
|
253
194
|
}
|
|
254
195
|
};
|
|
255
|
-
__privateSet(this,
|
|
256
|
-
|
|
257
|
-
};
|
|
258
|
-
_request2 = new WeakMap();
|
|
259
|
-
var _request3;
|
|
260
|
-
var WorkspaceInvitesClient = class {
|
|
261
|
-
/** @hidden */
|
|
262
|
-
constructor(request) {
|
|
263
|
-
__privateAdd(this, _request3);
|
|
264
|
-
__privateSet(this, _request3, request);
|
|
265
|
-
}
|
|
266
|
-
preview(token) {
|
|
267
|
-
return __privateGet(this, _request3).call(this, `/platform/workspace-invites/${segment(token)}`);
|
|
268
|
-
}
|
|
269
|
-
accept(token, input = {}) {
|
|
270
|
-
return __privateGet(this, _request3).call(this, `/platform/workspace-invites/${segment(token)}/accept`, {
|
|
271
|
-
method: "POST",
|
|
272
|
-
body: { name: input.name, password: input.password }
|
|
273
|
-
});
|
|
196
|
+
__privateSet(this, _request, scopedRequest(request, token));
|
|
197
|
+
this.security = subjectSecurity(__privateGet(this, _request));
|
|
274
198
|
}
|
|
275
199
|
};
|
|
276
|
-
|
|
200
|
+
_request = new WeakMap();
|
|
277
201
|
|
|
278
202
|
// ../../internal/core/auth/expiringTokenProvider.ts
|
|
279
203
|
var _token, _inFlight;
|
|
@@ -352,9 +276,6 @@ var AuthyonServerClient = class {
|
|
|
352
276
|
}
|
|
353
277
|
})
|
|
354
278
|
};
|
|
355
|
-
this.workspaceInvites = new WorkspaceInvitesClient(
|
|
356
|
-
(path, options) => this.http.request(path, options)
|
|
357
|
-
);
|
|
358
279
|
// ── Environment management (users, tenants, roles, permissions, audit) ───
|
|
359
280
|
this.environment = {
|
|
360
281
|
users: {
|
|
@@ -449,12 +370,12 @@ var AuthyonServerClient = class {
|
|
|
449
370
|
credentials: {
|
|
450
371
|
/** GET /env/tenants/{tenantId}/credentials. Returns metadata only, including revoked credentials. */
|
|
451
372
|
list: (tenantId) => allCredentials(
|
|
452
|
-
(
|
|
373
|
+
(path2, options) => this.request(path2, { ...options, envBearer: true }),
|
|
453
374
|
`/env/tenants/${segment(tenantId)}/credentials`
|
|
454
375
|
),
|
|
455
376
|
/** Paginated searchable listing. Prefer this over loading every credential. */
|
|
456
377
|
listPage: (tenantId, options = {}) => credentialPage(
|
|
457
|
-
(
|
|
378
|
+
(path2, requestOptions) => this.request(path2, { ...requestOptions, envBearer: true }),
|
|
458
379
|
`/env/tenants/${segment(tenantId)}/credentials`,
|
|
459
380
|
options
|
|
460
381
|
),
|
|
@@ -632,6 +553,58 @@ var AuthyonServerClient = class {
|
|
|
632
553
|
loginActivity: (params = {}) => this.request("/env/audit/login-activity", { envBearer: true, query: params })
|
|
633
554
|
}
|
|
634
555
|
};
|
|
556
|
+
// ── Security: one-time codes and approvals ───────────────────────────────
|
|
557
|
+
//
|
|
558
|
+
// Everything here runs with the environment credential, which needs the
|
|
559
|
+
// `authyon:financial:authorize` scope. Keep that credential on the server.
|
|
560
|
+
this.security = {
|
|
561
|
+
otp: {
|
|
562
|
+
/**
|
|
563
|
+
* POST /env/users/{userId}/otp/verify — checks the user's authenticator
|
|
564
|
+
* app (TOTP) code. A wrong code returns `{ valid: false }` instead of
|
|
565
|
+
* throwing. Each code is accepted once; 3 wrong codes in a row sign the
|
|
566
|
+
* user out everywhere (`sessionsRevoked: true`); 5 lock the check for 15
|
|
567
|
+
* minutes (`rate_limited`).
|
|
568
|
+
*/
|
|
569
|
+
check: (userId, code) => this.request(`/env/users/${segment(userId)}/otp/verify`, {
|
|
570
|
+
method: "POST",
|
|
571
|
+
envBearer: true,
|
|
572
|
+
body: { code }
|
|
573
|
+
})
|
|
574
|
+
},
|
|
575
|
+
/**
|
|
576
|
+
* The customer approves a payload with their authenticator code or
|
|
577
|
+
* passkey, once.
|
|
578
|
+
*
|
|
579
|
+
* 1. `create()` the approval with the payload and the customer.
|
|
580
|
+
* 2. The customer confirms it (`@authyon/auth` → `security.approvals.confirm`).
|
|
581
|
+
* 3. `consume()` it right before executing, and execute the returned payload.
|
|
582
|
+
*/
|
|
583
|
+
approvals: {
|
|
584
|
+
/** POST /env/authorizations — registers a payload awaiting the customer's approval. */
|
|
585
|
+
create: (input) => {
|
|
586
|
+
const { idempotencyKey, ...body } = input;
|
|
587
|
+
return this.request("/env/authorizations", {
|
|
588
|
+
method: "POST",
|
|
589
|
+
envBearer: true,
|
|
590
|
+
headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0,
|
|
591
|
+
body
|
|
592
|
+
});
|
|
593
|
+
},
|
|
594
|
+
/** GET /env/authorizations/{id} — current status and, once approved, the assurance evidence. */
|
|
595
|
+
get: (id) => this.request(`/env/authorizations/${segment(id)}`, { envBearer: true }),
|
|
596
|
+
/**
|
|
597
|
+
* POST /env/authorizations/{id}/consume — redeems an approved approval
|
|
598
|
+
* exactly once and returns the approved payload. Pass `payload` to have
|
|
599
|
+
* the API check it matches (`payload_mismatch` otherwise).
|
|
600
|
+
*/
|
|
601
|
+
consume: (id, payload) => this.request(`/env/authorizations/${segment(id)}/consume`, {
|
|
602
|
+
method: "POST",
|
|
603
|
+
envBearer: true,
|
|
604
|
+
body: payload === void 0 ? void 0 : { payload }
|
|
605
|
+
})
|
|
606
|
+
}
|
|
607
|
+
};
|
|
635
608
|
// ── Generic permission grants ─────────────────────────────────────────────
|
|
636
609
|
this.permissions = {
|
|
637
610
|
/** POST /users/{userId}/permissions — grant a permission directly to a user. */
|
|
@@ -675,7 +648,7 @@ var AuthyonServerClient = class {
|
|
|
675
648
|
};
|
|
676
649
|
});
|
|
677
650
|
}
|
|
678
|
-
async request(
|
|
651
|
+
async request(path2, options = {}) {
|
|
679
652
|
const headers = {
|
|
680
653
|
...clientIpHeaders({ clientIp: this.clientIp }),
|
|
681
654
|
...options.headers
|
|
@@ -684,7 +657,7 @@ var AuthyonServerClient = class {
|
|
|
684
657
|
headers.Authorization = `Bearer ${await this.getEnvironmentAccessToken()}`;
|
|
685
658
|
}
|
|
686
659
|
if (this.envKey) headers["X-Authyon-Environment"] = this.envKey;
|
|
687
|
-
return this.http.request(
|
|
660
|
+
return this.http.request(path2, { ...options, headers });
|
|
688
661
|
}
|
|
689
662
|
/** Mints (and caches) an environment access token from `clientId`/`clientSecret`. */
|
|
690
663
|
async getEnvironmentAccessToken() {
|
|
@@ -739,17 +712,13 @@ var AuthyonServerClient = class {
|
|
|
739
712
|
tenant(credentials) {
|
|
740
713
|
return new TenantScopedClient(this, credentials);
|
|
741
714
|
}
|
|
742
|
-
/** Uses only the supplied platform-user access token. */
|
|
743
|
-
platform(token) {
|
|
744
|
-
return new PlatformScopedClient((path, options) => this.http.request(path, options), token);
|
|
745
|
-
}
|
|
746
715
|
/** Uses an end-user token; the configured environment key selects the environment. */
|
|
747
716
|
user(token) {
|
|
748
|
-
return new UserScopedClient((
|
|
717
|
+
return new UserScopedClient((path2, options) => this.request(path2, options), token);
|
|
749
718
|
}
|
|
750
719
|
/** @internal used by {@link TenantScopedClient} to share the base URL/fetch/error handling. */
|
|
751
|
-
_requestAsTenant(accessToken,
|
|
752
|
-
return this.request(
|
|
720
|
+
_requestAsTenant(accessToken, path2, options = {}) {
|
|
721
|
+
return this.request(path2, {
|
|
753
722
|
...options,
|
|
754
723
|
headers: { ...options.headers, Authorization: `Bearer ${accessToken}` },
|
|
755
724
|
envBearer: false
|
|
@@ -826,8 +795,8 @@ var TenantScopedClient = class {
|
|
|
826
795
|
async getAccessToken() {
|
|
827
796
|
return this.tokenProvider.getAccessToken();
|
|
828
797
|
}
|
|
829
|
-
async request(
|
|
830
|
-
return this.server._requestAsTenant(await this.getAccessToken(),
|
|
798
|
+
async request(path2, options = {}) {
|
|
799
|
+
return this.server._requestAsTenant(await this.getAccessToken(), path2, options);
|
|
831
800
|
}
|
|
832
801
|
/** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
|
|
833
802
|
async validate(context) {
|
|
@@ -890,11 +859,9 @@ export {
|
|
|
890
859
|
FetchHttpAdapter,
|
|
891
860
|
JwksTokenVerifier,
|
|
892
861
|
LoggingHttpAdapter,
|
|
893
|
-
PlatformScopedClient,
|
|
894
862
|
TenantScopedClient,
|
|
895
863
|
TokenVerificationError,
|
|
896
864
|
UserScopedClient,
|
|
897
|
-
WorkspaceInvitesClient,
|
|
898
865
|
authorizeRequest,
|
|
899
866
|
authorizeToken,
|
|
900
867
|
createAuthorizationErrorResponse,
|
package/dist/next.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { R as RequestAuthorizationOptions, A as AbilitySubject, a as AuthorizationError } from './authorization-
|
|
3
|
-
import { A as AuthyonServerClient } from './authyonServerClient-
|
|
2
|
+
import { R as RequestAuthorizationOptions, A as AbilitySubject, a as AuthorizationError } from './authorization-B82XXf3B.cjs';
|
|
3
|
+
import { A as AuthyonServerClient } from './authyonServerClient-DQzhfaja.cjs';
|
|
4
4
|
import 'jose';
|
|
5
5
|
|
|
6
6
|
interface ServerPermissionGuardFallbackContext {
|
package/dist/next.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { R as RequestAuthorizationOptions, A as AbilitySubject, a as AuthorizationError } from './authorization-
|
|
3
|
-
import { A as AuthyonServerClient } from './authyonServerClient-
|
|
2
|
+
import { R as RequestAuthorizationOptions, A as AbilitySubject, a as AuthorizationError } from './authorization-WlwcTBwG.js';
|
|
3
|
+
import { A as AuthyonServerClient } from './authyonServerClient-DQzhfaja.js';
|
|
4
4
|
import 'jose';
|
|
5
5
|
|
|
6
6
|
interface ServerPermissionGuardFallbackContext {
|
package/package.json
CHANGED