@flipstream/sdk 0.7.0 → 0.9.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +211 -65
  3. package/dist/auth/discovery.js +1 -1
  4. package/dist/auth/discovery.js.map +1 -1
  5. package/dist/auth/signIn.js +7 -2
  6. package/dist/auth/signIn.js.map +1 -1
  7. package/dist/core/fetch.d.ts +5 -0
  8. package/dist/core/fetch.js +3 -0
  9. package/dist/core/fetch.js.map +1 -1
  10. package/dist/core/identify.d.ts +63 -0
  11. package/dist/core/identify.js +122 -0
  12. package/dist/core/identify.js.map +1 -0
  13. package/dist/core/names.d.ts +61 -0
  14. package/dist/core/names.js +73 -0
  15. package/dist/core/names.js.map +1 -0
  16. package/dist/core/read.js +8 -2
  17. package/dist/core/read.js.map +1 -1
  18. package/dist/core/result.d.ts +26 -3
  19. package/dist/core/result.js +22 -3
  20. package/dist/core/result.js.map +1 -1
  21. package/dist/core/transport.d.ts +6 -2
  22. package/dist/flipstream.d.ts +47 -3
  23. package/dist/flipstream.js +46 -5
  24. package/dist/flipstream.js.map +1 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/node/clientSecret.js +1 -1
  29. package/dist/node/clientSecret.js.map +1 -1
  30. package/dist/node/index.d.ts +3 -0
  31. package/dist/node/index.js +2 -0
  32. package/dist/node/index.js.map +1 -1
  33. package/dist/node/keychainChild.js +78 -18
  34. package/dist/node/keychainChild.js.map +1 -1
  35. package/dist/node/keychainError.d.ts +53 -0
  36. package/dist/node/keychainError.js +48 -0
  37. package/dist/node/keychainError.js.map +1 -0
  38. package/dist/node/keychainStore.d.ts +19 -9
  39. package/dist/node/keychainStore.js +61 -27
  40. package/dist/node/keychainStore.js.map +1 -1
  41. package/dist/node/session.d.ts +88 -28
  42. package/dist/node/session.js +60 -40
  43. package/dist/node/session.js.map +1 -1
  44. package/dist/node/store.d.ts +11 -1
  45. package/dist/node/store.js +14 -1
  46. package/dist/node/store.js.map +1 -1
  47. package/dist/query/query.d.ts +15 -10
  48. package/dist/query/query.js +21 -11
  49. package/dist/query/query.js.map +1 -1
  50. package/dist/version.gen.js +1 -1
  51. package/package.json +1 -1
@@ -2,6 +2,8 @@ import { spawn } from 'node:child_process';
2
2
  import { Socket } from 'node:net';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { z } from 'zod';
5
+ import { TIMINGS } from './fileLock.js';
6
+ import { KeychainError, refusalKind } from './keychainError.js';
5
7
  import { parse, storeOf } from './store.js';
6
8
  /*
7
9
  * Through `@napi-rs/keyring` (D481), an optional peer dependency that only this store needs, in one
@@ -32,24 +34,42 @@ const MAX_TIMEOUT_MS = 2_147_483_647;
32
34
  * lower limit, and one limit everywhere means tokens that save on one platform save on all.
33
35
  */
34
36
  const LIMIT_BYTES = 2_560;
