UNPKG

@identity.com/sol-did-client

Version:
43 lines (42 loc) 2.9 kB
/// <reference types="node" /> import * as anchor from '@project-serum/anchor'; import { Program, Provider } from '@project-serum/anchor'; import { SolDid } from '@identity.com/sol-did-idl'; import { Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js'; import { VerificationMethod as ResolverVerificationMethod } from 'did-resolver'; import { DidVerificationMethodComponents, EthSigner, PrivateKey, Service } from './types'; import { ServiceEndpoint as DidService, VerificationMethod as DidVerificationMethod } from 'did-resolver'; import { DidSolIdentifier } from '../DidSolIdentifier'; import { ExtendedCluster } from './connection'; import { VerificationMethod } from './wrappers'; export declare const fetchProgram: (provider: Provider) => Program<SolDid>; export declare const findProgramAddress: (authority: PublicKey) => [anchor.web3.PublicKey, number]; export declare const findLegacyProgramAddress: (authority: PublicKey) => [anchor.web3.PublicKey, number]; export declare const ethSignPayload: (instruction: TransactionInstruction, nonce: anchor.BN, signer: EthSigner) => Promise<TransactionInstruction>; export declare const isValidDid: (did: string) => boolean; export declare const isDidSol: (did: string) => boolean; export declare const validateAndSplitControllers: (controllerDids: string[]) => { nativeControllers: anchor.web3.PublicKey[]; otherControllers: string[]; }; export declare const defaultVerificationMethod: (authority: PublicKey) => VerificationMethod; export declare const mapVerificationMethodsToDidComponents: (methods: VerificationMethod[], identifier: DidSolIdentifier) => DidVerificationMethodComponents; export declare const mapServices: (services: Service[], identifier: DidSolIdentifier) => DidService[]; export declare const mapControllers: (nativeControllers: PublicKey[], otherControllers: string[], clusterType: ExtendedCluster | undefined) => string[]; export declare const getBinarySize: (input: string) => number; export declare const privateKeyIsArray: (privateKey: PrivateKey) => privateKey is number[]; export declare const privateKeyIsString: (privateKey: PrivateKey) => privateKey is string; export declare const privateKeyIsBuffer: (privateKey: PrivateKey) => privateKey is Buffer; export declare const privateKeyIsUint8Array: (privateKey: PrivateKey) => privateKey is Uint8Array; /** * Create a Solana account object from an x25519 private key * @param privateKey */ export declare const makeKeypair: (privateKey: PrivateKey) => Keypair; /** * Given a private key on the x25519 curve, get its public key * @param privateKey */ export declare const getPublicKey: (privateKey: PrivateKey) => PublicKey; export declare const getKeyDataFromVerificationMethod: (vm: DidVerificationMethod) => Buffer; export declare const isStringDID: (identifier: ResolverVerificationMethod | DidSolIdentifier | string) => identifier is string;