Skip to main content

Agent

@hyperledger/identus-sdk v7.0.0


@hyperledger/identus-sdk / overview / Agent

Class: Agent

Defined in: src/edge-agent/Agent.ts:50

Edge agent implementation

Agent

Extends

Constructors

Constructor

new Agent(apollo: Apollo, castor: Castor, pluto: Pluto, mercury: Mercury, seed: Seed, api: Api, options?: AgentOptions): Agent

Defined in: src/edge-agent/Agent.ts:61

Creates an instance of Agent.

Parameters

ParameterType
apolloApollo
castorCastor
plutoPluto
mercuryMercury
seedSeed
apiApi
options?AgentOptions

Returns

Agent

Overrides

Controller.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
apireadonlyApiundefined--src/edge-agent/Agent.ts:67
apolloreadonlyApolloundefined--src/edge-agent/Agent.ts:62
backuppublicAgentBackupundefined--src/edge-agent/Agent.ts:51
castorreadonlyCastorundefined--src/edge-agent/Agent.ts:63
connectionsreadonlyConnectionsManagerundefined--src/edge-agent/Agent.ts:52
eventsreadonlyEventsManagerundefined--src/edge-agent/Agent.ts:53
jobsreadonlyJobManagerundefined--src/edge-agent/Agent.ts:54
mercuryreadonlyMercuryundefined--src/edge-agent/Agent.ts:65
pluginsreadonlyPluginManagerundefined--src/edge-agent/Agent.ts:55
plutoreadonlyPlutoundefined--src/edge-agent/Agent.ts:64
seedreadonlySeedundefined--src/edge-agent/Agent.ts:66
statepublicStateState.STOPPEDcurrent status of the entityController.statesrc/domain/protocols/Startable.ts:42

Accessors

currentMediatorDID

Get Signature

get currentMediatorDID(): DID | undefined

Defined in: src/edge-agent/Agent.ts:183

Deprecated

Get current mediator DID if available or null

Returns

DID | undefined

Methods

acceptDIDCommInvitation()

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

Defined in: src/edge-agent/Agent.ts:366

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

Parameters

ParameterTypeDescription
invitationOutOfBandInvitation
alias?string-

Returns

Promise<void>

Deprecated

  • use acceptInvitation

acceptInvitation()

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

Defined in: src/edge-agent/Agent.ts:288

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

ParameterTypeDescription
invitationInvitationTypean OOB or PrismOnboarding invitation
optionalAlias?string-

Returns

Promise<void>


addListener()

addListener<T>(eventName: T, callback: EventCallback<T>): number

Defined in: src/edge-agent/Agent.ts:160

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

Type Parameters

Type Parameter
T extends ListenerKey

Parameters

ParameterTypeDescription
eventNameT
callbackEventCallback<T>

Returns

number


createNewPeerDID()

createNewPeerDID(services?: Service[], updateMediator?: boolean): Promise<DID>

Defined in: src/edge-agent/Agent.ts:243

Asyncronously Create a new PeerDID

Parameters

ParameterTypeDefault valueDescription
services?Service[][]
updateMediator?booleantrue

Returns

Promise<DID>


createNewPrismDID()

createNewPrismDID(alias: string, services?: Service[], keyPathIndex?: number): Promise<DID>

Defined in: src/edge-agent/Agent.ts:226

Asyncronously create a new PrismDID

Parameters

ParameterTypeDefault valueDescription
aliasstringundefined
services?Service[][]
keyPathIndex?numberundefined

Returns

Promise<DID>


createPresentationForRequestProof()

createPresentationForRequestProof(request: RequestPresentation, credential: Credential): Promise<Presentation>

Defined in: src/edge-agent/Agent.ts:522

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

ParameterTypeDescription
requestRequestPresentation
credentialCredential

Returns

Promise<Presentation>


handle()

handle(message: Message): Promise<any>

Defined in: src/edge-agent/Agent.ts:426

Find and execute a task registered for the given Message.piuri

Parameters

ParameterTypeDescription
messageMessage

Returns

Promise<any>


handlePresentation()

handlePresentation(presentation: Presentation): Promise<boolean>

Defined in: src/edge-agent/Agent.ts:568

Initiate the Presentation and presentationSubmission

Parameters

ParameterTypeDescription
presentationPresentation

Returns

Promise<boolean>


initiatePresentationRequest()

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

Defined in: src/edge-agent/Agent.ts:555

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

Type Parameters

Type ParameterDefault type
T extends CredentialTypeJWT

Parameters

ParameterTypeDescription
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'}}}
);

isCredentialRevoked()

isCredentialRevoked(credential: Credential): Promise<boolean>

Defined in: src/edge-agent/Agent.ts:442

Parameters

ParameterTypeDescription
credentialCredential

Returns

Promise<boolean>


parseInvitation()

parseInvitation(str: string): Promise<InvitationType>

Defined in: src/edge-agent/Agent.ts:271

Asyncronously parse an invitation from a valid json string

Parameters

ParameterTypeDescription
strstring

Returns

Promise<InvitationType>


parseOOBInvitation()

