@deque/axe-auth 1.8.0-next.c21acb40 → 1.8.0-next.cea3092f
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/dist/commands/token.d.ts
CHANGED
|
@@ -9,13 +9,26 @@ export interface TokenDeps extends CommandDeps {
|
|
|
9
9
|
/** Override the token store. Defaults to a fresh `KeyringTokenStore()`. */
|
|
10
10
|
tokenStore?: TokenStore;
|
|
11
11
|
}
|
|
12
|
+
/** Arguments for `axe-auth token`. */
|
|
13
|
+
export interface TokenArgs extends CommonArgs {
|
|
14
|
+
/**
|
|
15
|
+
* Undocumented on purpose: only the axe MCP server reads it (#1448). The
|
|
16
|
+
* server accepts axe-auth from its own release version up, so this shape may
|
|
17
|
+
* only gain fields until the next major version.
|
|
18
|
+
*/
|
|
19
|
+
json?: boolean;
|
|
20
|
+
}
|
|
12
21
|
/** `axe-auth token` — print a currently-valid access token to stdout. */
|
|
13
22
|
declare const tokenCommand: {
|
|
14
23
|
name: string;
|
|
15
24
|
summary: string;
|
|
16
25
|
helpText: string;
|
|
17
|
-
options: {
|
|
26
|
+
options: {
|
|
27
|
+
json: {
|
|
28
|
+
type: "boolean";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
18
31
|
requiresConfig: false;
|
|
19
|
-
run(
|
|
32
|
+
run(args: TokenArgs, deps: TokenDeps): Promise<void>;
|
|
20
33
|
};
|
|
21
34
|
export default tokenCommand;
|
package/dist/commands/token.js
CHANGED
|
@@ -10,9 +10,9 @@ const tokenCommand = {
|
|
|
10
10
|
name: "token",
|
|
11
11
|
summary: "Print a currently-valid access token to stdout, refreshing silently if needed.",
|
|
12
12
|
helpText: token_help_1.HELP_TOKEN,
|
|
13
|
-
options: {},
|
|
13
|
+
options: { json: { type: "boolean" } },
|
|
14
14
|
requiresConfig: false,
|
|
15
|
-
async run(
|
|
15
|
+
async run(args, deps) {
|
|
16
16
|
const getToken = deps.getToken ?? getValidAccessToken_1.getValidAccessToken;
|
|
17
17
|
const tokenStore = deps.tokenStore ?? new tokenStore_1.KeyringTokenStore();
|
|
18
18
|
const loaded = deps.loadedEntry ?? (await tokenStore.load());
|
|
@@ -34,6 +34,13 @@ const tokenCommand = {
|
|
|
34
34
|
}
|
|
35
35
|
throw err;
|
|
36
36
|
}
|
|
37
|
+
if (args.json && loaded.ok) {
|
|
38
|
+
// Named for the user-facing `--server` / AXE_SERVER_URL, not the
|
|
39
|
+
// internal codename the stored entry uses.
|
|
40
|
+
const serverURL = loaded.entry.walnutURL;
|
|
41
|
+
deps.stdout.write(`${JSON.stringify({ accessToken: token, serverURL })}\n`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
37
44
|
deps.stdout.write(`${token}\n`);
|
|
38
45
|
},
|
|
39
46
|
};
|
|
@@ -42,13 +42,11 @@ export interface GetValidAccessTokenOptions {
|
|
|
42
42
|
* Throws `OAuthFlowError("DISCOVERY_FAILED", ...)` when the issuer
|
|
43
43
|
* URL cannot be reached or parsed at refresh time.
|
|
44
44
|
*
|
|
45
|
-
* **Concurrency note.**
|
|
46
|
-
* the same
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* per-request callers should wrap in an in-flight-Promise singleton
|
|
52
|
-
* keyed by issuer.
|
|
45
|
+
* **Concurrency note.** Parallel invocations for the same issuer each
|
|
46
|
+
* refresh with the same stored refresh token. Deque's Keycloak realms
|
|
47
|
+
* accept a used refresh token again, so both succeed and the last save
|
|
48
|
+
* wins. A realm with "Revoke Refresh Token" on rejects the second
|
|
49
|
+
* refresh and ends the session, so per-request callers should still
|
|
50
|
+
* wrap this in an in-flight-Promise singleton keyed by issuer.
|
|
53
51
|
*/
|
|
54
52
|
export declare function getValidAccessToken(options: GetValidAccessTokenOptions): Promise<string>;
|
|
@@ -42,14 +42,12 @@ function notAuthenticated(message, cause) {
|
|
|
42
42
|
* Throws `OAuthFlowError("DISCOVERY_FAILED", ...)` when the issuer
|
|
43
43
|
* URL cannot be reached or parsed at refresh time.
|
|
44
44
|
*
|
|
45
|
-
* **Concurrency note.**
|
|
46
|
-
* the same
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* per-request callers should wrap in an in-flight-Promise singleton
|
|
52
|
-
* keyed by issuer.
|
|
45
|
+
* **Concurrency note.** Parallel invocations for the same issuer each
|
|
46
|
+
* refresh with the same stored refresh token. Deque's Keycloak realms
|
|
47
|
+
* accept a used refresh token again, so both succeed and the last save
|
|
48
|
+
* wins. A realm with "Revoke Refresh Token" on rejects the second
|
|
49
|
+
* refresh and ends the session, so per-request callers should still
|
|
50
|
+
* wrap this in an in-flight-Promise singleton keyed by issuer.
|
|
53
51
|
*/
|
|
54
52
|
async function getValidAccessToken(options) {
|
|
55
53
|
const { issuerURL, clientId, expiryBufferMs = DEFAULT_EXPIRY_BUFFER_MS, tokenStore = new tokenStore_1.KeyringTokenStore(), loadedEntry, signal, allowInsecureIssuer, onWarning = defaultOnWarning, now = Date.now, } = options;
|
|
@@ -110,12 +108,11 @@ async function getValidAccessToken(options) {
|
|
|
110
108
|
// retry without re-logging-in.
|
|
111
109
|
throw err;
|
|
112
110
|
}
|
|
113
|
-
// HAZARD:
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
// get `invalid_grant`, and prompt re-authentication.
|
|
111
|
+
// HAZARD: if persisting the new set fails, the store keeps the old
|
|
112
|
+
// refresh token. Deque's Keycloak realms accept a used refresh token
|
|
113
|
+
// again, so the next invocation still refreshes; a realm with "Revoke
|
|
114
|
+
// Refresh Token" on rejects it with `invalid_grant`, and the user has
|
|
115
|
+
// to log in again.
|
|
119
116
|
//
|
|
120
117
|
// We still return the fresh access token so the current call is
|
|
121
118
|
// useful, and warn the caller so "why does the next run need me to
|
|
@@ -130,7 +127,7 @@ async function getValidAccessToken(options) {
|
|
|
130
127
|
});
|
|
131
128
|
}
|
|
132
129
|
catch (err) {
|
|
133
|
-
onWarning(`Refreshed tokens could not be saved: ${err instanceof Error ? err.message : String(err)}. The current call will succeed, but the next invocation
|
|
130
|
+
onWarning(`Refreshed tokens could not be saved: ${err instanceof Error ? err.message : String(err)}. The current call will succeed, but the next invocation may require re-authentication.`);
|
|
134
131
|
}
|
|
135
132
|
return fresh.accessToken;
|
|
136
133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/axe-auth",
|
|
3
|
-
"version": "1.8.0-next.
|
|
3
|
+
"version": "1.8.0-next.cea3092f",
|
|
4
4
|
"description": "CLI authentication utility for Deque services",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"ts-dedent": "^2.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@hono/node-server": "^2.1.
|
|
40
|
+
"@hono/node-server": "^2.1.6",
|
|
41
41
|
"@types/cross-spawn": "^6.0.6",
|
|
42
|
-
"@types/node": "^24.
|
|
42
|
+
"@types/node": "^24.19.2",
|
|
43
43
|
"c8": "^12.0.0",
|
|
44
|
-
"hono": "^4.13.
|
|
44
|
+
"hono": "^4.13.16",
|
|
45
45
|
"tsx": "^4.23.15",
|
|
46
46
|
"typescript": "^6.0.3"
|
|
47
47
|
},
|