Skip to main content

@hyperledger/identus-edge-agent-sdk / Exports / Agent

Class: Agent

Edge agent implementation

Export

Agent

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Agent(apollo, castor, pluto, mercury, mediationHandler, connectionManager, seed?, api?, options?): Agent

Creates an instance of Agent.

Parameters

NameType
apolloApollo
castorCastor
plutoPluto
mercuryMercury
mediationHandlerMediatorHandler
connectionManagerConnectionsManager
seedSeed
apiApi
options?AgentOptions

Returns

Agent

Overrides

Controller.constructor

Defined in

src/edge-agent/didcomm/Agent.ts:62

Properties

api

Readonly api: Api

Defined in

src/edge-agent/didcomm/Agent.ts:70


apollo

Readonly apollo: Apollo

Defined in

src/edge-agent/didcomm/Agent.ts:63


backup

backup: AgentBackup

Defined in

src/edge-agent/didcomm/Agent.ts:51


castor

Readonly castor: Castor

Defined in

src/edge-agent/didcomm/Agent.ts:64


connectionManager

Readonly connectionManager: ConnectionsManager

Defined in

src/edge-agent/didcomm/Agent.ts:68


mediationHandler

Readonly mediationHandler: MediatorHandler

Defined in

src/edge-agent/didcomm/Agent.ts:67


mercury

Readonly mercury: Mercury

Defined in

src/edge-agent/didcomm/Agent.ts:66


pluto

Readonly pluto: Pluto

Defined in

src/edge-agent/didcomm/Agent.ts:65


pollux

Readonly pollux: Pollux

Defined in

src/edge-agent/didcomm/Agent.ts:52


seed

Readonly seed: Seed

Defined in

src/edge-agent/didcomm/Agent.ts:69


state

state: State = State.STOPPED

current status of the entity

Inherited from

Controller.state

Defined in

src/domain/protocols/Startable.ts:42

Accessors

currentMediatorDID

get currentMediatorDID(): undefined | DID

Get current mediator DID if available or null

Returns

undefined | DID

Defined in

src/edge-agent/didcomm/Agent.ts:213

Methods

_start

_start(): Promise<void>

internal method to define specific startup routine

used by start() internally

implement with protected to keep hidden from class interface

Returns

Promise<void>

Overrides

Controller._start

Defined in

src/edge-agent/didcomm/Agent.ts:140


_stop

_stop(): Promise<void>

internal method to define teardown routine

used by stop() internally

implement with protected to keep hidden from class interface

Returns

Promise<void>

Overrides

Controller._stop

Defined in

src/edge-agent/didcomm/Agent.ts:171


acceptDIDCommInvitation

acceptDIDCommInvitation(invitation, alias?): Promise<void>

Asyncronously accept a didcomm v2 invitation, will create a pair between the Agent its connecting with and the current owner's did

Parameters

NameType
invitationOutOfBandInvitation
alias?string

Returns

Promise<void>

Deprecated

  • use acceptInvitation

Async

Defined in

src/edge-agent/didcomm/Agent.ts:383


acceptInvitation

acceptInvitation(invitation, optionalAlias?): Promise<void>

Handle an invitation based on it's type

  • PrismOnboardingInvitation: creates a new connection
  • OutOfBandInvitation:
    • no Attachment: creates a new connection
    • with Attachment: stores / emits the attached message

Parameters

NameTypeDescription
invitationInvitationTypean OOB or PrismOnboarding invitation
optionalAlias?string-

Returns

Promise<void>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:305


acceptPrismOnboardingInvitation

acceptPrismOnboardingInvitation(invitation): Promise<void>

Asyncronously accept an onboarding invitation, used to onboard the current DID in the Cloud Agent.

Parameters

NameType
invitationPrismOnboardingInvitation

Returns

Promise<void>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:336


addListener

addListener(eventName, callback): void

Add an event listener to get notified from an Event "MESSAGE"

Parameters

NameType
eventNameListenerKey
callbackEventCallback

Returns

void

Defined in

src/edge-agent/didcomm/Agent.ts:187


createNewPeerDID

createNewPeerDID(services?, updateMediator?): Promise<DID>

Asyncronously Create a new PeerDID

Parameters

NameTypeDefault value
services?Service[][]
updateMediator?booleantrue

Returns

Promise<DID>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:260


createNewPrismDID

createNewPrismDID(alias, services?, keyPathIndex?): Promise<DID>

Asyncronously create a new PrismDID

Parameters

NameTypeDefault value
aliasstringundefined
services?Service[][]
keyPathIndex?numberundefined

Returns

Promise<DID>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:243


createPresentationForRequestProof

createPresentationForRequestProof(request, credential): Promise<Presentation>

Asyncronously create a verifiablePresentation from a valid stored verifiableCredential This is used when the verified requests a specific verifiable credential, this will create the actual instance of the presentation which we can share with the verifier.

Parameters

NameType
requestRequestPresentation
credentialCredential

Returns

Promise<Presentation>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:485


handlePresentation

handlePresentation(presentation): Promise<boolean>

Initiate the Presentation and presentationSubmission

Parameters

NameType
presentationPresentation

Returns

Promise<boolean>

Defined in

src/edge-agent/didcomm/Agent.ts:531


initiatePresentationRequest

initiatePresentationRequest<T>(type, toDID, presentationClaims): Promise<RequestPresentation>

Initiate a PresentationRequest from the SDK, to create oob Verification Requests

Type parameters

