Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Agent

The Agent class mainly provides an abstraction around the {@link IdentityWallet} and InteractionManager components. It provides glue code for:

  • Identities: create and load identities
  • Interactions: find interactions, and process incoming tokens
  • Interaction Requests: start interactions by creating a new request message
  • Credential Issuance: issue credentials

The JolocomSDK has further convenience methods for Agent construction: JolocomSDK.createAgent, JolocomSDK.loadAgent, JolocomSDK.initAgent

Hierarchy

  • Agent

Index

Constructors

constructor

Properties

channels

channels: ChannelKeeper = new ChannelKeeper(this)

interactionManager

interactionManager: InteractionManager = new InteractionManager(this)

passwordStore

passwordStore: IPasswordStore

resolve

resolve: (did: string) => Promise<Identity>

Type declaration

    • (did: string): Promise<Identity>
    • Parameters

      • did: string

      Returns Promise<Identity>

resolver

resolver: IResolver

sdk

storage

storage: IStorage

Accessors

didMethod

  • get didMethod(): IDidMethod
  • The DID method that this Agent was constructed with, or otherwise the SDK's default DID method

    Returns IDidMethod

identityWallet

  • get identityWallet(): IdentityWallet
  • The Agent's IdentityWallet instance.

    throws

    SDKError(ErrorCode.NoWallet) if there is none

    Returns IdentityWallet

idw

  • get idw(): IdentityWallet

keyProvider

  • get keyProvider(): SoftwareKeyProvider
  • The Agent's KeyProvider instance.

    throws

    SDKError(ErrorCode.NoKeyProvider) if there is none

    Returns SoftwareKeyProvider

Credential Management Methods

credIssuanceToken

  • credIssuanceToken(issuance: ICredentialsReceiveAttrs, selection: string): Promise<JSONWebToken<CredentialsReceive>>
  • Returns a base64 encoded signed credential issuance token, given issuance attributes and a recieved token selecting desired issuance

    Parameters

    • issuance: ICredentialsReceiveAttrs

      credential issuance attributes

    • selection: string

      base64 encoded credential offer response token

    Returns Promise<JSONWebToken<CredentialsReceive>>

    A base64 encoded signed issuance token containing verifiable credentials

signedCredential

  • signedCredential<T>(credParams: ISignedCredCreationArgs<T>): Promise<SignedCredential>
  • Returns a Signed Credential

    Type parameters

    • T: BaseMetadata

    Parameters

    • credParams: ISignedCredCreationArgs<T>

      credential attributes

    Returns Promise<SignedCredential>

    SignedCredential instance

Identity Management Methods

createFromMnemonic

  • createFromMnemonic(mnemonic: string, shouldOverwrite?: undefined | false | true): Promise<IdentityWallet>
  • Creates and registers an Identity based on a BIP39 mnemonic phrase

    Parameters

    • mnemonic: string

      a BIP39 mnemonic phrase to use

    • Optional shouldOverwrite: undefined | false | true

      if true, overwrite any pre-existing identity in storage (default false)

    Returns Promise<IdentityWallet>

    An IdentityWallet holding an Identity created by the configured DID Method given the entropy encoded in the mnemonic phrase

createNewIdentity

  • createNewIdentity(): Promise<IdentityWallet>
  • Create and store new Identity using the Agent's didMethod

    Returns Promise<IdentityWallet>

    the newly created {@link IdentityWallet}

loadFromMnemonic

  • loadFromMnemonic(mnemonic: string): Promise<IdentityWallet>
  • Loads an Identity based on a BIP39 mnemonic phrase

    Parameters

    • mnemonic: string

      a BIP39 mnemonic phrase to use

    Returns Promise<IdentityWallet>

    An IdentityWallet holding an Identity created by the configured DID Method given the entropy encoded in the mnemonic phrase

loadIdentity

  • loadIdentity(did?: undefined | string): Promise<IdentityWallet>
  • Load an Identity from storage, given its DID.

    If no DID is specified, the first Identity found in storage will be loaded.

    Parameters

    • Optional did: undefined | string

      DID of Identity to be loaded from DB

    Returns Promise<IdentityWallet>

    An IdentityWallet corrosponding to the given DID

Interaction Management Methods

