@schemavaults/auth-server-sdk 0.41.1 → 0.41.2
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 +5 -1
- package/dist/cli.cjs +2 -2
- package/dist/confidential-client/exchange-token-for-delegated-token.d.ts +6 -5
- package/dist/confidential-client/exchange-token-for-delegated-token.js +11 -6
- package/dist/confidential-client/exchange-token-for-delegated-token.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -332,7 +332,7 @@ const delegated = await exchangeTokenForDelegatedToken({
|
|
|
332
332
|
scope: ["notes:read"], // optional: a subset of its scope (default: all of it)
|
|
333
333
|
});
|
|
334
334
|
delegated.access_token; // give this to the agent
|
|
335
|
-
delegated.expires_in; // seconds
|
|
335
|
+
delegated.expires_in; // seconds: what the subject token had left. No refresh token: renew the user's token and exchange again
|
|
336
336
|
delegated.scope; // the granted scope
|
|
337
337
|
|
|
338
338
|
// When the agent's session ends:
|
|
@@ -347,6 +347,10 @@ await revokeToken({ ...client, token: delegated.access_token });
|
|
|
347
347
|
Other refusals: `invalid_request` (the subject token is expired, revoked, already
|
|
348
348
|
delegated, issued to another client, or the user withdrew the app's access) and
|
|
349
349
|
`invalid_scope` (more scope than the subject token holds).
|
|
350
|
+
- A delegated token expires when its subject token does, so exchange a freshly
|
|
351
|
+
renewed access token of the user's (a subject token with under 30 seconds left is
|
|
352
|
+
refused with `invalid_request`). It also ends with the user's session it came from:
|
|
353
|
+
revoking that session's refresh token (or the user logging out) revokes it.
|
|
350
354
|
- Revoking makes introspection and resource servers with an `isTokenRevoked` hook
|
|
351
355
|
refuse the token at once; resource servers that only verify tokens locally stop
|
|
352
356
|
accepting it when it expires.
|
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.41.
|
|
92
|
+
const version2 = true ? "0.41.2" : "unknown";
|
|
93
93
|
return `${CODEGEN_MARKER_PREFIX}${version2}`;
|
|
94
94
|
}
|
|
95
95
|
function hasCodegenMarker(firstLine) {
|
|
@@ -23384,7 +23384,7 @@ async function main() {
|
|
|
23384
23384
|
return;
|
|
23385
23385
|
}
|
|
23386
23386
|
if (args.includes("--version") || args.includes("-v")) {
|
|
23387
|
-
console.log(`${PACKAGE_NAME}@${"0.41.
|
|
23387
|
+
console.log(`${PACKAGE_NAME}@${"0.41.2"}`);
|
|
23388
23388
|
return;
|
|
23389
23389
|
}
|
|
23390
23390
|
const command = findCommand(args, FLAGS_WITH_VALUES) ?? "codegen";
|
|
@@ -43,13 +43,14 @@ export type DelegatedTokenResponse = z.infer<typeof delegatedTokenResponseSchema
|
|
|
43
43
|
* Only confidential clients can exchange (they authenticate with
|
|
44
44
|
* `client_secret_basic` here), and only for API servers whose managers
|
|
45
45
|
* accept delegated tokens (otherwise `invalid_target`). The response holds
|
|
46
|
-
* an access token alone
|
|
47
|
-
*
|
|
46
|
+
* an access token alone, which expires when the subject token does (auth
|
|
47
|
+
* server >= 0.67.8): when it expires, exchange a fresh access token of the
|
|
48
|
+
* user's again. End the delegation early with `revokeToken()`.
|
|
48
49
|
*
|
|
49
50
|
* @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
|
|
52
|
-
* withdrawn), `invalid_scope` (wider than the subject token's), and
|
|
51
|
+
* Notable codes: `invalid_request` (the subject token is invalid, expired
|
|
52
|
+
* or about to, revoked, already delegated, or the user's access behind it
|
|
53
|
+
* was withdrawn), `invalid_scope` (wider than the subject token's), and
|
|
53
54
|
* `invalid_target` (another audience, or an API server that does not
|
|
54
55
|
* accept delegated tokens).
|
|
55
56
|
*/
|
|
@@ -7,7 +7,11 @@ export const delegatedTokenResponseSchema = z.looseObject({
|
|
|
7
7
|
access_token: z.string().min(1),
|
|
8
8
|
issued_token_type: z.literal(OAUTH_ACCESS_TOKEN_TYPE),
|
|
9
9
|
token_type: z.literal("Bearer"),
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Lifetime in seconds: what the subject token had left (a delegated token
|
|
12
|
+
* expires with it). To keep the agent going, renew the user's access token
|
|
13
|
+
* and exchange the new one; there is no refresh token.
|
|
14
|
+
*/
|
|
11
15
|
expires_in: z.number().int().positive(),
|
|
12
16
|
/** Space-delimited granted scope; absent when the token carries none. */
|
|
13
17
|
scope: z.string().optional(),
|
|
@@ -33,13 +37,14 @@ function serializeScope(scope) {
|
|
|
33
37
|
* Only confidential clients can exchange (they authenticate with
|
|
34
38
|
* `client_secret_basic` here), and only for API servers whose managers
|
|
35
39
|
* accept delegated tokens (otherwise `invalid_target`). The response holds
|
|
36
|
-
* an access token alone
|
|
37
|
-
*
|
|
40
|
+
* an access token alone, which expires when the subject token does (auth
|
|
41
|
+
* server >= 0.67.8): when it expires, exchange a fresh access token of the
|
|
42
|
+
* user's again. End the delegation early with `revokeToken()`.
|
|
38
43
|
*
|
|
39
44
|
* @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
|
|
42
|
-
* withdrawn), `invalid_scope` (wider than the subject token's), and
|
|
45
|
+
* Notable codes: `invalid_request` (the subject token is invalid, expired
|
|
46
|
+
* or about to, revoked, already delegated, or the user's access behind it
|
|
47
|
+
* was withdrawn), `invalid_scope` (wider than the subject token's), and
|
|
43
48
|
* `invalid_target` (another audience, or an API server that does not
|
|
44
49
|
* accept delegated tokens).
|
|
45
50
|
*/
|
|
@@ -1 +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/B,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B
|
|
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/B,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B;;;;OAIG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvC,yEAAyE;IACzE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC;AAIH,SAAS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AK,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"}
|
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.41.
|
|
4
|
+
"version": "0.41.2",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"zod": "4.6.7",
|
|
21
|
-
"@schemavaults/jwt": "0.
|
|
21
|
+
"@schemavaults/jwt": "0.17.0",
|
|
22
22
|
"@schemavaults/auth-common": "0.38.0",
|
|
23
23
|
"@schemavaults/app-definitions": "0.17.0"
|
|
24
24
|
},
|