Skip to main content

Agent<Extras>

@hyperledger/identus-sdk v8.1.3


@hyperledger/identus-sdk / overview / Agent

Class: Agent<Extras>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:76

Edge agent implementation

The optional tuple type parameter Extras carries the concrete types of any extra DID methods passed to Agent.initialize, so that createDID, publishDID, updateDID and deactivateDID only accept method names that are actually registered and infer their payload types directly from the passed DID method instances.

Agent

Extends​

Type Parameters​

Type ParameterDefault type
Extras extends readonly DIDMethodInput[]readonly []

Properties​

PropertyModifierTypeDescriptionInherited fromDefined in
apireadonlyApi--packages/lib/sdk/src/edge-agent/Agent.ts:91
apolloreadonlyApollo--packages/lib/sdk/src/edge-agent/Agent.ts:86
backuppublicAgentBackup--packages/lib/sdk/src/edge-agent/Agent.ts:79
castorreadonlyCastor<Extras>--packages/lib/sdk/src/edge-agent/Agent.ts:87
connectionsreadonlyConnectionsManager--packages/lib/sdk/src/edge-agent/Agent.ts:80
eventsreadonlyEventsManager--packages/lib/sdk/src/edge-agent/Agent.ts:81
jobsreadonlyJobManager--packages/lib/sdk/src/edge-agent/Agent.ts:82
mercuryreadonlyMercury--packages/lib/sdk/src/edge-agent/Agent.ts:89
pluginsreadonlyPluginManager--packages/lib/sdk/src/edge-agent/Agent.ts:83
plutoreadonlyPluto--packages/lib/sdk/src/edge-agent/Agent.ts:88
seedreadonlySeedFunction--packages/lib/sdk/src/edge-agent/Agent.ts:90
statepublicStatecurrent status of the entityController.statepackages/shared/domain/build/index.d.ts:2330

Accessors​

currentMediatorDID​

Get Signature​

get currentMediatorDID(): DID | undefined

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:223

Deprecated​

Get current mediator DID if available or null

Returns​

DID | undefined


runtimeContext​

Get Signature​

get runtimeContext(): AgentContext

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:229

Returns​

AgentContext

Methods​

acceptDIDCommInvitation()​

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

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:520

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: packages/lib/sdk/src/edge-agent/Agent.ts:442

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: packages/lib/sdk/src/edge-agent/Agent.ts:200

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


createDID()​

createDID<M>(method: M, opts: CreatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]> & { alias?: string; }): Promise<DID>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:306

Create a new DID using the specified method, store it in Pluto, and (for peer DIDs) update the mediator key list.

The method name is statically checked against the DID methods actually registered on this Agent (the built-in prism / peer plus any custom ones supplied via Agent.initialize) and the payload type is inferred directly from the matching DID method instance.

Type Parameters​

Type ParameterDescription
M extends stringregistered DID method name (e.g. "prism", "peer", or a custom method)

Parameters​

ParameterTypeDescription
methodMthe DID method to use
optsCreatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]> & { alias?: string; }method-specific creation options; may include an optional alias string that is persisted alongside the DID

Returns​

Promise<DID>

the newly created DID

Example​

const prismDID = await agent.createDID('prism', {
keys: { MASTER_KEY: masterSK },
alias: 'my-issuer',
});

const peerDID = await agent.createDID('peer', {
keys: {
AUTHENTICATION_KEY: [authSK],
KEY_AGREEMENT_KEY: [agreementSK],
},
});

createPeerDID()​

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

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:397

Asyncronously Create a new PeerDID

Parameters​

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

Returns​

Promise<DID>


createPresentationForRequestProof()​

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

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:677

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>


createPrismDID()​

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

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

Asyncronously create a new PrismDID

Parameters​

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

Returns​

Promise<DID>


deactivateDID()​

deactivateDID<M>(method: M, opts: DeactivatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>): Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>

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

Deactivate a DID via its registered method.

The method name and payload are statically checked against the DID methods registered on this Agent.

Type Parameters​

Type Parameter
M extends string

Parameters​

ParameterType
methodM
optsDeactivatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>

Returns​

Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>


handle()​

handle(message: Message): Promise<any>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:580

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: packages/lib/sdk/src/edge-agent/Agent.ts:723

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: packages/lib/sdk/src/edge-agent/Agent.ts:710

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: packages/lib/sdk/src/edge-agent/Agent.ts:596

Parameters​

ParameterTypeDescription
credentialCredential-

Returns​

Promise<boolean>


