UNPKG

@enbox/api

Version:

SDK for accessing the features and capabilities of Web5

59 lines 2.59 kB
/** * NOTE: Added reference types here to avoid a `pnpm` bug during build. * https://github.com/TBD54566975/web5-js/pull/507 */ import type { DwnMessage, DwnResponseStatus, Web5Agent } from '@enbox/agent'; import { DwnInterface } from '@enbox/agent'; /** * Represents metadata associated with a protocol, including the author and an optional message CID. */ export type ProtocolMetadata = { /** The author of the protocol. */ author: string; /** * The Content Identifier (CID) of a ProtocolsConfigure message. * * This is an optional field, and is used by {@link Protocol.send}. */ messageCid?: string; }; /** * Encapsulates a DWN Protocol with its associated metadata and configuration. * * This class primarly exists to provide developers with a convenient way to configure/install * protocols on remote DWNs. */ export declare class Protocol { /** The {@link Web5Agent} instance that handles DWNs requests. */ private _agent; /** The ProtocolsConfigureMessage containing the detailed configuration for the protocol. */ private _metadata; /** Metadata associated with the protocol, including the author and optional message CID. */ private _protocolsConfigureMessage; /** * Constructs a new instance of the Protocol class. * * @param agent - The Web5Agent instance used for network interactions. * @param protocolsConfigureMessage - The configuration message containing the protocol details. * @param metadata - Metadata associated with the protocol, including the author and optional message CID. */ constructor(agent: Web5Agent, protocolsConfigureMessage: DwnMessage[DwnInterface.ProtocolsConfigure], metadata: ProtocolMetadata); /** * Retrieves the protocol definition from the protocol's configuration message. * @returns The protocol definition. */ get definition(): import("@enbox/agent").DwnProtocolDefinition; /** * Serializes the protocol's configuration message to JSON. * @returns The serialized JSON object of the protocol's configuration message. */ toJSON(): import("@enbox/dwn-sdk-js").ProtocolsConfigureMessage; /** * Sends the protocol configuration to a remote DWN identified by the target DID. * * @param target - The DID of the target DWN to which the protocol configuration will be installed. * @returns A promise that resolves to an object containing the status of the send operation. */ send(target: string): Promise<DwnResponseStatus>; } //# sourceMappingURL=protocol.d.ts.map