@flipstream/sdk 0.8.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.
- package/CHANGELOG.md +32 -0
- package/README.md +161 -54
- package/dist/auth/discovery.js +1 -1
- package/dist/auth/discovery.js.map +1 -1
- package/dist/auth/signIn.js +7 -2
- package/dist/auth/signIn.js.map +1 -1
- package/dist/core/fetch.d.ts +5 -0
- package/dist/core/fetch.js +3 -0
- package/dist/core/fetch.js.map +1 -1
- package/dist/core/identify.d.ts +63 -0
- package/dist/core/identify.js +122 -0
- package/dist/core/identify.js.map +1 -0
- package/dist/core/names.d.ts +61 -0
- package/dist/core/names.js +73 -0
- package/dist/core/names.js.map +1 -0
- package/dist/core/read.js +8 -2
- package/dist/core/read.js.map +1 -1
- package/dist/core/result.d.ts +26 -3
- package/dist/core/result.js +22 -3
- package/dist/core/result.js.map +1 -1
- package/dist/core/transport.d.ts +6 -2
- package/dist/flipstream.d.ts +47 -3
- package/dist/flipstream.js +46 -5
- package/dist/flipstream.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node/clientSecret.js +1 -1
- package/dist/node/clientSecret.js.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/keychainChild.js +10 -6
- package/dist/node/keychainChild.js.map +1 -1
- package/dist/node/keychainStore.d.ts +6 -3
- package/dist/node/keychainStore.js +6 -3
- package/dist/node/keychainStore.js.map +1 -1
- package/dist/node/session.d.ts +79 -29
- package/dist/node/session.js +52 -38
- package/dist/node/session.js.map +1 -1
- package/dist/node/store.d.ts +11 -1
- package/dist/node/store.js +14 -1
- package/dist/node/store.js.map +1 -1
- package/dist/query/query.d.ts +15 -10
- package/dist/query/query.js +21 -11
- package/dist/query/query.js.map +1 -1
- package/dist/version.gen.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.0](https://github.com/flipstream-io/sdk/compare/typescript-v0.8.0...typescript-v0.9.0) (2026-10-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* **typescript:** RevokeResult gains a required `cleared`, and revoke() now answers once its clear is done, which can take minutes on a stalled store, where it used to answer within 10 s. When `cleared` is `failed`, `failure: { step, cause }` says where the store failed (`read`, `lock` or `clear`) and what it threw. Adds StoreMovedOnError, for a store that has moved on: `fileStore` and `keychainStore` now throw `StoreMovedOnError` where they threw a plain `Error`. A store of your own should throw it too: a sign-out then says `kept`, and any other throw from its clear says `failed`.
|
|
9
|
+
* **typescript:** createFlipstream requires app: { name, version }, on both ways of making a client. In Node, each request to an API host says which app sent it (User-Agent), carries a W3C traceparent, and, when given, the agent and conversation as baggage.
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **typescript:** a query names its dataset as dataset_id, sent as connection_id ([#207](https://github.com/flipstream-io/sdk/issues/207)) ([2f1e956](https://github.com/flipstream-io/sdk/commit/2f1e956ccb5cdab75afa5e0619caf53d2f015e8d))
|
|
14
|
+
* **typescript:** a refused call says why, in reason ([#204](https://github.com/flipstream-io/sdk/issues/204)) ([b1cebb6](https://github.com/flipstream-io/sdk/commit/b1cebb658da12509fdc771afd623671a047d6850))
|
|
15
|
+
* **typescript:** every request says which app and agent sent it ([#195](https://github.com/flipstream-io/sdk/issues/195)) ([5653c8a](https://github.com/flipstream-io/sdk/commit/5653c8aa317147eb1a1e0fa0eeacd9fe19ce04d7))
|
|
16
|
+
* **typescript:** revoke() waits for its clear, and says how it went ([#197](https://github.com/flipstream-io/sdk/issues/197)) ([8936d61](https://github.com/flipstream-io/sdk/commit/8936d61d255ccbfdb7268d852757b5049a5226e0))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **typescript:** a short token refuses only a value equal to it ([#203](https://github.com/flipstream-io/sdk/issues/203)) ([ea05225](https://github.com/flipstream-io/sdk/commit/ea0522560a20e5d366fc59734cdbf6a4d4331024))
|
|
22
|
+
* **typescript:** health sends none of the caller's values ([#202](https://github.com/flipstream-io/sdk/issues/202)) ([32ce143](https://github.com/flipstream-io/sdk/commit/32ce143f2fbca14e48d648cbc645f01921f082f2))
|
|
23
|
+
* **typescript:** the keychain helper ignores Ctrl-C before zod loads ([#201](https://github.com/flipstream-io/sdk/issues/201)) ([660ea0c](https://github.com/flipstream-io/sdk/commit/660ea0ca393f084afb287e4b082c05f102aaf784))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Miscellaneous
|
|
27
|
+
|
|
28
|
+
* **typescript:** the client is flipstream, not fs ([#227](https://github.com/flipstream-io/sdk/issues/227)) ([8ae4981](https://github.com/flipstream-io/sdk/commit/8ae498154263e9ee954e51a68456b6cc0804121a))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Tests
|
|
32
|
+
|
|
33
|
+
* **typescript:** a keychain test follows its helper by its spawn ([#200](https://github.com/flipstream-io/sdk/issues/200)) ([58d747d](https://github.com/flipstream-io/sdk/commit/58d747dabff2c908cb392b7ccb7f23a3b665adee))
|
|
34
|
+
|
|
3
35
|
## [0.8.0](https://github.com/flipstream-io/sdk/compare/typescript-v0.7.0...typescript-v0.8.0) (2026-10-23)
|
|
4
36
|
|
|
5
37
|
|
package/README.md
CHANGED
|
@@ -26,16 +26,20 @@ npm install @flipstream/sdk
|
|
|
26
26
|
```ts
|
|
27
27
|
import { createFlipstream, orThrow } from '@flipstream/sdk'
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const flipstream = createFlipstream({
|
|
30
|
+
// Required: every request says which app sent it (see "Which app sent a request").
|
|
31
|
+
app: { name: 'my-app', version: '1.0.0' },
|
|
32
|
+
// Asked before every attempt: return the current access token.
|
|
33
|
+
token: async () => '<your token>',
|
|
34
|
+
})
|
|
31
35
|
|
|
32
|
-
const catalog = await
|
|
36
|
+
const catalog = await flipstream.catalog.list()
|
|
33
37
|
if (!catalog.ok) console.error(catalog.error.kind) // 'unauthorized', 'unavailable', …
|
|
34
38
|
|
|
35
39
|
const answer = orThrow(
|
|
36
|
-
await
|
|
40
|
+
await flipstream.query({
|
|
37
41
|
source: '<source>',
|
|
38
|
-
|
|
42
|
+
dataset_id: '<dataset id>',
|
|
39
43
|
dimensions: ['<dimension>'],
|
|
40
44
|
metrics: ['<metric>'],
|
|
41
45
|
}),
|
|
@@ -43,8 +47,8 @@ const answer = orThrow(
|
|
|
43
47
|
console.log(answer.rows, answer.lastRow)
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
The catalogue names each source with its dimensions and metrics.
|
|
47
|
-
one source.
|
|
50
|
+
The catalogue names each source with its dimensions and metrics.
|
|
51
|
+
`flipstream.catalog.get({ source })` gives one source.
|
|
48
52
|
|
|
49
53
|
Each dimension and metric has a `format`, a union on its `type`:
|
|
50
54
|
- `number`, `currency` and `percentage` carry `decimals`, and a `number` may carry
|
|
@@ -119,7 +123,7 @@ const signedIn = await signInWithLoopback({
|
|
|
119
123
|
})
|
|
120
124
|
if (!signedIn.ok) throw new Error(`sign-in failed: ${signedIn.error.kind}`)
|
|
121
125
|
|
|
122
|
-
const
|
|
126
|
+
const flipstream = createFlipstream({ app: { name: 'my-cli', version: '1.0.0' }, token: () => signedIn.data.accessToken })
|
|
123
127
|
```
|
|
124
128
|
|
|
125
129
|
- **The SDK opens nothing and writes nothing to the terminal.** `open` does that, once the port is
|
|
@@ -263,11 +267,19 @@ if (saved === null) {
|
|
|
263
267
|
|
|
264
268
|
// The session discovers the server itself, only when a refresh or a sign-out needs it.
|
|
265
269
|
const session = createSession({ issuer, clientId: '<your client id>', ...store })
|
|
266
|
-
const
|
|
270
|
+
const flipstream = createFlipstream({ app: { name: 'my-cli', version: '1.0.0' }, token: session.token })
|
|
267
271
|
|
|
268
|
-
// Signing out ends the session at the server,
|
|
272
|
+
// Signing out ends the session at the server, then clears the store through onTokens, and says
|
|
273
|
+
// how each went.
|
|
269
274
|
const signedOut = await session.revoke()
|
|
270
275
|
console.log(signedOut.kind)
|
|
276
|
+
if (signedOut.cleared === 'failed') {
|
|
277
|
+
// Where the store failed (read, lock or clear), and its own error: a KeychainError says why.
|
|
278
|
+
const { step, cause } = signedOut.failure
|
|
279
|
+
console.error(`the tokens may still be stored: the ${step} failed (${cause instanceof Error ? cause.message : String(cause)})`)
|
|
280
|
+
} else if (signedOut.cleared !== 'cleared' && signedOut.cleared !== 'kept') {
|
|
281
|
+
console.error(`the tokens may still be stored (${signedOut.cleared}): sign out again`)
|
|
282
|
+
}
|
|
271
283
|
```
|
|
272
284
|
|
|
273
285
|
- **`issuer`,** as above, discovers the server itself, only when a refresh or a sign-out needs it,
|
|
@@ -305,10 +317,12 @@ console.log(signedOut.kind)
|
|
|
305
317
|
Linux (GNOME Keyring, KWallet). It needs the optional package `@napi-rs/keyring`
|
|
306
318
|
(`npm install @napi-rs/keyring`).
|
|
307
319
|
- **Every failure of the keychain or its helper is a `KeychainError`,** which is also the
|
|
308
|
-
`cause` of a session's `store_failed`.
|
|
309
|
-
`save` rejects tokens with no access token as a `TypeError` before any step
|
|
310
|
-
holding something other than tokens fails its read with a plain `Error` that never
|
|
311
|
-
it
|
|
320
|
+
`cause` of a session's `store_failed`. Three failures are the store's own, not the
|
|
321
|
+
keychain's: `save` rejects tokens with no access token as a `TypeError` before any step; an
|
|
322
|
+
item holding something other than tokens fails its read with a plain `Error` that never
|
|
323
|
+
quotes it; and an update for tokens the item no longer holds is refused with a
|
|
324
|
+
`StoreMovedOnError`, which a sign-out reads as `kept` and a refresh reports as `store_failed`
|
|
325
|
+
(`save`). A `KeychainError`'s `failure.kind` says why:
|
|
312
326
|
- `unavailable`: there's no keychain on this machine, as on Linux with no Secret Service or no
|
|
313
327
|
D-Bus session (most servers and containers). It's the only kind after which a file may
|
|
314
328
|
stand in, if your app or the person chooses it;
|
|
@@ -328,7 +342,9 @@ console.log(signedOut.kind)
|
|
|
328
342
|
warm while your app runs (about 57 MB), so a step after that takes a keychain call, not a
|
|
329
343
|
process start. A step that takes longer than 30 s (`timeoutMs`) ends it, so a keychain prompt
|
|
330
344
|
that nobody answers can't hold up your app, and the next step starts another. A Ctrl-C in
|
|
331
|
-
the terminal reaches the helper too, and it ignores it
|
|
345
|
+
the terminal reaches the helper too, and it ignores it, from before its own code loads. Not
|
|
346
|
+
during Node's own start-up, though, or any preload in `NODE_OPTIONS`: a Ctrl-C then still
|
|
347
|
+
ends a helper that is just starting. When your app ends, the helper ends
|
|
332
348
|
too: at once if it's idle or reading, or once it has finished the save or delete it's on, so
|
|
333
349
|
a refresh's save isn't lost to a Ctrl-C. It gives that step 1 s more at most, less than the
|
|
334
350
|
soonest `fileLock` lets another process take the lock your app held: at the soonest about
|
|
@@ -375,7 +391,7 @@ console.log(signedOut.kind)
|
|
|
375
391
|
- **`unavailable` comes at the caller's wait,** the store's read included: 15 s unless you pass
|
|
376
392
|
`createSession({ waitMs })`. Give a store that can wait on a person, such as a keychain asking
|
|
377
393
|
for access, as long as they may take: 120 s when interactive, say. Only this wait changes. A
|
|
378
|
-
refresh still waits at most 60 s for its answer, and a sign-out
|
|
394
|
+
refresh still waits at most 60 s for its answer, and a sign-out sends nothing after its 10 s.
|
|
379
395
|
- **Before your process exits, `await session.settled()`.** It resolves once the session has no
|
|
380
396
|
refresh, save or sign-out in flight. `unavailable` comes while a refresh may still be saving the
|
|
381
397
|
token it got, and an exit then loses it. It never rejects and starts nothing.
|
|
@@ -383,26 +399,52 @@ console.log(signedOut.kind)
|
|
|
383
399
|
a save holds it, and so does a lock that ignores its signal. A sign-out's store call still
|
|
384
400
|
running after 60 s isn't waited for.
|
|
385
401
|
- **The SDK's own stores answer every call.** A `keychainStore` save or clear is two steps of up
|
|
386
|
-
to its `timeoutMs` each, so keep `timeoutMs` at 30 s or under, or a sign-out's clear can be cut
|
|
402
|
+
to its `timeoutMs` each, so keep `timeoutMs` at 30 s or under, or a sign-out's clear can be cut,
|
|
403
|
+
which it reports as `cut`.
|
|
387
404
|
- **Stop making calls before you await it:** calls that keep coming keep it waiting.
|
|
388
|
-
- **`session.revoke()`**
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
405
|
+
- **`session.revoke()`** ends the session the store holds when its turn comes, then, whatever the
|
|
406
|
+
server said, clears it through `onTokens` (`cleared`), once, in the same hold of the lock, so a
|
|
407
|
+
refresh can't bring it back. A sign-in saved after that is kept. A refresh token the session holds
|
|
408
|
+
only because saving it failed goes too, after the stored session, even once the store has moved
|
|
409
|
+
on, and the session then lets it go.
|
|
410
|
+
- **It answers once both are done:** `kind` is `revoked`, or `unconfirmed` with the reason, and
|
|
411
|
+
`cleared` says what became of the store:
|
|
412
|
+
- `cleared`: it was cleared;
|
|
413
|
+
- `kept`: there was nothing to clear: nothing stored, or the store moved on meanwhile, to a
|
|
414
|
+
newer sign-in, which is kept, or to another sign-out's clear;
|
|
415
|
+
- `failed`: the store failed, and `failure` says where and how: its `step` is `read`, `lock`
|
|
416
|
+
or `clear`, and its `cause` is what the store threw, such as a `KeychainError`, whose
|
|
417
|
+
`failure.kind` and message say why. A clear or a lock that rejects with something other
|
|
418
|
+
than an `Error` gives an `Error` carrying its text instead. A clear it refuses with anything
|
|
419
|
+
but `StoreMovedOnError` counts as failed, at `clear`;
|
|
420
|
+
- `cut`: the lock or a store call took longer than its 60 s;
|
|
421
|
+
- `pending`: your `signal` answered first, and the clear goes on, unless the signal had already
|
|
422
|
+
fired when you called, when nothing runs at all.
|
|
423
|
+
|
|
424
|
+
After anything but `cleared` and `kept`, the tokens may still be stored: tell the person, so
|
|
425
|
+
they can sign out again.
|
|
426
|
+
- **It can take minutes on a stalled store, and longer behind one.** It sends nothing after its
|
|
427
|
+
10 s, but it waits for the clear. First it waits for any turn ahead of it, for as long as that
|
|
428
|
+
takes: a refresh that is still saving, or a lock that ignores its signal. Then it waits at most
|
|
429
|
+
60 s for the lock and for each of its three store calls, so up to about four minutes. It used to
|
|
430
|
+
answer within 10 s while the clear went on behind it. A lock held longer than its 60 s by
|
|
431
|
+
another process, or a store call that doesn't answer within its 60 s, leaves the store as it
|
|
432
|
+
was, unless that call finishes later on its own.
|
|
433
|
+
- **Pass a `signal` to stop waiting:** it answers at once, with `cleared: 'pending'`, and the
|
|
434
|
+
clear goes on. Await `session.settled()` before the process exits. A signal that has already
|
|
435
|
+
fired when you call runs nothing at all, and answers `pending` too.
|
|
396
436
|
|
|
397
437
|
**Writing your own store:** give `tokens` and `onTokens` instead, and keep the same two rules.
|
|
398
438
|
`tokens()` returns only what `onTokens` has durably saved: write first, show second. `onTokens`
|
|
399
|
-
writes only while the store's key is still `update.replaces`, and
|
|
400
|
-
|
|
401
|
-
|
|
439
|
+
writes only while the store's key is still `update.replaces`, and when it refuses, throws a
|
|
440
|
+
`StoreMovedOnError`, as the ready-made stores do. A sign-out whose clear is refused that way says
|
|
441
|
+
`kept`: the store holds a newer sign-in, or nothing. Any other throw is read as the store failing,
|
|
442
|
+
and the sign-out says `failed`. The key is the stored refresh token, or the access token when it has
|
|
443
|
+
none or an empty one (`refreshToken || accessToken`). Here in memory:
|
|
402
444
|
|
|
403
445
|
```ts
|
|
404
446
|
import { discover } from '@flipstream/sdk'
|
|
405
|
-
import { createSession, type SessionTokens, type TokenUpdate } from '@flipstream/sdk/node'
|
|
447
|
+
import { createSession, StoreMovedOnError, type SessionTokens, type TokenUpdate } from '@flipstream/sdk/node'
|
|
406
448
|
|
|
407
449
|
const server = await discover('https://auth.flipstream.io')
|
|
408
450
|
if (!server.ok) throw new Error(`sign-in is unavailable: ${server.error.kind}`)
|
|
@@ -415,7 +457,7 @@ const session = createSession({
|
|
|
415
457
|
tokens: () => stored,
|
|
416
458
|
onTokens: (update: TokenUpdate) => {
|
|
417
459
|
// Compare and set: only while the store's key is still the one this update replaces.
|
|
418
|
-
if (stored === null || (stored.refreshToken || stored.accessToken) !== update.replaces) throw new
|
|
460
|
+
if (stored === null || (stored.refreshToken || stored.accessToken) !== update.replaces) throw new StoreMovedOnError()
|
|
419
461
|
if (update.kind === 'cleared') {
|
|
420
462
|
stored = null
|
|
421
463
|
return
|
|
@@ -477,16 +519,17 @@ await session.revoke()
|
|
|
477
519
|
nothing.
|
|
478
520
|
- **A process that dies holding it** holds the others off for about 10 s: a holder touches the file
|
|
479
521
|
every second, and a waiter takes a file over once nobody has touched it for 10 s and it has
|
|
480
|
-
watched it for 3 s. A sign-out, which
|
|
481
|
-
within about 3 s.
|
|
522
|
+
watched it for 3 s. A sign-out, which sends nothing after its 10 s, takes over a file left 10 s or
|
|
523
|
+
more before within about 3 s.
|
|
482
524
|
- **On Ctrl-C,** Node ends the process without letting a held lock go, and the next process waits
|
|
483
525
|
up to 10 s for it. An app that wants it gone sooner can handle SIGINT itself, and exit only once
|
|
484
526
|
every hold of its lock has settled, as below: a hold still waiting for the file gives up at once,
|
|
485
|
-
and one running its work finishes it. Waiting for the session's calls isn't enough:
|
|
486
|
-
|
|
487
|
-
session's own work has finished before the exit. The keychain store's own helper
|
|
488
|
-
Ctrl-C and finishes the step it's on, within that step's 30 s and at most 1 s after
|
|
489
|
-
gone; the lock file goes when that work settles, as long as the app waits for it, as
|
|
527
|
+
and one running its work finishes it. Waiting for the session's calls isn't enough: `token()` can
|
|
528
|
+
answer before its hold ends, and so can `revoke()` at its `signal`. Await `session.settled()`
|
|
529
|
+
too, so the session's own work has finished before the exit. The keychain store's own helper
|
|
530
|
+
ignores the Ctrl-C and finishes the step it's on, within that step's 30 s and at most 1 s after
|
|
531
|
+
the app has gone; the lock file goes when that work settles, as long as the app waits for it, as
|
|
532
|
+
below.
|
|
490
533
|
|
|
491
534
|
```ts
|
|
492
535
|
import { homedir } from 'node:os'
|
|
@@ -566,7 +609,11 @@ await session.revoke()
|
|
|
566
609
|
your saves on `store.lock`, and `{ lock, ...store }` swaps yours out without a word. Either way a
|
|
567
610
|
sign-in can land between a refresh's compare and its write.
|
|
568
611
|
- **Never call the session inside `store.lock`:** the lock isn't reentrant, so the call waits for
|
|
569
|
-
the hold it's in, and fails at its own limit (`token()` at its `waitMs`, `revoke()`
|
|
612
|
+
the hold it's in, and fails at its own limit (`token()` at its `waitMs`, `revoke()` once its turn
|
|
613
|
+
gives up on the lock, 60 s on, with `cut`).
|
|
614
|
+
- **Nor from your own `tokens` or `onTokens`,** if you wrap the store's: they run inside the
|
|
615
|
+
session's own turn. A `revoke()` there waits for that turn for ever, answering only at its
|
|
616
|
+
`signal`, and a `token()` answers only at its `waitMs`.
|
|
570
617
|
|
|
571
618
|
## In a browser
|
|
572
619
|
|
|
@@ -577,6 +624,9 @@ The main entry, `@flipstream/sdk`, runs in browsers with no Node polyfills. Only
|
|
|
577
624
|
in a browser.
|
|
578
625
|
- **The API must allow your page's origin (CORS).** The query API doesn't allow other origins yet,
|
|
579
626
|
so until it does, call it from a server.
|
|
627
|
+
- **A browser sends no identification yet.** `app`, `agent` and `conversationId` are still
|
|
628
|
+
required and checked, but none of "Which app sent a request"'s headers go from a page until the
|
|
629
|
+
hosts' CORS allows them (query-planner#48); a page can't set `User-Agent` anyway.
|
|
580
630
|
- **Signing in from a page** uses the same two halves as the paste-back above:
|
|
581
631
|
- `startSignIn` gives the URL to send the person to, and a `pending` to keep, for instance in
|
|
582
632
|
`sessionStorage`;
|
|
@@ -643,19 +693,20 @@ only on a programming error. For instance, a request that can't be sent as JSON
|
|
|
643
693
|
cycle) rejects with the `TypeError`, and nothing is sent. `orThrow(result)` gives the data, or
|
|
644
694
|
throws the failure as an `ApiFailure` carrying its `error`, for callers who'd rather catch.
|
|
645
695
|
|
|
646
|
-
- **`
|
|
647
|
-
- **`
|
|
648
|
-
- **`
|
|
649
|
-
`totals` and `timings`. Only the request's declared fields are sent: `source`, `
|
|
650
|
-
`dimensions`, `metrics`, `filters`, `sort`, `offset` and `rows`.
|
|
651
|
-
`
|
|
652
|
-
|
|
696
|
+
- **`flipstream.catalog.list()`** gives a `Catalog`.
|
|
697
|
+
- **`flipstream.catalog.get({ source })`** gives a `CatalogSource`: a source plus `catalogVersion`.
|
|
698
|
+
- **`flipstream.query(request)`** gives a `QueryResponse`, with `rows` and `lastRow`, and sometimes
|
|
699
|
+
`totals` and `timings`. Only the request's declared fields are sent: `source`, `dataset_id`,
|
|
700
|
+
`dimensions`, `metrics`, `filters`, `sort`, `offset` and `rows`. The query API names the dataset
|
|
701
|
+
`connection_id`, so `dataset_id` goes as that, and the API's own errors may say so. A request
|
|
702
|
+
with any other key, `table` and `connection_id` included, is `refused` with nothing sent, and
|
|
703
|
+
`error.fields` names each one, so a misspelt field never quietly changes the numbers.
|
|
653
704
|
- **`refusedQueryFields(request)`** runs that check on its own, with no client and nothing
|
|
654
|
-
sent. It gives the same names, sorted, or `[]` for a request `
|
|
655
|
-
app can refuse a request before anything else it does: a CLI given a raw JSON body, for
|
|
705
|
+
sent. It gives the same names, sorted, or `[]` for a request `flipstream.query` would send.
|
|
706
|
+
So an app can refuse a request before anything else it does: a CLI given a raw JSON body, for
|
|
656
707
|
instance, before its other calls. It reads only the keys; a missing `source` is still the
|
|
657
708
|
API's to refuse.
|
|
658
|
-
- **`
|
|
709
|
+
- **`flipstream.health()`** gives the planner's answer to `GET /health`, an object of strings
|
|
659
710
|
(`{ status: 'ok' }` today). It works signed out: no token is asked for or sent, so it tells "the
|
|
660
711
|
service is down" from "the sign-in is wrong".
|
|
661
712
|
|
|
@@ -674,7 +725,7 @@ back as data. A field the SDK doesn't know yet is kept.
|
|
|
674
725
|
| `invalid` | Outside the contract: an answer that isn't JSON or doesn't match its type, or a status no API sends |
|
|
675
726
|
| `timeout` | The call's own deadline passed |
|
|
676
727
|
| `aborted` | The caller's `signal` fired |
|
|
677
|
-
| `refused` | Nothing was sent, by rule
|
|
728
|
+
| `refused` | Nothing was sent, by rule, and `reason` says which (below) |
|
|
678
729
|
| `no_token` | The token function failed, or gave no token. `cause` is what it threw |
|
|
679
730
|
| `cancelled` | The app's own transport cancelled the call, because the session it was made for moved on |
|
|
680
731
|
|
|
@@ -686,6 +737,22 @@ back as data. A field the SDK doesn't know yet is kept.
|
|
|
686
737
|
came.
|
|
687
738
|
- When the API asked the caller to wait, the failure keeps that as `retryAfterMs`.
|
|
688
739
|
|
|
740
|
+
**A `refused` call says why, in `reason`** (`RefusedReason`), and `orThrow`'s message names it,
|
|
741
|
+
never the value:
|
|
742
|
+
|
|
743
|
+
| `reason` | When |
|
|
744
|
+
|---|---|
|
|
745
|
+
| `destination` | Not an allowed host: a configured one, or for sign-in the issuer's own, over https, or over http on this machine with `allowLocalhostHttp`, for the client as for sign-in |
|
|
746
|
+
| `identification` | A value identifying the app, its agent or the conversation holds the access token (see "Which app sent a request") |
|
|
747
|
+
| `path` | A `source` of `''`, `.` or `..`, which can't stay one path segment |
|
|
748
|
+
| `conversation-id` | A call's own `conversationId` that breaks its rule |
|
|
749
|
+
| `fields` | A query with keys it doesn't send, each named in `fields` |
|
|
750
|
+
| `pending` | Sign-in: a `pending` that isn't one, wasn't started by this app at this server, or whose token endpoint breaks its issuer's rule |
|
|
751
|
+
| `callback` | Sign-in: a callback URL that can't be read |
|
|
752
|
+
|
|
753
|
+
Every refusal the SDK returns has a `reason`. The type leaves it optional, so an error your own
|
|
754
|
+
code builds, such as a test double, may leave it out.
|
|
755
|
+
|
|
689
756
|
```ts
|
|
690
757
|
import { isPlannerCode, type ApiError } from '@flipstream/sdk'
|
|
691
758
|
|
|
@@ -708,7 +775,7 @@ function explain(error: ApiError): string {
|
|
|
708
775
|
case 'cancelled':
|
|
709
776
|
return 'Stopped.'
|
|
710
777
|
case 'refused':
|
|
711
|
-
return error.fields === undefined ?
|
|
778
|
+
return error.fields === undefined ? `Not sent: ${error.reason ?? 'refused'}.` : `Not sent: unknown field ${error.fields.join(', ')}`
|
|
712
779
|
case 'no_token':
|
|
713
780
|
return 'No token to send.'
|
|
714
781
|
default: {
|
|
@@ -729,8 +796,9 @@ function explain(error: ApiError): string {
|
|
|
729
796
|
redirect (`parsePastedRedirect`, or `signInWithLoopback`'s `readPasted`).
|
|
730
797
|
|
|
731
798
|
There, `refused` also covers an issuer that isn't https (unless it's http on this machine, with
|
|
732
|
-
`allowLocalhostHttp`),
|
|
733
|
-
|
|
799
|
+
`allowLocalhostHttp`), with `reason: 'destination'`; a `pending` that isn't one (from storage the
|
|
800
|
+
app couldn't read back), with `reason: 'pending'`; and a callback URL that can't be read, with
|
|
801
|
+
`reason: 'callback'`. Nothing is sent for any of them.
|
|
734
802
|
|
|
735
803
|
## Options
|
|
736
804
|
|
|
@@ -739,7 +807,10 @@ import { createFlipstream } from '@flipstream/sdk'
|
|
|
739
807
|
|
|
740
808
|
declare const session: { accessToken(rejected?: string): Promise<string> }
|
|
741
809
|
|
|
742
|
-
const
|
|
810
|
+
const flipstream = createFlipstream({
|
|
811
|
+
app: { name: 'my-cli', version: '1.0.0' }, // required: see "Which app sent a request"
|
|
812
|
+
agent: { name: 'claude-code', version: '2.1.0' }, // optional: the agent running the app
|
|
813
|
+
conversationId: 'c-123', // optional: the conversation or run the calls belong to
|
|
743
814
|
// Asked before every attempt; after a 401, asked once more with the token the API refused.
|
|
744
815
|
token: ({ rejected }) => session.accessToken(rejected),
|
|
745
816
|
fetch: globalThis.fetch, // optional: every request goes through it
|
|
@@ -748,7 +819,9 @@ const fs = createFlipstream({
|
|
|
748
819
|
})
|
|
749
820
|
|
|
750
821
|
const controller = new AbortController()
|
|
751
|
-
await
|
|
822
|
+
await flipstream.catalog.list({ signal: controller.signal, deadlineMs: 10_000 })
|
|
823
|
+
// A call may name its own conversation, and carry on the caller's W3C trace context.
|
|
824
|
+
await flipstream.catalog.list({ conversationId: 'c-456', traceparent: '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' })
|
|
752
825
|
```
|
|
753
826
|
|
|
754
827
|
- **The token function** is asked before every attempt, so a renewed token is always the one sent.
|
|
@@ -776,6 +849,40 @@ await fs.catalog.list({ signal: controller.signal, deadlineMs: 10_000 })
|
|
|
776
849
|
it never goes through your transport: it goes to the query host, over https, with the global
|
|
777
850
|
`fetch`.
|
|
778
851
|
|
|
852
|
+
## Which app sent a request
|
|
853
|
+
|
|
854
|
+
Every signed-in request says which app sent it, and, when you name them, which agent and
|
|
855
|
+
conversation, so a later query log can show who asked what. It reports nothing beyond the request:
|
|
856
|
+
the SDK has no telemetry. In Node, each signed-in request to an API host carries:
|
|
857
|
+
|
|
858
|
+
| Header | Value | Standard |
|
|
859
|
+
|---|---|---|
|
|
860
|
+
| `User-Agent` | `<app>/<version> flipstream-sdk/<version> node/<version>` | RFC 9110 product tokens |
|
|
861
|
+
| `traceparent` | one trace-id per call, kept across its retries, with a new parent-id for each request | W3C Trace Context |
|
|
862
|
+
| `baggage` | `gen_ai.agent.name`, `gen_ai.agent.version` and `gen_ai.conversation.id`, percent-encoded, only those given | W3C Baggage, with OpenTelemetry's GenAI names (not stable yet) |
|
|
863
|
+
|
|
864
|
+
- **`app` is required;** `agent` and `conversationId` are optional, and a call's own
|
|
865
|
+
`conversationId` replaces the client's for that call.
|
|
866
|
+
- **Strict values:** names and versions are 1 to 64 of RFC 9110's token characters (letters,
|
|
867
|
+
digits and ``!#$%&'*+-.^_`|~``); `conversationId` is 1 to 128 of A-Z, a-z, 0-9, `.`, `_`, `:`
|
|
868
|
+
and `-`. Anything else is a TypeError at creation, which names the option but not its value. A
|
|
869
|
+
call's `conversationId` that breaks the rule is `refused`, with nothing sent.
|
|
870
|
+
- **Never the token:** a call whose `app`, `agent` or `conversationId` holds the access token is
|
|
871
|
+
`refused`, with nothing sent. A token of 16 characters or more is looked for anywhere in a value.
|
|
872
|
+
A shorter one, which only tests and local servers use, counts only when a value equals it, so it
|
|
873
|
+
can't refuse an ordinary value that happens to contain it. With your own transport, the SDK never
|
|
874
|
+
sees the token, so that check is your transport's.
|
|
875
|
+
- **`health` says only who the SDK is.** It's signed out and asks for no token, so it sends
|
|
876
|
+
`User-Agent: flipstream-sdk/<version> node/<version>` and a `traceparent`, and none of `app`,
|
|
877
|
+
`agent` or `conversationId`: nothing could check them there.
|
|
878
|
+
- **Your trace:** pass `traceparent` on a call to carry on your own trace. The call keeps its
|
|
879
|
+
trace-id and flags, with its own parent-id for each request. One that isn't a valid version-00
|
|
880
|
+
traceparent is dropped, as W3C Trace Context says, and the call starts its own trace, sampled
|
|
881
|
+
(`01`).
|
|
882
|
+
- **Only to the API hosts.** The auth server never gets them: `discover`, sign-in, refresh and
|
|
883
|
+
revoke send none.
|
|
884
|
+
- **Not from a browser yet:** see "In a browser".
|
|
885
|
+
|
|
779
886
|
## Which version is running
|
|
780
887
|
|
|
781
888
|
```ts
|
package/dist/auth/discovery.js
CHANGED
|
@@ -21,7 +21,7 @@ const zMetadata = z.looseObject({
|
|
|
21
21
|
*/
|
|
22
22
|
export async function discover(issuer, options = {}) {
|
|
23
23
|
if (typeof issuer !== 'string' || !isSignInUrl(issuer, options.allowLocalhostHttp))
|
|
24
|
-
return { ok: false, error: { kind: 'refused' } };
|
|
24
|
+
return { ok: false, error: { kind: 'refused', reason: 'destination' } };
|
|
25
25
|
const read = await call(authTransport(options), {
|
|
26
26
|
effect: 'read',
|
|
27
27
|
service: 'auth',
|
|
@@ -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,eAAe,EAAE,WAAW,EAAwB,MAAM,gBAAgB,CAAA;AAgBlG,kGAAkG;AAClG,mDAAmD;AACnD,MAAM,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,sBA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,CAAA;IAChH,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/auth/signIn.js
CHANGED
|
@@ -96,8 +96,13 @@ export function finishSignIn(callbackUrl, pending, options = {}) {
|
|
|
96
96
|
* entry never exports this, so browser code has no way to send client credentials.
|
|
97
97
|
*/
|
|
98
98
|
export async function exchangeCode(callbackUrl, pending, options, authorization) {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
// Refused with nothing sent, each for its own reason (#199): what it refuses is as before.
|
|
100
|
+
if (!isPendingSignIn(pending))
|
|
101
|
+
return { ok: false, error: { kind: 'refused', reason: 'pending' } };
|
|
102
|
+
if (!isSignInUrl(pending.tokenEndpoint, options.allowLocalhostHttp))
|
|
103
|
+
return { ok: false, error: { kind: 'refused', reason: 'destination' } };
|
|
104
|
+
if (!URL.canParse(callbackUrl))
|
|
105
|
+
return { ok: false, error: { kind: 'refused', reason: 'callback' } };
|
|
101
106
|
const callback = readCallback(callbackUrl, pending);
|
|
102
107
|
if (callback.kind !== 'code')
|
|
103
108
|
return { ok: false, error: callback };
|
package/dist/auth/signIn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signIn.js","sourceRoot":"","sources":["../../src/auth/signIn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAGtC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAwB,MAAM,gBAAgB,CAAA;AAoElG,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAA;AAE/F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WA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AAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9I,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAA;IAC7B,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,IAAI,CAAA;IACtE,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE;YACJ,WAAW,EAAE,YAAY;YACzB,+FAA+F;YAC/F,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC;YAC9E,wFAAwF;YACxF,wBAAwB;YACxB,KAAK,EAAE,KAAK,IAAI,OAAO,CAAC,KAAK;SAC9B;KACF,CAAA;AACH,CAAC"}
|
package/dist/core/fetch.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export interface FetchTransportOptions {
|
|
|
15
15
|
readonly hosts: Readonly<Partial<Record<ServiceName, string>>>;
|
|
16
16
|
/** Plain http to a loopback host (localhost, 127.0.0.1, [::1]): development and tests only. */
|
|
17
17
|
readonly allowLocalhostHttp?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Whether `request`, as built, carries `token` where only its authorization header may: then it
|
|
20
|
+
* is refused, unsent (#192). createFlipstream's check of the values that identify the caller.
|
|
21
|
+
*/
|
|
22
|
+
readonly holdsToken?: ((request: Request, token: string) => boolean) | undefined;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Plain http to this machine (localhost, 127.0.0.1, [::1]), which `allowLocalhostHttp` lets
|
package/dist/core/fetch.js
CHANGED
|
@@ -9,6 +9,7 @@ export function isLoopbackHttp(url) {
|
|
|
9
9
|
}
|
|
10
10
|
const ABORTED = { kind: 'aborted' };
|
|
11
11
|
const REFUSED = { kind: 'refused', reason: 'destination' };
|
|
12
|
+
const HOLDS_TOKEN = { kind: 'refused', reason: 'identification' };
|
|
12
13
|
export function fetchTransport(options) {
|
|
13
14
|
const send = options.fetch ?? globalThis.fetch;
|
|
14
15
|
const allowed = destinations(options);
|
|
@@ -26,6 +27,8 @@ export function fetchTransport(options) {
|
|
|
26
27
|
return token;
|
|
27
28
|
if (call.signal.aborted)
|
|
28
29
|
return ABORTED;
|
|
30
|
+
if (options.holdsToken?.(built, token.token) === true)
|
|
31
|
+
return HOLDS_TOKEN;
|
|
29
32
|
const headers = new Headers(built.headers);
|
|
30
33
|
try {
|
|
31
34
|
headers.set('authorization', `Bearer ${token.token}`);
|
package/dist/core/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/core/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/core/fetch.ts"],"names":[],"mappings":"AAgCA,MAAM,QAAQ,GAA2B,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AACjE,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;AAElF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,GAAQ;IACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC;AACD,MAAM,OAAO,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,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;IACF,qFAAqF;IACrF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE;SAC5B,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACtB,IAAI,CACH,CAAC,KAAK,EAAS,EAAE,CACf,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;QACvC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;QACjC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,kCAAkC,CAAC,EAAE,EACpF,CAAC,KAAc,EAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CACzD,CAAA;IACH,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;IAC7C,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC3C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** An app's or an agent's name and version, as a product token: `name/version`. */
|
|
2
|
+
export interface Product {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly version: string;
|
|
5
|
+
}
|
|
6
|
+
/** What a client says about itself, checked once, at creation. */
|
|
7
|
+
export interface Identity {
|
|
8
|
+
readonly app: Product;
|
|
9
|
+
readonly agent: Product | undefined;
|
|
10
|
+
readonly conversationId: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function isConversationId(value: unknown): value is string;
|
|
13
|
+
/** The client's identity from createFlipstream's options, or a TypeError naming what breaks its rule. */
|
|
14
|
+
export declare function identityOf(options: {
|
|
15
|
+
readonly app?: unknown;
|
|
16
|
+
readonly agent?: unknown;
|
|
17
|
+
readonly conversationId?: unknown;
|
|
18
|
+
}): Identity;
|
|
19
|
+
/** One call's trace: the caller's trace-id and flags when it passed a valid traceparent, or new ones. */
|
|
20
|
+
export interface Trace {
|
|
21
|
+
readonly traceId: string;
|
|
22
|
+
readonly flags: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The trace a call goes out under. A caller's own `traceparent` is carried on when it is one;
|
|
26
|
+
* otherwise, as W3C Trace Context says of one that can't be parsed, the call starts its own. A new
|
|
27
|
+
* trace is sampled (`01`), so a backend that samples on its parent records it: the query log
|
|
28
|
+
* needs every request (D527).
|
|
29
|
+
*/
|
|
30
|
+
export declare function traceFor(callerTraceparent: unknown): Trace;
|
|
31
|
+
/** The traceparent of one attempt: the call's trace, with a parent-id of its own. */
|
|
32
|
+
export declare function traceparent(trace: Trace): string;
|
|
33
|
+
/** What a request says about who sent it: its User-Agent and baggage, and the caller's values in them. */
|
|
34
|
+
export interface Sender {
|
|
35
|
+
readonly userAgent: string;
|
|
36
|
+
readonly baggage: string | undefined;
|
|
37
|
+
/** Each of which must never hold the access token. */
|
|
38
|
+
readonly values: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A signed-in call's: `User-Agent: <app>/<version> flipstream-sdk/<version> node/<version>`, and
|
|
42
|
+
* `baggage` with OpenTelemetry's GenAI names, each value percent-encoded, only when there is an
|
|
43
|
+
* agent or a conversation: no empty header.
|
|
44
|
+
*/
|
|
45
|
+
export declare function callerSender(identity: Identity, conversationId: string | undefined, nodeVersion: string): Sender;
|
|
46
|
+
/**
|
|
47
|
+
* Health's, signed out (D535): `User-Agent: flipstream-sdk/<version> node/<version>` alone. It asks
|
|
48
|
+
* for no token, so nothing could check a caller's value there, and a probe gains little from one.
|
|
49
|
+
*/
|
|
50
|
+
export declare function sdkSender(nodeVersion: string): Sender;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a caller's `value` holds the access token (#199): contains it, for a token of real
|
|
53
|
+
* length; equals it, for a shorter one, which as a substring turns up in ordinary values ('abc' in
|
|
54
|
+
* 'abcdef') and would refuse them by chance.
|
|
55
|
+
*/
|
|
56
|
+
export declare function valueHolds(value: string, token: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Node's version, where these headers go out: Node, or a runtime that says it is Node's (Bun, Deno),
|
|
59
|
+
* with no `window`. In a browser, a CORS preflight would refuse every call until the hosts allow
|
|
60
|
+
* the headers (query-planner#48), so none go there yet. Electron's renderer and a jsdom test, which
|
|
61
|
+
* have both, send none: an unidentified request still works, a refused preflight doesn't.
|
|
62
|
+
*/
|
|
63
|
+
export declare function nodeVersion(): string | undefined;
|