@schemavaults/auth-server-sdk 0.39.0 → 0.41.1
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 +93 -18
- package/dist/cli.cjs +10 -3
- package/dist/confidential-client/exchange-token-for-delegated-token.d.ts +57 -0
- package/dist/confidential-client/exchange-token-for-delegated-token.js +72 -0
- package/dist/confidential-client/exchange-token-for-delegated-token.js.map +1 -0
- package/dist/confidential-client/index.d.ts +13 -0
- package/dist/confidential-client/index.js +11 -0
- package/dist/confidential-client/index.js.map +1 -0
- package/dist/confidential-client/revoke-token.d.ts +25 -0
- package/dist/confidential-client/revoke-token.js +27 -0
- package/dist/confidential-client/revoke-token.js.map +1 -0
- package/dist/confidential-client/shared.d.ts +40 -0
- package/dist/confidential-client/shared.js +73 -0
- package/dist/confidential-client/shared.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/introspectToken.d.ts +31 -0
- package/dist/introspectToken.js +55 -1
- package/dist/introspectToken.js.map +1 -1
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -275,7 +275,12 @@ the auth server, authenticating with your JWKS access key (`private_key_jwt`: a
|
|
|
275
275
|
fresh single-use JWKS access assertion per call):
|
|
276
276
|
|
|
277
277
|
```ts
|
|
278
|
-
import {
|
|
278
|
+
import {
|
|
279
|
+
getActorFromIntrospectionResult,
|
|
280
|
+
getAuthServerUrl,
|
|
281
|
+
introspectToken,
|
|
282
|
+
loadJwksAccessPrivateKey,
|
|
283
|
+
} from "@schemavaults/auth-server-sdk";
|
|
279
284
|
|
|
280
285
|
const result = await introspectToken({
|
|
281
286
|
auth_server_url: getAuthServerUrl(),
|
|
@@ -284,10 +289,12 @@ const result = await introspectToken({
|
|
|
284
289
|
token: accessToken,
|
|
285
290
|
});
|
|
286
291
|
if (result.active) {
|
|
287
|
-
result.uid;
|
|
288
|
-
result.sub;
|
|
289
|
-
result.client_id;
|
|
290
|
-
result.scope;
|
|
292
|
+
result.uid; // platform user id
|
|
293
|
+
result.sub; // OIDC subject `<auth_server_app_id>|<uid>`
|
|
294
|
+
result.client_id; // the client app the token was issued to
|
|
295
|
+
result.scope; // granted scope, if any
|
|
296
|
+
result.service_account; // true when the user is a client app's service account (a machine)
|
|
297
|
+
getActorFromIntrospectionResult(result); // the RFC 8693 actor of a delegated token, or null
|
|
291
298
|
}
|
|
292
299
|
```
|
|
293
300
|
|
|
@@ -297,6 +304,56 @@ A refused request (e.g. a JWKS access key that is not your active one) throws.
|
|
|
297
304
|
Each call is a round trip to the auth server, so reserve it for requests where
|
|
298
305
|
revocation must be honoured immediately.
|
|
299
306
|
|
|
307
|
+
## Minting delegated tokens for agents (confidential clients)
|
|
308
|
+
|
|
309
|
+
A client app that runs agents for its users (in a sandbox, say) should hand each agent
|
|
310
|
+
a delegated token, not the user's own: the API server then sees who is calling (the
|
|
311
|
+
`act` claim names the app's service account), and the agent holds only the scope its
|
|
312
|
+
task needs. The app's backend swaps one of its users' access tokens for one with the
|
|
313
|
+
RFC 8693 token exchange grant (advertised in the discovery document's
|
|
314
|
+
`grant_types_supported`), authenticating with its client secret:
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
import {
|
|
318
|
+
exchangeTokenForDelegatedToken,
|
|
319
|
+
revokeToken,
|
|
320
|
+
OAuthEndpointError,
|
|
321
|
+
} from "@schemavaults/auth-server-sdk/confidential-client";
|
|
322
|
+
|
|
323
|
+
const client = {
|
|
324
|
+
auth_server_url: getAuthServerUrl(),
|
|
325
|
+
client_id: process.env.SCHEMAVAULTS_CLIENT_APP_ID!,
|
|
326
|
+
client_secret: process.env.SCHEMAVAULTS_CLIENT_SECRET!, // server-side only
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const delegated = await exchangeTokenForDelegatedToken({
|
|
330
|
+
...client,
|
|
331
|
+
subject_token: usersAccessToken, // the user's access token for the API server the agent calls
|
|
332
|
+
scope: ["notes:read"], // optional: a subset of its scope (default: all of it)
|
|
333
|
+
});
|
|
334
|
+
delegated.access_token; // give this to the agent
|
|
335
|
+
delegated.expires_in; // seconds; there is no refresh token: exchange again for a fresh one
|
|
336
|
+
delegated.scope; // the granted scope
|
|
337
|
+
|
|
338
|
+
// When the agent's session ends:
|
|
339
|
+
await revokeToken({ ...client, token: delegated.access_token });
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
- One delegated token per API server: it is minted for the subject token's own
|
|
343
|
+
audience. For an agent that calls several API servers (e.g. several MCP servers),
|
|
344
|
+
exchange one of the user's access tokens for each.
|
|
345
|
+
- The API server's managers must turn on **Accept delegated tokens** first; until
|
|
346
|
+
they do, the exchange fails with `OAuthEndpointError` `error: "invalid_target"`.
|
|
347
|
+
Other refusals: `invalid_request` (the subject token is expired, revoked, already
|
|
348
|
+
delegated, issued to another client, or the user withdrew the app's access) and
|
|
349
|
+
`invalid_scope` (more scope than the subject token holds).
|
|
350
|
+
- Revoking makes introspection and resource servers with an `isTokenRevoked` hook
|
|
351
|
+
refuse the token at once; resource servers that only verify tokens locally stop
|
|
352
|
+
accepting it when it expires.
|
|
353
|
+
- `revokeToken()` also revokes the client's users' refresh tokens (RFC 7009); it
|
|
354
|
+
resolves for tokens the auth server does not know.
|
|
355
|
+
- Keep the client secret out of the agent's sandbox: only the delegated token goes in.
|
|
356
|
+
|
|
300
357
|
## `UserData.sub`
|
|
301
358
|
|
|
302
359
|
`UserData.sub` is the OIDC subject `<auth_server_app_id>|<uid>` (the value the
|
|
@@ -309,8 +366,17 @@ versions keep verifying them; `userDataSchema` upgrades a bare-uuid `sub` with
|
|
|
309
366
|
|
|
310
367
|
An access token may say that someone acts on behalf of its user (an agent, say): its
|
|
311
368
|
`sub` is still the user, and its `act` claim names the actor (RFC 8693 §4.1). The
|
|
312
|
-
auth server
|
|
313
|
-
|
|
369
|
+
auth server mints them with the RFC 8693 token exchange grant, for confidential
|
|
370
|
+
clients that run agents for their users (see
|
|
371
|
+
[Minting delegated tokens for agents](#minting-delegated-tokens-for-agents-confidential-clients)).
|
|
372
|
+
SDK versions before 0.39.0 reject a token carrying `act`.
|
|
373
|
+
|
|
374
|
+
The auth server mints delegated tokens only for API servers that accept them, and
|
|
375
|
+
none does by default. Once your resource server runs this version, have one of the
|
|
376
|
+
API server's managers turn on **Accept delegated tokens** on its page in the auth
|
|
377
|
+
server console (`PUT /api/apis/{api_server_id}/delegated-token-policy` with
|
|
378
|
+
`{ "accept_delegated_tokens": true }`). The API server definition reports the
|
|
379
|
+
setting as `accept_delegated_tokens`.
|
|
314
380
|
|
|
315
381
|
Route guards expose the actor of the token that resolved the user next to
|
|
316
382
|
`client_app_id`, and `decodeJWTsWithKeyManager()` returns it as `actor`:
|
|
@@ -329,6 +395,13 @@ guard.actor?.prior_actor; // the previous actor of a delegation chain, or null
|
|
|
329
395
|
token was revoked. A chain holds at most three actors; tokens with a deeper or
|
|
330
396
|
malformed `act` do not verify.
|
|
331
397
|
|
|
398
|
+
Introspection reports the actor too: the auth server's response carries `act`
|
|
399
|
+
(`sub` in the OIDC form plus `uid`, `client_id`, the prior actor nested), and
|
|
400
|
+
`getActorFromIntrospectionResult(result)` returns it as the same `TokenActor`, so a
|
|
401
|
+
resource server that introspects delegated tokens (to honour an ended agent session
|
|
402
|
+
at once) applies the same actor policy as one that verifies them locally. A
|
|
403
|
+
malformed `act` makes `introspectToken()` throw rather than drop it.
|
|
404
|
+
|
|
332
405
|
**Base access control only on the user and the current actor** (`guard.actor`, the
|
|
333
406
|
principal's `actor`). Prior actors (`prior_actor`, `actor.actor`) are informational:
|
|
334
407
|
RFC 8693 §4.1 forbids using them for access-control decisions.
|
|
@@ -387,26 +460,28 @@ Per request:
|
|
|
387
460
|
access assertion with the JWKS access key and forward the token the user presented in
|
|
388
461
|
`X-Subject-Token`.
|
|
389
462
|
|
|
390
|
-
|
|
463
|
+
Once your API server accepts delegated tokens, every operation accepts them unless it
|
|
464
|
+
says otherwise. To keep agents away from a sensitive operation, declare
|
|
465
|
+
`delegatedCallers: "refused"` (`@schemavaults/openapi-operations` ≥ 0.7.0): the runtime
|
|
466
|
+
answers a principal with an actor 403 `delegated_caller_refused`, whatever scope its
|
|
467
|
+
token carries, and the OpenAPI document (`x-schemavaults-auth`) and `/docs` pages show it:
|
|
391
468
|
|
|
392
469
|
```ts
|
|
393
|
-
import { OperationError } from "@schemavaults/openapi-operations";
|
|
394
|
-
|
|
395
470
|
export const deleteAccount = defineOperation({
|
|
396
471
|
// ...
|
|
472
|
+
auth: requireAuth({
|
|
473
|
+
schemes: userCredentialSchemes,
|
|
474
|
+
delegatedCallers: "refused", // only the user's own credential, never an agent's
|
|
475
|
+
}),
|
|
397
476
|
handler: async (ctx) => {
|
|
398
|
-
|
|
399
|
-
// Someone (e.g. an agent) is acting on the user's behalf: only the user may do this.
|
|
400
|
-
throw new OperationError(403, {
|
|
401
|
-
error: "delegation_not_allowed",
|
|
402
|
-
message: "This operation cannot be performed on your behalf",
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
// ...
|
|
477
|
+
// ctx.auth.actor is always absent here
|
|
406
478
|
},
|
|
407
479
|
});
|
|
408
480
|
```
|
|
409
481
|
|
|
482
|
+
Handlers that need a finer rule (e.g. agents of one client only) read `ctx.auth.actor`
|
|
483
|
+
themselves and throw `OperationError(403, ...)`.
|
|
484
|
+
|
|
410
485
|
### Organization memberships
|
|
411
486
|
|
|
412
487
|
By default an API server only sees memberships of the organization that owns it:
|
package/dist/cli.cjs
CHANGED
|
@@ -89,7 +89,7 @@ var init_resolve_codegen_templates_directory = __esm({
|
|
|
89
89
|
|
|
90
90
|
// src/NextjsAppDirectoryPlugin/codegen-marker.ts
|
|
91
91
|
function getCodegenMarkerComment() {
|
|
92
|
-
const version2 = true ? "0.
|
|
92
|
+
const version2 = true ? "0.41.1" : "unknown";
|
|
93
93
|
return `${CODEGEN_MARKER_PREFIX}${version2}`;
|
|
94
94
|
}
|
|
95
95
|
function hasCodegenMarker(firstLine) {
|
|
@@ -20325,6 +20325,11 @@ var apiServerOrganizationMembershipVisibilityFieldsShape = {
|
|
|
20325
20325
|
organization_membership_visibility: organizationMembershipVisibilitySchema.optional()
|
|
20326
20326
|
};
|
|
20327
20327
|
|
|
20328
|
+
// ../app-definitions/dist/api-server-delegated-tokens.js
|
|
20329
|
+
var apiServerDelegatedTokenFieldsShape = {
|
|
20330
|
+
accept_delegated_tokens: external_exports.boolean().optional()
|
|
20331
|
+
};
|
|
20332
|
+
|
|
20328
20333
|
// ../app-definitions/dist/list-registry-apps-query-params.js
|
|
20329
20334
|
var list_apps_query_type = [
|
|
20330
20335
|
"all",
|
|
@@ -20359,7 +20364,9 @@ var schemaVaultsApiServerDefinitionSchema = external_exports.object({
|
|
|
20359
20364
|
// Dynamic-client policy: see api-server-dynamic-clients.ts
|
|
20360
20365
|
...apiServerDynamicClientFieldsShape,
|
|
20361
20366
|
// Organization membership lookups: see api-server-organization-membership-visibility.ts
|
|
20362
|
-
...apiServerOrganizationMembershipVisibilityFieldsShape
|
|
20367
|
+
...apiServerOrganizationMembershipVisibilityFieldsShape,
|
|
20368
|
+
// Delegated (RFC 8693 `act`) access tokens: see api-server-delegated-tokens.ts
|
|
20369
|
+
...apiServerDelegatedTokenFieldsShape
|
|
20363
20370
|
}).required({
|
|
20364
20371
|
api_server_id: true,
|
|
20365
20372
|
api_server_name: true,
|
|
@@ -23377,7 +23384,7 @@ async function main() {
|
|
|
23377
23384
|
return;
|
|
23378
23385
|
}
|
|
23379
23386
|
if (args.includes("--version") || args.includes("-v")) {
|
|
23380
|
-
console.log(`${PACKAGE_NAME}@${"0.
|
|
23387
|
+
console.log(`${PACKAGE_NAME}@${"0.41.1"}`);
|
|
23381
23388
|
return;
|
|
23382
23389
|
}
|
|
23383
23390
|
const command = findCommand(args, FLAGS_WITH_VALUES) ?? "codegen";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type ConfidentialClientCredentials } from "./shared";
|
|
3
|
+
export interface IExchangeTokenForDelegatedTokenOptions extends ConfidentialClientCredentials {
|
|
4
|
+
/**
|
|
5
|
+
* An access token one of this client's users holds for the API server the
|
|
6
|
+
* agent will call (the RFC 8693 `subject_token`). It must be the user's
|
|
7
|
+
* own token, issued to this client, and still live: not expired or
|
|
8
|
+
* revoked, and the user's authorization of the app still standing.
|
|
9
|
+
*/
|
|
10
|
+
subject_token: string;
|
|
11
|
+
/**
|
|
12
|
+
* The scope of the delegated token, a subset of the subject token's
|
|
13
|
+
* (space-delimited, or a list). Omit to keep the subject token's whole
|
|
14
|
+
* scope. Asking for more answers `invalid_scope`.
|
|
15
|
+
*/
|
|
16
|
+
scope?: string | readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* RFC 8707 resource indicator. Optional: a delegated token is always
|
|
19
|
+
* minted for the subject token's own audience, and any other value
|
|
20
|
+
* answers `invalid_target`. To act at another API server, exchange an
|
|
21
|
+
* access token for that one.
|
|
22
|
+
*/
|
|
23
|
+
resource?: string;
|
|
24
|
+
}
|
|
25
|
+
/** The auth server's RFC 8693 §2.2.1 token exchange response. */
|
|
26
|
+
export declare const delegatedTokenResponseSchema: z.ZodObject<{
|
|
27
|
+
access_token: z.ZodString;
|
|
28
|
+
issued_token_type: z.ZodLiteral<"urn:ietf:params:oauth:token-type:access_token">;
|
|
29
|
+
token_type: z.ZodLiteral<"Bearer">;
|
|
30
|
+
expires_in: z.ZodNumber;
|
|
31
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$loose>;
|
|
33
|
+
export type DelegatedTokenResponse = z.infer<typeof delegatedTokenResponseSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* Swaps an access token of one of this client's users for a DELEGATED
|
|
36
|
+
* access token (RFC 8693 token exchange): same user (`sub`), same API
|
|
37
|
+
* server, at most the same scope, with the client's service account named
|
|
38
|
+
* as the actor (`act`). Hand the delegated token, not the user's, to an
|
|
39
|
+
* agent acting for the user (e.g. one running in a sandbox), so the API
|
|
40
|
+
* server can tell the agent from the user and the agent holds only the
|
|
41
|
+
* scope it needs.
|
|
42
|
+
*
|
|
43
|
+
* Only confidential clients can exchange (they authenticate with
|
|
44
|
+
* `client_secret_basic` here), and only for API servers whose managers
|
|
45
|
+
* accept delegated tokens (otherwise `invalid_target`). The response holds
|
|
46
|
+
* an access token alone: when it expires, exchange a fresh access token of
|
|
47
|
+
* the user's again. End the delegation early with `revokeToken()`.
|
|
48
|
+
*
|
|
49
|
+
* @throws {OAuthEndpointError} when the auth server refuses the exchange.
|
|
50
|
+
* Notable codes: `invalid_request` (the subject token is invalid, expired,
|
|
51
|
+
* revoked, already delegated, or the user's access behind it was
|
|
52
|
+
* withdrawn), `invalid_scope` (wider than the subject token's), and
|
|
53
|
+
* `invalid_target` (another audience, or an API server that does not
|
|
54
|
+
* accept delegated tokens).
|
|
55
|
+
*/
|
|
56
|
+
export declare function exchangeTokenForDelegatedToken({ subject_token, scope, resource, ...credentials }: IExchangeTokenForDelegatedTokenOptions): Promise<DelegatedTokenResponse>;
|
|
57
|
+
export default exchangeTokenForDelegatedToken;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getOidcEndpointUrl, OAUTH_ACCESS_TOKEN_TYPE, OAUTH_TOKEN_EXCHANGE_GRANT_TYPE, } from "@schemavaults/auth-common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { postAsConfidentialClient, } from "./shared";
|
|
4
|
+
/** The auth server's RFC 8693 §2.2.1 token exchange response. */
|
|
5
|
+
export const delegatedTokenResponseSchema = z.looseObject({
|
|
6
|
+
/** The delegated access token: hand it to the agent. */
|
|
7
|
+
access_token: z.string().min(1),
|
|
8
|
+
issued_token_type: z.literal(OAUTH_ACCESS_TOKEN_TYPE),
|
|
9
|
+
token_type: z.literal("Bearer"),
|
|
10
|
+
/** Lifetime in seconds. Exchange again for a fresh token; there is no refresh token. */
|
|
11
|
+
expires_in: z.number().int().positive(),
|
|
12
|
+
/** Space-delimited granted scope; absent when the token carries none. */
|
|
13
|
+
scope: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
function serializeScope(scope) {
|
|
16
|
+
const values = (typeof scope === "string" ? scope.split(" ") : [...scope])
|
|
17
|
+
.map((value) => value.trim())
|
|
18
|
+
.filter((value) => value.length > 0);
|
|
19
|
+
if (values.length === 0) {
|
|
20
|
+
throw new TypeError("Expected a non-empty 'scope'; omit it to keep the subject token's scope.");
|
|
21
|
+
}
|
|
22
|
+
return values.join(" ");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Swaps an access token of one of this client's users for a DELEGATED
|
|
26
|
+
* access token (RFC 8693 token exchange): same user (`sub`), same API
|
|
27
|
+
* server, at most the same scope, with the client's service account named
|
|
28
|
+
* as the actor (`act`). Hand the delegated token, not the user's, to an
|
|
29
|
+
* agent acting for the user (e.g. one running in a sandbox), so the API
|
|
30
|
+
* server can tell the agent from the user and the agent holds only the
|
|
31
|
+
* scope it needs.
|
|
32
|
+
*
|
|
33
|
+
* Only confidential clients can exchange (they authenticate with
|
|
34
|
+
* `client_secret_basic` here), and only for API servers whose managers
|
|
35
|
+
* accept delegated tokens (otherwise `invalid_target`). The response holds
|
|
36
|
+
* an access token alone: when it expires, exchange a fresh access token of
|
|
37
|
+
* the user's again. End the delegation early with `revokeToken()`.
|
|
38
|
+
*
|
|
39
|
+
* @throws {OAuthEndpointError} when the auth server refuses the exchange.
|
|
40
|
+
* Notable codes: `invalid_request` (the subject token is invalid, expired,
|
|
41
|
+
* revoked, already delegated, or the user's access behind it was
|
|
42
|
+
* withdrawn), `invalid_scope` (wider than the subject token's), and
|
|
43
|
+
* `invalid_target` (another audience, or an API server that does not
|
|
44
|
+
* accept delegated tokens).
|
|
45
|
+
*/
|
|
46
|
+
export async function exchangeTokenForDelegatedToken({ subject_token, scope, resource, ...credentials }) {
|
|
47
|
+
if (typeof subject_token !== "string" || subject_token.length === 0) {
|
|
48
|
+
throw new TypeError("Expected a subject_token to exchange!");
|
|
49
|
+
}
|
|
50
|
+
if (resource !== undefined && (typeof resource !== "string" || resource.length === 0)) {
|
|
51
|
+
throw new TypeError("Expected 'resource' to be a non-empty string when set!");
|
|
52
|
+
}
|
|
53
|
+
const form = new URLSearchParams({
|
|
54
|
+
grant_type: OAUTH_TOKEN_EXCHANGE_GRANT_TYPE,
|
|
55
|
+
subject_token,
|
|
56
|
+
subject_token_type: OAUTH_ACCESS_TOKEN_TYPE,
|
|
57
|
+
});
|
|
58
|
+
if (scope !== undefined) {
|
|
59
|
+
form.set("scope", serializeScope(scope));
|
|
60
|
+
}
|
|
61
|
+
if (resource !== undefined) {
|
|
62
|
+
form.set("resource", resource);
|
|
63
|
+
}
|
|
64
|
+
const response = await postAsConfidentialClient(credentials, "token", getOidcEndpointUrl(credentials.auth_server_url, "token"), form);
|
|
65
|
+
const parsed = delegatedTokenResponseSchema.safeParse(await response.json());
|
|
66
|
+
if (!parsed.success) {
|
|
67
|
+
throw new Error("Received an unexpected token exchange response from the auth server", { cause: parsed.error });
|
|
68
|
+
}
|
|
69
|
+
return parsed.data;
|
|
70
|
+
}
|
|
71
|
+
export default exchangeTokenForDelegatedToken;
|
|
72
|
+
//# sourceMappingURL=exchange-token-for-delegated-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exchange-token-for-delegated-token.js","sourceRoot":"","sources":["../../src/confidential-client/exchange-token-for-delegated-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,wBAAwB,GACzB,MAAM,UAAU,CAAC;AA0BlB,iEAAiE;AACjE,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CAAC;IACxD,wDAAwD;IACxD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC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AAC,CAAC,EAAE,CAAC;QACtF,MAAM,IAAI,SAAS,CAAC,wDAAwD,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC;QAC/B,UAAU,EAAE,+BAA+B;QAC3C,aAAa;QACb,kBAAkB,EAAE,uBAAuB;KAC5C,CAAC,CAAC;IACH,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,QAAQ,GAAa,MAAM,wBAAwB,CACvD,WAAW,EACX,OAAO,EACP,kBAAkB,CAAC,WAAW,CAAC,eAAe,EAAE,OAAO,CAAC,EACxD,IAAI,CACL,CAAC;IAEF,MAAM,MAAM,GAAG,4BAA4B,CAAC,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,qEAAqE,EACrE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,eAAe,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls a confidential client application's backend makes to the auth
|
|
3
|
+
* server with its client secret: minting delegated tokens for the agents it
|
|
4
|
+
* runs for its users (RFC 8693 token exchange) and revoking tokens issued to
|
|
5
|
+
* it (RFC 7009). Server-side only: never ship the client secret to a browser
|
|
6
|
+
* or into an agent's sandbox.
|
|
7
|
+
*/
|
|
8
|
+
export { exchangeTokenForDelegatedToken, delegatedTokenResponseSchema, } from "./exchange-token-for-delegated-token";
|
|
9
|
+
export type { DelegatedTokenResponse, IExchangeTokenForDelegatedTokenOptions, } from "./exchange-token-for-delegated-token";
|
|
10
|
+
export { revokeToken } from "./revoke-token";
|
|
11
|
+
export type { IRevokeTokenOptions } from "./revoke-token";
|
|
12
|
+
export { OAuthEndpointError, clientSecretBasicAuthorization } from "./shared";
|
|
13
|
+
export type { ConfidentialClientCredentials } from "./shared";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls a confidential client application's backend makes to the auth
|
|
3
|
+
* server with its client secret: minting delegated tokens for the agents it
|
|
4
|
+
* runs for its users (RFC 8693 token exchange) and revoking tokens issued to
|
|
5
|
+
* it (RFC 7009). Server-side only: never ship the client secret to a browser
|
|
6
|
+
* or into an agent's sandbox.
|
|
7
|
+
*/
|
|
8
|
+
export { exchangeTokenForDelegatedToken, delegatedTokenResponseSchema, } from "./exchange-token-for-delegated-token";
|
|
9
|
+
export { revokeToken } from "./revoke-token";
|
|
10
|
+
export { OAuthEndpointError, clientSecretBasicAuthorization } from "./shared";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/confidential-client/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ConfidentialClientCredentials } from "./shared";
|
|
2
|
+
export interface IRevokeTokenOptions extends ConfidentialClientCredentials {
|
|
3
|
+
/**
|
|
4
|
+
* A token issued to this client: a delegated access token it obtained by
|
|
5
|
+
* token exchange, or one of its users' refresh tokens.
|
|
6
|
+
*/
|
|
7
|
+
token: string;
|
|
8
|
+
/** RFC 7009 §2.1 hint; the auth server reads the kind from the token itself. */
|
|
9
|
+
token_type_hint?: "access_token" | "refresh_token";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Revokes a token issued to this confidential client (RFC 7009), e.g. the
|
|
13
|
+
* delegated token of an agent whose session ended, so that introspection and
|
|
14
|
+
* resource servers checking revocation refuse it before it expires.
|
|
15
|
+
*
|
|
16
|
+
* Resolves for any token the auth server does not know (RFC 7009 §2.2: an
|
|
17
|
+
* invalid token is not an error); revoking twice is harmless.
|
|
18
|
+
*
|
|
19
|
+
* @throws {OAuthEndpointError} when the auth server refuses the request:
|
|
20
|
+
* `invalid_client` (bad credentials), `invalid_grant` (the token was issued
|
|
21
|
+
* to another client), `unsupported_token_type` (a token the client cannot
|
|
22
|
+
* revoke, such as a user's own access token for an API server).
|
|
23
|
+
*/
|
|
24
|
+
export declare function revokeToken({ token, token_type_hint, ...credentials }: IRevokeTokenOptions): Promise<void>;
|
|
25
|
+
export default revokeToken;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getOidcEndpointUrl } from "@schemavaults/auth-common";
|
|
2
|
+
import { postAsConfidentialClient, } from "./shared";
|
|
3
|
+
/**
|
|
4
|
+
* Revokes a token issued to this confidential client (RFC 7009), e.g. the
|
|
5
|
+
* delegated token of an agent whose session ended, so that introspection and
|
|
6
|
+
* resource servers checking revocation refuse it before it expires.
|
|
7
|
+
*
|
|
8
|
+
* Resolves for any token the auth server does not know (RFC 7009 §2.2: an
|
|
9
|
+
* invalid token is not an error); revoking twice is harmless.
|
|
10
|
+
*
|
|
11
|
+
* @throws {OAuthEndpointError} when the auth server refuses the request:
|
|
12
|
+
* `invalid_client` (bad credentials), `invalid_grant` (the token was issued
|
|
13
|
+
* to another client), `unsupported_token_type` (a token the client cannot
|
|
14
|
+
* revoke, such as a user's own access token for an API server).
|
|
15
|
+
*/
|
|
16
|
+
export async function revokeToken({ token, token_type_hint, ...credentials }) {
|
|
17
|
+
if (typeof token !== "string" || token.length === 0) {
|
|
18
|
+
throw new TypeError("Expected a token to revoke!");
|
|
19
|
+
}
|
|
20
|
+
const form = new URLSearchParams({ token });
|
|
21
|
+
if (token_type_hint !== undefined) {
|
|
22
|
+
form.set("token_type_hint", token_type_hint);
|
|
23
|
+
}
|
|
24
|
+
await postAsConfidentialClient(credentials, "revocation", getOidcEndpointUrl(credentials.auth_server_url, "revocation"), form);
|
|
25
|
+
}
|
|
26
|
+
export default revokeToken;
|
|
27
|
+
//# sourceMappingURL=revoke-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke-token.js","sourceRoot":"","sources":["../../src/confidential-client/revoke-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAEL,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAYlB;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAChC,KAAK,EACL,eAAe,EACf,GAAG,WAAW,EACM;IACpB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CAAC,6BAA6B,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5C,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,wBAAwB,CAC5B,WAAW,EACX,YAAY,EACZ,kBAAkB,CAAC,WAAW,CAAC,eAAe,EAAE,YAAY,CAAC,EAC7D,IAAI,CACL,CAAC;AACJ,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The credentials of a confidential client application: its app id and a
|
|
3
|
+
* client secret registered for it on the auth server. Keep the secret on the
|
|
4
|
+
* server; never ship it to a browser or into an agent's sandbox.
|
|
5
|
+
*/
|
|
6
|
+
export interface ConfidentialClientCredentials {
|
|
7
|
+
/** The auth server URL (the issuer). */
|
|
8
|
+
auth_server_url: string;
|
|
9
|
+
/** The client application's id. */
|
|
10
|
+
client_id: string;
|
|
11
|
+
/** A client secret registered for the application. */
|
|
12
|
+
client_secret: string;
|
|
13
|
+
/** Defaults to the global `fetch`. */
|
|
14
|
+
fetch?: typeof fetch;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An OAuth 2.0 error answered by one of the auth server's endpoints
|
|
18
|
+
* (RFC 6749 §5.2, RFC 7009 §2.2.1, RFC 8693 §2.2.2): `error` is the
|
|
19
|
+
* machine-readable code (e.g. `invalid_request`, `invalid_scope`,
|
|
20
|
+
* `invalid_target`, `unauthorized_client`), or null when the auth server
|
|
21
|
+
* answered without one (an unreachable or misconfigured server).
|
|
22
|
+
*/
|
|
23
|
+
export declare class OAuthEndpointError extends Error {
|
|
24
|
+
readonly status: number;
|
|
25
|
+
readonly error: string | null;
|
|
26
|
+
readonly error_description: string | null;
|
|
27
|
+
constructor(endpoint: string, status: number, error: string | null, error_description: string | null);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The `client_secret_basic` Authorization header (RFC 6749 §2.3.1): the id
|
|
31
|
+
* and secret are URL-encoded, joined by a colon and base64-encoded. The URL
|
|
32
|
+
* encoding keeps the input ASCII, so `btoa` is safe for any secret.
|
|
33
|
+
*/
|
|
34
|
+
export declare function clientSecretBasicAuthorization({ client_id, client_secret, }: Pick<ConfidentialClientCredentials, "client_id" | "client_secret">): string;
|
|
35
|
+
/**
|
|
36
|
+
* POSTs an `application/x-www-form-urlencoded` request authenticated as the
|
|
37
|
+
* confidential client. Resolves with the response when it is a 2xx and
|
|
38
|
+
* throws {@link OAuthEndpointError} otherwise.
|
|
39
|
+
*/
|
|
40
|
+
export declare function postAsConfidentialClient(credentials: ConfidentialClientCredentials, endpoint_name: string, url: string, form: URLSearchParams): Promise<Response>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An OAuth 2.0 error answered by one of the auth server's endpoints
|
|
3
|
+
* (RFC 6749 §5.2, RFC 7009 §2.2.1, RFC 8693 §2.2.2): `error` is the
|
|
4
|
+
* machine-readable code (e.g. `invalid_request`, `invalid_scope`,
|
|
5
|
+
* `invalid_target`, `unauthorized_client`), or null when the auth server
|
|
6
|
+
* answered without one (an unreachable or misconfigured server).
|
|
7
|
+
*/
|
|
8
|
+
export class OAuthEndpointError extends Error {
|
|
9
|
+
status;
|
|
10
|
+
error;
|
|
11
|
+
error_description;
|
|
12
|
+
constructor(endpoint, status, error, error_description) {
|
|
13
|
+
super(`The auth server's ${endpoint} endpoint refused the request (status: ${status}` +
|
|
14
|
+
`${error ? `, error: ${error}` : ""})` +
|
|
15
|
+
`${error_description ? `: ${error_description}` : ""}`);
|
|
16
|
+
this.name = "OAuthEndpointError";
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.error = error;
|
|
19
|
+
this.error_description = error_description;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `client_secret_basic` Authorization header (RFC 6749 §2.3.1): the id
|
|
24
|
+
* and secret are URL-encoded, joined by a colon and base64-encoded. The URL
|
|
25
|
+
* encoding keeps the input ASCII, so `btoa` is safe for any secret.
|
|
26
|
+
*/
|
|
27
|
+
export function clientSecretBasicAuthorization({ client_id, client_secret, }) {
|
|
28
|
+
if (typeof client_id !== "string" || client_id.length === 0) {
|
|
29
|
+
throw new TypeError("Expected a client_id!");
|
|
30
|
+
}
|
|
31
|
+
if (typeof client_secret !== "string" || client_secret.length === 0) {
|
|
32
|
+
throw new TypeError("Expected a client_secret!");
|
|
33
|
+
}
|
|
34
|
+
return `Basic ${btoa(`${encodeURIComponent(client_id)}:${encodeURIComponent(client_secret)}`)}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* POSTs an `application/x-www-form-urlencoded` request authenticated as the
|
|
38
|
+
* confidential client. Resolves with the response when it is a 2xx and
|
|
39
|
+
* throws {@link OAuthEndpointError} otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export async function postAsConfidentialClient(credentials, endpoint_name, url, form) {
|
|
42
|
+
const fetchImpl = credentials.fetch ?? fetch;
|
|
43
|
+
const response = await fetchImpl(url, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: new Headers({
|
|
46
|
+
Authorization: clientSecretBasicAuthorization(credentials),
|
|
47
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
48
|
+
Accept: "application/json",
|
|
49
|
+
}),
|
|
50
|
+
body: form.toString(),
|
|
51
|
+
});
|
|
52
|
+
if (response.ok) {
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
let error = null;
|
|
56
|
+
let error_description = null;
|
|
57
|
+
try {
|
|
58
|
+
const body = await response.json();
|
|
59
|
+
if (typeof body === "object" && body !== null) {
|
|
60
|
+
const record = body;
|
|
61
|
+
if (typeof record.error === "string")
|
|
62
|
+
error = record.error;
|
|
63
|
+
if (typeof record.error_description === "string") {
|
|
64
|
+
error_description = record.error_description;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Not a JSON error body.
|
|
70
|
+
}
|
|
71
|
+
throw new OAuthEndpointError(endpoint_name, response.status, error, error_description);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/confidential-client/shared.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,MAAM,CAAS;IACf,KAAK,CAAgB;IACrB,iBAA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C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,IAAI,OAAO,CAAC;YACnB,aAAa,EAAE,8BAA8B,CAAC,WAAW,CAAC;YAC1D,cAAc,EAAE,mCAAmC;YACnD,MAAM,EAAE,kBAAkB;SAC3B,CAAC;QACF,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;KACtB,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,IAAI,iBAAiB,GAAkB,IAAI,CAAC;IAC5C,IAAI,CAAC;QACH,MAAM,IAAI,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,IAA+B,CAAC;YAC/C,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;gBAAE,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAC3D,IAAI,OAAO,MAAM,CAAC,iBAAiB,KAAK,QAAQ,EAAE,CAAC;gBACjD,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yBAAyB;IAC3B,CAAC;IACD,MAAM,IAAI,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;AACzF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,8 +34,10 @@ export { isUserInOrganization } from "./isUserInOrganization";
|
|
|
34
34
|
export type { IIsUserInOrganizationOptions } from "./isUserInOrganization";
|
|
35
35
|
export { listUserOrganizations, SUBJECT_TOKEN_HEADER_NAME, } from "./listUserOrganizations";
|
|
36
36
|
export type { IListUserOrganizationsOptions } from "./listUserOrganizations";
|
|
37
|
-
export { introspectToken, tokenIntrospectionResultSchema, } from "./introspectToken";
|
|
38
|
-
export type { IIntrospectTokenOptions, TokenIntrospectionResult, } from "./introspectToken";
|
|
37
|
+
export { getActorFromIntrospectionResult, introspectToken, tokenIntrospectionResultSchema, } from "./introspectToken";
|
|
38
|
+
export type { IIntrospectTokenOptions, IntrospectedTokenActor, TokenIntrospectionResult, } from "./introspectToken";
|
|
39
|
+
export { exchangeTokenForDelegatedToken, delegatedTokenResponseSchema, revokeToken, OAuthEndpointError, } from "./confidential-client";
|
|
40
|
+
export type { ConfidentialClientCredentials, DelegatedTokenResponse, IExchangeTokenForDelegatedTokenOptions, IRevokeTokenOptions, } from "./confidential-client";
|
|
39
41
|
export { userDataSchema } from "@schemavaults/auth-common";
|
|
40
42
|
export type { UserData } from "@schemavaults/auth-common";
|
|
41
43
|
export { organizationIdSchema, organizationDefinitionSchema, isValidOrganizationID, getAuthServerOwnerOrganizationId, DEFAULT_AUTH_SERVER_OWNER_ORGANIZATION_ID, isValidOrganizationMembershipRoleType, organizationMembershipRoleTypes, organizationMembershipRoleTypeSchema, } from "@schemavaults/auth-common/organizations";
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,10 @@ export { resolveExpectedTokenAudience, normalizeAcceptedAudiences, } from "./res
|
|
|
27
27
|
export { isUserInOrganization } from "./isUserInOrganization";
|
|
28
28
|
export { listUserOrganizations, SUBJECT_TOKEN_HEADER_NAME, } from "./listUserOrganizations";
|
|
29
29
|
// RFC 7662 token introspection of this API server's access tokens
|
|
30
|
-
export { introspectToken, tokenIntrospectionResultSchema, } from "./introspectToken";
|
|
30
|
+
export { getActorFromIntrospectionResult, introspectToken, tokenIntrospectionResultSchema, } from "./introspectToken";
|
|
31
|
+
// Confidential clients: delegated tokens for agents (RFC 8693 token
|
|
32
|
+
// exchange) and token revocation (RFC 7009)
|
|
33
|
+
export { exchangeTokenForDelegatedToken, delegatedTokenResponseSchema, revokeToken, OAuthEndpointError, } from "./confidential-client";
|
|
31
34
|
// Re-export user data types
|
|
32
35
|
export { userDataSchema } from "@schemavaults/auth-common";
|
|
33
36
|
// Re-export organization types
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAG7B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,yBAAyB,CAAC;AAGxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,EACL,qBAAqB,EACrB,cAAc,GACf,MAAM,qCAAqC,CAAC;AAG7C,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,CAAC;AAEpC,iBAAiB;AACjB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,IAAI,0BAA0B,EACzD,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,yBAAyB;AACzB,OAAO,EACL,kCAAkC,EAClC,kCAAkC,IAAI,kCAAkC,EACzE,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,eAAe;AACf,OAAO,EACL,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,kBAAkB;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAEjF,gBAAgB;AAChB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gC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AAC;AAGtD,kBAAkB;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAEjF,gBAAgB;AAChB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAO1E,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAE3C,6EAA6E;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AAGjC,kEAAkE;AAClE,OAAO,EACL,+BAA+B,EAC/B,eAAe,EACf,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAO3B,oEAAoE;AACpE,4CAA4C;AAC5C,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,WAAW,EACX,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAQ/B,4BAA4B;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,+BAA+B;AAC/B,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACrB,gCAAgC,EAChC,yCAAyC,EACzC,qCAAqC,EACrC,+BAA+B,EAC/B,oCAAoC,GACrC,MAAM,yCAAyC,CAAC;AAmBjD,8BAA8B;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,kDAAkD;AAClD,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
import { type TokenActor } from "@schemavaults/jwt";
|
|
1
2
|
import { type ApiServerId } from "@schemavaults/app-definitions";
|
|
2
3
|
import { z } from "zod";
|
|
4
|
+
/**
|
|
5
|
+
* The RFC 8693 §4.1 actor (`act`) of a delegated token, as the auth server's
|
|
6
|
+
* introspection response reports it: who acts on behalf of the token's user
|
|
7
|
+
* (e.g. an agent). The outermost actor is the current one; a nested `act` is
|
|
8
|
+
* the prior actor of a delegation chain and is informational only.
|
|
9
|
+
* {@link getActorFromIntrospectionResult} turns it into a `TokenActor`.
|
|
10
|
+
*/
|
|
11
|
+
export interface IntrospectedTokenActor {
|
|
12
|
+
/** The actor's OIDC subject `<auth_server_app_id>|<uid>`. */
|
|
13
|
+
sub: string;
|
|
14
|
+
/** The actor's platform id (the `<uid>` part of `sub`). */
|
|
15
|
+
uid: string;
|
|
16
|
+
/** The client app the actor acts through. */
|
|
17
|
+
client_id?: string;
|
|
18
|
+
/** The prior actor of a delegation chain (informational only). */
|
|
19
|
+
act?: IntrospectedTokenActor;
|
|
20
|
+
}
|
|
3
21
|
/**
|
|
4
22
|
* The auth server's RFC 7662 §2.2 introspection response. An inactive token
|
|
5
23
|
* is exactly `{ active: false }`: expired, revoked, issued for another API
|
|
@@ -20,8 +38,21 @@ export declare const tokenIntrospectionResultSchema: z.ZodUnion<readonly [z.ZodO
|
|
|
20
38
|
aud: z.ZodString;
|
|
21
39
|
iss: z.ZodString;
|
|
22
40
|
jti: z.ZodOptional<z.ZodString>;
|
|
41
|
+
service_account: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
act: z.ZodOptional<z.ZodType<IntrospectedTokenActor, unknown, z.core.$ZodTypeInternals<IntrospectedTokenActor, unknown>>>;
|
|
23
43
|
}, z.core.$loose>]>;
|
|
24
44
|
export type TokenIntrospectionResult = z.infer<typeof tokenIntrospectionResultSchema>;
|
|
45
|
+
/**
|
|
46
|
+
* The actor acting on behalf of the user of an introspected token, in the
|
|
47
|
+
* shape route guards and `decodeJWTsWithKeyManager()` report it (`uid`,
|
|
48
|
+
* `sub`, `client_id`, `prior_actor`), or null when the token is inactive or
|
|
49
|
+
* names no actor.
|
|
50
|
+
*
|
|
51
|
+
* This is the CURRENT actor: base access-control decisions on it and the
|
|
52
|
+
* token's top-level claims only. `prior_actor` is informational
|
|
53
|
+
* (RFC 8693 §4.1).
|
|
54
|
+
*/
|
|
55
|
+
export declare function getActorFromIntrospectionResult(result: TokenIntrospectionResult): TokenActor | null;
|
|
25
56
|
export interface IIntrospectTokenOptions {
|
|
26
57
|
/** The auth server URL (the issuer). */
|
|
27
58
|
auth_server_url: string;
|
package/dist/introspectToken.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import { createJwksAccessProofToken } from "@schemavaults/jwt";
|
|
1
|
+
import { createJwksAccessProofToken, MAX_JWT_ACTOR_CLAIM_DEPTH, } from "@schemavaults/jwt";
|
|
2
2
|
import { apiServerIdSchema, } from "@schemavaults/app-definitions";
|
|
3
3
|
import { getOidcEndpointUrl, OAUTH_JWT_BEARER_CLIENT_ASSERTION_TYPE, } from "@schemavaults/auth-common";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
+
/**
|
|
6
|
+
* One level of an introspected actor chain, built level by level like the
|
|
7
|
+
* token's own `act` schema. Loose objects, so identity members a newer auth
|
|
8
|
+
* server adds do not break this SDK; a malformed actor still fails the whole
|
|
9
|
+
* response, so an agent can never pass for the user it acts for.
|
|
10
|
+
*/
|
|
11
|
+
function introspectedActorSchema(remaining_levels) {
|
|
12
|
+
const identity = {
|
|
13
|
+
sub: z.string().min(1),
|
|
14
|
+
uid: z.string().min(1),
|
|
15
|
+
client_id: z.string().optional(),
|
|
16
|
+
};
|
|
17
|
+
if (remaining_levels <= 1) {
|
|
18
|
+
return z.looseObject(identity);
|
|
19
|
+
}
|
|
20
|
+
return z.looseObject({
|
|
21
|
+
...identity,
|
|
22
|
+
act: introspectedActorSchema(remaining_levels - 1).optional(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
5
25
|
/**
|
|
6
26
|
* The auth server's RFC 7662 §2.2 introspection response. An inactive token
|
|
7
27
|
* is exactly `{ active: false }`: expired, revoked, issued for another API
|
|
@@ -30,8 +50,42 @@ export const tokenIntrospectionResultSchema = z.union([
|
|
|
30
50
|
aud: z.string(),
|
|
31
51
|
iss: z.string(),
|
|
32
52
|
jti: z.string().optional(),
|
|
53
|
+
/**
|
|
54
|
+
* True when the user is a client app's service account: a machine
|
|
55
|
+
* identity (client_credentials grant), not a person. Absent otherwise.
|
|
56
|
+
*/
|
|
57
|
+
service_account: z.boolean().optional(),
|
|
58
|
+
/**
|
|
59
|
+
* The RFC 8693 actor of a delegated token (e.g. an agent acting for the
|
|
60
|
+
* user); absent otherwise. See {@link getActorFromIntrospectionResult}.
|
|
61
|
+
*/
|
|
62
|
+
act: introspectedActorSchema(MAX_JWT_ACTOR_CLAIM_DEPTH).optional(),
|
|
33
63
|
}),
|
|
34
64
|
]);
|
|
65
|
+
function introspectedActorToTokenActor(actor) {
|
|
66
|
+
return {
|
|
67
|
+
uid: actor.uid,
|
|
68
|
+
sub: actor.sub,
|
|
69
|
+
client_id: typeof actor.client_id === "string" ? actor.client_id : null,
|
|
70
|
+
prior_actor: actor.act ? introspectedActorToTokenActor(actor.act) : null,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The actor acting on behalf of the user of an introspected token, in the
|
|
75
|
+
* shape route guards and `decodeJWTsWithKeyManager()` report it (`uid`,
|
|
76
|
+
* `sub`, `client_id`, `prior_actor`), or null when the token is inactive or
|
|
77
|
+
* names no actor.
|
|
78
|
+
*
|
|
79
|
+
* This is the CURRENT actor: base access-control decisions on it and the
|
|
80
|
+
* token's top-level claims only. `prior_actor` is informational
|
|
81
|
+
* (RFC 8693 §4.1).
|
|
82
|
+
*/
|
|
83
|
+
export function getActorFromIntrospectionResult(result) {
|
|
84
|
+
if (!result.active || !result.act) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return introspectedActorToTokenActor(result.act);
|
|
88
|
+
}
|
|
35
89
|
/**
|
|
36
90
|
* Asks the auth server whether an access token minted for this API server is
|
|
37
91
|
* still active (RFC 7662 token introspection).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspectToken.js","sourceRoot":"","sources":["../src/introspectToken.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"introspectToken.js","sourceRoot":"","sources":["../src/introspectToken.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,GAE1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,sCAAsC,GACvC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB;;;;;GAKG;AACH,SAAS,uBAAuB,CAC9B,gBAAwB;IAExB,MAAM,QAAQ,GAAG;QACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACtB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACjC,CAAC;IACF,IAAI,gBAAgB,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,CAAC,CAAC,WAAW,CAAC;QACnB,GAAG,QAAQ;QACX,GAAG,EAAE,uBAAuB,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;KAC9D,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC;IACpD,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IACtC,CAAC,CAAC,WAAW,CAAC;QACZ,MAAM,EAAE,CA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CACF,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,MAAM,GAAW,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,IAAI,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC5C,IACE,OAAO,IAAI,KAAK,QAAQ;gBACxB,IAAI,KAAK,IAAI;gBACb,OAAO,IAAI,IAAI;gBACf,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAC9B,CAAC;gBACD,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YAC7B,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;QAC3B,CAAC;QACD,MAAM,IAAI,KAAK,CACb,+DAA+D,QAAQ,CAAC,MAAM,GAAG,MAAM,GAAG,CAC3F,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,8BAA8B,CAAC,SAAS,CACrD,MAAM,QAAQ,CAAC,IAAI,EAAE,CACtB,CAAC;IACF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,0EAA0E,EAC1E,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,eAAe,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemavaults/auth-server-sdk",
|
|
3
3
|
"description": "TypeScript SDK for building authenticated endpoints/middlewares for the Auth Server and Resource Servers",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.41.1",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"repository": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"zod": "4.6.7",
|
|
21
|
-
"@schemavaults/jwt": "0.16.
|
|
22
|
-
"@schemavaults/auth-common": "0.
|
|
23
|
-
"@schemavaults/app-definitions": "0.
|
|
21
|
+
"@schemavaults/jwt": "0.16.2",
|
|
22
|
+
"@schemavaults/auth-common": "0.38.0",
|
|
23
|
+
"@schemavaults/app-definitions": "0.17.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsc --project tsconfig.json && tsc-alias --project tsconfig.json && bun run copy-codegen-templates && bun run prepare-cli",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "8.48.1",
|
|
47
47
|
"@typescript-eslint/parser": "8.48.1",
|
|
48
48
|
"esbuild": "0.27.3",
|
|
49
|
-
"@schemavaults/openapi-operations": "0.
|
|
49
|
+
"@schemavaults/openapi-operations": "0.7.0"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
@@ -172,10 +172,15 @@
|
|
|
172
172
|
"types": "./dist/api-scopes/index.d.ts",
|
|
173
173
|
"import": "./dist/api-scopes/index.js",
|
|
174
174
|
"require": "./dist/api-scopes/index.js"
|
|
175
|
+
},
|
|
176
|
+
"./confidential-client": {
|
|
177
|
+
"types": "./dist/confidential-client/index.d.ts",
|
|
178
|
+
"import": "./dist/confidential-client/index.js",
|
|
179
|
+
"require": "./dist/confidential-client/index.js"
|
|
175
180
|
}
|
|
176
181
|
},
|
|
177
182
|
"peerDependencies": {
|
|
178
|
-
"@schemavaults/openapi-operations": "0.
|
|
183
|
+
"@schemavaults/openapi-operations": "0.7.0"
|
|
179
184
|
},
|
|
180
185
|
"peerDependenciesMeta": {
|
|
181
186
|
"@schemavaults/openapi-operations": {
|