@tinycloud/web-sdk 3.3.0-beta.8 → 3.3.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/README.md +140 -4
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/modules/tcw.d.ts +24 -4
- package/dist/share/receiver-credentials.d.ts +1 -0
- package/dist/share/receiver-session.d.ts +60 -9
- package/dist/share/service.d.ts +2 -1
- package/dist/share/types.d.ts +2 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -138,15 +138,103 @@ and the worker keep TC-1413's ceilings. The ledger's `tc1436Ratchet` row records
|
|
|
138
138
|
and cannot change later. If another root-growing PR lands first, #578 re-measures
|
|
139
139
|
against the new base and replaces its own row before it merges.
|
|
140
140
|
|
|
141
|
+
TC-1432 (vault `etag`, `ifMatch` and opt-in `expectAad` in sdk-services, #580) landed
|
|
142
|
+
after #578, so it was re-measured against master `129c7935` and sits on top of TC-1436's
|
|
143
|
+
root ceilings. It raised four buckets once, by the exact bytes GitHub run 39144311690
|
|
144
|
+
measured on source `83c9d75a`, identical in both jobs: the root to 1,466,908 /
|
|
145
|
+
1,396,591 B (+913 / +872 over TC-1436's), first import to 51,925 / 67,138 B (+1 / -1),
|
|
146
|
+
activation to 23,106 / 24,685 B (+1 / +2) and the worker to 822,044 B (+1,109 over
|
|
147
|
+
TC-1413's, also `MAX_WORKER_GZIP_BYTES`). It is #580's own row, taken after a documented
|
|
148
|
+
shrink attempt (see the row's `reason`). The ledger's `tc1432Ratchet` row and the
|
|
149
|
+
matching optional allowance record it and cannot change later; whichever PR lands after
|
|
150
|
+
it re-measures against the new base and updates its own row.
|
|
151
|
+
|
|
152
|
+
TC-1424 (the share receiver's non-extractable signing key, #583) landed after #580, so
|
|
153
|
+
it was re-measured against master `1d7b78fd` and sits on top of TC-1432's root ceilings.
|
|
154
|
+
It raised only the root ceilings once, by the exact bytes GitHub run 39150995159
|
|
155
|
+
measured on source `55145dbb`, identical in both jobs: 1,468,581 / 1,397,877 B (+1,673 /
|
|
156
|
+
+1,286 over TC-1432's). First import, activation, gated and the worker keep TC-1432's
|
|
157
|
+
ceilings. It is #583's own row, taken after a documented shrink attempt (see the row's
|
|
158
|
+
`reason`). The ledger's `tc1424Ratchet` row records it and cannot change later; whichever
|
|
159
|
+
PR lands after it re-measures against the new base and updates its own row.
|
|
160
|
+
|
|
161
|
+
TC-1448 (the `did:pkh` recipient guard for terminal grants in `TinyCloudNode.delegateTo`,
|
|
162
|
+
#591) landed after #583, so it was re-measured against master `1c89b697` and sits on top of
|
|
163
|
+
TC-1424's root ceilings. It raised only the root ceilings once, after a real shrink (it
|
|
164
|
+
reuses the existing terminal-grant error string), by the exact bytes GitHub run 39159867318
|
|
165
|
+
measured on `b8d13379` (master merged into the PR branch, source unchanged since
|
|
166
|
+
`18b6c9fa`), identical in both jobs: 1,468,625 / 1,397,910 B (+44 / +33 over TC-1424's).
|
|
167
|
+
The ledger's `tc1448Ratchet` row records them and cannot change later; whichever PR lands
|
|
168
|
+
after it re-measures against the new base and updates its own row.
|
|
169
|
+
|
|
170
|
+
The TC-1443 registry verdict classifier in sdk-core (#586) raised only the root
|
|
171
|
+
ceilings once more, after removing a duplicate secp256k1 from the bundle. It landed
|
|
172
|
+
after #591, so it was re-measured against master `70304c3d` and chains after
|
|
173
|
+
TC-1448's root ceilings. Naomi approved the row as a delta over its base (+2,368 / +61
|
|
174
|
+
gzip, ±50 B); GitHub run 39166751086 measured it on source `72ba295c`, identical in
|
|
175
|
+
both Node jobs: 1,470,995 / 1,397,981 B, i.e. +2,370 / +71 over master's measured
|
|
176
|
+
1,468,625 / 1,397,910 B. The row's ceilings are those measured bytes. First import,
|
|
177
|
+
activation, the gated artifact and the worker keep TC-1432's ceilings. The ledger's
|
|
178
|
+
`tc1443Ratchet` row records them and cannot change later. If another root-growing PR
|
|
179
|
+
lands first, #586 re-measures against the new base and replaces its own row before
|
|
180
|
+
it merges.
|
|
181
|
+
|
|
182
|
+
TC-1466 (a share receiver opened in several tabs at once could end up with different
|
|
183
|
+
signing keys, #595) landed after #586, so it sits on top of TC-1443's root ceilings. It
|
|
184
|
+
raised only the root ceilings once, after shrink attempts recorded in the row's `reason`,
|
|
185
|
+
by the exact bytes GitHub run 39172186671 measured on `b2725dd6` (master `28ca77a0`
|
|
186
|
+
merged into the PR branch), identical in both Node jobs: 1,471,007 / 1,397,987 B (+12 /
|
|
187
|
+
+6 over TC-1443's, inside the approved +12 / +6 ± 10 B). The ledger's `tc1466Ratchet` row
|
|
188
|
+
records them and cannot change later; whichever PR lands after it re-measures against
|
|
189
|
+
the new base and updates its own row.
|
|
190
|
+
|
|
191
|
+
The TC-1443 slice b registry policy (#589: the opt-in fail-closed `registryPolicy` and
|
|
192
|
+
its space-creation guard) raises the root ceilings once more, as an exact-delta row with
|
|
193
|
+
zero headroom, `tc1443bRatchet`, chained after TC-1466's. It landed after #595, so it was
|
|
194
|
+
re-measured on master `4a717372` (CI-measured at `f819c542`, a version commit away):
|
|
195
|
+
1,471,007 / 1,397,987 B, equal to TC-1466's ceilings. GitHub run 39176947473 measured the
|
|
196
|
+
PR on its merge commit `f65c2a0f`, identical in both Node jobs: 1,473,920 / 1,402,497 B,
|
|
197
|
+
i.e. +2,913 / +4,510 over master, the same delta as on the earlier base `28ca77a0`
|
|
198
|
+
(1,473,908 / 1,402,491 B over 1,470,995 / 1,397,981 B). Naomi approved the delta
|
|
199
|
+
(+2,913 / +4,510 gzip, ±50 B each, 2026-10-18). The row's ceilings are those measured
|
|
200
|
+
bytes. First import, activation, the gated artifact and the worker keep TC-1432's
|
|
201
|
+
ceilings. The ledger's `tc1443bRatchet` row records them and cannot change later. If
|
|
202
|
+
another root-growing PR lands first, #589 re-measures against the new base and replaces
|
|
203
|
+
its own row before it merges.
|
|
204
|
+
|
|
205
|
+
TC-1428 (the owner-signed artifact pin the viewer verifies for addressed artifact shares, #582) was
|
|
206
|
+
re-measured after #589 landed, against master `42b08909`, and sits on top of TC-1443b's root ceilings.
|
|
207
|
+
It raised only the root ceilings once, by the exact bytes GitHub run 39181586326 measured on source
|
|
208
|
+
`90f21ae6`, identical in both jobs: 1,474,835 / 1,403,309 B (+915 / +812 over TC-1443b's). First import,
|
|
209
|
+
activation, gated and the worker keep their ceilings. It is #582's own row, taken after a documented
|
|
210
|
+
shrink attempt (see the row's `reason`). The ledger's `tc1428Ratchet` row records it and cannot change
|
|
211
|
+
later; whichever PR lands after it re-measures against the new base and updates its own row.
|
|
212
|
+
|
|
213
|
+
TC-1476 (the debug event recorded when the account registry sync is skipped for want of account access, #600) was
|
|
214
|
+
measured on canonical CI against master `c7a379c5`: master 1,474,761 / 1,403,138 B, the PR on source `bf9349ed`
|
|
215
|
+
1,474,808 / 1,403,191 B, identical in both jobs, i.e. +47 / +53, inside Naomi's +62 B +/-20 ruling. It lowers the
|
|
216
|
+
root ceilings to exactly those bytes. The ledger's `tc1476Ratchet` row records it and cannot change later;
|
|
217
|
+
whichever PR lands after it re-measures against the new base and updates its own row.
|
|
218
|
+
|
|
219
|
+
TC-1475 (automatic retry of node 503 busy and request_timeout responses in `ServiceContext.invokeWithRetry`, which
|
|
220
|
+
re-signs the invocation on every attempt, plus the web-sdk and node-sdk `retryPolicy` config, #599) was measured
|
|
221
|
+
against master `5317cc78` and sits on top of TC-1476's root ceilings and TC-1432's first-import, activation and
|
|
222
|
+
worker ceilings. GitHub run 39292038037 on source `092144080` measured the same bytes in both Node jobs: root
|
|
223
|
+
1,475,166 / 1,403,595 B (+358 / +404 over the merge base; ceilings exactly the measured values), first import 51,925 / 67,140 B (0 / +2),
|
|
224
|
+
activation 23,117 / 24,699 B (+11 / +14) and the kv-storage worker 822,667 B (+623). The
|
|
225
|
+
ledger's `tc1475Ratchet` row records it and cannot change later;
|
|
226
|
+
whichever PR lands after it re-measures against the new base and updates its own row.
|
|
227
|
+
|
|
141
228
|
**Ancestry pins and squash merges.** A policy row records the PR-branch commit it
|
|
142
229
|
was reviewed at, and its introduction check requires that literal commit in the
|
|
143
|
-
PR head. js-sdk
|
|
144
|
-
|
|
230
|
+
PR head. js-sdk uses merge commits, which keep that commit reachable, but squash
|
|
231
|
+
merging is still enabled and a squash leaves it unreachable from master; ancestry
|
|
232
|
+
is therefore checked only when a PR introduces a row. Any
|
|
145
233
|
new check that re-validates merged pins against HEAD would break master again
|
|
146
234
|
after the next squash, and only review prevents that. As a consistency check,
|
|
147
235
|
every PR also requires each merged row's pin to be on its base or landed by it:
|
|
148
|
-
the first first-parent master commit that added the pin to `scripts/`,
|
|
149
|
-
|
|
236
|
+
the first first-parent master commit that added the pin to `scripts/`, the merge commit
|
|
237
|
+
(`landingCommit` in `scripts/replica-size-policy.ts`). After a
|
|
150
238
|
squash merge, nothing needs editing. Content keys (blob hashes) were rejected:
|
|
151
239
|
pinned files such as `authority.ts` legitimately change later, whereas the
|
|
152
240
|
landing commit stays an ancestor for good.
|
|
@@ -232,6 +320,38 @@ const userKeys = userKeysResponse.data;
|
|
|
232
320
|
console.log('User keys:', userKeys); // ['profile', ...]
|
|
233
321
|
```
|
|
234
322
|
|
|
323
|
+
### Listing Keys That Start With a Partial Name
|
|
324
|
+
|
|
325
|
+
The node matches list prefixes on **whole path segments** (node 1.19.0, TC-731):
|
|
326
|
+
`list({ prefix: 'qa/b' })` returns `qa/b` and `qa/b/...`, never `qa/b00`. This is
|
|
327
|
+
deliberate: a list is the authorization scope, so a grant on `docs` cannot be used to
|
|
328
|
+
enumerate `docsecret/...`.
|
|
329
|
+
|
|
330
|
+
When you want "names starting with X" (UI type-ahead over a small folder), use the
|
|
331
|
+
standalone `listMatching(kv, prefix, options?)` function. It lists the folder up to the
|
|
332
|
+
last `/` with the normal `list`, reads **every** page, and filters client-side. It takes
|
|
333
|
+
`tc.kv` or a prefixed view (`tc.kv.withPrefix('notes')`), and is not part of the KV
|
|
334
|
+
service itself, so apps that don't import it don't ship it.
|
|
335
|
+
|
|
336
|
+
**Browser apps import it from `@tinycloud/sdk-core/kv-list-matching`** (web-sdk already
|
|
337
|
+
depends on sdk-core). It is a separate entry, not in any package root, so
|
|
338
|
+
`@tinycloud/web-sdk` and `@tinycloud/sdk-core` root bundles are unchanged:
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
import { listMatching } from '@tinycloud/sdk-core/kv-list-matching';
|
|
342
|
+
// TypeScript: the subpath's types need `moduleResolution` node16, nodenext or
|
|
343
|
+
// bundler. With "node" tsc reports TS2307 (the runtime import still works).
|
|
344
|
+
|
|
345
|
+
// Keys: qa/b00, qa/b01, qa/c00
|
|
346
|
+
const result = await listMatching(tc.kv, 'qa/b');
|
|
347
|
+
if (result.ok) console.log(result.data.keys); // ['qa/b00', 'qa/b01']
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
It never lists more than the folder, so a delegated session sees only what its grant
|
|
351
|
+
allows, and a folder outside the grant fails exactly as `list` would. The cost is the
|
|
352
|
+
size of the **folder**, not the number of matches, so it is slow for large folders. For
|
|
353
|
+
those, give the data a real folder structure (`users/<id>/...`) and use `list`.
|
|
354
|
+
|
|
235
355
|
### Deleting Data
|
|
236
356
|
|
|
237
357
|
```typescript
|
|
@@ -242,6 +362,22 @@ await storage.delete('messages/welcome');
|
|
|
242
362
|
await storage.deleteAll('user');
|
|
243
363
|
```
|
|
244
364
|
|
|
365
|
+
### Automatic retry
|
|
366
|
+
|
|
367
|
+
When the node answers `503` busy (`NODE_BUSY`) or `503` request timeout (`REQUEST_TIMEOUT`), it
|
|
368
|
+
applied nothing, so the SDK retries on its own: up to 4 attempts in about 12 s, waiting the node's
|
|
369
|
+
`Retry-After` when sent, otherwise exponentially with full jitter (250 ms base, 4 s cap). It stops
|
|
370
|
+
early on abort or the per-request `timeout`, and returns the last typed error once the budget is
|
|
371
|
+
spent. `OUTCOME_UNKNOWN` is never retried. Tune or opt out with `retryPolicy`; `{ maxAttempts: 1 }`
|
|
372
|
+
(or `retryableErrors: []`) disables it. Monitors and probes should disable retries. A successful KV response carries
|
|
373
|
+
`retry: { attempts, backoffMs }`, so latency can be split from backoff. The CLI disables retries
|
|
374
|
+
with `--no-retry` or `TINYCLOUD_RETRY=0`, and its `kv get|put|delete --json` output reports
|
|
375
|
+
`attempts` and `backoffMs`.
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
const tcw = new TinyCloudWeb({ retryPolicy: { maxAttempts: 1 } });
|
|
379
|
+
```
|
|
380
|
+
|
|
245
381
|
## Core Values
|
|
246
382
|
|
|
247
383
|
TinyCloud is built on these fundamental principles:
|