parseOOBInvitation(url: URL): Promise<OutOfBandInvitation>

Defined in: src/edge-agent/Agent.ts:346

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

Parameters

ParameterTypeDescription
urlURL

Returns

Promise<OutOfBandInvitation>


parsePrismInvitation()

parsePrismInvitation(str: string): Promise<PrismOnboardingInvitation>

Defined in: src/edge-agent/Agent.ts:307

Asyncronously parse a prismOnboarding invitation from a string

Parameters

ParameterTypeDescription
strstring

Returns

Promise<PrismOnboardingInvitation>


prepareRequestCredentialWithIssuer()

prepareRequestCredentialWithIssuer(offer: OfferCredential): Promise<RequestCredential>

Defined in: src/edge-agent/Agent.ts:489

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

Parameters

ParameterTypeDescription
offerOfferCredential

Returns

Promise<RequestCredential>


processIssuedCredentialMessage()

processIssuedCredentialMessage(issueCredential: IssueCredential): Promise<Credential>

Defined in: src/edge-agent/Agent.ts:504

Extract the verifiableCredential object from the Issue credential message asyncronously

Parameters

ParameterTypeDescription
issueCredentialIssueCredential

Returns

Promise<Credential>


removeListener()

removeListener<T>(eventName: T, callback: EventCallback<T>): void

Defined in: src/edge-agent/Agent.ts:170

Remove event listener, used by stop procedure

Type Parameters

Type Parameter
T extends ListenerKey

Parameters

ParameterTypeDescription
eventNameT
callbackEventCallback<T>

Returns

void


revealCredentialFields()

revealCredentialFields(credential: Credential, fields: string[], linkSecret: string): Promise<{ }>

Defined in: src/edge-agent/Agent.ts:463

Parameters

ParameterTypeDescription
credentialCredential
fieldsstring[]-
linkSecretstring-

Returns

Promise<{ }>

Deprecated

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.


runTask()

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

Defined in: src/edge-agent/Agent.ts:195

run the given Task

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
taskTask<T>

Returns

Promise<T>


send()

Call Signature

send(message: ApiRequest): Promise<ApiResponse<unknown> | undefined>

Defined in: src/edge-agent/Agent.ts:413

Handle sending a Protocol

Parameters
ParameterTypeDescription
messageApiRequest
Returns

Promise<ApiResponse<unknown> | undefined>

Call Signature

send(message: Message): Promise<Message | undefined>

Defined in: src/edge-agent/Agent.ts:414

Handle sending a Protocol

Parameters
ParameterTypeDescription
messageMessage
Returns

Promise<Message | undefined>


sendMessage()

sendMessage(message: ApiRequest | Message): Promise<Message | undefined>

Defined in: src/edge-agent/Agent.ts:402

Asyncronously send a didcomm Message

Parameters

ParameterTypeDescription
messageApiRequest | Message

Returns

Promise<Message | undefined>

Deprecated

use send instead


signWith()

signWith(did: DID, message: Uint8Array): Promise<Signature>

Defined in: src/edge-agent/Agent.ts:259

Asyncronously sign a message with a DID

Parameters

ParameterTypeDescription
didDID
messageUint8Array

Returns

Promise<Signature>


start()

start(): Promise<State>

Defined in: src/domain/protocols/Startable.ts:62

handle the startup of an entity

updates state according to lifecycle

Returns

Promise<State>

Inherited from

Controller.start


startFetchingMessages()

startFetchingMessages(period?: number): Promise<void>

Defined in: src/edge-agent/Agent.ts:381

Start the fetch messages long running job

sends a PickupRequest to all mediator connections

Parameters

ParameterTypeDescription
period?number

Returns

Promise<void>


stop()

stop(): Promise<State>

Defined in: src/domain/protocols/Startable.ts:72

handle the teardown of an entity

updates state according to lifecycle

Returns

Promise<State>

Inherited from

Controller.stop


stopFetchingMessages()

stopFetchingMessages(): void

Defined in: src/edge-agent/Agent.ts:390

Stop the fetch message long running job

Returns

void


verifiableCredentials()

verifiableCredentials(): Promise<Credential[]>

Defined in: src/edge-agent/Agent.ts:478

Asyncronously get all verifiable credentials

Returns

Promise<Credential[]>


initialize()

static initialize(params: { api?: Api; apollo?: Apollo; castor?: Castor; mediatorDID?: string | DID; mercury?: Mercury; options?: AgentOptions; pluto: Pluto; seed?: Seed; }): Agent

Defined in: src/edge-agent/Agent.ts:97

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

Parameters

ParameterTypeDescription
params{ api?: Api; apollo?: Apollo; castor?: Castor; mediatorDID?: string | DID; mercury?: Mercury; options?: AgentOptions; pluto: Pluto; seed?: Seed; }dependencies object
params.api?Api
params.apollo?Apollo
params.castor?Castor
params.mediatorDID?string | DIDdid of the mediator to be used
params.mercury?Mercury
params.options?AgentOptions-
params.plutoPlutostorage implementation
params.seed?Seed

Returns

Agent