/*! * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved. */ import type { IEDVChunk, IEDVConfig, IEDVQuery, IEncryptedDocument, IIndexEntry, IZcap } from '@interop/data-integrity-core'; /** * Options for `createEdv`. */ export interface ITransportCreateEdvOptions { url?: string; config?: IEDVConfig; } /** * Options for `findConfigs`. */ export interface ITransportFindConfigsOptions { controller?: string; referenceId?: string; after?: string; limit?: number; } /** * Options for `updateIndex`. */ export interface ITransportUpdateIndexOptions { docId?: string; entry?: IIndexEntry; } /** * Options for `storeChunk`. */ export interface ITransportStoreChunkOptions { docId?: string; chunk?: IEDVChunk; } /** * Options for `getChunk`. */ export interface ITransportGetChunkOptions { docId?: string; chunkIndex?: number; } export declare class Transport { /** * Creates a Transport layer for an EDV client. * * @returns {Transport} A Transport instance. */ constructor(); /** * Creates a new EDV using the given configuration. * * @param {object} options - The options to use. * @param {string} options.url - The url to post the configuration to. * @param {string} options.config - The EDV's configuration. * * @returns {Promise} - Resolves to the configuration for the newly * created EDV. */ createEdv({ url, config }?: ITransportCreateEdvOptions): Promise; /** * Gets the configuration for an EDV from the server. * * @param {object} options - The options to use. * @param {string} options.id - The ID of the EDV. * * @returns {Promise} - Resolves to the configuration for the EDV. */ getConfig({ id }?: { id?: string; }): Promise; /** * Sends an updated EDV configuration to the server. The new configuration * `sequence` must be incremented by `1` over the previous configuration or * the update will fail. * * @param {object} options - The options to use. * @param {object} options.config - The new EDV config. * * @returns {Promise} - Settles once the operation completes. */ updateConfig({ config }?: { config?: IEDVConfig; }): Promise; /** * Get all EDV configurations matching a query. * * @param {object} options - The options to use. * @param {string} options.controller - The EDV's controller. * @param {string} [options.referenceId] - A controller-unique reference ID. * @param {string} [options.after] - An EDV's ID. * @param {number} [options.limit] - How many EDV configs to return. * * @returns {Promise} - Resolves to the matching EDV configurations. */ findConfigs({ controller, referenceId, after, limit }?: ITransportFindConfigsOptions): Promise; /** * Sends a new encrypted document to an EDV server. If the server reports * that a document with a matching ID already exists, a `DuplicateError` is * thrown. * * @param {object} options - The options to use. * @param {object} options.encrypted - The encrypted document to insert. * * @returns {Promise} - Settles once the operation completes. */ insert({ encrypted }?: { encrypted?: IEncryptedDocument; }): Promise; /** * Sends an encrypted document to an EDV server. If the document does not * already exist, it will be created. If the update is rejected because of a * conflict, then an `InvalidStateError` will be thrown. * * @param {object} options - The options to use. * @param {object} options.encrypted - The encrypted document to insert. * * @returns {Promise} - Settles once the operation completes. */ update({ encrypted }?: { encrypted?: IEncryptedDocument; }): Promise; /** * Sends an update for an index for the given document, without updating the * document itself. If the index entry's sequence number does not match the * document's current sequence number, update will be rejected with an * `InvalidStateError`. * * Note: If the index does not exist or the document does not have an * existing entry for the index, it will be added. * * @param {object} options - The options to use. * @param {string} options.docId - The ID of the document. * @param {object} options.entry - The index entry to send. * * @returns {Promise} - Settles once the operation completes. */ updateIndex({ docId, entry }?: ITransportUpdateIndexOptions): Promise; /** * Gets an encrypted document from an EDV server by its ID. * * @param {object} options - The options to use. * @param {string} options.id - The ID of the document to get. * * @returns {Promise} - Resolves to the encrypted document. */ get({ id }?: { id?: string; }): Promise; /** * Sends a query to an EDV server to find encrypted documents based on their * attributes. * * @param {object} options - The options to use. * @param {object} options.query - The query to send. * * @returns {Promise} - Resolves to the matching encrypted documents: * `{documents: [...]}` or `{count: docCount}` if `query.count === true`. */ find({ query }?: { query?: IEDVQuery; }): Promise; /** * Store a capability revocation. * * @param {object} options - The options to use. * @param {object} options.capabilityToRevoke - The capability to revoke. * * @returns {Promise} Resolves once the operation completes. */ revokeCapability({ capabilityToRevoke }?: { capabilityToRevoke?: IZcap; }): Promise; /** * Sends an encrypted document chunk to an EDV server. * * @param {object} options - The options to use. * @param {string} options.docId - The document ID. * @param {number} options.chunk - The encrypted chunk. * * @returns {Promise} - Settles once the operation completes. */ storeChunk({ docId, chunk }?: ITransportStoreChunkOptions): Promise; /** * Gets an encrypted document chunk from an EDV server. * * @param {object} options - The options to use. * @param {string} options.docId - The document ID. * @param {number} options.chunkIndex - The index of the chunk. * * @returns {Promise} - Resolves to the chunk data. */ getChunk({ docId, chunkIndex }?: ITransportGetChunkOptions): Promise; } //# sourceMappingURL=Transport.d.ts.map