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
| Parameter | Type | 
|---|---|
| apollo | Apollo | 
| castor | Castor | 
| pluto | Pluto | 
| mercury | Mercury | 
| seed | Seed | 
| api | Api | 
| options? | AgentOptions | 
Returns
Agent
Overrides
Properties
| Property | Modifier | Type | Default value | Description | Inherited from | Defined in | 
|---|---|---|---|---|---|---|
| api | readonly | Api | undefined | - | - | src/edge-agent/Agent.ts:67 | 
| apollo | readonly | Apollo | undefined | - | - | src/edge-agent/Agent.ts:62 | 
| backup | public | AgentBackup | undefined | - | - | src/edge-agent/Agent.ts:51 | 
| castor | readonly | Castor | undefined | - | - | src/edge-agent/Agent.ts:63 | 
| connections | readonly | ConnectionsManager | undefined | - | - | src/edge-agent/Agent.ts:52 | 
| events | readonly | EventsManager | undefined | - | - | src/edge-agent/Agent.ts:53 | 
| jobs | readonly | JobManager | undefined | - | - | src/edge-agent/Agent.ts:54 | 
| mercury | readonly | Mercury | undefined | - | - | src/edge-agent/Agent.ts:65 | 
| plugins | readonly | PluginManager | undefined | - | - | src/edge-agent/Agent.ts:55 | 
| pluto | readonly | Pluto | undefined | - | - | src/edge-agent/Agent.ts:64 | 
| seed | readonly | Seed | undefined | - | - | src/edge-agent/Agent.ts:66 | 
| state | public | State | State.STOPPED | current status of the entity | Controller.state | src/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
| Parameter | Type | Description | 
|---|---|---|
| invitation | OutOfBandInvitation | |
| 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
| Parameter | Type | Description | 
|---|---|---|
| invitation | InvitationType | an 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 | 
|---|
| TextendsListenerKey | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| eventName | T | |
| callback | EventCallback<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
| Parameter | Type | Default value | Description | 
|---|---|---|---|
| services? | Service[] | [] | |
| updateMediator? | boolean | true | 
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
| Parameter | Type | Default value | Description | 
|---|---|---|---|
| alias | string | undefined | |
| services? | Service[] | [] | |
| keyPathIndex? | number | undefined | 
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
| Parameter | Type | Description | 
|---|---|---|
| request | RequestPresentation | |
| credential | Credential | 
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
| Parameter | Type | Description | 
|---|---|---|
| message | Message | 
Returns
Promise<any>
handlePresentation()
handlePresentation(
presentation:Presentation):Promise<boolean>
Defined in: src/edge-agent/Agent.ts:568
Initiate the Presentation and presentationSubmission
Parameters
| Parameter | Type | Description | 
|---|---|---|
| presentation | Presentation | 
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 Parameter | Default type | 
|---|---|
| TextendsCredentialType | JWT | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| type | T | |
| toDID | DID | |
| presentationClaims | PresentationClaims<T> | 
Returns
Promise<RequestPresentation>
- 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: {}}
);
- 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
| Parameter | Type | Description | 
|---|---|---|
| credential | Credential | 
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
| Parameter | Type | Description | 
|---|---|---|
| str | string | 
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
| Parameter | Type | Description | 
|---|---|---|
| url | URL | 
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
| Parameter | Type | Description | 
|---|---|---|
| str | string | 
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
| Parameter | Type | Description | 
|---|---|---|
| offer | OfferCredential | 
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
| Parameter | Type | Description | 
|---|---|---|
| issueCredential | IssueCredential | 
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 | 
|---|
| TextendsListenerKey | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| eventName | T | |
| callback | EventCallback<T> | 
Returns
void
revealCredentialFields()
revealCredentialFields(
credential:Credential,fields:string[],linkSecret:string):Promise<{ }>
Defined in: src/edge-agent/Agent.ts:463
Parameters
| Parameter | Type | Description | 
|---|---|---|
| credential | Credential | |
| fields | string[] | - | 
| linkSecret | string | - | 
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
| Parameter | Type | Description | 
|---|---|---|
| task | Task<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
| Parameter | Type | Description | 
|---|---|---|
| message | ApiRequest | 
Returns
Promise<ApiResponse<unknown> | undefined>
Call Signature
Defined in: src/edge-agent/Agent.ts:414
Handle sending a Protocol
Parameters
| Parameter | Type | Description | 
|---|---|---|
| message | Message | 
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
| Parameter | Type | Description | 
|---|---|---|
| message | ApiRequest|Message | 
Returns
Promise<Message | undefined>
Deprecated
use send instead
signWith()
Defined in: src/edge-agent/Agent.ts:259
Asyncronously sign a message with a DID
Parameters
| Parameter | Type | Description | 
|---|---|---|
| did | DID | |
| message | Uint8Array | 
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
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
| Parameter | Type | Description | 
|---|---|---|
| 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
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()
staticinitialize(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
| Parameter | Type | Description | 
|---|---|---|
| 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|DID | did of the mediator to be used | 
| params.mercury? | Mercury | |
| params.options? | AgentOptions | - | 
| params.pluto | Pluto | storage implementation | 
| params.seed? | Seed | 
Returns
Agent