@flipstream/sdk 0.5.0 → 0.7.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 (57) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +325 -53
  3. package/dist/auth/discovery.d.ts +5 -4
  4. package/dist/auth/discovery.js +10 -8
  5. package/dist/auth/discovery.js.map +1 -1
  6. package/dist/auth/signIn.js +10 -5
  7. package/dist/auth/signIn.js.map +1 -1
  8. package/dist/auth/transport.d.ts +20 -2
  9. package/dist/auth/transport.js +25 -5
  10. package/dist/auth/transport.js.map +1 -1
  11. package/dist/core/fetch.d.ts +5 -0
  12. package/dist/core/fetch.js +8 -1
  13. package/dist/core/fetch.js.map +1 -1
  14. package/dist/flipstream.d.ts +8 -0
  15. package/dist/flipstream.js +4 -3
  16. package/dist/flipstream.js.map +1 -1
  17. package/dist/index.d.ts +3 -1
  18. package/dist/index.js +4 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/node/fileLock.d.ts +21 -0
  21. package/dist/node/fileLock.js +36 -48
  22. package/dist/node/fileLock.js.map +1 -1
  23. package/dist/node/fileStore.d.ts +41 -0
  24. package/dist/node/fileStore.js +137 -0
  25. package/dist/node/fileStore.js.map +1 -0
  26. package/dist/node/index.d.ts +4 -0
  27. package/dist/node/index.js +3 -1
  28. package/dist/node/index.js.map +1 -1
  29. package/dist/node/keychainChild.d.ts +1 -0
  30. package/dist/node/keychainChild.js +136 -0
  31. package/dist/node/keychainChild.js.map +1 -0
  32. package/dist/node/keychainStore.d.ts +34 -0
  33. package/dist/node/keychainStore.js +268 -0
  34. package/dist/node/keychainStore.js.map +1 -0
  35. package/dist/node/loopback.js +1 -1
  36. package/dist/node/loopback.js.map +1 -1
  37. package/dist/node/session.d.ts +73 -12
  38. package/dist/node/session.js +248 -35
  39. package/dist/node/session.js.map +1 -1
  40. package/dist/node/store.d.ts +48 -0
  41. package/dist/node/store.js +99 -0
  42. package/dist/node/store.js.map +1 -0
  43. package/dist/query/catalog.d.ts +271 -2
  44. package/dist/query/catalog.js +93 -5
  45. package/dist/query/catalog.js.map +1 -1
  46. package/dist/query/query.d.ts +14 -5
  47. package/dist/query/query.js +21 -6
  48. package/dist/query/query.js.map +1 -1
  49. package/dist/spec/query-planner/index.d.ts +1 -1
  50. package/dist/spec/query-planner/types.gen.d.ts +35 -4
  51. package/dist/spec/query-planner/zod.gen.d.ts +257 -64
  52. package/dist/spec/query-planner/zod.gen.js +31 -5
  53. package/dist/spec/query-planner/zod.gen.js.map +1 -1
  54. package/dist/version.gen.d.ts +2 -0
  55. package/dist/version.gen.js +4 -0
  56. package/dist/version.gen.js.map +1 -0
  57. package/package.json +9 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.0](https://github.com/flipstream-io/sdk/compare/typescript-v0.6.0...typescript-v0.7.0) (2026-10-18)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **typescript:** Format is a union on type. Read decimals, format or thousandSeparator only after narrowing on type. An unknown type arrives as { type: 'unknown', declared }, and a known type with a part missing makes the answer invalid.
9
+
10
+ ### Features
11
+
12
+ * **typescript:** a field's format is a union on its type ([#156](https://github.com/flipstream-io/sdk/issues/156)) ([4427029](https://github.com/flipstream-io/sdk/commit/4427029741b88d54322596cad3458837b682eea9))
13
+ * **typescript:** an app can check a query's fields before it sends ([#184](https://github.com/flipstream-io/sdk/issues/184)) ([c708b78](https://github.com/flipstream-io/sdk/commit/c708b78cdced950d2dfb69dcf06a129a883899eb))
14
+ * **typescript:** fileStore(path, { lock: true }) also returns its lock ([#186](https://github.com/flipstream-io/sdk/issues/186)) ([f34b6f4](https://github.com/flipstream-io/sdk/commit/f34b6f4e7c431ad697dbdfc7d0f4b129f900e74b))
15
+ * **typescript:** onWarning decides where the SDK's warnings go ([#173](https://github.com/flipstream-io/sdk/issues/173)) ([11e1f58](https://github.com/flipstream-io/sdk/commit/11e1f589596af28cd129f88b236729acb440e000))
16
+ * **typescript:** session.settled() waits for the session before an exit ([#185](https://github.com/flipstream-io/sdk/issues/185)) ([9aa6dc5](https://github.com/flipstream-io/sdk/commit/9aa6dc51cde1ebecd51d2dcfb62c0cd0b4d75977))
17
+ * **typescript:** sign-in accepts a local http auth server, opt-in ([#172](https://github.com/flipstream-io/sdk/issues/172)) ([e626d08](https://github.com/flipstream-io/sdk/commit/e626d08651992144aba3464632272511cb39bea3))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **typescript:** a sign-out also revokes a rotation held only in memory ([#167](https://github.com/flipstream-io/sdk/issues/167)) ([826f925](https://github.com/flipstream-io/sdk/commit/826f925b77289c40ff77137ad9ca19a47ee49d56))
23
+ * **typescript:** two spellings of one token file take one turn ([#174](https://github.com/flipstream-io/sdk/issues/174)) ([2c0d893](https://github.com/flipstream-io/sdk/commit/2c0d893cdff87b2b2839a32b10fb0806191774f6))
24
+
25
+
26
+ ### Performance Improvements
27
+
28
+ * **typescript:** keychainStore keeps one helper process warm ([#159](https://github.com/flipstream-io/sdk/issues/159)) ([f2823e6](https://github.com/flipstream-io/sdk/commit/f2823e6200152f12eb4f1eb436c76a46d1567a51))
29
+
30
+
31
+ ### Documentation
32
+
33
+ * **typescript:** fileLock on Ctrl-C, and the decisions behind its rules ([#166](https://github.com/flipstream-io/sdk/issues/166)) ([49d936d](https://github.com/flipstream-io/sdk/commit/49d936d0695f3f34d53c3ec56dfebb5258644b76))
34
+ * **typescript:** keychain by default, and fileLock's Windows limits ([#158](https://github.com/flipstream-io/sdk/issues/158)) ([d463a9c](https://github.com/flipstream-io/sdk/commit/d463a9cd0899751234551b0cb0f971b4a1312606))
35
+ * **typescript:** on Ctrl-C, a hold still waiting for the lock gives up ([#180](https://github.com/flipstream-io/sdk/issues/180)) ([cef2e80](https://github.com/flipstream-io/sdk/commit/cef2e805159dea0ebcd7604b8fb896b1e5f27e97))
36
+
37
+
38
+ ### Tests
39
+
40
+ * **typescript:** check:lock-live cleans up after a failed case ([#177](https://github.com/flipstream-io/sdk/issues/177)) ([648d36a](https://github.com/flipstream-io/sdk/commit/648d36a226e7f911037c18925822539cf32ad246))
41
+ * **typescript:** check:lock-live's third case, across two processes ([#179](https://github.com/flipstream-io/sdk/issues/179)) ([127444e](https://github.com/flipstream-io/sdk/commit/127444e8c54d8431ae696e7a1228a56743a68fcc))
42
+ * **typescript:** fileLock's slow cases run on a quarter of its timings ([#161](https://github.com/flipstream-io/sdk/issues/161)) ([e1126dd](https://github.com/flipstream-io/sdk/commit/e1126dd80b9e7ffd5c1a71e948fbe5e0be1fcb90))
43
+ * **typescript:** install:check holds the keyring to an optional peer ([#178](https://github.com/flipstream-io/sdk/issues/178)) ([ee2fce7](https://github.com/flipstream-io/sdk/commit/ee2fce7a21df523f7433a3d858fd258146652ed1))
44
+ * **typescript:** no lock turn outlives check:lock-live's clean-up ([#182](https://github.com/flipstream-io/sdk/issues/182)) ([bf603dc](https://github.com/flipstream-io/sdk/commit/bf603dcf24ddfaf2f3af0fce5895c3660c5f58d9))
45
+ * **typescript:** session.test.mjs ends in 5 s, not 60 s ([#162](https://github.com/flipstream-io/sdk/issues/162)) ([de96632](https://github.com/flipstream-io/sdk/commit/de96632c287b26ec6b4f58a373ab84640a95e208))
46
+
47
+ ## [0.6.0](https://github.com/flipstream-io/sdk/compare/typescript-v0.5.0...typescript-v0.6.0) (2026-10-17)
48
+
49
+
50
+ ### Features
51
+
52
+ * **typescript:** a sign-out clears the store, once, however it ends ([#140](https://github.com/flipstream-io/sdk/issues/140)) ([e594331](https://github.com/flipstream-io/sdk/commit/e594331fc796bebdc125cc58b6ed9eaedb2d9549))
53
+ * **typescript:** createSession({ issuer }) discovers on first need ([#152](https://github.com/flipstream-io/sdk/issues/152)) ([3120bf7](https://github.com/flipstream-io/sdk/commit/3120bf7bc20f8651b85fd91a7806710e4d132850))
54
+ * **typescript:** keychain and file token stores in /node ([#142](https://github.com/flipstream-io/sdk/issues/142)) ([bc81870](https://github.com/flipstream-io/sdk/commit/bc8187045dcf05a30952fba1971ba52eb6db86cf))
55
+ * **typescript:** version, the SDK's own version, readable at run time ([#148](https://github.com/flipstream-io/sdk/issues/148)) ([ac287e0](https://github.com/flipstream-io/sdk/commit/ac287e06d790971fee316335e73e1401790054bb))
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * **typescript:** fileLock restarts its watch after a clock jump ([#145](https://github.com/flipstream-io/sdk/issues/145)) ([4990d88](https://github.com/flipstream-io/sdk/commit/4990d886c81e7faa43473c6d0f90176307ecda0a))
61
+
62
+
63
+ ### Tests
64
+
65
+ * **typescript:** an opt-in check of a sign-out behind a real fileLock ([#155](https://github.com/flipstream-io/sdk/issues/155)) ([5a1956c](https://github.com/flipstream-io/sdk/commit/5a1956cd0af293d656b60c81025076193ba547da))
66
+
67
+
68
+ ### CI
69
+
70
+ * close three blind spots in the root check scripts ([#150](https://github.com/flipstream-io/sdk/issues/150)) ([00e6d41](https://github.com/flipstream-io/sdk/commit/00e6d415da1dfcd6aa1dc434547a3661d0a89ec4))
71
+
3
72
  ## [0.5.0](https://github.com/flipstream-io/sdk/compare/typescript-v0.4.0...typescript-v0.5.0) (2026-10-17)
4
73
 
5
74
 
package/README.md CHANGED
@@ -46,16 +46,56 @@ console.log(answer.rows, answer.lastRow)
46
46
  The catalogue names each source with its dimensions and metrics. `fs.catalog.get({ source })` gives
47
47
  one source.
48
48
 
49
+ Each dimension and metric has a `format`, a union on its `type`:
50
+ - `number`, `currency` and `percentage` carry `decimals`, and a `number` may carry
51
+ `thousandSeparator`;
52
+ - `date` carries its pattern, `YYYY-MM-DD`;
53
+ - `string` carries nothing more.
54
+
55
+ A type this version of the SDK doesn't know arrives as `{ type: 'unknown', declared }`, naming the
56
+ type it came as, and the rest of the catalogue reads as usual. The SDK then warns once per process
57
+ for each such type, on the console, or to your `onWarning` (see "Options"). The warning names the
58
+ type, the source and field it was first seen on, and how to update the SDK. A known type with a
59
+ part missing, such as a
60
+ `number` without `decimals`, makes the answer `invalid`, like any other answer that breaks the
61
+ contract.
62
+
63
+ ```ts
64
+ import type { Format } from '@flipstream/sdk'
65
+
66
+ function shownAs(format: Format): string {
67
+ switch (format.type) {
68
+ case 'number':
69
+ case 'currency':
70
+ case 'percentage':
71
+ return `${format.type}, ${format.decimals} decimals`
72
+ case 'date':
73
+ return `a date, ${format.format}`
74
+ case 'string':
75
+ return 'text'
76
+ case 'unknown':
77
+ return `as it comes (${format.declared})`
78
+ }
79
+ }
80
+ ```
81
+
49
82
  ## Signing in from Node and the CLI
50
83
 
51
84
  For an app that runs on the person's own machine, or in their terminal: a CLI, a script, a local
52
85
  tool. `@flipstream/sdk/node` signs them in through their browser, with OAuth 2.0's authorisation
53
- code and PKCE. The SDK stores nothing: the tokens are the app's to keep. A web app signs in on its
54
- server instead (see "In a browser").
86
+ code and PKCE. Signing in stores nothing: the tokens are the app's to keep, and the SDK has stores
87
+ ready for them (see "Keeping the person signed in"). A web app signs in on its server instead (see
88
+ "In a browser").
55
89
 
56
90
  In a TypeScript project, add `@types/node` (`npm install --save-dev @types/node`): this entry's
57
91
  types use Node's own.
58
92
 
93
+ **Against an auth server on your own machine,** while developing it, pass `allowLocalhostHttp: true`
94
+ to `discover`, `signInWithLoopback`, `finishSignIn` and `createSession`, as `createFlipstream` takes
95
+ it. Plain http is then accepted for `localhost`, `127.0.0.1` and `[::1]` only, and every endpoint
96
+ such a server names must be on its own origin. It's off unless your code sets it: the SDK never
97
+ reads it from the environment. Never set it in production.
98
+
59
99
  ### With a browser on the same machine
60
100
 
61
101
  `signInWithLoopback` opens a one-time server on `127.0.0.1`, on a port the system chooses, and
@@ -176,16 +216,158 @@ if (isHeadless(process.env)) {
176
216
  ### Keeping the person signed in
177
217
 
178
218
  `createSession` keeps an access token fresh from the tokens your store holds, and signs the person
179
- out. It holds a refresh token, so it belongs in a CLI or on a server, never in browser code.
219
+ out. It holds a refresh token, so it belongs in a CLI or on a server, never in browser code. The
220
+ SDK has two stores ready for it, which keep the store's rules for you.
180
221
 
181
222
  ```ts
182
223
  import { createFlipstream, discover } from '@flipstream/sdk'
224
+ import { createSession, fileStore, keychainStore, signInWithLoopback } from '@flipstream/sdk/node'
225
+ import { homedir } from 'node:os'
226
+ import { join } from 'node:path'
227
+
228
+ const issuer = 'https://auth.flipstream.io'
229
+
230
+ // The system's keychain by default. A file that only this user can read when the person asks for
231
+ // one, for a machine with no keychain (Linux without a Secret Service, as on most servers). A real
232
+ // app remembers that choice, in its config say, so every run uses the same store.
233
+ const inFile = process.argv.includes('--tokens-in-file')
234
+ const tokensFile = join(homedir(), '.config', 'example-cli', 'tokens.json')
235
+ const store = inFile ? fileStore(tokensFile) : keychainStore({ service: 'io.example.cli', account: issuer })
236
+ if (inFile) console.error(`Your sign-in is kept in ${tokensFile}, which only your user can read.`)
237
+
238
+ // A store that can't be read is the person's to fix: never a quiet switch from the keychain to a file.
239
+ const saved = await store.tokens().catch((error: unknown) => {
240
+ const why = error instanceof Error ? error.message : String(error)
241
+ if (inFile) throw new Error(`${tokensFile} can't be read (${why})`)
242
+ throw new Error(`the keychain can't be read (${why}): if it's locked, unlock it or log in at this machine once; where there is no keychain, run with --tokens-in-file`)
243
+ })
244
+
245
+ // Sign in once, and save the tokens. Only signing in needs the server first.
246
+ if (saved === null) {
247
+ const server = await discover(issuer)
248
+ if (!server.ok) throw new Error(`sign-in is unavailable: ${server.error.kind}`)
249
+ const signedIn = await signInWithLoopback({
250
+ server: server.data,
251
+ clientId: '<your client id>',
252
+ scopes: ['<scope>'],
253
+ open: (url) => {
254
+ console.log(`Sign in at ${url}`)
255
+ },
256
+ })
257
+ if (!signedIn.ok) throw new Error(`sign-in failed: ${signedIn.error.kind}`)
258
+ await store.save(signedIn.data)
259
+ }
260
+
261
+ // The session discovers the server itself, only when a refresh or a sign-out needs it.
262
+ const session = createSession({ issuer, clientId: '<your client id>', ...store })
263
+ const fs = createFlipstream({ token: session.token })
264
+
265
+ // Signing out ends the session at the server, and clears the store through onTokens.
266
+ const signedOut = await session.revoke()
267
+ console.log(signedOut.kind)
268
+ ```
269
+
270
+ - **`issuer`,** as above, discovers the server itself, only when a refresh or a sign-out needs it,
271
+ and keeps it. A command holding a token with time left then sends nothing to the auth host, and
272
+ an outage there doesn't stop it. Give exactly one of `issuer` and `server`, from your own
273
+ `discover` (as in "Writing your own store" below).
274
+ - **Write the issuer exactly as its metadata names it,** with no slash at the end for
275
+ `https://auth.flipstream.io`. Any other spelling fails every discovery.
276
+ - **A discovery that gets no answer** (offline, a 5xx, a timeout) is `unavailable` from
277
+ `token()`. **One answered outside the contract** (a 404, metadata naming another issuer) is
278
+ `refresh_failed`, with the error: waiting won't mend it. From `revoke()`, either is
279
+ `unconfirmed`. A failed discovery is tried again at the next need.
280
+ - **What it guarantees:** with a store that shows only what it has saved and compares and sets on
281
+ `replaces`, and one lock shared by every process, the session never sends a refresh token another
282
+ refresh is spending, never hands out a token that wasn't saved, never overwrites a newer sign-in,
283
+ and says `revoked` only when the server took the access token just before and refuses it just
284
+ after. A lost answer or a failed save can still leave a spent token stored, and a server fault
285
+ between the two checks reads as `revoked`.
286
+ - **The ready-made stores keep both rules:** each shows only what it has saved, and saves a
287
+ refresh's tokens only while it still holds the ones they replace, so a newer sign-in is kept.
288
+ `save` is for a sign-in's tokens, and `clear` for an app that signs out without a session:
289
+ `session.revoke()` clears the store itself.
290
+ - **`fileStore(path)`** is for a machine with no keychain, chosen by the app or the person, never
291
+ switched to quietly when the keychain fails: tell them where the file is. **The risk:** anyone
292
+ who can read their files, as them or as an administrator, can use the tokens in it.
293
+ It writes the whole file under a temporary name in its folder, flushes it to disk, renames it
294
+ over the old one and flushes the folder: a reader, or a power cut, sees the old
295
+ tokens or the new ones, never half. The file's mode is 0600, and a folder it makes is 0700. It
296
+ refuses a file that is a link, isn't this user's or is open to others, and it won't read or
297
+ save in a folder others can write to. On Windows the folder isn't flushed, and nothing checks
298
+ who owns what. With `{ lock: true }` it also brings a lock for several processes (see
299
+ "Several processes on one store").
300
+ - **`keychainStore({ service, account })`** keeps the tokens in one item of the system's
301
+ credential store: the macOS keychain, Windows' Credential Manager, or the Secret Service on
302
+ Linux (GNOME Keyring, KWallet). It needs the optional package `@napi-rs/keyring`
303
+ (`npm install @napi-rs/keyring`); without it, every step fails as `store_failed`, naming the
304
+ package.
305
+ - Its steps run in one helper process, one at a time. The first step starts it, and it stays
306
+ warm while your app runs (about 57 MB), so a step after that takes a keychain call, not a
307
+ process start. A step that takes longer than 30 s (`timeoutMs`) ends it, so a keychain prompt
308
+ that nobody answers can't hold up your app, and the next step starts another. A step whose
309
+ helper died before it answered (a Ctrl-C reaches the helper too) runs once more on a fresh
310
+ one, within the same 30 s. The helper never keeps your app running, and it ends when your
311
+ app does. It's `process.execPath`, so
312
+ it needs a Node that runs a script: not an Electron app (without `ELECTRON_RUN_AS_NODE`), a
313
+ Node single-executable application, or a compiled Bun binary. A bundle must keep
314
+ `keychainChild.js` beside the module, with `zod` and `@napi-rs/keyring` resolvable from
315
+ there, and `import.meta.url` set. Where it doesn't (an esbuild CommonJS bundle, say), only the
316
+ keychain's steps fail, as `store_failed`.
317
+ - Through `session.token()`, a keychain read that takes longer than the caller's 15 s wait is
318
+ `unavailable`. A longer `timeoutMs` helps your own `tokens`, `save` and `clear`, and a
319
+ refresh, which goes on after the caller's wait.
320
+ - Tokens over 2,560 bytes, Windows' limit, kept on every platform, fail the save with nothing
321
+ written. A Flipstream sign-in's tokens take about 1.6 KB.
322
+ - On Linux without a Secret Service, as on most servers, use `fileStore`.
323
+ - Over SSH on a Mac it works too, unless the keychain is locked, as after a reboot with nobody
324
+ logged in at the screen: then every step fails, at the latest after its 30 s, until the person
325
+ logs in at the machine once, or runs `security unlock-keychain`.
326
+ - On macOS, a script run by the same Node can read the item without a prompt, much as with a
327
+ file only the person can read.
328
+ - It's tested on macOS. Windows and Linux aren't tested yet.
329
+ - **One session per store,** shared by everything that uses it, or pass `lock`, a lock every
330
+ process takes, which settles only once its work has settled. Two sessions on one store refresh as
331
+ two processes would, and the server can end the session.
332
+ - **In one process,** the ready-made stores take each save, update and clear of the same file or
333
+ item in turn, so a sign-in saved while a refresh is saving is kept. A file counts as the same
334
+ however its folder is spelt (through a link, or in another case on macOS), but not when its own
335
+ name differs only in case.
336
+ - **Across processes,** take the session's lock around `save` and `clear` too: a store's compare
337
+ and its write are one step only among processes that take turns.
338
+ - **`session.token()`** rejects with a `SessionError` when there's no token to give: `signed-out`,
339
+ `unavailable` (after 15 s at most), `store_failed` or `refresh_failed`.
340
+ - **Before your process exits, `await session.settled()`.** It resolves once the session has no
341
+ refresh, save or sign-out in flight. `unavailable` comes while a refresh may still be saving the
342
+ token it got, and an exit then loses it. It never rejects and starts nothing.
343
+ - **It waits at most as long as the session's own limits.** A store that never answers a read or
344
+ a save holds it, and so does a lock that ignores its signal. A sign-out's store call still
345
+ running after 60 s isn't waited for.
346
+ - **The SDK's own stores answer every call.** A `keychainStore` save or clear is two steps of up
347
+ to its `timeoutMs` each, so keep `timeoutMs` at 30 s or under, or a sign-out's clear can be cut.
348
+ - **Stop making calls before you await it:** calls that keep coming keep it waiting.
349
+ - **`session.revoke()`** gives `revoked`, or `unconfirmed` with the reason. It ends the session the
350
+ store holds when its turn comes, and, whatever the result, clears it through `onTokens`
351
+ (`cleared`), once, in the same hold of the lock, so a refresh can't bring it back. A sign-in saved
352
+ after that is kept. A refresh token the session holds only because saving it failed goes too,
353
+ after the stored session, even once the store has moved on, and the session then lets it go. It waits for the clear at most 10 s. After `timeout` or `aborted`, the clear
354
+ may still be on its way: once it reaches the lock, it waits at most 60 s for the lock and for each
355
+ of its three store calls, so up to about four minutes. A lock held longer than its 60 s by another
356
+ process, or a store call that doesn't answer within its 60 s, leaves the store as it was.
357
+
358
+ **Writing your own store:** give `tokens` and `onTokens` instead, and keep the same two rules.
359
+ `tokens()` returns only what `onTokens` has durably saved: write first, show second. `onTokens`
360
+ writes only while the store's key is still `update.replaces`, and throws when it refuses. The key is
361
+ the stored refresh token, or the access token when it has none or an empty one
362
+ (`refreshToken || accessToken`). Here in memory:
363
+
364
+ ```ts
365
+ import { discover } from '@flipstream/sdk'
183
366
  import { createSession, type SessionTokens, type TokenUpdate } from '@flipstream/sdk/node'
184
367
 
185
368
  const server = await discover('https://auth.flipstream.io')
186
369
  if (!server.ok) throw new Error(`sign-in is unavailable: ${server.error.kind}`)
187
370
 
188
- // Your store, here in memory. A real one saves first and shows second (see below).
189
371
  let stored: SessionTokens | null = null
190
372
 
191
373
  const session = createSession({
@@ -204,37 +386,8 @@ const session = createSession({
204
386
  stored = { accessToken, ...(refreshToken === undefined ? {} : { refreshToken }), ...(expiresAt === undefined ? {} : { expiresAt }) }
205
387
  },
206
388
  })
207
-
208
- const fs = createFlipstream({ token: session.token })
209
-
210
- // Signing out ends the session at the server. Then clear your own store, whatever the result.
211
- const signedOut = await session.revoke()
212
- stored = null
213
- console.log(signedOut.kind)
214
389
  ```
215
390
 
216
- - **What it guarantees:** with a store that shows only what it has saved and compares and sets on
217
- `replaces`, and one lock shared by every process, the session never sends a refresh token another
218
- refresh is spending, never hands out a token that wasn't saved, never overwrites a newer sign-in,
219
- and says `revoked` only when the server took the access token just before and refuses it just
220
- after. A lost answer or a failed save can still leave a spent token stored, and a server fault
221
- between the two checks reads as `revoked`.
222
- - **Your store saves first and shows second.** `tokens()` returns only what `onTokens` has durably
223
- saved: the system keychain, or a file written under a temporary name, flushed to disk (fsync),
224
- renamed over the old one, and its folder flushed too. `onTokens` writes only while the store's key
225
- is still `update.replaces`, and throws when it refuses. The key is the stored refresh token, or the
226
- access token when it has none or an empty one (`refreshToken || accessToken`).
227
- - **One session per store,** shared by everything that uses it, or pass `lock`, a lock every
228
- process takes, which settles only once its work has settled. Two sessions on one store refresh as
229
- two processes would, and the server can end the session.
230
- - **`session.token()`** rejects with a `SessionError` when there's no token to give: `signed-out`,
231
- `unavailable` (after 15 s at most), `store_failed` or `refresh_failed`.
232
- - **`session.revoke()`** gives `revoked`, or `unconfirmed` with the reason. It doesn't touch your
233
- store: clear it yourself afterwards, whatever the result.
234
- - **A known risk:** on a store that doesn't compare and set, a refresh whose save is slow can
235
- land after your clear and bring a live session back. A later release moves the clear into the
236
- session, inside its queue.
237
-
238
391
  ### Several processes on one store
239
392
 
240
393
  `fileLock(path)` is a ready-made `lock` for Node processes that share one store, such as a CLI
@@ -244,26 +397,36 @@ run several times at once.
244
397
  import { homedir } from 'node:os'
245
398
  import { join } from 'node:path'
246
399
  import { discover } from '@flipstream/sdk'
247
- import { createSession, fileLock, type SessionTokens, type TokenUpdate } from '@flipstream/sdk/node'
400
+ import { createSession, fileLock, signInWithLoopback, type TokenStore } from '@flipstream/sdk/node'
248
401
 
249
- const server = await discover('https://auth.flipstream.io')
250
- if (!server.ok) throw new Error(`sign-in is unavailable: ${server.error.kind}`)
402
+ const issuer = 'https://auth.flipstream.io'
251
403
 
252
- // Your store, kept on disk, which every process reads and writes.
253
- declare const store: {
254
- tokens(): Promise<SessionTokens | null>
255
- onTokens(update: TokenUpdate): Promise<void>
256
- clear(): Promise<void>
257
- }
404
+ // The store, chosen as above: the keychain, or the file the person asked for.
405
+ declare const store: TokenStore
258
406
 
259
407
  // One lock file for every process on this machine.
260
- const lock = fileLock(join(homedir(), '.config', 'my-app', 'session.lock'))
261
- const session = createSession({ server: server.data, clientId: '<your client id>', tokens: store.tokens, onTokens: store.onTokens, lock })
408
+ const lock = fileLock(join(homedir(), '.config', 'example-cli', 'session.lock'))
409
+ const session = createSession({ issuer, clientId: '<your client id>', ...store, lock })
410
+
411
+ // A sign-in's save takes the same lock. Give it longer than the 10 s a lock file left by a crash
412
+ // can take to go stale.
413
+ if ((await store.tokens()) === null) {
414
+ const server = await discover(issuer)
415
+ if (!server.ok) throw new Error(`sign-in is unavailable: ${server.error.kind}`)
416
+ const signedIn = await signInWithLoopback({
417
+ server: server.data,
418
+ clientId: '<your client id>',
419
+ scopes: ['<scope>'],
420
+ open: (url) => {
421
+ console.log(`Sign in at ${url}`)
422
+ },
423
+ })
424
+ if (!signedIn.ok) throw new Error(`sign-in failed: ${signedIn.error.kind}`)
425
+ await lock(() => store.save(signedIn.data), AbortSignal.timeout(30_000))
426
+ }
262
427
 
263
- // The store's other writes take the same lock: here, the clear after signing out. Give them
264
- // longer than the 10 s a lock file left by a crash can take to go stale.
428
+ // Signing out takes the lock itself, and clears the store inside it.
265
429
  await session.revoke()
266
- await lock(() => store.clear(), AbortSignal.timeout(30_000))
267
430
  ```
268
431
 
269
432
  - **Give every process the same absolute path,** on a local disk, for processes on this machine's
@@ -277,12 +440,94 @@ await lock(() => store.clear(), AbortSignal.timeout(30_000))
277
440
  every second, and a waiter takes a file over once nobody has touched it for 10 s and it has
278
441
  watched it for 3 s. A sign-out, which has 10 s in all, takes over a file left 10 s or more before
279
442
  within about 3 s.
443
+ - **On Ctrl-C,** Node ends the process without letting a held lock go, and the next process waits
444
+ up to 10 s for it. An app that wants it gone sooner can handle SIGINT itself, and exit only once
445
+ every hold of its lock has settled, as below: a hold still waiting for the file gives up at once,
446
+ and one running its work finishes it. Waiting for the session's calls isn't enough:
447
+ `token()` and `revoke()` can answer before their hold ends. Await `session.settled()` too, so the
448
+ session's own work has finished before the exit. The keychain store's own helper gets
449
+ the Ctrl-C too; a step it was running is tried once more on a fresh helper, within its 30 s, and
450
+ the lock file goes when its work settles.
451
+
452
+ ```ts
453
+ import { homedir } from 'node:os'
454
+ import { join } from 'node:path'
455
+ import { fileLock, type Session } from '@flipstream/sdk/node'
456
+
457
+ // The lock for the session and the app's own saves, with every hold kept until it settles. Once
458
+ // the app is stopping, a hold still waiting for the file gives up, and a new one creates nothing
459
+ // (fileLock with a signal that has fired), so the wait below is only for work already running.
460
+ const file = fileLock(join(homedir(), '.config', 'example-cli', 'session.lock'))
461
+ const holds = new Set<Promise<unknown>>()
462
+ const stop = new AbortController()
463
+ const lock: typeof file = (work, signal) => {
464
+ const hold = file(work, AbortSignal.any([signal, stop.signal]))
465
+ holds.add(hold)
466
+ const done = (): void => {
467
+ holds.delete(hold)
468
+ }
469
+ hold.then(done, done)
470
+ return hold
471
+ }
472
+
473
+ declare const session: Session
474
+
475
+ // On Ctrl-C, exit once every hold has let its lock file go and the session's own work is done; a
476
+ // second Ctrl-C exits at once.
477
+ process.on('SIGINT', () => {
478
+ if (stop.signal.aborted) process.exit(130)
479
+ stop.abort(new Error('stopping'))
480
+ void Promise.all([Promise.allSettled([...holds]), session.settled()]).then(() => process.exit(130))
481
+ })
482
+ ```
483
+
280
484
  - **A holder that can't touch its file for 10 s loses the lock,** and its work goes on beside the
281
485
  next holder's: a thread blocked by a synchronous store waiting for a person, or a process stopped
282
486
  by Ctrl-Z or a debugger. Keep your store asynchronous.
283
- - **Take the same lock for the store's other writes,** such as saving a sign-in's tokens, or
284
- clearing the store after `revoke()`, so they can't land between a refresh's compare and its set.
285
- Never inside `onTokens`, which runs inside it already: the lock isn't reentrant.
487
+ - **Take the same lock for the store's other writes,** a sign-in's `save`, or a `clear` without a
488
+ session, so they can't land between a refresh's compare and its set. `session.revoke()` takes it
489
+ for its own clear. Never take it inside `onTokens`, which runs inside it already: the lock isn't
490
+ reentrant.
491
+ - **On Windows, `fileLock` hasn't been tried yet.** What may differ there:
492
+ - the lock file and its folder take the folder's own permissions, so they aren't private to this
493
+ user;
494
+ - a lock file it isn't allowed to create, for the folder's permissions, reads as held by another
495
+ process: a refresh then waits out its 60 s and is `unavailable`, not `store_failed`. A file
496
+ antivirus still holds open reads as held only until it lets go;
497
+ - taking over a crashed holder's file fails while antivirus or the indexer has it open, as
498
+ `store_failed`;
499
+ - a path such as `\my-app\session.lock` counts as absolute but names a file on whichever drive
500
+ is current: give the drive as well (`C:\…`).
501
+
502
+ **A file store can bring its own lock.** `fileStore(path, { lock: true })` also returns `lock`:
503
+ `fileLock` on the file's path with `.lock` added, beside it. Every process, and every version of
504
+ your app, that opens the same file then takes the same lock, with no path of its own to agree on.
505
+
506
+ ```ts
507
+ import { homedir } from 'node:os'
508
+ import { join } from 'node:path'
509
+ import { createSession, fileStore, type SessionTokens } from '@flipstream/sdk/node'
510
+
511
+ const store = fileStore(join(homedir(), '.config', 'example-cli', 'tokens.json'), { lock: true })
512
+
513
+ // Spread in, so the session takes store.lock for its refreshes and sign-outs.
514
+ const session = createSession({ issuer: 'https://auth.flipstream.io', clientId: '<your client id>', ...store })
515
+
516
+ // A sign-in's save takes it too, as does a clear of your own.
517
+ declare const signedIn: SessionTokens
518
+ await store.lock(() => store.save(signedIn), AbortSignal.timeout(30_000))
519
+
520
+ // Signing out takes it itself.
521
+ await session.revoke()
522
+ ```
523
+
524
+ - **The store's own steps never take it,** so a `save` or `clear` inside it doesn't wait for itself,
525
+ and a clear leaves the lock file alone. Without `{ lock: true }`, nothing changes.
526
+ - **Don't pass a `lock` of your own as well:** `{ ...store, lock }` leaves the session on yours and
527
+ your saves on `store.lock`, and `{ lock, ...store }` swaps yours out without a word. Either way a
528
+ sign-in can land between a refresh's compare and its write.
529
+ - **Never call the session inside `store.lock`:** the lock isn't reentrant, so the call waits for
530
+ the hold it's in, and fails at its own limit (`token()` at 15 s, `revoke()` at 10 s).
286
531
 
287
532
  ## In a browser
288
533
 
@@ -336,7 +581,10 @@ if (!signedIn.ok) throw new Error(`sign-in failed: ${signedIn.error.kind}`)
336
581
  - **The secret goes only in the token request's `Authorization: Basic` header** (RFC 6749 §2.3.1),
337
582
  and only to the token endpoint of the `server` you pass. A `pending` that names another server,
338
583
  or another client ID than `clientId`, is refused, with nothing sent. The secret is never in a body, a URL, a result or an error, and
339
- the SDK logs nothing. A `fetch` you pass sees the request, header included: don't log it.
584
+ never logged. The SDK logs nothing but one warning per catalogue format type it doesn't know,
585
+ which never holds a token, a secret or a field's value, and which `onWarning` routes or
586
+ silences. A `fetch` you pass sees the request,
587
+ header included: don't log it.
340
588
  - **A failure keeps its kind, status and OAuth code** (`invalid_client`, `invalid_grant`, …), but
341
589
  not the server's description or body (an empty `message` or `text`): a server or proxy that
342
590
  echoes the request would put the credentials there.
@@ -363,6 +611,11 @@ throws the failure as an `ApiFailure` carrying its `error`, for callers who'd ra
363
611
  `dimensions`, `metrics`, `filters`, `sort`, `offset` and `rows`. A request with any other key,
364
612
  `table` included, is `refused` with nothing sent, and `error.fields` names each one, so a
365
613
  misspelt field never quietly changes the numbers.
614
+ - **`refusedQueryFields(request)`** runs that check on its own, with no client and nothing
615
+ sent. It gives the same names, sorted, or `[]` for a request `fs.query` would send. So an
616
+ app can refuse a request before anything else it does: a CLI given a raw JSON body, for
617
+ instance, before its other calls. It reads only the keys; a missing `source` is still the
618
+ API's to refuse.
366
619
  - **`fs.health()`** gives the planner's answer to `GET /health`, an object of strings
367
620
  (`{ status: 'ok' }` today). It works signed out: no token is asked for or sent, so it tells "the
368
621
  service is down" from "the sign-in is wrong".
@@ -436,8 +689,9 @@ function explain(error: ApiError): string {
436
689
  - `not_a_url` and `wrong_redirect`: a pasted address that isn't a URL, or isn't this sign-in's
437
690
  redirect (`parsePastedRedirect`, or `signInWithLoopback`'s `readPasted`).
438
691
 
439
- There, `refused` also covers an issuer that isn't https, and a `pending` that isn't one (from
440
- storage the app couldn't read back). Nothing is sent for either.
692
+ There, `refused` also covers an issuer that isn't https (unless it's http on this machine, with
693
+ `allowLocalhostHttp`), and a `pending` that isn't one (from storage the app couldn't read back).
694
+ Nothing is sent for either.
441
695
 
442
696
  ## Options
443
697
 
@@ -451,6 +705,7 @@ const fs = createFlipstream({
451
705
  token: ({ rejected }) => session.accessToken(rejected),
452
706
  fetch: globalThis.fetch, // optional: every request goes through it
453
707
  hosts: { query: 'https://query.flipstream.io' }, // optional: the default
708
+ onWarning: (message) => process.stderr.write(`${message}\n`), // optional: console.warn by default
454
709
  })
455
710
 
456
711
  const controller = new AbortController()
@@ -473,11 +728,26 @@ await fs.catalog.list({ signal: controller.signal, deadlineMs: 10_000 })
473
728
  - **Deadlines:** 60 s for `query`, 10 s for `health` and 30 s for the rest, every attempt and
474
729
  wait included. `deadlineMs` sets one call's.
475
730
  - **Abort:** `signal` ends a call at once, also while it waits for a token or to try again.
731
+ - **Warnings:** the SDK's warnings go to `onWarning`, or to `console.warn` without it; `() => {}`
732
+ silences them. Today there is one kind: a catalogue format type this version doesn't know,
733
+ reported once per process to the client that read it first. A handler that throws is ignored,
734
+ and the read goes on.
476
735
  - **Your own transport:** an app that attaches the token itself passes `{ transport }` instead of
477
736
  `token` and `fetch`. Retries and deadlines still apply, above it. `health` carries no token, so
478
737
  it never goes through your transport: it goes to the query host, over https, with the global
479
738
  `fetch`.
480
739
 
740
+ ## Which version is running
741
+
742
+ ```ts
743
+ import { version } from '@flipstream/sdk'
744
+
745
+ console.log(`@flipstream/sdk ${version}`) // "@flipstream/sdk 0.5.0", say
746
+ ```
747
+
748
+ `version` is the installed package's own, from its `package.json`. It's a string in the code, so it
749
+ reads the same in Node and in a browser bundle, with no file to load.
750
+
481
751
  ## Requirements
482
752
 
483
753
  - **Node 20.19+ or 22.12+,** or a current browser. Sign-in needs WebCrypto, so a page that signs
@@ -486,6 +756,8 @@ await fs.catalog.list({ signal: controller.signal, deadlineMs: 10_000 })
486
756
  CommonJS too, both entries; Node 22.12 prints an experimental warning when it does.
487
757
  - **The types ship in the package,** for both entries. The Node entry's types use Node's own,
488
758
  from `@types/node`.
759
+ - **`keychainStore` needs `@napi-rs/keyring` 2.1 or later,** an optional peer dependency. Nothing
760
+ else needs it, and npm doesn't install it for you.
489
761
 
490
762
  ## Licence
491
763
 
@@ -15,9 +15,10 @@ export interface AuthServer {
15
15
  }
16
16
  /**
17
17
  * The authorization server at `issuer`, from its RFC 8414 metadata. `refused`, with nothing sent,
18
- * when `issuer` isn't an https URL. Refused as `invalid`: metadata that doesn't name `issuer`
19
- * exactly (§3.3), an endpoint that is not an https URL, and a server that doesn't list PKCE's
20
- * S256, since one that lists no methods supports no PKCE (§2), and a code it issues is bound to no
21
- * verifier.
18
+ * when `issuer` isn't an https URL, or with `allowLocalhostHttp`, an http one on this machine.
19
+ * Refused as `invalid`: metadata that doesn't name `issuer` exactly (§3.3), an endpoint that is
20
+ * not an https URL (for an http issuer on this machine, one not on its own origin), and a server
21
+ * that doesn't list PKCE's S256, since one that lists no methods supports no PKCE (§2), and a code
22
+ * it issues is bound to no verifier.
22
23
  */
23
24
  export declare function discover(issuer: string, options?: AuthCallOptions): Promise<ApiResult<AuthServer>>;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { call } from '../core/call.js';
3
- import { authTransport, isHttpsUrl } from './transport.js';
3
+ import { authTransport, endpointProblem, isSignInUrl } from './transport.js';
4
4
  // Unknown fields are kept and never read: `first_party_client_id` among them, which the SDK never
5
5
  // uses in place of the app's own client ID (D421).
6
6
  const zMetadata = z.looseObject({
@@ -13,13 +13,14 @@ const zMetadata = z.looseObject({
13
13
  });
14
14
  /**
15
15
  * The authorization server at `issuer`, from its RFC 8414 metadata. `refused`, with nothing sent,
16
- * when `issuer` isn't an https URL. Refused as `invalid`: metadata that doesn't name `issuer`
17
- * exactly (§3.3), an endpoint that is not an https URL, and a server that doesn't list PKCE's
18
- * S256, since one that lists no methods supports no PKCE (§2), and a code it issues is bound to no
19
- * verifier.
16
+ * when `issuer` isn't an https URL, or with `allowLocalhostHttp`, an http one on this machine.
17
+ * Refused as `invalid`: metadata that doesn't name `issuer` exactly (§3.3), an endpoint that is
18
+ * not an https URL (for an http issuer on this machine, one not on its own origin), and a server
19
+ * that doesn't list PKCE's S256, since one that lists no methods supports no PKCE (§2), and a code
20
+ * it issues is bound to no verifier.
20
21
  */
21
22
  export async function discover(issuer, options = {}) {
22
- if (typeof issuer !== 'string' || !isHttpsUrl(issuer))
23
+ if (typeof issuer !== 'string' || !isSignInUrl(issuer, options.allowLocalhostHttp))
23
24
  return { ok: false, error: { kind: 'refused' } };
24
25
  const read = await call(authTransport(options), {
25
26
  effect: 'read',
@@ -62,8 +63,9 @@ function problemWith(doc, issuer) {
62
63
  if (doc.issuer !== issuer)
63
64
  return 'the metadata names another issuer';
64
65
  const endpoints = [doc.authorization_endpoint, doc.token_endpoint, ...(doc.revocation_endpoint === undefined ? [] : [doc.revocation_endpoint])];
65
- if (!endpoints.every(isHttpsUrl))
66
- return 'an endpoint is not an https URL';
66
+ const problem = endpointProblem(issuer, endpoints);
67
+ if (problem !== null)
68
+ return problem;
67
69
  if (doc.code_challenge_methods_supported?.includes('S256') !== true)
68
70
  return 'the server does not list PKCE S256';
69
71
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/auth/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAwB,MAAM,gBAAgB,CAAA;AAgBhF,kGAAkG;AAClG,mDAAmD;AACnD,MAAM,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE;IAClC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE;IAC/C,gCAAgC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE;IACrE,8CAA8C,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE;CAC5E,CAAC,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,MAAc,EAAE,UAA2B,EAAE;IAC1E,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAA;IACvG,MAAM,IAAI,GAAG,MAAM,IAAI,CACrB,aAAa,CAAC,OAAO,CA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