import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core'; import { type Json } from '../sync/index.js'; import { type WasRemoteStore } from './wasRemoteStore.js'; /** * Default page size for the `changes`-feed walk. The server clamps its own * maximum, and a page shorter than what was asked for is the feed's end-of-walk * signal. Lower it on a collection of large envelopes to bound per-response * size. */ export declare const SHARED_CHANGES_PAGE_SIZE = 100; /** * One decrypted resource of a shared collection: the WAS resource id (the * envelope id, opaque) and its decrypted payload. */ export interface SharedResource { id: string; data: Json; } /** * Thrown when a shared collection cannot be opened for reading: it carries no * multi-recipient key-epoch roster, or this app is not a recipient of any epoch * on it (the wallet never shared it, or a later un-share rotated the epoch off * this app's key). */ export declare class SharedCollectionUnavailableError extends Error { constructor(message: string, options?: { cause?: unknown; }); } export declare class SharedCollectionReader { #private; readonly collectionId: string; private constructor(); /** * Opens a reader over one shared collection: reads its `encryption` descriptor * through the delegated zcap and builds the epoch-aware cipher from it. * * Throws {@link SharedCollectionUnavailableError} when the collection carries * no descriptor or a descriptor with no key epochs (it is not multi-recipient, so this * app cannot be a recipient of it), and likewise when the cipher cannot unwrap * any epoch (this app is not, or is no longer, in the roster). * * @param options {object} * @param options.remoteStore {WasRemoteStore} the delegated remote store * @param options.keyAgreementKey {IKeyAgreementKey} this app's IDENTITY KAK * @param options.keyResolver {IKeyResolver} its one-key resolver * @param options.collectionId {string} the WAS collection id * @param [options.pageSize] {number} `changes`-feed page size (defaults to * {@link SHARED_CHANGES_PAGE_SIZE}) * @returns {Promise} */ static open({ remoteStore, keyAgreementKey, keyResolver, collectionId, pageSize }: { remoteStore: WasRemoteStore; keyAgreementKey: IKeyAgreementKey; keyResolver: IKeyResolver; collectionId: string; pageSize?: number; }): Promise; /** * Lists the LIVE resources of the shared collection, decrypted. A body that is * not an EDV envelope, or a pre-epoch legacy envelope this app is not a * recipient of, is SKIPPED with a warning rather than failing the whole * listing. * * Two paths, same result. The fast path pages the `changes` feed * ({@link SharedCollectionReader.listViaChanges}), which returns whole pages of * documents WITH their bodies -- and on an encrypted collection those bodies * are exactly the opaque EDV envelopes wanted here, since the feed does not * decrypt. That is one round trip per PAGE rather than the one per RESOURCE a * listing plus a `get` each would cost, which on a wallet's * `private-credentials` or `contacts` is the difference between a handful of * requests and one per credential. It is also the same primitive replication * pulls with. * * The slow path ({@link SharedCollectionReader.listViaResources}) is the * fallback for a backend that does not advertise the `changes-query` feature * (it answers 501, surfaced as `NotImplementedError`): list the resource * summaries, then fetch each body. Taken only on that specific error, and * warned about once per reader. * * @returns {Promise} */ list(): Promise; /** * Reads and decrypts one resource of the shared collection by its WAS * resource id. Returns `undefined` for a missing resource, a body that is * not an EDV envelope, or an envelope this app cannot decrypt (each warned * about, distinguishably). * * @param resourceId {string} the WAS resource id * @returns {Promise} */ get(resourceId: string): Promise; } //# sourceMappingURL=sharedCollectionReader.d.ts.map