Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DID

Interact with DIDs.

Hierarchy

  • DID

Index

Constructors

constructor

  • new DID(__namedParameters?: { cache: undefined | DIDCache; provider: undefined | RPCConnection; resolver: Resolver | Record<string, DIDResolver> }): DID
  • Parameters

    • Default value __namedParameters: { cache: undefined | DIDCache; provider: undefined | RPCConnection; resolver: Resolver | Record<string, DIDResolver> } = {}
      • cache: undefined | DIDCache
      • provider: undefined | RPCConnection
      • resolver: Resolver | Record<string, DIDResolver>

    Returns DID

Accessors

authenticated

  • get authenticated(): boolean

id

  • get id(): string
  • Get the DID identifier of the user.

    Returns string

Methods

authenticate

  • authenticate(__namedParameters?: { aud: undefined | string; paths: undefined | string[]; provider: undefined | RPCConnection }): Promise<string>
  • Authenticate the user.

    Parameters

    • Default value __namedParameters: { aud: undefined | string; paths: undefined | string[]; provider: undefined | RPCConnection } = {}
      • aud: undefined | string
      • paths: undefined | string[]
      • provider: undefined | RPCConnection

    Returns Promise<string>

createDagJWE

  • createDagJWE(cleartext: Record<string, any>, recipients: Array<string>, options?: CreateJWEOptions): Promise<JWE>
  • Create an IPFS compatibe DagJWE encrypted to the given recipients.

    Parameters

    • cleartext: Record<string, any>

      The cleartext to be encrypted, may include ipld links

    • recipients: Array<string>

      An array of DIDs

    • Default value options: CreateJWEOptions = {}

      Optional parameters

    Returns Promise<JWE>

createDagJWS

  • Create an IPFS compatibe DagJWS encoded signature over the given payload. Will be signed by the currently authenticated DID.

    Parameters

    • payload: Record<string, any>

      The payload to sign, may include ipld links

    • Default value options: CreateJWSOptions = {}

      Optional parameters

    Returns Promise<DagJWSResult>

createJWE

  • createJWE(cleartext: Uint8Array, recipients: Array<string>, options?: CreateJWEOptions): Promise<JWE>
  • Create a JWE encrypted to the given recipients.

    Parameters

    • cleartext: Uint8Array

      The cleartext to be encrypted

    • recipients: Array<string>

      An array of DIDs

    • Default value options: CreateJWEOptions = {}

      Optional parameters

    Returns Promise<JWE>

createJWS

  • Create a JWS encoded signature over the given payload. Will be signed by the currently authenticated DID.

    Type parameters

    • T = any

    Parameters

    • payload: T

      The payload to sign

    • Default value options: CreateJWSOptions = {}

      Optional parameters

    Returns Promise<DagJWS>

decryptDagJWE

  • decryptDagJWE(jwe: JWE): Promise<Record<string, any>>
  • Try to decrypt the given DagJWE with the currently authenticated user.

    Parameters

    • jwe: JWE

      The JWE to decrypt

    Returns Promise<Record<string, any>>

    An ipld object

decryptJWE

  • Try to decrypt the given JWE with the currently authenticated user.

    Parameters

    • jwe: JWE

      The JWE to decrypt

    • Default value options: DecryptJWEOptions = {}

      Optional parameters

    Returns Promise<Uint8Array>

resolve

  • resolve(didUrl: string): Promise<DIDDocument>
  • Resolve the DID Document of the given DID.

    Parameters

    • didUrl: string

      The DID to resolve

    Returns Promise<DIDDocument>

setProvider

  • Set the DID provider of this instance. Only callable if provider not already set.

    Parameters

    Returns void

setResolver

  • Set the DID-resolver user by this instance

    Parameters

    • resolver: Resolver | ResolverRegistry

      Either a Resolver instance or an object with specific resolvers

    • Optional cache: DIDCache

      A custom cache to use for the created resolver. Will be ignored if a Resolver instance is passed

    Returns void

verifyJWS

  • Verify a JWS. Uses the 'kid' in the header as the way to resolve the author public key.

    Parameters

    • jws: string | DagJWS

      The JWS to verify

    Returns Promise<VerifyJWSResult>

    Information about the signed JWS

Generated using TypeDoc