37
+ /**
38
+ * How long the helper may go on with a save or a delete once this process has gone: less than the
39
+ * soonest `fileLock` passes a dead holder's lock to another process, so a late write can't land over
40
+ * the next holder's. That soonest is 3 s of watching a file whose last touch already looks old (the
41
+ * clock stepped, or the holder's clock was behind), and the last touch may be 1 s before the end:
42
+ * 2 s. A second of that is left for the helper to see its parent go and end.
43
+ */
44
+ const AFTER_PARENT_MS = TIMINGS.oldWatchMs - TIMINGS.touchMs - 1_000;
35
45
  /**
36
46
  * The tokens in the system's own credential store, for a CLI or a tool on the person's own machine:
37
47
  * the macOS keychain, Windows' Credential Manager, or the Secret Service on Linux (GNOME Keyring,
38
48
  * KWallet). One item (`service`, `account`) holds them; a save is one write, seen whole once it has
39
49
  * succeeded, or not at all.
40
50
  *
51
+ * - **Every failure of the keychain or its helper is a `KeychainError`,** whose `failure.kind` says
52
+ * why: the cause of a session's `store_failed`. The store's own three are not: tokens with no
53
+ * access token (a `TypeError`, before any step), an item holding something other than tokens, and
54
+ * an update the item no longer holds the tokens for (a `StoreMovedOnError`, which a sign-out reads
55
+ * as `kept`, and a refresh reports as `store_failed`, step `save`).
41
56
  * - **It needs `@napi-rs/keyring`** (`npm install @napi-rs/keyring`), which nothing else in the
42
- * SDK uses. Without it, every step fails as `store_failed`, and says so.
43
- * - **Linux without a Secret Service** (a server, a container) fails as `store_failed`: use
57
+ * SDK uses. Without it, every step fails as `missing`, and says so.
58
+ * - **Linux without a Secret Service** (a server, a container) fails as `unavailable`: use
44
59
  * `fileStore` there.
45
60
  * - **Its steps run in one helper process,** one at a time: started by the first step and kept
46
61
  * warm while the app runs, for every keychain store of the process. A step past its `timeoutMs`
47
- * (30 s) kills it, and the next step starts another. A step whose helper died before it answered
48
- * (a terminal Ctrl-C reaches the helper too) runs once more on a fresh one, within its `timeoutMs`.
49
- * It never keeps the app running, and it ends with the app. It is `process.execPath`, so it needs a Node that runs a script: not an Electron
62
+ * (30 s) kills it, and the next step starts another. It ignores a terminal Ctrl-C from before
63
+ * its own code loads, though not during Node's start-up or a preload in `NODE_OPTIONS`. A step whose
64
+ * helper died before it answered runs once more on a fresh one, within its `timeoutMs`. It never
65
+ * keeps the app running. When the app ends, it ends too: at once when idle or on a read, or once
66
+ * the save or delete it's on is done, within that step's `timeoutMs` and 1 s at most, so a
67
+ * refresh's save isn't lost to a Ctrl-C. 1 s is less than the soonest `fileLock` lets another
68
+ * process take the app's lock. For a helper's first step, the 1 s counts from the helper's own
69
+ * start, so a slow start can't stretch it, and that step may be cut sooner. It is `process.execPath`, so it needs a Node that runs a script: not an Electron
50
70
  * app (without `ELECTRON_RUN_AS_NODE`), a Node single-executable application, or a compiled Bun
51
71
  * binary.
52
- * - **Tokens over 2,560 bytes** fail the save, with nothing written.
72
+ * - **Tokens over 2,560 bytes** fail the save as `too-long`, with nothing written.
53
73
  */
54
74
  export function keychainStore(options) {
55
75
  const { service, account, timeoutMs = TIMEOUT_MS } = options;
@@ -67,8 +87,9 @@ export function keychainStore(options) {
67
87
  return;
68
88
  }
69
89
  const secret = JSON.stringify(tokens);
70
- if (Buffer.byteLength(secret, 'utf8') > LIMIT_BYTES)
71
- throw new Error(`the tokens are too long for the keychain store (over ${LIMIT_BYTES} bytes): nothing was saved`);
90
+ const bytes = Buffer.byteLength(secret, 'utf8');
91
+ if (bytes > LIMIT_BYTES)
92
+ throw new KeychainError(`the tokens are too long for the keychain store (over ${LIMIT_BYTES} bytes): nothing was saved`, { kind: 'too-long', bytes });
72
93
  await inChild({ op: 'set', ...item, secret }, timeoutMs);
73
94
  });
74
95
  }
