@ew-did-registry/did-ethr-resolver
Version:
The package resolve CRUD operations on DID Documents
72 lines (71 loc) • 3.06 kB
TypeScript
import { Contract, providers, BigNumber } from 'ethers';
import { DelegateTypes, IAuthentication, IDIDDocument, IDIDLogData, IPublicKey, IResolver, IServiceEndpoint, RegistrySettings, DocumentSelector } from '@ew-did-registry/did-resolver-interface';
/**
* To support different methods compliant with ERC1056, the user/developer simply has to provide
* different resolver settings. The default resolver settings are provided in the 'constants' folder
* Any settings that follow the IResolverSettings interface are valid.
*
* The read functionality is implemented in Resolver class. If one wants to adjust it or create her
* own implementation (for example according to ERC725), one could use this class as a
* starting point.
* All the functionality supporting document resolution is stored in 'functions' folder.
*/
declare class Resolver implements IResolver {
/**
* Stores resolver settings, such as abi, contract address, and IProvider
*/
readonly settings: Required<RegistrySettings>;
/**
* Stores the provider to connect to blockchain
*/
protected readonly _provider: providers.Provider;
/**
* Stores the smart contract instance with read functionality available
*/
protected _contract: Contract;
/**
* Constructor
*
* @param settings - Settings to connect to Ethr registry
* @param provider - Ethers provider. Can be obtained from getProvider(providerSettings)
*/
constructor(provider: providers.Provider, settings: RegistrySettings);
/**
* Resolve DID Document for a given did
*
* @example
* ```typescript
* import { Resolver } from '@ew-did-registry/did-resolver';
*
* const resolver = new Resolver(provider, resolverSettings);
* const didDocument = await resolver.read(did);
* ```
*
* @param did - entity identifier, which is associated with DID Document
* @returns {Promise<IDIDDocument>}
*/
private _read;
read(did: string): Promise<IDIDDocument>;
readAttribute(did: string, selector: DocumentSelector): Promise<IPublicKey | IServiceEndpoint | IAuthentication | undefined>;
/**
* Returns the Ethereum address of current identity owner
*
* @param { string } did - did of identity of interest
* @returns Promise<string>
*/
identityOwner(did: string): Promise<string>;
/**
* Performs the check if the delegate is valid for particular did
* Return boolean
*
* @param { string } identityDID - did of identity of interest
* @param { DelegateTypes } delegateType - type of delegate of interest
* @param { delegateDID } did - did of delegate of interest
* @returns Promise<boolean>
*/
validDelegate(identityDID: string, delegateType: DelegateTypes, delegateDID: string): Promise<boolean>;
readOwnerPubKey(did: string): Promise<string | undefined>;
readFromBlock(did: string, topBlock: BigNumber): Promise<IDIDLogData>;
lastBlock(did: string): Promise<BigNumber>;
}
export default Resolver;