@interop/was-client 0.33.0 → 0.35.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 +112 -0
- package/dist/Collection.d.ts +172 -1
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +368 -2
- package/dist/Collection.js.map +1 -1
- package/dist/codec.d.ts +101 -3
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +34 -4
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +268 -42
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +5 -9
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/hmacKey.d.ts +76 -0
- package/dist/edv/hmacKey.d.ts.map +1 -0
- package/dist/edv/hmacKey.js +105 -0
- package/dist/edv/hmacKey.js.map +1 -0
- package/dist/edv/index.d.ts +7 -0
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +6 -0
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/recipients.d.ts +22 -3
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +197 -21
- package/dist/edv/recipients.js.map +1 -1
- package/dist/errors.d.ts +28 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +36 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +64 -3
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/content.d.ts +12 -0
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +18 -0
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/indexSchema.d.ts +95 -0
- package/dist/internal/indexSchema.d.ts.map +1 -0
- package/dist/internal/indexSchema.js +120 -0
- package/dist/internal/indexSchema.js.map +1 -0
- package/dist/internal/paths.d.ts +6 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +8 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/revoke.d.ts +21 -1
- package/dist/internal/revoke.d.ts.map +1 -1
- package/dist/internal/revoke.js +1 -1
- package/dist/internal/revoke.js.map +1 -1
- package/dist/paths.d.ts +30 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +29 -0
- package/dist/paths.js.map +1 -0
- package/dist/sync/index.d.ts +6 -4
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +6 -4
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/port.d.ts +34 -4
- package/dist/sync/port.d.ts.map +1 -1
- package/dist/sync/port.js +123 -20
- package/dist/sync/port.js.map +1 -1
- package/dist/sync/types.d.ts +12 -4
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types.d.ts +40 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -2
package/dist/Collection.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* lifecycle (`describe`/`configure`/`delete`) and contained-resource operations
|
|
7
7
|
* (`add`/`get`/`put`/`list`, plus `resource(id)` for delete-by-id).
|
|
8
8
|
*/
|
|
9
|
-
import { collectionPath, collectionItems, collectionPolicy, collectionLinkset, collectionBackend, collectionQuota, collectionQuery, resourcePath, toUrl } from './internal/paths.js';
|
|
9
|
+
import { collectionPath, collectionItems, collectionPolicy, collectionLinkset, collectionBackend, collectionQuota, collectionQuery, collectionMeta, resourcePath, toUrl } from './internal/paths.js';
|
|
10
10
|
import { assertNotReserved } from './internal/reserved.js';
|
|
11
|
+
import { PreconditionFailedError, ValidationError, WasServerError } from './errors.js';
|
|
11
12
|
import { delegateGrantAt } from './internal/grant.js';
|
|
12
13
|
import { send, readData } from './internal/request.js';
|
|
13
14
|
import { collectionCodecHolder } from './internal/codec.js';
|
|
@@ -17,7 +18,8 @@ import { collectionWritableFields, describeCollection, describeCollectionRespons
|
|
|
17
18
|
import { readEtag, writeHeaders } from './internal/conditional.js';
|
|
18
19
|
import { insertResource } from './internal/write.js';
|
|
19
20
|
import { readPolicy, writePolicy, deletePolicy, isPublicPolicy, setPublicPolicy } from './internal/policy.js';
|
|
20
|
-
import { createdResource, dataOrNull } from './internal/content.js';
|
|
21
|
+
import { createdResource, dataOrNull, storedResponse } from './internal/content.js';
|
|
22
|
+
import { INDEX_SCHEMA_PROPERTY, attributeKey, normalizeAttribute, readIndexSchema } from './internal/indexSchema.js';
|
|
21
23
|
import { Resource } from './Resource.js';
|
|
22
24
|
export class Collection {
|
|
23
25
|
spaceId;
|
|
@@ -283,6 +285,370 @@ export class Collection {
|
|
|
283
285
|
idempotent: true
|
|
284
286
|
});
|
|
285
287
|
}
|
|
288
|
+
get #metaPath() {
|
|
289
|
+
return collectionMeta(this.spaceId, this.id);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Reads the Collection's metadata object (server-managed timestamps,
|
|
293
|
+
* `createdBy` and the encrypted-`custom` key `epoch`, plus the user-writable
|
|
294
|
+
* `custom` object). Returns `null` if the collection is missing or not
|
|
295
|
+
* visible to you (404 conflation caveat). A server without Collection
|
|
296
|
+
* metadata support surfaces its 501 as `NotImplementedError`.
|
|
297
|
+
*
|
|
298
|
+
* On an encrypted collection the stored `custom` is an opaque envelope; this
|
|
299
|
+
* decodes it (decrypts, via the codec) so a caller always sees plaintext
|
|
300
|
+
* `{ name, tags }`. A collection with no user metadata reports `custom` as
|
|
301
|
+
* `{}`.
|
|
302
|
+
*
|
|
303
|
+
* Against a backend with the `conditional-writes` feature the result also
|
|
304
|
+
* carries the metadata's current `etag` (the `/meta` `metaVersion`
|
|
305
|
+
* validator) -- pass it as `setMeta(meta, { ifMatch })` for a
|
|
306
|
+
* lost-update-safe metadata update. That validator is independent of the
|
|
307
|
+
* Collection Description's ETag ({@link describeWithEtag}) and of every
|
|
308
|
+
* Resource's versions: writing one never bumps the other.
|
|
309
|
+
*
|
|
310
|
+
* @returns {Promise<(CollectionMetadata & { etag?: string }) | null>}
|
|
311
|
+
*/
|
|
312
|
+
async meta() {
|
|
313
|
+
// Overlapped like `Resource.meta()`: the metadata GET does not depend on
|
|
314
|
+
// the codec (only its `custom` decode below does), the codec is awaited
|
|
315
|
+
// first for error precedence, and the no-op handler keeps an abandoned read
|
|
316
|
+
// from becoming an unhandled rejection.
|
|
317
|
+
const codecPromise = this.#codec();
|
|
318
|
+
const responsePromise = send(this.#context, {
|
|
319
|
+
path: this.#metaPath,
|
|
320
|
+
method: 'GET',
|
|
321
|
+
capability: this.#capability,
|
|
322
|
+
read: true
|
|
323
|
+
});
|
|
324
|
+
responsePromise.catch(() => { });
|
|
325
|
+
const codec = await codecPromise;
|
|
326
|
+
const response = await responsePromise;
|
|
327
|
+
if (response === null) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
if (response.data === undefined) {
|
|
331
|
+
// A 200 whose body `@interop/http-client` did not pre-parse into `.data`
|
|
332
|
+
// (a non-JSON content-type, or an empty/204 body): a metadata document
|
|
333
|
+
// always carries its server-managed fields as JSON, so an absent `.data`
|
|
334
|
+
// is a malformed response. Fail with a typed error rather than
|
|
335
|
+
// dereferencing `metadata.custom` off `undefined` as a raw `TypeError`.
|
|
336
|
+
// (Kept distinct from the `null` return, which means the collection is
|
|
337
|
+
// missing or not visible -- not that the server answered malformed.)
|
|
338
|
+
throw new WasServerError(`Metadata response for collection "${this.id}" carried no JSON body ` +
|
|
339
|
+
`(content-type ` +
|
|
340
|
+
`"${response.headers.get('content-type') ?? 'unknown'}").`);
|
|
341
|
+
}
|
|
342
|
+
const metadata = response.data;
|
|
343
|
+
// Decode the user-writable `custom` (decrypting it on an encrypted
|
|
344
|
+
// collection) so callers uniformly see plaintext `{ name, tags }`. No
|
|
345
|
+
// resource id is passed: this slot belongs to the collection itself, and
|
|
346
|
+
// the encrypting codec refuses a resource-bound envelope served here.
|
|
347
|
+
const custom = await codec.decodeMeta({ custom: metadata.custom });
|
|
348
|
+
const decoded = { ...metadata, custom };
|
|
349
|
+
const etag = readEtag(response);
|
|
350
|
+
return etag !== undefined ? { ...decoded, etag } : decoded;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Replaces the Collection's user-writable metadata (`custom`). This is a full
|
|
354
|
+
* replacement: any property omitted from `custom` is cleared, and an omitted
|
|
355
|
+
* `custom` clears them all. Does not create the collection -- a `PUT` to the
|
|
356
|
+
* metadata of a nonexistent collection throws `NotFoundError`. Servers
|
|
357
|
+
* without Collection metadata support surface their 501 as
|
|
358
|
+
* `NotImplementedError`.
|
|
359
|
+
*
|
|
360
|
+
* On an encrypted collection `custom` is encrypted into an opaque envelope by
|
|
361
|
+
* the codec before it is sent, so `name` / `tags` are never stored as
|
|
362
|
+
* server-visible plaintext -- transparently, the same call works on plaintext
|
|
363
|
+
* and encrypted collections alike.
|
|
364
|
+
*
|
|
365
|
+
* Conditional metadata writes (the backend's `conditional-writes` feature):
|
|
366
|
+
* pass `ifMatch` (the `etag` from a prior `meta()`) for an
|
|
367
|
+
* update-if-unchanged, or `ifNoneMatch: true` for a
|
|
368
|
+
* write-only-if-no-metadata. A failed precondition throws
|
|
369
|
+
* `PreconditionFailedError` (412). The `/meta` ETag (`metaVersion`) is
|
|
370
|
+
* independent of the Collection Description's ETag. Returns the new `etag`.
|
|
371
|
+
*
|
|
372
|
+
* @param meta {object}
|
|
373
|
+
* @param [meta.custom] {ResourceMetadataCustom} the user-writable properties
|
|
374
|
+
* @param options {object}
|
|
375
|
+
* @param [options.ifMatch] {string} update only if the `/meta` ETag matches
|
|
376
|
+
* @param [options.ifNoneMatch] {boolean} write only if no metadata is set
|
|
377
|
+
* @returns {Promise<{ etag?: string }>} the metadata's new ETag
|
|
378
|
+
*/
|
|
379
|
+
async setMeta(meta = {}, options = {}) {
|
|
380
|
+
const codec = await this.#codec();
|
|
381
|
+
const { custom, epoch } = await codec.encodeMeta({
|
|
382
|
+
custom: meta.custom ?? {}
|
|
383
|
+
});
|
|
384
|
+
const response = await send(this.#context, {
|
|
385
|
+
path: this.#metaPath,
|
|
386
|
+
method: 'PUT',
|
|
387
|
+
capability: this.#capability,
|
|
388
|
+
// The key epoch travels in the body here, not in the `Key-Epoch` header:
|
|
389
|
+
// the header channel stamps a Resource's *content* write, while the
|
|
390
|
+
// Collection metadata stamp describes the `custom` envelope itself and is
|
|
391
|
+
// a top-level member of this PUT body. The server clears the stored stamp
|
|
392
|
+
// when the member is omitted -- which is exactly right on a plaintext
|
|
393
|
+
// collection, whose codec surfaces no epoch.
|
|
394
|
+
json: epoch !== undefined ? { custom, epoch } : { custom },
|
|
395
|
+
headers: writeHeaders({
|
|
396
|
+
precondition: {
|
|
397
|
+
ifMatch: options.ifMatch,
|
|
398
|
+
ifNoneMatch: options.ifNoneMatch
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
return { etag: readEtag(response) };
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* The shared read-then-CAS body of {@link setName} / {@link setTags}: reads
|
|
406
|
+
* the current metadata, merges `patch` over its `custom`, and writes it back
|
|
407
|
+
* pinned to the read's `etag` (when the backend supports
|
|
408
|
+
* `conditional-writes`), so a concurrent metadata write surfaces as
|
|
409
|
+
* `PreconditionFailedError` instead of being silently erased by the
|
|
410
|
+
* full-replacement write.
|
|
411
|
+
*
|
|
412
|
+
* @param patch {ResourceMetadataCustom} the properties to merge over the
|
|
413
|
+
* current `custom`
|
|
414
|
+
* @returns {Promise<void>}
|
|
415
|
+
*/
|
|
416
|
+
async #patchCustom(patch) {
|
|
417
|
+
const current = await this.meta();
|
|
418
|
+
await this.setMeta({ custom: { ...current?.custom, ...patch } }, { ifMatch: current?.etag });
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Sets the Collection's metadata-level human-readable `name`, preserving any
|
|
422
|
+
* existing `tags`. Convenience over `setMeta()`. The write is pinned to the
|
|
423
|
+
* `etag` the `meta()` read returned (when the backend supports
|
|
424
|
+
* `conditional-writes`), so a concurrent metadata write surfaces as
|
|
425
|
+
* `PreconditionFailedError` instead of being silently erased by this
|
|
426
|
+
* full-replacement write.
|
|
427
|
+
*
|
|
428
|
+
* On an encrypted collection this is the collection's client-encrypted name
|
|
429
|
+
* surface: the codec seals it into the `custom` envelope, and by convention
|
|
430
|
+
* the plaintext Description `name` is left unpopulated. On a plaintext
|
|
431
|
+
* collection the two are separate labels -- space-level listings surface the
|
|
432
|
+
* Description's `name` (set via `configure({ name })`), while this one is
|
|
433
|
+
* metadata-level.
|
|
434
|
+
*
|
|
435
|
+
* @param name {string}
|
|
436
|
+
* @returns {Promise<void>}
|
|
437
|
+
*/
|
|
438
|
+
async setName(name) {
|
|
439
|
+
return this.#patchCustom({ name });
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Sets the Collection's `tags`, preserving any existing `name`. Convenience
|
|
443
|
+
* over `setMeta()`. Pinned to the `meta()` read's `etag` like
|
|
444
|
+
* {@link setName}.
|
|
445
|
+
*
|
|
446
|
+
* @param tags {Record<string, string>}
|
|
447
|
+
* @returns {Promise<void>}
|
|
448
|
+
*/
|
|
449
|
+
async setTags(tags) {
|
|
450
|
+
return this.#patchCustom({ tags });
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* The codec's search capability, or a typed refusal when this collection is
|
|
454
|
+
* not searchable this way -- a plaintext collection (whose contents the
|
|
455
|
+
* server can index itself) or an encrypted collection provisioned without a
|
|
456
|
+
* blinded-index key (which is installed at provisioning or never, since
|
|
457
|
+
* retro-fitting one would leave every already-written document unindexed).
|
|
458
|
+
*
|
|
459
|
+
* @param operation {string} what the caller was trying to do, for the message
|
|
460
|
+
* @returns {Promise<CodecIndexing>}
|
|
461
|
+
*/
|
|
462
|
+
async #indexing(operation) {
|
|
463
|
+
const codec = await this.#codec();
|
|
464
|
+
if (!codec.indexing) {
|
|
465
|
+
throw new ValidationError(`Cannot ${operation} on collection "${this.id}": it carries no ` +
|
|
466
|
+
'client-side search index. Only an encrypted collection provisioned ' +
|
|
467
|
+
'with a blinded-index key is searchable this way (install it at ' +
|
|
468
|
+
'creation with ensureFirstEpoch({ blindedIndex: true }) -- it cannot ' +
|
|
469
|
+
'be added later). A plaintext collection is queried server-side ' +
|
|
470
|
+
'instead.');
|
|
471
|
+
}
|
|
472
|
+
return codec.indexing;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Reads the Collection's persisted index schema: which attributes its
|
|
476
|
+
* documents are searchable by, whether each index is unique, and the schema
|
|
477
|
+
* revision each was added in. Any recipient that can decrypt the collection
|
|
478
|
+
* can read it, which is the point of persisting it -- an app granted access
|
|
479
|
+
* to an existing collection learns what is queryable with no out-of-band
|
|
480
|
+
* coordination (the stored index tokens cannot teach it, being blinded).
|
|
481
|
+
*
|
|
482
|
+
* `addedIn` is the partial-coverage marker: documents written before an
|
|
483
|
+
* attribute was declared carry no token for it, so they do not match a search
|
|
484
|
+
* on it until they are rewritten.
|
|
485
|
+
*
|
|
486
|
+
* @returns {Promise<IndexDeclaration[]>}
|
|
487
|
+
*/
|
|
488
|
+
async indexes() {
|
|
489
|
+
const indexing = await this.#indexing('read the index schema');
|
|
490
|
+
return indexing.schema().indexes;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Declares an attribute searchable, persisting it in the Collection's
|
|
494
|
+
* encrypted index schema and installing it on this handle's codec.
|
|
495
|
+
* Idempotent: re-declaring an attribute already in the schema on the same
|
|
496
|
+
* terms is a no-op write.
|
|
497
|
+
*
|
|
498
|
+
* Declarations are collection state, not app state: they are stored inside
|
|
499
|
+
* the encrypted `/meta` envelope, so every recipient discovers them (see
|
|
500
|
+
* {@link indexes}). Concurrent declarations from two clients are reconciled
|
|
501
|
+
* with a compare-and-swap against the metadata's own `metaVersion` ETag and a
|
|
502
|
+
* bounded retry, so neither is silently erased.
|
|
503
|
+
*
|
|
504
|
+
* A declaration is prospective: documents already written carry no token for
|
|
505
|
+
* the new attribute and do not match a search on it until they are rewritten
|
|
506
|
+
* (the backfill is a re-encrypt sweep of the collection).
|
|
507
|
+
*
|
|
508
|
+
* Pass an array of attribute names for a compound index. A compound index can
|
|
509
|
+
* be searched by a leading prefix of its attributes; `unique` is enforced
|
|
510
|
+
* only when a document carries the whole combination.
|
|
511
|
+
*
|
|
512
|
+
* @param options {object}
|
|
513
|
+
* @param options.attribute {string | string[]} a dotted attribute path
|
|
514
|
+
* rooted at `content` or `meta` (e.g. `content.type`), or an array of them
|
|
515
|
+
* for a compound index
|
|
516
|
+
* @param [options.unique] {boolean} reject a second document that carries
|
|
517
|
+
* the same value (the server answers a colliding write with `409`)
|
|
518
|
+
* @returns {Promise<IndexSchema>} the schema now in force
|
|
519
|
+
*/
|
|
520
|
+
async declareIndex({ attribute, unique }) {
|
|
521
|
+
const indexing = await this.#indexing('declare an index');
|
|
522
|
+
const declared = normalizeAttribute(attribute);
|
|
523
|
+
const key = attributeKey(declared);
|
|
524
|
+
// Read, reconcile, conditionally write. A 412 means another client wrote
|
|
525
|
+
// the metadata between the read and the write, so re-read and re-apply
|
|
526
|
+
// rather than clobbering its declaration with ours.
|
|
527
|
+
const maxAttempts = 4;
|
|
528
|
+
for (let attempt = 1;; attempt++) {
|
|
529
|
+
const current = await this.meta();
|
|
530
|
+
const custom = (current?.custom ?? {});
|
|
531
|
+
const schema = readIndexSchema(custom);
|
|
532
|
+
const existing = schema.indexes.find(entry => attributeKey(entry.attribute) === key);
|
|
533
|
+
if (existing) {
|
|
534
|
+
if ((existing.unique === true) !== (unique === true)) {
|
|
535
|
+
throw new ValidationError(`Cannot declare index "${key}" as ` +
|
|
536
|
+
`${unique === true ? 'unique' : 'non-unique'}: this collection ` +
|
|
537
|
+
`already declares it as ` +
|
|
538
|
+
`${existing.unique === true ? 'unique' : 'non-unique'}. An ` +
|
|
539
|
+
'index cannot change uniqueness in place -- already-stored ' +
|
|
540
|
+
'documents were indexed under the old terms.');
|
|
541
|
+
}
|
|
542
|
+
indexing.applySchema(schema);
|
|
543
|
+
return schema;
|
|
544
|
+
}
|
|
545
|
+
const revision = schema.revision + 1;
|
|
546
|
+
const next = {
|
|
547
|
+
revision,
|
|
548
|
+
indexes: [
|
|
549
|
+
...schema.indexes,
|
|
550
|
+
{
|
|
551
|
+
attribute: declared,
|
|
552
|
+
...(unique === true && { unique: true }),
|
|
553
|
+
addedIn: revision
|
|
554
|
+
}
|
|
555
|
+
]
|
|
556
|
+
};
|
|
557
|
+
try {
|
|
558
|
+
await this.setMeta({
|
|
559
|
+
// The schema shares the `custom` object with the user's own
|
|
560
|
+
// `name` / `tags`, which are carried forward untouched.
|
|
561
|
+
custom: {
|
|
562
|
+
...custom,
|
|
563
|
+
[INDEX_SCHEMA_PROPERTY]: next
|
|
564
|
+
}
|
|
565
|
+
}, { ifMatch: current?.etag });
|
|
566
|
+
}
|
|
567
|
+
catch (err) {
|
|
568
|
+
if (err instanceof PreconditionFailedError && attempt < maxAttempts) {
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
throw err;
|
|
572
|
+
}
|
|
573
|
+
indexing.applySchema(next);
|
|
574
|
+
return next;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Searches the collection's encrypted documents by indexed attribute. The
|
|
579
|
+
* terms are blinded client-side before they are sent, so the server matches
|
|
580
|
+
* opaque tokens and learns neither the attribute names nor the values; the
|
|
581
|
+
* documents it returns are decrypted here, exactly as `get()` decrypts one.
|
|
582
|
+
*
|
|
583
|
+
* Give either `equals` (attribute/value pairs a document must match -- an
|
|
584
|
+
* array of objects is an OR of alternatives) or `has` (attribute names a
|
|
585
|
+
* document must carry), not both. Every attribute named must already be in
|
|
586
|
+
* the collection's schema ({@link declareIndex}); an undeclared one is
|
|
587
|
+
* refused with `ValidationError` rather than silently matching nothing.
|
|
588
|
+
*
|
|
589
|
+
* Pass `count: true` for just the number of matches. Otherwise the result is
|
|
590
|
+
* one page: `limit` caps its size (the server clamps its own maximum), and a
|
|
591
|
+
* `hasMore` page carries the `cursor` to pass back for the next one.
|
|
592
|
+
*
|
|
593
|
+
* Requires the collection's backend to advertise the `blinded-index-query`
|
|
594
|
+
* feature; a backend without it answers `501` (`NotImplementedError`).
|
|
595
|
+
*
|
|
596
|
+
* @param options {object}
|
|
597
|
+
* @param [options.equals] {object | object[]} attribute/value pairs to match
|
|
598
|
+
* @param [options.has] {string | string[]} attribute names to require
|
|
599
|
+
* @param [options.count] {boolean} return `{ count }` instead of documents
|
|
600
|
+
* @param [options.limit] {number} maximum documents in the page
|
|
601
|
+
* @param [options.cursor] {string} continue from a previous page
|
|
602
|
+
* @returns {Promise<FindPage | { count: number }>}
|
|
603
|
+
*/
|
|
604
|
+
async find(options) {
|
|
605
|
+
const { equals, has, count, limit, cursor } = options;
|
|
606
|
+
const indexing = await this.#indexing('search');
|
|
607
|
+
const codec = await this.#codec();
|
|
608
|
+
const query = await indexing.buildQuery({ equals, has });
|
|
609
|
+
const response = await send(this.#context, {
|
|
610
|
+
path: collectionQuery(this.spaceId, this.id),
|
|
611
|
+
method: 'POST',
|
|
612
|
+
capability: this.#capability,
|
|
613
|
+
// The profile is bound here the way `changes()` binds its own: same
|
|
614
|
+
// endpoint, no client-side feature probe -- a backend that does not
|
|
615
|
+
// implement the profile answers 501, which is a clearer signal than a
|
|
616
|
+
// guess made from the backend descriptor.
|
|
617
|
+
json: {
|
|
618
|
+
profile: 'blinded-index',
|
|
619
|
+
...query,
|
|
620
|
+
...(count === true && { count: true }),
|
|
621
|
+
...(limit !== undefined && { limit }),
|
|
622
|
+
...(cursor !== undefined && { cursor })
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
const result = dataOrNull(response);
|
|
626
|
+
if (result === null) {
|
|
627
|
+
throw new WasServerError(`Search response for collection "${this.id}" carried no JSON body.`);
|
|
628
|
+
}
|
|
629
|
+
if (count === true) {
|
|
630
|
+
return { count: typeof result.count === 'number' ? result.count : 0 };
|
|
631
|
+
}
|
|
632
|
+
const documents = Array.isArray(result.documents) ? result.documents : [];
|
|
633
|
+
const items = [];
|
|
634
|
+
for (const envelope of documents) {
|
|
635
|
+
// Restrict-mode ids make the stored document's own id the WAS resource
|
|
636
|
+
// id, so it is also the id the codec verifies the envelope's
|
|
637
|
+
// AEAD-authenticated binding against -- a server that returns one
|
|
638
|
+
// document under another's id is caught here, not trusted.
|
|
639
|
+
const id = envelope.id;
|
|
640
|
+
if (typeof id !== 'string') {
|
|
641
|
+
throw new WasServerError(`Search response for collection "${this.id}" returned a document ` +
|
|
642
|
+
'with no id.');
|
|
643
|
+
}
|
|
644
|
+
items.push({ id, data: await codec.decode(storedResponse(envelope), id) });
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
items,
|
|
648
|
+
hasMore: result.hasMore === true,
|
|
649
|
+
...(result.cursor !== undefined && { cursor: result.cursor })
|
|
650
|
+
};
|
|
651
|
+
}
|
|
286
652
|
/**
|
|
287
653
|
* Returns a lazy handle to a resource by id. No I/O.
|
|
288
654
|
*
|
package/dist/Collection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,KAAK,EACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAA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
|
100
|
+
/**
|
|
101
|
+
* One entry of a collection's persisted index schema: an attribute path (or an
|
|
102
|
+
* array of them, for a compound index), whether the index is unique, and the
|
|
103
|
+
* schema revision it was added in.
|
|
104
|
+
*
|
|
105
|
+
* `addedIn` is the partial-coverage marker: a document written before the
|
|
106
|
+
* attribute was declared carries no token for it, so a querier comparing
|
|
107
|
+
* `addedIn` against how long the collection has existed knows matches may be
|
|
108
|
+
* incomplete until those documents are rewritten.
|
|
109
|
+
*/
|
|
110
|
+
export interface IndexDeclaration {
|
|
111
|
+
attribute: string | string[];
|
|
112
|
+
unique?: true;
|
|
113
|
+
addedIn: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The collection's persisted index schema: which attributes are searchable, and
|
|
117
|
+
* a monotonic `revision` bumped by each declaration. It is stored inside the
|
|
118
|
+
* collection's encrypted metadata envelope, so any recipient can discover what
|
|
119
|
+
* is queryable without out-of-band coordination (the attribute names are
|
|
120
|
+
* themselves sensitive -- they describe the data model -- so they never travel
|
|
121
|
+
* as server-visible plaintext).
|
|
122
|
+
*/
|
|
123
|
+
export interface IndexSchema {
|
|
124
|
+
revision: number;
|
|
125
|
+
indexes: IndexDeclaration[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A built search query in the form the server evaluates: an index key id plus
|
|
129
|
+
* blinded terms. The client blinds attribute names and values before they leave
|
|
130
|
+
* it, so the server matches opaque strings and learns neither.
|
|
131
|
+
*/
|
|
132
|
+
export interface BlindedQuery {
|
|
133
|
+
index: string;
|
|
134
|
+
equals?: Array<Record<string, string>>;
|
|
135
|
+
has?: string[];
|
|
136
|
+
count?: boolean;
|
|
137
|
+
limit?: number;
|
|
138
|
+
cursor?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The optional search capability of a codec that indexes what it stores. It is
|
|
142
|
+
* deliberately scheme-agnostic -- no EDV type appears in it -- so the handle
|
|
143
|
+
* layer can drive declaration and search without knowing how blinding works.
|
|
144
|
+
* The identity (plaintext) codec does not implement it, which is how the handle
|
|
145
|
+
* layer detects that a collection is not searchable this way.
|
|
146
|
+
*/
|
|
147
|
+
export interface CodecIndexing {
|
|
148
|
+
/**
|
|
149
|
+
* Installs the collection's persisted schema on this codec, so subsequent
|
|
150
|
+
* writes emit index tokens for the declared attributes and queries can be
|
|
151
|
+
* built for them. Called at codec-resolution time with the stored schema, and
|
|
152
|
+
* again by `declareIndex` after it persists a new one.
|
|
153
|
+
*
|
|
154
|
+
* @param schema {IndexSchema}
|
|
155
|
+
* @returns {void}
|
|
156
|
+
*/
|
|
157
|
+
applySchema(schema: IndexSchema): void;
|
|
158
|
+
/**
|
|
159
|
+
* The schema currently installed on this codec (the empty schema before one
|
|
160
|
+
* is applied).
|
|
161
|
+
*
|
|
162
|
+
* @returns {IndexSchema}
|
|
163
|
+
*/
|
|
164
|
+
schema(): IndexSchema;
|
|
165
|
+
/**
|
|
166
|
+
* Blinds a caller's search terms into the query the server evaluates.
|
|
167
|
+
* Attributes absent from the installed schema are refused rather than
|
|
168
|
+
* silently blinded into a term-less query that matches nothing.
|
|
169
|
+
*
|
|
170
|
+
* @param input {object}
|
|
171
|
+
* @param [input.equals] {object | object[]} attribute/value pairs to match
|
|
172
|
+
* @param [input.has] {string | string[]} attribute names a document must have
|
|
173
|
+
* @returns {Promise<BlindedQuery>}
|
|
174
|
+
*/
|
|
175
|
+
buildQuery(input: {
|
|
176
|
+
equals?: Record<string, unknown> | Array<Record<string, unknown>>;
|
|
177
|
+
has?: string | string[];
|
|
178
|
+
}): Promise<BlindedQuery>;
|
|
179
|
+
}
|
|
100
180
|
/**
|
|
101
181
|
* A pluggable encode/decode transform bound to a single collection handle.
|
|
102
182
|
* Implementations must be stateless with respect to a given call (a resolved
|
|
103
183
|
* codec is reused across every read/write on the handle).
|
|
104
184
|
*/
|
|
105
185
|
export interface ResourceCodec {
|
|
186
|
+
/**
|
|
187
|
+
* The codec's search capability, when it indexes what it stores (the EDV
|
|
188
|
+
* codec on a collection whose descriptor declares a blinded-index key).
|
|
189
|
+
* Absent for the identity codec and for an encrypted collection provisioned
|
|
190
|
+
* without an index key, so `Collection.declareIndex()` / `find()` refuse
|
|
191
|
+
* rather than pretend.
|
|
192
|
+
*/
|
|
193
|
+
readonly indexing?: CodecIndexing;
|
|
106
194
|
/**
|
|
107
195
|
* Whether this codec drives optimistic-concurrency (conditional) writes. When
|
|
108
196
|
* `true`, the write path pre-reads the current stored resource and passes it
|
|
@@ -159,14 +247,22 @@ export interface ResourceCodec {
|
|
|
159
247
|
* @param [input.id] {string} the resource id the metadata belongs to. An
|
|
160
248
|
* encrypting codec binds it into the metadata envelope's AEAD-authenticated
|
|
161
249
|
* protected header (so a server-side swap of two resources' metadata is
|
|
162
|
-
* detected on decode); the identity codec ignores it.
|
|
163
|
-
*
|
|
250
|
+
* detected on decode); the identity codec ignores it. Absent for a
|
|
251
|
+
* Collection-level metadata write, which belongs to no resource -- an
|
|
252
|
+
* encrypting codec then binds its own collection id instead.
|
|
253
|
+
* @returns {Promise<{ custom: object; epoch?: string }>} the value to store
|
|
254
|
+
* under `custom`, plus -- for an encrypting codec -- `epoch`, the key-epoch
|
|
255
|
+
* id the metadata envelope sealed under. A Collection-level `/meta` write
|
|
256
|
+
* forwards it as the PUT body's top-level `epoch` stamp (the server clears
|
|
257
|
+
* the stamp when it is omitted, so it must be sent on every encrypted
|
|
258
|
+
* Collection metadata write). Absent for a plaintext/identity codec.
|
|
164
259
|
*/
|
|
165
260
|
encodeMeta(input: {
|
|
166
261
|
custom: ResourceMetadataCustom;
|
|
167
262
|
id?: string;
|
|
168
263
|
}): Promise<{
|
|
169
264
|
custom: object;
|
|
265
|
+
epoch?: string;
|
|
170
266
|
}>;
|
|
171
267
|
/**
|
|
172
268
|
* Inverts {@link encodeMeta}: transforms the stored `custom` value read from
|
|
@@ -178,7 +274,9 @@ export interface ResourceCodec {
|
|
|
178
274
|
* @param [stored.custom] {unknown} the stored `custom` value from `/meta`
|
|
179
275
|
* @param [expectedId] {string} the resource id the metadata belongs to. An
|
|
180
276
|
* encrypting codec verifies the envelope's AEAD-authenticated binding
|
|
181
|
-
* against it; the identity codec ignores it.
|
|
277
|
+
* against it; the identity codec ignores it. Omitted for a Collection-level
|
|
278
|
+
* read, where an encrypting codec instead requires the envelope to be bound
|
|
279
|
+
* to that collection.
|
|
182
280
|
* @returns {Promise<ResourceMetadataCustom>}
|
|
183
281
|
*/
|
|
184
282
|
decodeMeta(stored: {
|
package/dist/codec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,IAAI,EACJ,YAAY,EACZ,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IACxB,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;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