parseInvitation()​

parseInvitation(str: string): Promise<InvitationType>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:425

Asyncronously parse an invitation from a valid json string

Parameters​

ParameterTypeDescription
strstring-

Returns​

Promise<InvitationType>


parseOOBInvitation()​

parseOOBInvitation(url: URL): Promise<OutOfBandInvitation>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:500

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: packages/lib/sdk/src/edge-agent/Agent.ts:461

Asyncronously parse a prismOnboarding invitation from a string

Parameters​

ParameterTypeDescription
strstring-

Returns​

Promise<PrismOnboardingInvitation>


prepareRequestCredentialWithIssuer()​

prepareRequestCredentialWithIssuer(offer: OfferCredential): Promise<RequestCredential>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:644

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: packages/lib/sdk/src/edge-agent/Agent.ts:659

Extract the verifiableCredential object from the Issue credential message asyncronously

Parameters​

ParameterTypeDescription
issueCredentialIssueCredential-

Returns​

Promise<Credential>


publishDID()​

publishDID<M>(method: M, opts: PublishPayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>): Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:340

Publish a DID via its registered method.

The method name and payload are statically checked against the DID methods registered on this Agent; the return type is the metadata type declared by the matching DID method instance.

Type Parameters​

Type Parameter
M extends string

Parameters​

ParameterType
methodM
optsPublishPayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>

Returns​

Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>


removeListener()​

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

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:210

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[]): Promise<{ }>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:620

Parameters​

ParameterTypeDescription
credentialCredential-
fieldsstring[]-

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: packages/lib/sdk/src/edge-agent/Agent.ts:256

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: packages/lib/sdk/src/edge-agent/Agent.ts:567

Handle sending a Protocol

Parameters​
ParameterTypeDescription
messageApiRequest-
Returns​

Promise<ApiResponse<unknown> | undefined>

Call Signature​

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

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

Handle sending a Protocol

Parameters​
ParameterTypeDescription
messageMessage-
Returns​

Promise<Message | undefined>


sendMessage()​

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

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:556

Asyncronously send a didcomm Message

Parameters​

ParameterTypeDescription
messageMessage | ApiRequest-

Returns​

Promise<Message | undefined>

Deprecated​

use send instead


signWith()​

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

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

Asyncronously sign a message with a DID

Parameters​

ParameterTypeDescription
didDID-
messageUint8Array-

Returns​

Promise<Signature>


start()​

start(): Promise<State>

Defined in: packages/shared/domain/build/index.d.ts:2347

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: packages/lib/sdk/src/edge-agent/Agent.ts:535

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: packages/shared/domain/build/index.d.ts:2348

handle the teardown of an entity

updates state according to lifecycle

Returns​

Promise<State>

Inherited from​

Controller.stop


stopFetchingMessages()​

stopFetchingMessages(): void

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:544

Stop the fetch message long running job

Returns​

void


updateDID()​

updateDID<M>(method: M, opts: UpdatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>): Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:353

Update a DID via its registered method.

The method name and payload are statically checked against the DID methods registered on this Agent.

Type Parameters​

Type Parameter
M extends string

Parameters​

ParameterType
methodM
optsUpdatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>

Returns​

Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>


verifiableCredentials()​

verifiableCredentials(): Promise<Credential[]>

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:633

Asyncronously get all verifiable credentials

Returns​

Promise<Credential[]>


initialize()​

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

Defined in: packages/lib/sdk/src/edge-agent/Agent.ts:127

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

DID methods registered through the top-level didMethods param are propagated through to the Agent's type parameter, so agent.createDID and friends are fully typed against them (defaults "prism" | "peer" plus any extras).

Type Parameters​

Type ParameterDefault type
ExtraMethods extends readonly DIDMethodInput[]readonly []

Parameters​

ParameterTypeDescription
params{ api?: Api; apollo?: Apollo; castor?: Castor<ExtraMethods>; didMethods?: ExtraMethods; mediatorDID?: string | DID; mercury?: Mercury; options?: AgentOptions; pluto: Pluto; seed?: SeedFunction; }dependencies object
params.api?Api-
params.apollo?Apollo-
params.castor?Castor<ExtraMethods>-
params.didMethods?ExtraMethodscustom DID methods to register alongside the built-in prism/peer methods
params.mediatorDID?string | DIDdid of the mediator to be used
params.mercury?Mercury-
params.options?AgentOptions-
params.plutoPlutostorage implementation
params.seed?SeedFunction-

Returns​

Agent<ExtraMethods>