findInteraction

  • findInteraction<F>(inp: string | JSONWebToken<any>): Promise<Interaction<F>>
  • Find an interaction, by id or by jwt, or by JSONWebToken object

    Type parameters

    Parameters

    • inp: string | JSONWebToken<any>

      id, JWT string, or JSONWebToken object

    Returns Promise<Interaction<F>>

    Promise the associated Interaction object

processJWT

  • Parses a recieved interaction token in JWT format and process it through the interaction system, returning the corresponding Interaction

    throws

    AppError with origError set to the original token validation error from the jolocom library

    Parameters

    • jwt: string

      recieved jwt string

    • Optional transportAPI: TransportAPI

    Returns Promise<Interaction>

    Promise the associated Interaction object

Interaction Requests Methods

authRequestToken

  • authRequestToken(auth: { callbackURL: string; description?: undefined | string }): Promise<JSONWebToken<Authentication>>
  • Creates a signed, base64 encoded Authentication Request, given a callbackURL

    Parameters

    • auth: { callbackURL: string; description?: undefined | string }
      • callbackURL: string
      • Optional description?: undefined | string

    Returns Promise<JSONWebToken<Authentication>>

    Base64 encoded signed Authentication Request

authorizationRequestToken

  • Creates a signed, base64 encoded Authorization Request, given the request attributes

    Parameters

    Returns Promise<JSONWebToken<AuthorizationRequest>>

    Base64 encoded signed Authentication Request

credOfferToken

  • credOfferToken(offer: CredentialOfferRequestAttrs): Promise<JSONWebToken<CredentialOfferRequest>>
  • Returns a base64 encoded signed credential offer token, given request attributes

    Parameters

    • offer: CredentialOfferRequestAttrs

      credential offer attributes

    Returns Promise<JSONWebToken<CredentialOfferRequest>>

    A base64 encoded signed credential offer token offering credentials according to offer

credRequestToken

  • credRequestToken(request: ICredentialRequestAttrs): Promise<JSONWebToken<CredentialRequest>>
  • Creates a signed, base64 encoded Credential Request, given a set of requirements

    Parameters

    • request: ICredentialRequestAttrs

      Credential Request Attributes

    Returns Promise<JSONWebToken<CredentialRequest>>

    Base64 encoded signed credential request

establishChannelRequestToken

resolutionRequestToken

  • resolutionRequestToken(req?: { callbackURL?: undefined | string; description?: undefined | string; uri?: undefined | string }): Promise<JSONWebToken<ResolutionRequest>>
  • Creates a signed, base64 encoded Resolution Request, given a URI

    Parameters

    • Default value req: { callbackURL?: undefined | string; description?: undefined | string; uri?: undefined | string } = {}
      • Optional callbackURL?: undefined | string
      • Optional description?: undefined | string
      • Optional uri?: undefined | string

    Returns Promise<JSONWebToken<ResolutionRequest>>

    Base64 encoded signed Resolution Request

rpcDecRequest

  • rpcDecRequest(req: { callbackURL: string; target?: undefined | string; toDecrypt: Buffer }): Promise<JSONWebToken<DecryptionRequest>>
  • Parameters

    • req: { callbackURL: string; target?: undefined | string; toDecrypt: Buffer }
      • callbackURL: string
      • Optional target?: undefined | string
      • toDecrypt: Buffer

    Returns Promise<JSONWebToken<DecryptionRequest>>

rpcEncRequest

  • rpcEncRequest(req: { callbackURL: string; target: string; toEncrypt: Buffer }): Promise<JSONWebToken<EncryptionRequest>>
  • Parameters

    • req: { callbackURL: string; target: string; toEncrypt: Buffer }
      • callbackURL: string
      • target: string
      • toEncrypt: Buffer

    Returns Promise<JSONWebToken<EncryptionRequest>>

signingRequest

  • signingRequest(req: { callbackURL: string; toSign: Buffer }): Promise<JSONWebToken<SigningRequest>>
  • Parameters

    • req: { callbackURL: string; toSign: Buffer }
      • callbackURL: string
      • toSign: Buffer

    Returns Promise<JSONWebToken<SigningRequest>>

Other Methods

getProofOfControlAuthority

  • getProofOfControlAuthority(): Promise<string>
  • Returns the Proof of Control Authority for an Agent the PCA is a DID Method specific set of data which proves that the key holder also controls the Identifier

    Returns Promise<string>

    Control Proof string

Generated using TypeDoc