@flipstream/sdk 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +48 -20
- package/dist/api/backend.d.ts +7 -0
- package/dist/api/backend.js +7 -0
- package/dist/api/backend.js.map +1 -1
- package/dist/api/credentials.js +4 -4
- package/dist/api/credentials.js.map +1 -1
- package/dist/api/datasets.js +30 -50
- package/dist/api/datasets.js.map +1 -1
- package/dist/api/handoff.d.ts +1 -1
- package/dist/api/handoff.js +7 -0
- package/dist/api/handoff.js.map +1 -1
- package/dist/api/log.d.ts +4 -4
- package/dist/api/log.js +23 -42
- package/dist/api/log.js.map +1 -1
- package/dist/api/me.d.ts +5 -3
- package/dist/api/me.js +3 -3
- package/dist/api/me.js.map +1 -1
- package/dist/api/members.d.ts +40 -17
- package/dist/api/members.js +66 -29
- package/dist/api/members.js.map +1 -1
- package/dist/api/ownRecord.d.ts +46 -0
- package/dist/api/ownRecord.js +57 -0
- package/dist/api/ownRecord.js.map +1 -0
- package/dist/api/refusal.d.ts +14 -0
- package/dist/api/refusal.js +23 -0
- package/dist/api/refusal.js.map +1 -0
- package/dist/api/wallet.d.ts +2 -1
- package/dist/api/wallet.js +18 -24
- package/dist/api/wallet.js.map +1 -1
- package/dist/api/workspaces.d.ts +7 -2
- package/dist/api/workspaces.js +14 -8
- package/dist/api/workspaces.js.map +1 -1
- package/dist/auth/discovery.js +4 -5
- package/dist/auth/discovery.js.map +1 -1
- package/dist/core/call.d.ts +5 -4
- package/dist/core/call.js +5 -7
- package/dist/core/call.js.map +1 -1
- package/dist/core/identify.d.ts +6 -0
- package/dist/core/identify.js +15 -7
- package/dist/core/identify.js.map +1 -1
- package/dist/core/inPlaceOf.d.ts +6 -0
- package/dist/core/inPlaceOf.js +17 -0
- package/dist/core/inPlaceOf.js.map +1 -0
- package/dist/core/invalid.d.ts +32 -9
- package/dist/core/invalid.js +36 -23
- package/dist/core/invalid.js.map +1 -1
- package/dist/core/notFound.d.ts +2 -2
- package/dist/core/notFound.js.map +1 -1
- package/dist/core/read.d.ts +4 -10
- package/dist/core/read.js +1 -11
- package/dist/core/read.js.map +1 -1
- package/dist/core/result.d.ts +13 -9
- package/dist/core/result.js +1 -0
- package/dist/core/result.js.map +1 -1
- package/dist/core/shared.d.ts +13 -9
- package/dist/core/shared.js +7 -6
- package/dist/core/shared.js.map +1 -1
- package/dist/flipstream.d.ts +81 -27
- package/dist/flipstream.js +37 -26
- package/dist/flipstream.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/node/keychainChild.js +60 -25
- package/dist/node/keychainChild.js.map +1 -1
- package/dist/node/keychainError.d.ts +4 -1
- package/dist/node/keychainError.js.map +1 -1
- package/dist/node/keychainStore.js +42 -8
- package/dist/node/keychainStore.js.map +1 -1
- package/dist/node/session.js +6 -7
- package/dist/node/session.js.map +1 -1
- package/dist/query/query.d.ts +52 -8
- package/dist/query/query.js +133 -19
- package/dist/query/query.js.map +1 -1
- package/dist/version.gen.js +1 -1
- package/docs/admin.md +53 -4
- package/docs/node-sign-in.md +8 -4
- package/package.json +1 -1
package/docs/admin.md
CHANGED
|
@@ -95,6 +95,13 @@ section's basics, and its most common example, are in the package's README under
|
|
|
95
95
|
token reaches, such as Flipstream's staff acting through a swap token. The organisation is
|
|
96
96
|
checked before the key, so another organisation's key is `invalid` too. So is an answer that
|
|
97
97
|
is someone else than the person asked for.
|
|
98
|
+
- **Removing someone from your organisation is a person's to do, in the console.** It can't be
|
|
99
|
+
undone. `flipstream.members.remove({ member_id })` never writes. It reads the person first, by
|
|
100
|
+
`get`'s rules above: `not_found` when there's no such person for you (an API key included),
|
|
101
|
+
`forbidden` when pulse-auth refuses the read, and `invalid` for another organisation's person.
|
|
102
|
+
Then it answers `needs_person` with `why`, and, where a console can be named (your own
|
|
103
|
+
`hosts.console`), the person's page in People as `url`, with what it shows as `sees`, as
|
|
104
|
+
`datasets.delete` does. There, Owners and Admins remove them.
|
|
98
105
|
|
|
99
106
|
## The workspaces you open
|
|
100
107
|
|
|
@@ -107,6 +114,20 @@ section's basics, and its most common example, are in the package's README under
|
|
|
107
114
|
no workspace opens every one, whatever its role, a role read as none included.
|
|
108
115
|
- **One you don't open is `not_found`,** exactly as one nobody has, so the answer says no more than
|
|
109
116
|
that. A write sends nothing, and a hand-off isn't made.
|
|
117
|
+
- **A record the service refuses you is `not_found` too** (D578): its own refusal of the record's
|
|
118
|
+
read, a 403 with code `FORBIDDEN_EXCEPTION`, says it exists, so it's answered as one nobody has, as
|
|
119
|
+
a workspace you don't open is (D571). That holds for a workspace's own read, in every call under
|
|
120
|
+
one, and for a record named by its id. In a scope, the answer names the same request as a record
|
|
121
|
+
nobody has would.
|
|
122
|
+
- **Still `forbidden`:**
|
|
123
|
+
- your own read's refusal;
|
|
124
|
+
- a 403 that isn't the service's own refusal of the record: a page from something in front of
|
|
125
|
+
it, such as a proxy or a sign-in gate, or the service's refusal of the token
|
|
126
|
+
(`TOKEN_INVALID_EXCEPTION`). Those say nothing about the record;
|
|
127
|
+
- a 403 on a workspace's list read beside it;
|
|
128
|
+
- a write's own 403 once the record is read: a role that can read but not write.
|
|
129
|
+
- **Accepted knowingly:** a role the service refuses every record gets `not_found` for every id,
|
|
130
|
+
and so does a token whose scopes don't cover the route, since the service refuses both alike.
|
|
110
131
|
- **When it's checked:**
|
|
111
132
|
- **A workspace named up front** (a workspace's own calls, its logbook's `list` and `add`, its
|
|
112
133
|
datasets' `list` and `count`): your organisation and you are read first. One you don't open is
|
|
@@ -116,8 +137,19 @@ section's basics, and its most common example, are in the package's README under
|
|
|
116
137
|
yours, then the workspace's, then the list's, is the answer.
|
|
117
138
|
- **A record named by its id** (an entry's `get`, `update` and `remove`; a dataset's `get`,
|
|
118
139
|
`pause`, `resume` and `delete`): its workspace is known only once the record is read, so you're
|
|
119
|
-
read beside it, and the service's own failure of that read is passed on as it came
|
|
120
|
-
|
|
140
|
+
read beside it, and the service's own failure of that read is passed on as it came, but its own
|
|
141
|
+
refusal of the record, which is `not_found` (D578, above). The answer is your organisation's
|
|
142
|
+
failure, then yours, then the record's, then its checks: another organisation's record is
|
|
143
|
+
`invalid`, and one in a workspace you don't open is `not_found`.
|
|
144
|
+
- A sign-in whose read of you fails, such as one the sign-in service refuses or one that isn't
|
|
145
|
+
a person, gets that failure whether the record exists or not, so it can't tell the two apart.
|
|
146
|
+
Once your read has failed, the call answers without waiting for the record.
|
|
147
|
+
- A sign-in that isn't a person, such as a service account, gets `not_found` with the sign-in
|
|
148
|
+
service's code, `USER_NOT_FOUND`: the same kind as a record nobody has, so read `error.code`
|
|
149
|
+
to tell the two apart.
|
|
150
|
+
- Another organisation's record answering `invalid` still says it exists, to a token the service
|
|
151
|
+
answers other organisations' records for, such as Flipstream's own staff's. That's intended:
|
|
152
|
+
such a record is never shown as yours.
|
|
121
153
|
- **You're read as `flipstream.me()` reads you:** who your token belongs to, then that person, under
|
|
122
154
|
the call's deadline. That's one more round trip to the sign-in service per call, two reads in a
|
|
123
155
|
row, with nothing cached. In a scope, the calls of one piece of work share it (see "One piece of
|
|
@@ -181,10 +213,26 @@ section's basics, and its most common example, are in the package's README under
|
|
|
181
213
|
- **Closing a scope ends its reads still on their way,** and a call still waiting on one answers
|
|
182
214
|
`aborted`. A call that takes a closed scope reads its own, as outside a scope: a late refetch is
|
|
183
215
|
fine.
|
|
184
|
-
- **A shared read goes out under a trace of its own,** never a
|
|
216
|
+
- **A shared read goes out under a trace of its own,** never a call's `traceparent`, and every call
|
|
185
217
|
it answers names that trace in `trace_id` (see "Finding a request in Logs" in
|
|
186
218
|
[README.md](../README.md)): the read's whose failure is the call's answer, else the call's own
|
|
187
219
|
requests', else the first shared read the call asked for.
|
|
220
|
+
- **Or under the scope's trace, when you give it one:** `flipstream.scope({ traceparent })` and
|
|
221
|
+
`withScope(run, { traceparent })` take your W3C trace context, as a call's `traceparent` does
|
|
222
|
+
(#409). Every shared read the scope sends to the admin host, your organisation's and a
|
|
223
|
+
workspace's own, goes out under its trace-id and flags, with a parent-id of its own for each
|
|
224
|
+
attempt, and the calls those reads answer name that trace-id. So one command is one trace.
|
|
225
|
+
- Your reads of you go to the sign-in service, which no request carries a trace to, so they carry
|
|
226
|
+
none, with or without it.
|
|
227
|
+
- From a browser, the SDK sends the admin host no trace yet, until its CORS allows one (see
|
|
228
|
+
"Which app sent a request" in [README.md](../README.md)), so there the option changes nothing.
|
|
229
|
+
- A call names the request that answered it as its `trace_id`. So a call answered by shared
|
|
230
|
+
reads alone, such as `me()`, names the scope's trace-id, even when it was given its own
|
|
231
|
+
`traceparent`.
|
|
232
|
+
- One that isn't a valid version-00 traceparent, a value that isn't a string included, is dropped
|
|
233
|
+
silently, as a call's is, and the shared reads keep traces of their own.
|
|
234
|
+
- It never reaches a call's own requests: those take the call's own `traceparent`, or a trace of
|
|
235
|
+
their own. And a call's own `traceparent` never reaches a shared read.
|
|
188
236
|
|
|
189
237
|
## Workspaces
|
|
190
238
|
|
|
@@ -360,7 +408,8 @@ orThrow(await flipstream.log.remove({ log_id: added.id })) // null
|
|
|
360
408
|
nothing else: never a credential, a setting or its parameters, beyond its account's id. The
|
|
361
409
|
service's answer embeds the dataset's sign-in, so a body that isn't the service's JSON is never
|
|
362
410
|
kept either: a failure of the dataset's own read or write gives its kind and status, with no
|
|
363
|
-
`text`. The reads of your organisation and the workspace beside it keep theirs
|
|
411
|
+
`text`. The reads of your organisation and the workspace beside it keep theirs, but the service's
|
|
412
|
+
own refusal of the workspace, which is `not_found` (see "The workspaces you open").
|
|
364
413
|
- `type` is one of the types `datasetTypes.list()` gives, such as `'google_search_console'`, or
|
|
365
414
|
a type this version doesn't know yet, kept as it came, so a new kind of dataset never makes the
|
|
366
415
|
list unreadable. It's `null` when the service holds no type for it.
|
package/docs/node-sign-in.md
CHANGED
|
@@ -207,7 +207,11 @@ if (signedOut.cleared === 'failed') {
|
|
|
207
207
|
reboot;
|
|
208
208
|
- `refused`: any other refusal, in the keychain's own words;
|
|
209
209
|
- `timeout`: the step took longer than its `timeoutMs`;
|
|
210
|
-
- `helper`: the helper process couldn't start, or ended before it answered (`exit` says how)
|
|
210
|
+
- `helper`: the helper process couldn't start, or ended before it answered (`exit` says how).
|
|
211
|
+
One that couldn't start for want of file descriptors (`EMFILE`, your process's own limit, or
|
|
212
|
+
`ENFILE`, the whole system's table) has the spawn's own error, with that `code`, as the
|
|
213
|
+
error's `cause`, when Node reports it in time: a hint for your logs, not a promise, so never
|
|
214
|
+
let your app depend on it;
|
|
211
215
|
- `missing`: `@napi-rs/keyring` isn't installed, and the message names it;
|
|
212
216
|
- `too-long`: the tokens are over 2,560 bytes, so nothing was saved.
|
|
213
217
|
|
|
@@ -242,9 +246,9 @@ if (signedOut.cleared === 'failed') {
|
|
|
242
246
|
the same 30 s. The helper never keeps your app running. It's `process.execPath`, so it needs a
|
|
243
247
|
Node that runs a script: not an Electron app (without `ELECTRON_RUN_AS_NODE`), a Node
|
|
244
248
|
single-executable application, or a compiled Bun binary. A bundle must keep `keychainChild.js`
|
|
245
|
-
beside the module, with
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
beside the module, with `@napi-rs/keyring` resolvable from there, and `import.meta.url` set.
|
|
250
|
+
Where it doesn't (an esbuild CommonJS bundle, say), only the keychain's steps fail, as
|
|
251
|
+
`store_failed`.
|
|
248
252
|
- Through `session.token()`, a keychain read that takes longer than the caller's wait, 15 s
|
|
249
253
|
unless you pass `createSession({ waitMs })`, is `unavailable`. On macOS a read can wait on
|
|
250
254
|
an access dialog, every time, for an item another program saved: give `waitMs` as long as
|