@doist/cli-core 0.13.0 → 0.14.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.14.0](https://github.com/Doist/cli-core/compare/v0.13.0...v0.14.0) (2026-05-16)
2
+
3
+ ### Features
4
+
5
+ * **auth:** tolerate AUTH_STORE_READ_FAILED in logout --user ([#26](https://github.com/Doist/cli-core/issues/26)) ([23652bc](https://github.com/Doist/cli-core/commit/23652bcb436fda917bc10aba99918ce1503786b6))
6
+
1
7
  ## [0.13.0](https://github.com/Doist/cli-core/compare/v0.12.0...v0.13.0) (2026-05-16)
2
8
 
3
9
  ### Features
package/README.md CHANGED
@@ -213,7 +213,7 @@ attachTokenViewCommand<Account>(auth, {
213
213
  })
214
214
  ```
215
215
 
216
- `attachLogoutCommand` snapshots `store.active()` (only when `revokeToken` or `onCleared` is supplied skipped otherwise to avoid keyring / file I/O), calls `store.clear()`, then awaits `revokeToken({ token, account, view, flags })` for best-effort server-side revocation, emits `✓ Logged out` (human) or `{ "ok": true }` (`--json`, silent under `--ndjson`), and finally fires `onCleared({ account, view, flags })`. Local clear runs first so logout always succeeds locally even if the snapshot read fails or the server is unreachable; both `store.active()` and `revokeToken` errors are swallowed (`revokeToken` is also skipped when no session was stored). The exported `AttachLogoutRevokeContext<TAccount>` is the ctx type for typing standalone revoke implementations.
216
+ `attachLogoutCommand` snapshots `store.active(ref)` when either `--user <ref>` is supplied or one of the consumer hooks (`revokeToken` / `onCleared`) needs the prior account, calls `store.clear(ref)`, awaits `revokeToken({ token, account, ref, view, flags })` for best-effort server-side revocation, emits `✓ Logged out` (human) or `{ "ok": true }` (`--json`, silent under `--ndjson`), and finally fires `onCleared({ account, ref, view, flags })`. `ref` is the parsed `--user` argument (or `undefined`) so consumers can distinguish "nothing was stored" (`account: null`, `ref: undefined`) from "cleared an unreadable record by ref" (`account: null`, `ref: "me"`). `revokeToken` failures are always swallowed; the pre-flight snapshot's error contract is covered in the `--user <ref>` section below. The exported `AttachLogoutRevokeContext<TAccount>` is the ctx type for typing standalone revoke implementations.
217
217
 
218
218
  `attachStatusCommand` reads `store.active()`, optionally runs `fetchLive` (consumer translates 401 → `CliError('NO_TOKEN', …)`), then dispatches to `renderJson` (`--json` / `--ndjson` via `formatJson` / `formatNdjson`, defaults to the account itself, **only invoked in machine-output mode**) or `renderText` (human mode, string or array of lines). When the store is empty it throws `CliError('NOT_AUTHENTICATED', 'Not signed in.')` unless `onNotAuthenticated` is supplied.
219
219
 
@@ -338,6 +338,8 @@ Account-selection resolvers (env > `--user` > default > single-only > error), `a
338
338
 
339
339
  `ACCOUNT_NOT_FOUND` is thrown by the account-touching attachers when `--user <ref>` was supplied but `store.active(ref)` returned `null`. `NO_ACCOUNT_SELECTED` is reserved for consumer-thrown resolver failures (multiple accounts stored, no default, no `--user`); cli-core does not throw it itself.
340
340
 
341
+ A `TokenStore` MAY throw `CliError('AUTH_STORE_READ_FAILED', …)` from `active(ref)` when a matching record exists but the token itself can't be read (e.g. an OS keyring backing the store is offline). `attachLogoutCommand` catches this specific code on the explicit-ref path and proceeds with `clear(ref)` — local logout doesn't need the token, and the `revokeToken` hook is skipped because there's no token to send. Every other error from `active(ref)` (notably `ACCOUNT_NOT_FOUND` from a genuine ref miss, plus any consumer-thrown code) still propagates so a real miss isn't masked. Without `--user`, the logout pre-flight swallows any snapshot read failure so the local clear always runs. `attachStatusCommand` and `attachTokenViewCommand` propagate `AUTH_STORE_READ_FAILED` since they have no way to render or print without the token.
342
+
341
343
  #### Custom `AuthProvider` (non-PKCE flows)
342
344
 
343
345
  Implement `AuthProvider` directly for Dynamic Client Registration, device code, magic-link, etc. The four hooks fire in this order during `runOAuthFlow`:
@@ -3,5 +3,5 @@
3
3
  * aggregator in `../errors.ts` so consumers don't have to redeclare them in
4
4
  * their own `TCode` union when catching.
5
5
  */
6
- export type AuthErrorCode = 'AUTH_OAUTH_FAILED' | 'AUTH_CALLBACK_TIMEOUT' | 'AUTH_PORT_BIND_FAILED' | 'AUTH_TOKEN_EXCHANGE_FAILED' | 'AUTH_STORE_WRITE_FAILED' | 'NOT_AUTHENTICATED' | 'TOKEN_FROM_ENV' | 'NO_ACCOUNT_SELECTED' | 'ACCOUNT_NOT_FOUND';
6
+ export type AuthErrorCode = 'AUTH_OAUTH_FAILED' | 'AUTH_CALLBACK_TIMEOUT' | 'AUTH_PORT_BIND_FAILED' | 'AUTH_TOKEN_EXCHANGE_FAILED' | 'AUTH_STORE_WRITE_FAILED' | 'AUTH_STORE_READ_FAILED' | 'NOT_AUTHENTICATED' | 'TOKEN_FROM_ENV' | 'NO_ACCOUNT_SELECTED' | 'ACCOUNT_NOT_FOUND';
7
7
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/auth/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACnB,mBAAmB,GACnB,uBAAuB,GACvB,uBAAuB,GACvB,4BAA4B,GAC5B,yBAAyB,GACzB,mBAAmB,GACnB,gBAAgB,GAChB,qBAAqB,GACrB,mBAAmB,CAAA"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/auth/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACnB,mBAAmB,GACnB,uBAAuB,GACvB,uBAAuB,GACvB,4BAA4B,GAC5B,yBAAyB,GACzB,wBAAwB,GACxB,mBAAmB,GACnB,gBAAgB,GAChB,qBAAqB,GACrB,mBAAmB,CAAA"}
@@ -1,9 +1,16 @@
1
1
  import type { Command } from 'commander';
2
2
  import type { ViewOptions } from '../options.js';
3
- import type { AuthAccount, TokenStore } from './types.js';
3
+ import type { AccountRef, AuthAccount, TokenStore } from './types.js';
4
4
  export type AttachLogoutContext<TAccount extends AuthAccount> = {
5
- /** The account that was active immediately before `clear()` ran, or `null` if nothing was stored. */
5
+ /**
6
+ * The account that was active immediately before `clear()` ran, or
7
+ * `null` if nothing was stored. Also `null` on the `AUTH_STORE_READ_FAILED`
8
+ * recovery path (matching record existed but the token wasn't readable);
9
+ * `ref` is still populated in that case so consumers can distinguish.
10
+ */
6
11
  account: TAccount | null;
12
+ /** The `--user <ref>` value, or `undefined` when not supplied. Always present so consumers can tell "no stored account" from "cleared an unreadable account by ref". */
13
+ ref: AccountRef | undefined;
7
14
  /** `--json` / `--ndjson` flag values, both present (defaulted to `false`). */
8
15
  view: Required<ViewOptions>;
9
16
  /** Consumer-attached options. The registrar flags (`--json`, `--ndjson`, `--user`) are stripped. */
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGzD,MAAM,MAAM,mBAAmB,CAAC,QAAQ,SAAS,WAAW,IAAI;IAC5D,qGAAqG;IACrG,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAA;IACxB,8EAA8E;IAC9E,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;IAC3B,oGAAoG;IACpG,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,yBAAyB,CAAC,QAAQ,SAAS,WAAW,IAAI,IAAI,CACtE,mBAAmB,CAAC,QAAQ,CAAC,EAC7B,SAAS,CACZ,GAAG;IACA,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,OAAO,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,0BAA0B,CAAC,QAAQ,SAAS,WAAW,GAAG,WAAW,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AC7B,SAAS,CACZ,GAAG;IACA,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,OAAO,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,0BAA0B,CAAC,QAAQ,SAAS,WAAW,GAAG,WAAW,IAAI;IACjF,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC3B,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,GAAG,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5E;;;;OAIG;IACH,SAAS,CAAC,CAAC,GAAG,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvE,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,WAAW,GAAG,WAAW,EAC1E,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,0BAA0B,CAAC,QAAQ,CAAC,GAC9C,OAAO,CA+DT"}
@@ -1,3 +1,4 @@
1
+ import { CliError } from '../errors.js';
1
2
  import { formatJson } from '../json.js';
2
3
  import { attachUserFlag, extractUserRef, requireSnapshotForRef } from './user-flag.js';
3
4
  /**
@@ -20,21 +21,30 @@ export function attachLogoutCommand(parent, options) {
20
21
  ndjson: Boolean(ndjson),
21
22
  };
22
23
  const ref = extractUserRef(cmd);
23
- // Explicit ref must surface a typed miss before `clear()` runs —
24
- // `clear(ref)` is contractually a no-op on miss, so otherwise
25
- // `logout --user mistake` would print `✓ Logged out`.
24
+ // Snapshot only when something downstream needs it:
25
+ // - an explicit `--user <ref>` must surface a typed miss before
26
+ // `clear()` runs (otherwise `logout --user mistake` would print
27
+ // `✓ Logged out` after a no-op clear);
28
+ // - either consumer hook is supplied and wants the prior account.
29
+ // `requireSnapshotForRef` handles both `ref === undefined` (returns
30
+ // the snapshot directly) and the explicit-ref path (throws
31
+ // `ACCOUNT_NOT_FOUND` on a null snapshot), so one call covers both.
26
32
  const needsSnapshot = ref !== undefined || Boolean(options.revokeToken || options.onCleared);
27
33
  let snapshot = null;
28
34
  if (needsSnapshot) {
29
- if (ref !== undefined) {
35
+ try {
30
36
  snapshot = await requireSnapshotForRef(options.store, ref);
31
37
  }
32
- else {
33
- try {
34
- snapshot = await options.store.active(ref);
35
- }
36
- catch {
37
- // Snapshot lookup failures must not block local clear.
38
+ catch (error) {
39
+ // Without an explicit ref, any snapshot read failure must
40
+ // not block local clear (we just lose the hooks' account
41
+ // context). With an explicit ref, `AUTH_STORE_READ_FAILED`
42
+ // is the only recoverable case — clear can still run
43
+ // without the token. Everything else (notably
44
+ // `ACCOUNT_NOT_FOUND` from a genuine ref miss) propagates.
45
+ if (ref !== undefined &&
46
+ !(error instanceof CliError && error.code === 'AUTH_STORE_READ_FAILED')) {
47
+ throw error;
38
48
  }
39
49
  }
40
50
  }
@@ -45,6 +55,7 @@ export function attachLogoutCommand(parent, options) {
45
55
  await options.revokeToken({
46
56
  token: snapshot.token,
47
57
  account: snapshot.account,
58
+ ref,
48
59
  view,
49
60
  flags,
50
61
  });
@@ -59,7 +70,7 @@ export function attachLogoutCommand(parent, options) {
59
70
  else if (!view.ndjson) {
60
71
  console.log('✓ Logged out');
61
72
  }
62
- await options.onCleared?.({ account, view, flags });
73
+ await options.onCleared?.({ account, ref, view, flags });
63
74
  });
64
75
  }
65
76
  //# sourceMappingURL=logout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAyCtF;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAC/B,M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CAAC,GAAG,CAAC,CAAA;QAC9B,IAAI,OAAO,CAAC,WAAW,IAAI,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC;gBACD,MAAM,OAAO,CAAC,WAAW,CAAC;oBACtB,KAAK,EAAE,QAAQ,CAAC,KAAK;oBACrB,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,GAAG;oBACH,IAAI;oBACJ,KAAK;iBACR,CAAC,CAAA;YACN,CAAC;YAAC,MAAM,CAAC;gBACL,oEAAoE;YACxE,CAAC;QACL,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACzC,CAAC;aAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QAC/B,CAAC;QACD,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5D,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -71,7 +71,15 @@ export type AccountRef = string;
71
71
  * the README example).
72
72
  */
73
73
  export type TokenStore<TAccount extends AuthAccount = AuthAccount> = {
74
- /** Active snapshot, or `null` when nothing matches (the attachers translate a ref miss into `ACCOUNT_NOT_FOUND`). */
74
+ /**
75
+ * Active snapshot, or `null` when nothing matches (the attachers translate
76
+ * a ref miss into `ACCOUNT_NOT_FOUND`). A store MAY throw
77
+ * `CliError('AUTH_STORE_READ_FAILED', …)` when a matching record exists
78
+ * but the token itself can't be read (e.g. an OS keyring backing the
79
+ * store is offline) — `attachLogoutCommand` catches that code on the
80
+ * explicit-ref path and proceeds with `clear(ref)`; `attachStatusCommand`
81
+ * and `attachTokenViewCommand` propagate it.
82
+ */
75
83
  active(ref?: AccountRef): Promise<{
76
84
  token: string;
77
85
  account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MAAM,CAAC;QAAC,OAAO,EAAE,QAAQ,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAC9E,8JAA8J;IAC9J,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,kEAAkE;IAClE,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,kDAAkD;IAClD,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;QAAE,OAAO,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAA;IACzE,uFAAuF;IACvF,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7C,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/cli-core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Shared core utilities for Doist CLI projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",