UNPKG

@civic/sol-did-client

Version:
73 lines (72 loc) 2.4 kB
import { BN, web3 } from '@coral-xyz/anchor'; import { ConfirmOptions, Connection, PublicKey } from '@solana/web3.js'; import { VerificationMethod as DidVerificationMethod } from 'did-resolver'; import { ExtendedCluster } from './connection'; import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider'; export type PrivateKey = number[] | string | Buffer | Uint8Array; export type Bytes = ArrayLike<number>; export type EthSigner = { signMessage: (message: Bytes | string) => Promise<string>; }; export type RawDidSolDataAccount = { version: number; bump: number; nonce: BN; initialVerificationMethod: RawVerificationMethod; verificationMethods: RawVerificationMethod[]; services: Service[]; nativeControllers: web3.PublicKey[]; otherControllers: string[]; }; export type RawVerificationMethod = { fragment: string; keyData: Buffer; methodType: VerificationMethodType; flags: number; }; export type AddVerificationMethodParams = Omit<RawVerificationMethod, 'flags'> & { flags: BitwiseVerificationMethodFlag[]; }; export type Service = { fragment: string; serviceType: string; serviceEndpoint: string; }; export type DidSolUpdateArgs = { verificationMethods: AddVerificationMethodParams[]; services: Service[]; controllerDIDs: string[]; }; export declare enum BitwiseVerificationMethodFlag { Authentication = 1, Assertion = 2, KeyAgreement = 4, CapabilityInvocation = 8, CapabilityDelegation = 16, DidDocHidden = 32, OwnershipProof = 64, Protected = 128 } export declare enum VerificationMethodType { Ed25519VerificationKey2018 = 0, EcdsaSecp256k1RecoveryMethod2020 = 1, EcdsaSecp256k1VerificationKey2019 = 2 } export type DecentralizedIdentifierConstructor = { clusterType: ExtendedCluster | undefined; authority: PublicKey; fragment?: string; }; export type DidVerificationMethodComponents = { verificationMethod: DidVerificationMethod[]; authentication: (string | DidVerificationMethod)[]; assertionMethod: (string | DidVerificationMethod)[]; keyAgreement: (string | DidVerificationMethod)[]; capabilityInvocation: (string | DidVerificationMethod)[]; capabilityDelegation: (string | DidVerificationMethod)[]; }; export type DidSolServiceOptions = { connection?: Connection; wallet?: Wallet; confirmOptions?: ConfirmOptions; };