@leordev-web5/api
Version:
SDK for accessing the features and capabilities of Web5
84 lines • 2.85 kB
TypeScript
import type { AppDataStore, Web5Agent } from '@web5/agent';
import { VcApi } from './vc-api.js';
import { DwnApi } from './dwn-api.js';
import { DidApi } from './did-api.js';
/**
* Override defaults configured during the technical preview phase.
*
* @beta
*/
export type TechPreviewOptions = {
dwnEndpoints?: string[];
};
/**
* Optional overrides that can be provided when calling {@link Web5.connect}.
*
* @beta
*/
export type Web5ConnectOptions = {
/**
* Provide a {@link @web5/agent#Web5Agent} implementation. Defaults to creating a local
* {@link @web5/user-agent#Web5UserAgent} if one isn't provided
**/
agent?: Web5Agent;
/**
* Provide an instance of a {@link @web5/agent#AppDataStore} implementation. Defaults to
* a LevelDB-backed store with an insecure, static unlock passphrase if one
* isn't provided. To allow the app user to enter a secure passphrase of
* their choosing, provide an initialized {@link @web5/agent#AppDataStore} instance.
**/
appData?: AppDataStore;
connectedDid?: string;
/** Enable synchronization of DWN records between local and remote DWNs.
* Sync defaults to running every 2 minutes and can be set to any value accepted by `ms()`.
* To disable sync set to 'off'. */
sync?: string;
/** Override defaults configured during the technical preview phase.
* See {@link TechPreviewOptions} for available options. */
techPreview?: TechPreviewOptions;
};
/**
* Options that are passed to Web5 constructor.
*
* @see {@link Web5ConnectOptions}
* @beta
*/
type Web5Options = {
agent: Web5Agent;
connectedDid: string;
};
/**
* The main Web5 API interface. It manages the creation of a DID if needed, the
* connection to the local DWN and all the web5 main foundational APIs such as VC,
* syncing, etc.
*
* @beta
*/
export declare class Web5 {
/**
* Web5 Agent knows how to handle DIDs, DWNs and VCs requests. The agent manages the
* user keys and identities, and is responsible to sign and verify messages.
*/
agent: Web5Agent;
/** Exposed instance to the DID APIs, allow users to create and resolve DIDs */
did: DidApi;
/** Exposed instance to the DWN APIs, allow users to read/write records */
dwn: DwnApi;
/** Exposed instance to the VC APIs, allow users to issue, present and verify VCs */
vc: VcApi;
private connectedDid;
constructor(options: Web5Options);
/**
* Connects to a {@link @web5/agent#Web5Agent}. Defaults to creating a local {@link @web5/user-agent#Web5UserAgent}
* if one isn't provided.
*
* @param options - optional overrides
* @returns
*/
static connect(options?: Web5ConnectOptions): Promise<{
web5: Web5;
did: string;
}>;
}
export {};
//# sourceMappingURL=web5.d.ts.map