NameType
Textends CredentialType = JWT

Parameters

NameType
typeT
toDIDDID
presentationClaimsPresentationClaims<T>

Returns

Promise<RequestPresentation>

  1. Example use-case: Send a Presentation Request for a JWT credential issued by a specific issuer
 agent.initiatePresentationRequest(
Domain.CredentialType.JWT,
toDID,
{ issuer: Domain.DID.fromString("did:peer:12345"), claims: {}}
);
  1. Example use-case: Send a Presentation Request for a JWT credential issued by a specific issuer and specific claims
 agent.initiatePresentationRequest(
Domain.CredentialType.JWT,
toDID,
{ issuer: Domain.DID.fromString("did:peer:12345"), claims: {email: {type: 'string', pattern:'email@email.com'}}}
);

Defined in

src/edge-agent/didcomm/Agent.ts:518


isCredentialRevoked

isCredentialRevoked(credential): Promise<boolean>

Parameters

NameType
credentialCredential

Returns

Promise<boolean>

Defined in

src/edge-agent/didcomm/Agent.ts:422


parseInvitation

parseInvitation(str): Promise<InvitationType>

Asyncronously parse an invitation from a valid json string

Parameters

NameType
strstring

Returns

Promise<InvitationType>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:288


parseOOBInvitation

parseOOBInvitation(url): Promise<OutOfBandInvitation>

Asyncronously parse an out of band invitation from a URI as the oob come in format of valid URL

Parameters

NameType
urlURL

Returns

Promise<OutOfBandInvitation>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:363


parsePrismInvitation

parsePrismInvitation(str): Promise<PrismOnboardingInvitation>

Asyncronously parse a prismOnboarding invitation from a string

Parameters

NameType
strstring

Returns

Promise<PrismOnboardingInvitation>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:324


prepareRequestCredentialWithIssuer

prepareRequestCredentialWithIssuer(offer): Promise<RequestCredential>

Asyncronously prepare a request credential message from a valid offerCredential for now supporting w3c verifiable credentials offers.

Parameters

NameType
offerOfferCredential

Returns

Promise<RequestCredential>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:454


processIssuedCredentialMessage

processIssuedCredentialMessage(issueCredential): Promise<Credential>

Extract the verifiableCredential object from the Issue credential message asyncronously

Parameters

NameType
issueCredentialIssueCredential

Returns

Promise<Credential>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:468


removeListener

removeListener(eventName, callback): void

Remove event listener, used by stop procedure

Parameters

NameType
eventNameListenerKey
callbackEventCallback

Returns

void

Date

20/06/2023 - 14:31:30

Defined in

src/edge-agent/didcomm/Agent.ts:198


revealCredentialFields

revealCredentialFields(credential, fields, linkSecret): Promise<Record<string, any>>

This method can be used by holders in order to disclose the value of a Credential JWT are just encoded plainText Anoncreds will really need to be disclosed as the fields are encoded.

Parameters

NameType
credentialCredential
fieldsstring[]
linkSecretstring

Returns

Promise<Record<string, any>>

Defined in

src/edge-agent/didcomm/Agent.ts:434


runTask

runTask<T>(task): Promise<T>

Type parameters

Name
T

Parameters

NameType
taskTask<T, unknown>

Returns

Promise<T>

Defined in

src/edge-agent/didcomm/Agent.ts:217


sendMessage

sendMessage(message): Promise<undefined | Message>

Asyncronously send a didcomm Message

Parameters

NameType
messageMessage

Returns

Promise<undefined | Message>

Defined in

src/edge-agent/didcomm/Agent.ts:413


signWith

signWith(did, message): Promise<Signature>

Asyncronously sign a message with a DID

Parameters

NameType
didDID
messageUint8Array

Returns

Promise<Signature>

Async

Defined in

src/edge-agent/didcomm/Agent.ts:276


start

start(): Promise<State>

handle the startup of an entity

updates state according to lifecycle

Returns

Promise<State>

Inherited from

Controller.start

Defined in

src/domain/protocols/Startable.ts:62


startFetchingMessages

startFetchingMessages(iterationPeriod): Promise<void>

Start fetching for new messages in such way that it can be stopped at any point in time without causing memory leaks

Parameters

NameType
iterationPeriodnumber

Returns

Promise<void>

Defined in

src/edge-agent/didcomm/Agent.ts:396


stop

stop(): Promise<State>

handle the teardown of an entity

updates state according to lifecycle

Returns

Promise<State>

Inherited from

Controller.stop

Defined in

src/domain/protocols/Startable.ts:72


stopFetchingMessages

stopFetchingMessages(): void

Stops fetching messages

Returns

void

Defined in

src/edge-agent/didcomm/Agent.ts:403


verifiableCredentials

verifiableCredentials(): Promise<Credential[]>

Asyncronously get all verifiable credentials

Returns

Promise<Credential[]>

Defined in

src/edge-agent/didcomm/Agent.ts:443


initialize

initialize(params): Agent

Convenience initializer for Agent allowing default instantiation, omitting all but the absolute necessary parameters

Parameters

NameTypeDescription
paramsObjectdependencies object
params.api?Api
params.apollo?Apollo
params.castor?Castor
params.mediatorDIDstring | DIDdid of the mediator to be used
params.mercury?Mercury
params.options?AgentOptions-
params.plutoPlutostorage implementation
params.seed?Seed

Returns

Agent

Defined in

src/edge-agent/didcomm/Agent.ts:92