@deque/axe-auth 1.8.0-next.3e251bf3 → 1.8.0-next.400936bf

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/credits.json CHANGED
@@ -86,13 +86,13 @@
86
86
  "publisher": "Ryan Govostes",
87
87
  "copyright": "Copyright (c) 2018 Ryan Govostes"
88
88
  },
89
- "ts-dedent@2.2.0": {
89
+ "ts-dedent@2.3.0": {
90
90
  "name": "ts-dedent",
91
- "version": "2.2.0",
91
+ "version": "2.3.0",
92
92
  "licenses": "MIT",
93
- "path": "/home/runner/work/axe-mcp-server/axe-mcp-server/node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent",
93
+ "path": "/home/runner/work/axe-mcp-server/axe-mcp-server/node_modules/.pnpm/ts-dedent@2.3.0/node_modules/ts-dedent",
94
94
  "licenseText": "MIT License\n\nCopyright (c) 2018 Tamino Martinius\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
95
- "licenseFile": "/home/runner/work/axe-mcp-server/axe-mcp-server/node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/LICENSE",
95
+ "licenseFile": "/home/runner/work/axe-mcp-server/axe-mcp-server/node_modules/.pnpm/ts-dedent@2.3.0/node_modules/ts-dedent/LICENSE",
96
96
  "repository": "https://github.com/tamino-martinius/node-ts-dedent",
97
97
  "publisher": "Tamino Martinius",
98
98
  "email": "dev@zaku.eu",
@@ -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(_args: CommonArgs, deps: TokenDeps): Promise<void>;
32
+ run(args: TokenArgs, deps: TokenDeps): Promise<void>;
20
33
  };
21
34
  export default tokenCommand;
@@ -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(_args, deps) {
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.** Not safe against parallel invocations for
46
- * the same issuer. Keycloak rotates refresh tokens by default; if
47
- * two parallel calls both land on the refresh path, only one
48
- * winner's rotated refresh token will be persisted and the loser's
49
- * rotated token is stranded. The intended consumer is the
50
- * `axe-auth token` CLI (a one-shot), so this is fine in context;
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.** Not safe against parallel invocations for
46
- * the same issuer. Keycloak rotates refresh tokens by default; if
47
- * two parallel calls both land on the refresh path, only one
48
- * winner's rotated refresh token will be persisted and the loser's
49
- * rotated token is stranded. The intended consumer is the
50
- * `axe-auth token` CLI (a one-shot), so this is fine in context;
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: Keycloak (and most rotating-refresh-token providers) have
114
- // already consumed the old refresh token server-side by the time
115
- // `refreshTokens` returns. If persisting the rotated set fails
116
- // here, we hold a valid access token in memory but the stored
117
- // refresh token is now stale — the next invocation will POST it,
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 will require re-authentication.`);
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
  }
@@ -29,6 +29,8 @@ flowchart TB
29
29
  cli <-- "tokens + issuer/client/walnutURL<br/>(versioned blob)" --> keychain
30
30
  cli -- "access token (stdout)" --> user
31
31
  cli -- "axe-auth run: spawn + supervise,<br/>access-token push (loopback POST /token)" --> mcp
32
+ mcp -- "spawns axe-auth token<br/>(saved sign-in, npm only)" --> cli
33
+ cli -- "access token + serverURL (stdout)" --> mcp
32
34
  ```
33
35
 
34
36
  **Components and their roles:**
@@ -40,7 +42,7 @@ flowchart TB
40
42
  5. **OS keychain**: the platform-native credential store accessed through [`@napi-rs/keyring`](https://www.npmjs.com/package/@napi-rs/keyring) — macOS Keychain, Windows Credential Manager, or Linux Secret Service (GNOME Keyring, KWallet). The CLI writes one entry per machine.
41
43
  6. **axe server**: the customer's deployment of the axe API. The CLI hits its `/api/sso-config` endpoint at the start of `login` to discover the Keycloak URL, realm, and OAuth client ID; no other CLI traffic flows through the axe server.
42
44
  7. **Customer Keycloak**: the OAuth authorization server for the customer's deployment. Issues access and refresh tokens. Federation between Keycloak and any upstream enterprise IdP (Okta, AAD, etc.) is the customer's concern and out of scope for this document.
43
- 8. **axe MCP server**: the server that `axe-auth run` launches and supervises. It receives freshly-minted access tokens pushed over loopback (`POST /token`) so a long session survives token expiry without a restart. Present only in the `run` flow, not in `login`/`token`/`logout`.
45
+ 8. **axe MCP server**: the server that `axe-auth run` launches and supervises. It receives freshly-minted access tokens pushed over loopback (`POST /token`) so a long session survives token expiry without a restart. An npm server started with no credential also runs `axe-auth token` itself, as a child process, to find out whether signing in with the saved session is enabled for the user's organization, and signs in with it only when it is; it reads only the access token and the axe server it was issued for from stdout, never the refresh token.
44
46
 
45
47
  `axe-auth` itself does **not** communicate with Deque's API services directly. The access tokens it produces are consumed by downstream tools, most notably the axe MCP server, which presents them to Deque's services as `Authorization: Bearer ...`. The one exception is `axe-auth run`, which supervises a running axe MCP server and pushes freshly-minted access tokens to it over a loopback (`127.0.0.1`) connection so a long session survives token expiry without a restart; it never sends the refresh token, only short-lived access tokens.
46
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/axe-auth",
3
- "version": "1.8.0-next.3e251bf3",
3
+ "version": "1.8.0-next.400936bf",
4
4
  "description": "CLI authentication utility for Deque services",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -34,14 +34,14 @@
34
34
  "cross-spawn": "^7.0.6",
35
35
  "remove-trailing-slash": "^0.1.1",
36
36
  "shlex": "^3.0.0",
37
- "ts-dedent": "^2.2.0"
37
+ "ts-dedent": "^2.3.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@hono/node-server": "^2.1.4",
40
+ "@hono/node-server": "^2.1.6",
41
41
  "@types/cross-spawn": "^6.0.6",
42
- "@types/node": "^24.13.3",
42
+ "@types/node": "^24.19.2",
43
43
  "c8": "^12.0.0",
44
- "hono": "^4.13.13",
44
+ "hono": "^4.13.16",
45
45
  "tsx": "^4.23.15",
46
46
  "typescript": "^6.0.3"
47
47
  },