UNPKG

@self.id/web

Version:

Read and write records in browsers environments

51 lines (50 loc) 2.12 kB
import { ThreeIdConnect } from '@3id/connect'; import type { EthereumAuthProvider } from '@3id/connect'; import type { CeramicClient } from '@ceramicnetwork/http-client'; import type { DIDDataStore } from '@glazed/did-datastore'; import type { ModelTypeAliases } from '@glazed/types'; import { Core } from '@self.id/core'; import type { CoreModelTypes, CoreParams } from '@self.id/core'; import { DID } from 'dids'; /** Ceramic networks supported by 3ID Connect. */ export declare type ConnectNetwork = 'dev-unstable' | 'mainnet' | 'testnet-clay'; export declare type WebClientParams<ModelTypes extends ModelTypeAliases = CoreModelTypes> = CoreParams<ModelTypes> & { /** Ceramic network used for authentication. */ connectNetwork?: ConnectNetwork; threeidConnect?: boolean; }; /** * WebClient extends the {@linkcode core.Core Core class} with authentication support in browser * environments. * * It is exported by the {@linkcode web} module. * * ```sh * import { WebClient } from '@self.id/web' * ``` */ export declare class WebClient<ModelTypes extends ModelTypeAliases = CoreModelTypes> extends Core<ModelTypes> { /** @internal */ _ceramic: CeramicClient; /** @internal */ _dataStore: DIDDataStore<ModelTypes>; /** @internal */ _threeId: ThreeIdConnect; constructor(params: WebClientParams<ModelTypes>); /** 3ID Connect instance used internally. */ get threeId(): ThreeIdConnect; /** * Create and authenticate a DID instance using the given `authProvider`. * * By default, this also attaches the created DID instance to the internal Ceramic client * instance. This behavior can be disabled by setting `attachToCeramic` to `false`. */ authenticate(authProvider: EthereumAuthProvider, attachToCeramic?: boolean): Promise<DID>; /** * Create a DID instance using the given `authProvider`. * * ⚠️ This method does **not** attempt to authenticate immediately, use {@linkcode authenticate} * instead if this is the wanted behavior. */ connect(authProvider: EthereumAuthProvider): Promise<DID>; }