@@ -93,7 +114,7 @@ let lastId = 0;
93
114
  function inChild(request, timeoutMs) {
94
115
  const script = childScript();
95
116
  if (script === undefined)
96
- return Promise.reject(new Error("the keychain store can't find its child script, keychainChild.js: this module's import.meta.url is empty, as a CommonJS bundle may leave it"));
117
+ return Promise.reject(new KeychainError("the keychain store can't find its child script, keychainChild.js: this module's import.meta.url is empty, as a CommonJS bundle may leave it", { kind: 'helper', exit: null }));
97
118
  return new Promise((resolve, reject) => {
98
119
  const deadline = Date.now() + timeoutMs;
99
120
  let settled = false;
@@ -108,7 +129,7 @@ function inChild(request, timeoutMs) {
108
129
  };
109
130
  const late = () => {
110
131
  settle(() => {
111
- reject(new Error(`the keychain didn't answer within ${timeoutMs / 1000} s`));
132
+ reject(new KeychainError(`the keychain didn't answer within ${timeoutMs / 1000} s`, { kind: 'timeout', timeoutMs }));
112
133
  });
113
134
  };
114
135
  const timer = setTimeout(() => {
@@ -117,9 +138,10 @@ function inChild(request, timeoutMs) {
117
138
  late();
118
139
  }, timeoutMs);
119
140
  // Exactly once more, on a fresh helper and within the same deadline, when the first helper
120
- // closed before it answered: one killed with the app's process group (a terminal Ctrl-C, which
121
- // an app may handle and go on), or one that died while idle. Every step is safe to repeat: a
122
- // read or a delete changes nothing twice, and a save writes the same tokens again.
141
+ // closed before it answered: one that crashed, died while idle, or was killed with the app's
142
+ // process group by a signal the app may handle and go on from. Ctrl-C isn't one of those: the
143
+ // helper ignores it (#169). Every step is safe to repeat: a read or a delete changes nothing
144
+ // twice, and a save writes the same tokens again.
123
145
  const turn = async () => {
124
146
  for (let attempt = 1; attempt <= 2; attempt++) {
125
147
  if (settled)
@@ -139,26 +161,30 @@ function inChild(request, timeoutMs) {
139
161
  }
140
162
  helper = current;
141
163
  sentTo = current;
142
- const answer = await ask(current, { id: ++lastId, ...request });
164
+ // With its time left, which the helper keeps to if this process ends while it's on the step.
165
+ const answer = await ask(current, { id: ++lastId, msLeft: Math.max(1, deadline - Date.now()), afterParentMs: AFTER_PARENT_MS, parent: process.pid, ...request });
143
166
  sentTo = null;
144
167
  if (answer instanceof HelperClosed && attempt === 1)
145
168
  continue;
146
169
  settle(() => {
147
- if (answer instanceof Error)
170
+ if (answer instanceof HelperClosed)
171
+ reject(new KeychainError(answer.message, { kind: 'helper', exit: answer.exit }));
172
+ else if (answer instanceof Error)
148
173
  reject(answer);
149
174
  else if (answer.ok)
150
175
  resolve(answer.value);
151
176
  else if (answer.missing === true)
152
- reject(new Error('the keychain store needs the optional package @napi-rs/keyring, which is not installed: npm install @napi-rs/keyring'));
177
+ reject(new KeychainError('the keychain store needs the optional package @napi-rs/keyring, which is not installed: npm install @napi-rs/keyring', { kind: 'missing' }));
153
178
  else
154
- reject(new Error(`the keychain refused the ${STEP[request.op]}: ${answer.error}`));
179
+ reject(new KeychainError(`the keychain refused the ${STEP[request.op]}: ${answer.error}`, { kind: refusalKind(answer.error) }));
155
180
  });
156
181
  return;
157
182
  }
158
183
  };
184
+ // A helper that threw while it was being started, as on a spawn that gave no stdio at all.
159
185
  queue = queue.then(turn).catch((error) => {
160
186
  settle(() => {
161
- reject(error instanceof Error ? error : new Error(String(error)));
187
+ reject(new KeychainError("the keychain helper couldn't start", { kind: 'helper', exit: null }, { cause: error }));
162
188
  });
163
189
  });
164
190
  });
@@ -185,17 +211,17 @@ function startHelper(script) {
185
211
  let started = null;
186
212
  child.on('error', (error) => {
187
213
  if (started !== null)
188
- gone(started, new Error("the keychain helper couldn't start", { cause: error }));
214
+ gone(started, new KeychainError("the keychain helper couldn't start", { kind: 'helper', exit: null }, { cause: error }));
189
215
  });
190
216
  const [stdin, , , answers] = child.stdio;
191
217
  if (!(stdin instanceof Socket) || !(answers instanceof Socket)) {
192
218
  child.kill('SIGKILL');
193
- return new Error("the keychain helper's pipes didn't open");
219
+ return new KeychainError("the keychain helper's pipes didn't open", { kind: 'helper', exit: null });
194
220
  }
195
- const ready = { child, stdin, answers, waiting: null };
221
+ const ready = { child, stdin, answers, waiting: null, unreadable: false };
196
222
  started = ready;
197
- child.on('close', () => {
198
- gone(ready, new HelperClosed());
223
+ child.on('close', (code, signal) => {
224
+ gone(ready, new HelperClosed({ code, signal }, ready.unreadable));
199
225
  });
200
226
  // A helper that died closes the pipe under a write; its close reports it.
201
227
  stdin.on('error', () => undefined);
@@ -210,6 +236,7 @@ function startHelper(script) {
210
236
  // Anything but the awaited step's answer: the helper can't be trusted with the next step.
211
237
  // Its close then settles the step that waits.
212
238
  if (answer === undefined || waiting === null || answer.id !== waiting.id) {
239
+ ready.unreadable = true;
213
240
  stop(ready);
214
241
  return;
215
242
  }
@@ -220,11 +247,17 @@ function startHelper(script) {
220
247
  idle(ready);
221
248
  return ready;
222
249
  }
223
- /** A helper that closed before it answered: the step it was answering may run once more (`inChild`). */
250
+ /**
251
+ * A helper that closed before it answered: the step it was answering may run once more (`inChild`).
252
+ * How it ended goes in the message (#157 item 2), never anything it printed, where a token could be.
253
+ */
224
254
  class HelperClosed extends Error {
225
- constructor() {
226
- super('the keychain step gave no readable answer');
255
+ exit;
256
+ constructor(exit, unreadable) {
257
+ const how = exit.signal !== null ? `signal ${exit.signal}` : exit.code !== null ? `exit ${exit.code}` : 'no exit status';
258
+ super(unreadable ? `the keychain step's answer couldn't be read, so its helper was stopped (${how})` : `the keychain step gave no readable answer (${how})`);
227
259
  this.name = 'HelperClosed';
260
+ this.exit = exit;
228
261
  }
229
262
  }
230
263
  /** A helper that died or couldn't start: the next step starts another, and the step it was answering fails with `reason`. */
@@ -243,7 +276,8 @@ function stop(stopping) {
243
276
  }
244
277
  // While a step waits, the helper and its pipes keep this process alive; between steps they don't,
245
278
  // so a warm helper never holds up the app's exit. When this process ends, however it ends, the
246
- // helper's standard input closes, and the helper kills itself.
279
+ // helper's standard input closes, and the helper ends: at once when idle or on a read, or once the
280
+ // save or delete it's on is done or cut off (keychainChild.ts).
247
281
  function busy(of) {
248
282
  of.child.ref();
249
283
  of.stdin.ref();
@@ -1 +1 @@
1
- {"version":3,"file":"keychainStore.js","sourceRoot":"","sources":["../../src/node/keychainStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAmB,MAAM,YAAY,CAAA;AAgB5D;;;;;;GAMG;AACH;;;;GAIG;AACH,SAAS,WAAW;IAClB,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AACD,MAAM,UAAU,GAAG,MAAM,CAAA;AACzB,2FAA2F;AAC3F,MAAM,cAAc,GAAG,aAAa,CAAA;AACpC;;;;GAIG;AACH,MAAM,WAAW,GAAG,KAAK,CAAA;AAEzB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,GAAG,UAAU,EAAE,GAAG,OAAO,CAAA;IAC5D,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,EAAE;QAAE,MAAM,IAAI,SAAS,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SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,MAAe,CAAA;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACxC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACjD,CAAC"}
@@ -70,6 +70,17 @@ export type SessionOptions = Pick<AuthCallOptions, 'fetch' | 'allowLocalhostHttp
70
70
  * no server text (`finishSignIn`'s rule). Left out, the session is a public client's. Never log it.
71
71
  */
72
72
  readonly clientSecret?: string | undefined;
73
+ /**
74
+ * How long a `token()` caller waits for its token in all, the store's read included, before it
75
+ * gets `unavailable`: 15 s when left out (#131, D497). A whole number of ms, from 1 to
76
+ * 2,147,483,647, the timers' own limit, or a TypeError at creation. Give a store that can wait on
77
+ * a person, such as a keychain asking for access, as long as that person may take: the CLI's
78
+ * 120 s when interactive, say. Only this wait changes. A refresh still waits at most 60 s for its
79
+ * lock and its answer, then its re-read and save are waited out, as before; a sign-out sends
80
+ * nothing after its 10 s; and D487's 60 s bounds on a sign-out's lock and store calls stay as
81
+ * they are.
82
+ */
83
+ readonly waitMs?: number | undefined;
73
84
  /**
74
85
  * The tokens as the store holds them now, or null when nobody is signed in. Read again before
75
86
  * every refresh, so the refresh token sent is the current one, even after another process
@@ -90,9 +101,15 @@ export type SessionOptions = Pick<AuthCallOptions, 'fetch' | 'allowLocalhostHttp
90
101
  * (`refreshToken || accessToken`) is still `update.replaces`. The session reads the
91
102
  * store again just before, and lets the answer go when the store has moved on (a newer sign-in,
92
103
  * or a sign-out); comparing and setting on `replaces` closes the moment between that read and
93
- * this write, and a store that refuses then throws. A refresh's answer is used only once this has
104
+ * this write, and a store that refuses then throws a `StoreMovedOnError`: a sign-out reads it as
105
+ * the store keeping what it now holds (`kept`), and any other throw as the store failing
106
+ * (`failed`, D534). A refresh's answer is used only once this has
94
107
  * settled. When a save fails, the session keeps a rotation's refresh token in memory, the only
95
108
  * live one, for its next refresh and for `revoke()` (D456).
109
+ *
110
+ * Never call the session from this, or from `tokens`: both run inside the session's own turn. A
111
+ * `revoke()` there waits for that turn for ever, answering only at its `signal`, and a `token()`
112
+ * answers only at its `waitMs`.
96
113
  */
97
114
  readonly onTokens: (update: TokenUpdate) => void | Promise<void>;
98
115
  /**
@@ -128,7 +145,7 @@ export type SessionFailure =
128
145
  {
129
146
  readonly kind: 'signed-out';
130
147
  }
131
- /** No token within 15 s, or no answer at all: offline, or the server is down. A refresh goes on, and its answer is still saved. */
148
+ /** No token within the caller's wait (`waitMs`, 15 s by default), or no answer at all: offline, or the server is down. A refresh goes on, and its answer is still saved. */
132
149
  | {
133
150
  readonly kind: 'unavailable';
134
151
  }
@@ -149,12 +166,14 @@ export declare class SessionError extends Error {
149
166
  constructor(failure: SessionFailure);
150
167
  }
151
168
  /**
152
- * How a revocation came out (RFC 7009). pulse-auth answers a revocation 200 whatever it was sent,
153
- * so that answer proves nothing: `revoked` rests on the issuer taking the session's access token
154
- * just before and refusing it just after (D461, D464). Either way, what the app clears locally is
155
- * its own call.
169
+ * How a sign-out came out: at the server (`kind`), and in the store (`cleared`, D526), with where
170
+ * the store failed when it did (`failure`, D549).
171
+ *
172
+ * The server's half (RFC 7009): pulse-auth answers a revocation 200 whatever it was sent, so that
173
+ * answer proves nothing: `revoked` rests on the issuer taking the session's access token just before
174
+ * and refusing it just after (D461, D464).
156
175
  */
157
- export type RevokeResult = {
176
+ export type RevokeResult = ({
158
177
  readonly kind: 'revoked';
159
178
  } | {
160
179
  readonly kind: 'unconfirmed';
@@ -186,7 +205,43 @@ export type RevokeResult = {
186
205
  } | Extract<SessionFailure, {
187
206
  readonly kind: 'store_failed';
188
207
  }>;
189
- };
208
+ }) & ({
209
+ /**
210
+ * What became of the session in the store, whatever `kind` says:
211
+ * - `cleared`: `onTokens` cleared it (`cleared`);
212
+ * - `kept`: nothing of this session's to clear: nothing was stored, or the store moved on
213
+ * after the turn read it, to a newer sign-in, which is kept, or to another sign-out's
214
+ * clear. The session's own read finds it, or the store says so by refusing the clear with
215
+ * a `StoreMovedOnError` (D534);
216
+ * - `failed` (the other arm): the store failed, and `failure` says where and how (D549);
217
+ * - `cut`: a 60 s bound ran out (D487), on the lock or on a store call. A store call cut off
218
+ * may still finish on its own;
219
+ * - `pending`: the caller's `signal` answered first, so the store may still hold the tokens.
220
+ * The clear goes on, and `settled()` waits for it. With a signal that had fired before the
221
+ * call, nothing runs: no turn, no lock, no clear (D532).
222
+ *
223
+ * After any but `cleared` and `kept`, the tokens may still be stored: until the next refresh
224
+ * meets `invalid_grant`, or, for a store holding only an access token, until that token
225
+ * expires.
226
+ */
227
+ readonly cleared: 'cleared' | 'kept' | 'cut' | 'pending';
228
+ } | {
229
+ /** The store failed, so the tokens may still be stored: `failure` says where and how (D549). */
230
+ readonly cleared: 'failed';
231
+ /**
232
+ * Where the store failed, and what it threw: `read`, the tokens' read (the turn's, or the
233
+ * clear's own check); `lock`, the app's lock, before the turn began; `clear`, `onTokens`'s
234
+ * clear, with any throw but a `StoreMovedOnError`. Nothing more is asked of the store.
235
+ * `cause` is what the store threw, unchanged, except that a clear or a lock rejecting with
236
+ * something other than an `Error` gives an `Error` carrying its text (#235). For
237
+ * `keychainStore`, `cause` is a `KeychainError`, whose `failure.kind` and message say why,
238
+ * never with a token in them.
239
+ */
240
+ readonly failure: {
241
+ readonly step: 'read' | 'lock' | 'clear';
242
+ readonly cause: unknown;
243
+ };
244
+ });
190
245
  export interface Session {
191
246
  /**
192
247
  * The token function for `createFlipstream` (or `fetchTransport`): the access token while it has
@@ -196,43 +251,48 @@ export interface Session {
196
251
  */
197
252
  token(ask?: TokenAsk): Promise<string>;
198
253
  /**
199
- * Ends the session at the server (RFC 7009), with the tokens read once no refresh is spending
200
- * them, inside the app's `lock` when there is one, all within 10 s, with nothing sent after. An
201
- * access token known to have at least 30 s left is checked at the issuer, revoked (pulse-auth
202
- * ends the whole session by it, whatever became of the refresh token) and checked again: only
203
- * taken before and refused after is `revoked`. Without such a token, or when the check before
204
- * fails, the live refresh token goes (the store's, or a rotation's whose save failed, D456), and
205
- * the result is `unconfirmed`.
254
+ * Ends the session at the server (RFC 7009), then clears it from the store, and answers once both
255
+ * are done (D526): `kind` for the server, `cleared` for the store. The revocation uses the tokens
256
+ * read once no refresh is spending them, inside the app's `lock` when there is one, and is sent
257
+ * within 10 s, with nothing sent after. An access token known to have at least 30 s left is
258
+ * checked at the issuer, revoked (pulse-auth ends the whole session by it, whatever became of the
259
+ * refresh token) and checked again: only taken before and refused after is `revoked`. Without
260
+ * such a token, or when the check before fails, the live refresh token goes (the store's, or a
261
+ * rotation's whose save failed, D456), and the result is `unconfirmed`.
206
262
  *
207
263
  * A sign-out ends the session the store holds when its turn comes (#134), a newer sign-in from
208
264
  * another terminal included: signing out means this person is signed out on this machine (D484).
209
265
  * Its turn is queued at the call, and in one hold of the app's lock it revokes that session, then
210
266
  * clears it from the store through `onTokens` (`cleared`), once, however the revocation went: in
211
267
  * time or too late to send anything, aborted by the caller (D478), failed, or with any result. A
212
- * sign-in saved after the turn read the store is kept. The caller waits for the clear within its
213
- * 10 s.
268
+ * sign-in saved after the turn read the store is kept (`kept`).
214
269
  *
215
270
  * A refresh token the session holds only in memory, because saving it failed (D456), goes too once
216
271
  * the store has moved on from the token it replaced: as a refresh token, after the stored session,
217
272
  * in the same 10 s. One sign-out sends it, whatever the result, and the session then lets it go
218
273
  * (D500). Its send failing is the result when the stored session's went as well as it can.
219
274
  *
220
- * Once the turn reaches the lock, it waits at most 60 s for it, and at most 60 s for each store
221
- * call; then it gives up, touching nothing more, and later turns run (D487). So after `timeout`
222
- * or `aborted` the clear may still be on its way: 60 s for the lock and for each of its three
223
- * store calls, so up to about four minutes after the turn reaches the lock, plus any queue ahead
224
- * of it. A lock held longer than its 60 s by another process, or a store call that doesn't answer
225
- * within its 60 s, leaves the store as it was. A clear the
226
- * store fails leaves the tokens too: until the next refresh meets `invalid_grant`, or, for a store
227
- * holding only an access token, until that token expires.
275
+ * The answer waits for the clear, so it can come well after the 10 s. This reverses #140's "a
276
+ * stalled clear holds the queue, not the caller" for the caller of `revoke()` (D526). It waits
277
+ * for the queue ahead of the turn for as long as that takes: a refresh's re-read and save are
278
+ * waited out, and so is a lock that ignores its signal (rev197's O2.F1). Once the turn reaches the
279
+ * lock, it waits at most 60 s for it, and at most 60 s for each of its three store calls (D487),
280
+ * so up to about four minutes. Past a bound, the turn gives up, touching nothing more, and
281
+ * answers with `cleared: 'cut'`, and later turns run. A lock held longer than its 60 s by another
282
+ * process leaves the store as it was, and so does a store call that hasn't answered within its
283
+ * 60 s, unless it finishes later on its own. `signal` is the way out: it answers at once, with the
284
+ * revocation's result once that is known, or `aborted`, and `cleared: 'pending'`, while the clear
285
+ * goes on. A signal that had fired before the call runs nothing at all, and answers `aborted` and
286
+ * `pending` too (D532).
228
287
  */
229
288
  revoke(options?: Pick<AuthCallOptions, 'signal'>): Promise<RevokeResult>;
230
289
  /**
231
290
  * Resolves once nothing is in flight in this session: no refresh, no save, no sign-out, and no
232
291
  * `token()` still reading the store before it queues a refresh (#170, D516). Await it before the
233
- * process exits, on Ctrl-C or after `unavailable`: `token()` answers at its 15 s and `revoke()`
234
- * at its 10 s while their work goes on, and an exit then can cut a refresh after pulse-auth has
235
- * rotated, losing the new token. Work that starts while it waits is waited for too.
292
+ * process exits, on Ctrl-C or after `unavailable`: `token()` answers at its `waitMs` while its
293
+ * refresh goes on, and `revoke()` at its `signal` while its clear goes on, and an exit then can
294
+ * cut a refresh after pulse-auth has rotated, losing the new token. Work that starts while it
295
+ * waits is waited for too.
236
296
  *
237
297
  * It never rejects, and it starts no work. It waits at most as long as the session's own limits
238
298
  * (D521): a refresh's 60 s for its lock and its request (D445), and a sign-out's 60 s for the lock