UNPKG

@enbox/identity-agent

Version:

| A library for building Web5 identity management applications | | ------------------------------------------------------------ |

93 lines 5.05 kB
import { Web5Rpc, DidRequest, VcResponse, DidResponse, DwnResponse, DidInterface, DwnInterface, SendVcRequest, SendDwnRequest, ProcessVcRequest, ProcessDwnRequest, Web5PlatformAgent, AgentPermissionsApi } from '@enbox/agent'; import { BearerDid } from '@enbox/dids'; import { AgentDidApi, AgentDwnApi, AgentSyncApi, AgentCryptoApi, AgentKeyManager, HdIdentityVault, LocalKeyManager, AgentIdentityApi } from '@enbox/agent'; /** * Initialization parameters for {@link Web5IdentityAgent}, including an optional recovery phrase that * can be used to derive keys to encrypt the vault and generate a DID. */ export type AgentInitializeParams = { /** * The password used to secure the Agent vault. * * The password selected should be strong and securely managed to prevent unauthorized access. */ password: string; /** * An optional recovery phrase used to deterministically generate the cryptographic keys for the * Agent vault. * * Supplying this phrase enables the vault's contents to be restored or replicated across devices. * If omitted, a new phrase is generated, which should be securely recorded for future recovery needs. */ recoveryPhrase?: string; }; export type AgentStartParams = { /** * The password used to unlock the previously initialized Agent vault. */ password: string; }; export type AgentParams<TKeyManager extends AgentKeyManager = LocalKeyManager> = { /** Optional. The Decentralized Identifier (DID) representing this Web5 User Agent. */ agentDid?: BearerDid; /** Encrypted vault used for managing the Agent's DID and associated keys. */ agentVault: HdIdentityVault; /** Provides cryptographic capabilties like signing, encryption, hashing and key derivation. */ cryptoApi: AgentCryptoApi; /** Specifies the local path to be used by the Agent's persistent data stores. */ dataPath?: string; /** Facilitates DID operations including create, update, and resolve. */ didApi: AgentDidApi<TKeyManager>; /** Facilitates DWN operations including processing and sending requests. */ dwnApi: AgentDwnApi; /** Facilitates decentralized Identity operations including create, import, and export. */ identityApi: AgentIdentityApi<TKeyManager>; /** Responsible for securely managing the cryptographic keys of the agent. */ keyManager: TKeyManager; /** Facilitates fetching, requesting, creating, revoking and validating revocation status of permissions */ permissionsApi: AgentPermissionsApi; /** Remote procedure call (RPC) client used to communicate with other Web5 services. */ rpcClient: Web5Rpc; /** Facilitates data synchronization of DWN records between nodes. */ syncApi: AgentSyncApi; }; export declare class Web5IdentityAgent<TKeyManager extends AgentKeyManager = LocalKeyManager> implements Web5PlatformAgent<TKeyManager> { crypto: AgentCryptoApi; did: AgentDidApi<TKeyManager>; dwn: AgentDwnApi; identity: AgentIdentityApi<TKeyManager>; keyManager: TKeyManager; permissions: AgentPermissionsApi; rpc: Web5Rpc; sync: AgentSyncApi; vault: HdIdentityVault; private _agentDid?; constructor(params: AgentParams<TKeyManager>); get agentDid(): BearerDid; set agentDid(did: BearerDid); /** * If any of the required agent components are not provided, instantiate default implementations. */ static create({ dataPath, agentDid, agentVault, cryptoApi, didApi, dwnApi, identityApi, keyManager, permissionsApi, rpcClient, syncApi }?: Partial<AgentParams>): Promise<Web5IdentityAgent>; firstLaunch(): Promise<boolean>; /** * Initializes the User Agent with a password, and optionally a recovery phrase. * * This method is typically called once, the first time the Agent is launched, and is responsible * for setting up the agent's operational environment, cryptographic key material, and readiness * for processing Web5 requests. * * The password is used to secure the Agent vault, and the recovery phrase is used to derive the * cryptographic keys for the vault. If a recovery phrase is not provided, a new recovery phrase * will be generated and returned. The password should be chosen and entered by the end-user. */ initialize({ password, recoveryPhrase }: AgentInitializeParams): Promise<string>; processDidRequest<T extends DidInterface>(request: DidRequest<T>): Promise<DidResponse<T>>; processDwnRequest<T extends DwnInterface>(request: ProcessDwnRequest<T>): Promise<DwnResponse<T>>; processVcRequest(_request: ProcessVcRequest): Promise<VcResponse>; sendDidRequest<T extends DidInterface>(_request: DidRequest<T>): Promise<DidResponse<T>>; sendDwnRequest<T extends DwnInterface>(request: SendDwnRequest<T>): Promise<DwnResponse<T>>; sendVcRequest(_request: SendVcRequest): Promise<VcResponse>; start({ password }: AgentInitializeParams): Promise<void>; } //# sourceMappingURL=identity-agent.d.ts.map