@hyperledger/identus-sdk / Exports / Agent
Class: Agent
Edge agent implementation
Export
Agent
Hierarchy
-
↳
Agent
Table of contents
Constructors
Properties
Accessors
Methods
- _start
- _stop
- acceptDIDCommInvitation
- acceptInvitation
- acceptPrismOnboardingInvitation
- addListener
- createNewPeerDID
- createNewPrismDID
- createPresentationForRequestProof
- handlePresentation
- initiatePresentationRequest
- isCredentialRevoked
- parseInvitation
- parseOOBInvitation
- parsePrismInvitation
- prepareRequestCredentialWithIssuer
- processIssuedCredentialMessage
- removeListener
- revealCredentialFields
- runTask
- sendMessage
- signWith
- start
- startFetchingMessages
- stop
- stopFetchingMessages
- verifiableCredentials
- initialize
Constructors
constructor
• new Agent(apollo
, castor
, pluto
, mercury
, seed?
, api?
, options?
): Agent
Creates an instance of Agent.
Parameters
Name | Type |
---|---|
apollo | Apollo |
castor | Castor |
pluto | Pluto |
mercury | Mercury |
seed | Seed |
api | Api |
options? | AgentOptions |
Returns
Overrides
Defined in
src/edge-agent/didcomm/Agent.ts:69
Properties
api
• Readonly
api: Api
Defined in
src/edge-agent/didcomm/Agent.ts:75
apollo
• Readonly
apollo: Apollo
Defined in
src/edge-agent/didcomm/Agent.ts:70
backup
• backup: AgentBackup
Defined in
src/edge-agent/didcomm/Agent.ts:55
castor
• Readonly
castor: Castor
Defined in
src/edge-agent/didcomm/Agent.ts:71
connectionManager
• Readonly
connectionManager: ConnectionsManager
Defined in
src/edge-agent/didcomm/Agent.ts:58
mediationHandler
• Readonly
mediationHandler: MediatorHandler
Defined in
src/edge-agent/didcomm/Agent.ts:59
mercury
• Readonly
mercury: Mercury
Defined in
src/edge-agent/didcomm/Agent.ts:73
plugins
• Readonly
plugins: PluginManager
Defined in
src/edge-agent/didcomm/Agent.ts:56
pluto
• Readonly
pluto: Pluto
Defined in
src/edge-agent/didcomm/Agent.ts:72
seed
• Readonly
seed: Seed
Defined in
src/edge-agent/didcomm/Agent.ts:74
state
• state: State
= State.STOPPED
current status of the entity
Inherited from
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:208
Methods
_start
▸ _start(): Promise
<void
>
Asyncronously start the agent
Returns
Promise
<void
>
Async
Overrides
Defined in
src/edge-agent/didcomm/Agent.ts:144
_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
Defined in
src/edge-agent/didcomm/Agent.ts:167
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
Name | Type |
---|---|
invitation | OutOfBandInvitation |
alias? | string |
Returns
Promise
<void
>
Deprecated
- use
acceptInvitation
Async
Defined in
src/edge-agent/didcomm/Agent.ts:379
acceptInvitation
▸ acceptInvitation(invitation
, optionalAlias?
): Promise
<void
>
Handle an invitation based on it's type
PrismOnboardingInvitation
: creates a new connectionOutOfBandInvitation
:- no Attachment: creates a new connection
- with Attachment: stores / emits the attached message
Parameters
Name | Type | Description |
---|---|---|
invitation | InvitationType | an OOB or PrismOnboarding invitation |
optionalAlias? | string | - |
Returns
Promise
<void
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:301
acceptPrismOnboardingInvitation
▸ acceptPrismOnboardingInvitation(invitation
): Promise
<void
>
Asyncronously accept an onboarding invitation, used to onboard the current DID in the Cloud Agent.
Parameters
Name | Type |
---|---|
invitation | PrismOnboardingInvitation |
Returns
Promise
<void
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:332
addListener
▸ addListener(eventName
, callback
): void
Add an event listener to get notified from an Event "MESSAGE"
Parameters
Name | Type |
---|---|
eventName | ListenerKey |
callback | EventCallback |
Returns
void
Defined in
src/edge-agent/didcomm/Agent.ts:182
createNewPeerDID
▸ createNewPeerDID(services?
, updateMediator?
): Promise
<DID
>
Asyncronously Create a new PeerDID
Parameters
Name | Type | Default value |
---|---|---|
services? | Service [] | [] |
updateMediator? | boolean | true |
Returns
Promise
<DID
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:256
createNewPrismDID
▸ createNewPrismDID(alias
, services?
, keyPathIndex?
): Promise
<DID
>
Asyncronously create a new PrismDID
Parameters
Name | Type | Default value |
---|---|---|
alias | string | undefined |
services? | Service [] | [] |
keyPathIndex? | number | undefined |
Returns
Promise
<DID
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:239
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
Name | Type |
---|---|
request | RequestPresentation |
credential | Credential |
Returns
Promise
<Presentation
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:491
handlePresentation
▸ handlePresentation(presentation
): Promise
<boolean
>
Initiate the Presentation and presentationSubmission
Parameters
Name | Type |
---|---|
presentation | Presentation |
Returns
Promise
<boolean
>
Defined in
src/edge-agent/didcomm/Agent.ts:537
initiatePresentationRequest
▸ initiatePresentationRequest<T
>(type
, toDID
, presentationClaims
): Promise
<RequestPresentation
>
Initiate a PresentationRequest from the SDK, to create oob Verification Requests
Type parameters
Name | Type |
---|---|
T | extends CredentialType = JWT |
Parameters
Name | Type |
---|---|
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'}}}
);
Defined in
src/edge-agent/didcomm/Agent.ts:524
isCredentialRevoked
▸ isCredentialRevoked(credential
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
credential | Credential |
Returns
Promise
<boolean
>
Defined in
src/edge-agent/didcomm/Agent.ts:418
parseInvitation
▸ parseInvitation(str
): Promise
<InvitationType
>
Asyncronously parse an invitation from a valid json string
Parameters
Name | Type |
---|---|
str | string |
Returns
Promise
<InvitationType
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:284
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
Name | Type |
---|---|
url | URL |
Returns
Promise
<OutOfBandInvitation
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:359
parsePrismInvitation
▸ parsePrismInvitation(str
): Promise
<PrismOnboardingInvitation
>
Asyncronously parse a prismOnboarding invitation from a string
Parameters
Name | Type |
---|---|
str | string |
Returns
Promise
<PrismOnboardingInvitation
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:320
prepareRequestCredentialWithIssuer
▸ prepareRequestCredentialWithIssuer(offer
): Promise
<RequestCredential
>
Asyncronously prepare a request credential message from a valid offerCredential for now supporting w3c verifiable credentials offers.
Parameters
Name | Type |
---|---|
offer | OfferCredential |
Returns
Promise
<RequestCredential
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:460
processIssuedCredentialMessage
▸ processIssuedCredentialMessage(issueCredential
): Promise
<Credential
>
Extract the verifiableCredential object from the Issue credential message asyncronously
Parameters
Name | Type |
---|---|
issueCredential | IssueCredential |
Returns
Promise
<Credential
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:474
removeListener
▸ removeListener(eventName
, callback
): void
Remove event listener, used by stop procedure
Parameters
Name | Type |
---|---|
eventName | ListenerKey |
callback | EventCallback |
Returns
void
Date
20/06/2023 - 14:31:30
Defined in
src/edge-agent/didcomm/Agent.ts:193
revealCredentialFields
▸ revealCredentialFields(credential
, fields
, linkSecret
): Promise
<JsonObj
<any
>>
Parameters
Name | Type |
---|---|
credential | Credential |
fields | string [] |
linkSecret | string |
Returns
Promise
<JsonObj
<any
>>
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.
Defined in
src/edge-agent/didcomm/Agent.ts:439
runTask
▸ runTask<T
>(task
): Promise
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
task | Task <T , unknown > |
Returns
Promise
<T
>
Defined in
src/edge-agent/didcomm/Agent.ts:212
sendMessage
▸ sendMessage(message
): Promise
<undefined
| Message
>
Asyncronously send a didcomm Message
Parameters
Name | Type |
---|---|
message | Message |
Returns
Promise
<undefined
| Message
>
Defined in
src/edge-agent/didcomm/Agent.ts:409
signWith
▸ signWith(did
, message
): Promise
<Signature
>
Asyncronously sign a message with a DID
Parameters
Name | Type |
---|---|
did | DID |
message | Uint8Array |
Returns
Promise
<Signature
>
Async
Defined in
src/edge-agent/didcomm/Agent.ts:272
start
▸ start(): Promise
<State
>
handle the startup of an entity
updates state
according to lifecycle
Returns
Promise
<State
>
Inherited from
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
Name | Type |
---|---|
iterationPeriod | number |
Returns
Promise
<void
>
Defined in
src/edge-agent/didcomm/Agent.ts:392
stop
▸ stop(): Promise
<State
>
handle the teardown of an entity
updates state
according to lifecycle
Returns
Promise
<State
>
Inherited from
Defined in
src/domain/protocols/Startable.ts:72
stopFetchingMessages
▸ stopFetchingMessages(): void
Stops fetching messages
Returns
void
Defined in
src/edge-agent/didcomm/Agent.ts:399
verifiableCredentials
▸ verifiableCredentials(): Promise
<Credential
[]>
Asyncronously get all verifiable credentials
Returns
Promise
<Credential
[]>
Defined in
src/edge-agent/didcomm/Agent.ts:449
initialize
▸ initialize(params
): Agent
Convenience initializer for Agent allowing default instantiation, omitting all but the absolute necessary parameters
Parameters
Name | Type | Description |
---|---|---|
params | Object | 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 |