UNPKG

@civic/sol-did-client

Version:
114 lines (113 loc) 5.89 kB
import { SolDid } from '@civic/sol-did-idl'; import { AnchorProvider, BN, Idl, Program } from '@coral-xyz/anchor'; import { Commitment, Connection, PublicKey } from '@solana/web3.js'; import { DIDDocument } from 'did-resolver'; import { DidSolServiceOptions, DidSolUpdateArgs, Service, BitwiseVerificationMethodFlag, AddVerificationMethodParams } from './lib/types'; import { DidSolIdentifier } from './DidSolIdentifier'; import { DidSolDataAccount } from './lib/wrappers'; import { DidSolTransactionBuilder } from './utils/DidSolTransactionBuilder'; import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider'; /** * The DidSolService class is a wrapper around the Solana DID program. * It provides methods for creating, reading, updating, and deleting DID documents. * Note, the provider or connection in the DidSolService MUST not be used for tx submissions. * Please use DidSolServiceBuilder instead */ export declare class DidSolService extends DidSolTransactionBuilder { private _program; private _didAuthority; private _cluster; private readonly _identifier; private readonly _didDataAccount; private readonly _legacyDidDataAccount; static build(identifier: DidSolIdentifier | string, options?: DidSolServiceOptions): DidSolService; static buildFromAnchor(program: Program<SolDid>, identifier: DidSolIdentifier | string, provider: AnchorProvider, wallet?: Wallet): DidSolService; private constructor(); get connection(): Connection; get didDataAccount(): PublicKey; get legacyDidDataAccount(): PublicKey; getDidAccount(): Promise<DidSolDataAccount | null>; getDidAccountWithSize(commitment?: Commitment): Promise<[DidSolDataAccount | null, number]>; get did(): string; getIdl(): Idl; getNonce(): Promise<BN>; /** * Initializes the did:sol account. * Does **not** support ethSignInstruction * @param size The initial size of the account * @param payer The account to pay the rent-exempt fee with. */ initialize(size?: number, payer?: PublicKey): DidSolService; /** * Resize the did:sol account. * Supports ethSignInstruction * @param size The new size of the account * @param payer The account to pay the rent-exempt fee with. * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ resize(size: number, payer?: PublicKey, authority?: PublicKey): DidSolService; /** * Close the did:sol account. * Supports ethSignInstruction * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner * @param destination The destination account to move the lamports to. */ close(destination: PublicKey, authority?: PublicKey): DidSolService; /** * Add a VerificationMethod to the did:sol account. * Supports ethSignInstruction * @param method The new VerificationMethod to add * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ addVerificationMethod(method: AddVerificationMethodParams, authority?: PublicKey): DidSolService; /** * Remove a VerificationMethod from the did:sol account. * @param fragment The fragment of the VerificationMethod to remove * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ removeVerificationMethod(fragment: string, authority?: PublicKey): DidSolService; /** * Add a Service to the did:sol account. * Supports ethSignInstruction * @param service The service to add * @param allowOverwrite If true, will overwrite an existing service with the same id * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ addService(service: Service, allowOverwrite?: boolean, authority?: PublicKey): DidSolService; /** * Removes a Service to the did:sol account. * Supports ethSignInstruction * @param fragment The id of the service to remove * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ removeService(fragment: string, authority?: PublicKey): DidSolService; /** * Update the Flags of a VerificationMethod. * @param fragment The fragment of the VerificationMethod to update * @param flags The flags to set. If flags contain BitwiseVerificationMethodFlag.OwnershipProof, the transaction must be signed by the exact same VM. * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ setVerificationMethodFlags(fragment: string, flags: BitwiseVerificationMethodFlag[], authority?: PublicKey): DidSolService; /** * Update the controllers of a Service. * @param controllerDIDs A list of DIDs to be set as controllers * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ setControllers(controllerDIDs: string[], authority?: PublicKey): DidSolService; /** * Updates a DID with contents of document. * @param document A did:sol Document of the DID to update * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ updateFromDoc(document: DIDDocument, authority?: PublicKey): DidSolService; /** * Updates several properties of a service. * @param updateArgs A subset of DID properties to update * @param authority The authority to use. Can be "wrong" if instruction is later signed with ethSigner */ update(updateArgs: DidSolUpdateArgs, authority?: PublicKey): DidSolService; /** * Resolves the DID Document for the did:sol account. */ resolve(checkLegacy?: boolean): Promise<DIDDocument>; }