Skip to main content

@atala/prism-wallet-sdk / Exports / Agent

Class: Agent

Edge agent implementation

Export

Agent

Implements

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
seed?Seed
api?Api
options?AgentOptions

Returns

Agent

Defined in

src/edge-agent/Agent.ts:84

Properties

agentCredentials

Private agentCredentials: AgentCredentials

Defined in

src/edge-agent/Agent.ts:64


agentDIDHigherFunctions

Private agentDIDHigherFunctions: AgentDIDHigherFunctions

Defined in

src/edge-agent/Agent.ts:65


agentInvitations

Private agentInvitations: AgentInvitations

Defined in

src/edge-agent/Agent.ts:66


api

Readonly api: Api

Defined in

src/edge-agent/Agent.ts:92


apollo

Readonly apollo: Apollo

Defined in

src/edge-agent/Agent.ts:85


backup

backup: AgentBackup

Defined in

src/edge-agent/Agent.ts:62


castor

Readonly castor: Castor

Defined in

src/edge-agent/Agent.ts:86


connectionManager

Readonly connectionManager: ConnectionsManager

Defined in

src/edge-agent/Agent.ts:90


mediationHandler

Readonly mediationHandler: MediatorHandler

Defined in

src/edge-agent/Agent.ts:89


mercury

Readonly mercury: Mercury

Defined in

src/edge-agent/Agent.ts:88


pluto

Readonly pluto: Pluto

Defined in

src/edge-agent/Agent.ts:87


pollux

Private pollux: Pollux

Defined in

src/edge-agent/Agent.ts:68


seed

Readonly seed: Seed

Defined in

src/edge-agent/Agent.ts:91


state

state: AgentState = AgentState.STOPPED

Agent state

Defined in

src/edge-agent/Agent.ts:61

Accessors

currentMediatorDID

get currentMediatorDID(): undefined | DID

Get current mediator DID if available or null

Returns

undefined | DID

Defined in

src/edge-agent/Agent.ts:220

Methods

acceptDIDCommInvitation

acceptDIDCommInvitation(invitation, optionalAlias?): 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
optionalAlias?string

Returns

Promise<void>

Deprecated

  • use acceptInvitation

Async

Implementation of

AgentInvitations.acceptDIDCommInvitation

Defined in

src/edge-agent/Agent.ts:444


acceptInvitation

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

Handle an invitation to create a connection

Parameters

NameTypeDescription
invitationInvitationTypean OOB or PrismOnboarding invitation
optionalAlias?string-

Returns

Promise<void>

Async

Implementation of

AgentInvitations.acceptInvitation

Defined in

src/edge-agent/Agent.ts:397


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/Agent.ts:491


createNewPeerDID

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

Asyncronously Create a new PeerDID

Parameters

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

Returns

Promise<DID>

Async

Implementation of

AgentDIDHigherFunctions.createNewPeerDID

Defined in

src/edge-agent/Agent.ts:369


createNewPrismDID

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

Asyncronously create a new PrismDID

Parameters

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

Returns

Promise<DID>

Async

Implementation of

AgentDIDHigherFunctions.createNewPrismDID

Defined in

src/edge-agent/Agent.ts:349


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

Implementation of

AgentCredentials.createPresentationForRequestProof

Defined in

src/edge-agent/Agent.ts:542


handlePresentation

handlePresentation<Type>(presentation): Promise<boolean>

Initiate the Presentation and presentationSubmission

Type parameters

NameType
Typeextends CredentialType = JWT

Parameters

NameType
presentationPresentation

Returns

Promise<boolean>

Implementation of

AgentCredentials.handlePresentation

Defined in

src/edge-agent/Agent.ts:594


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

Implementation of

AgentCredentials.initiatePresentationRequest

Defined in

src/edge-agent/Agent.ts:578


isCredentialRevoked

isCredentialRevoked(credential): Promise<boolean>

Parameters

NameType
credentialCredential

Returns

Promise<boolean>

Implementation of

AgentCredentials.isCredentialRevoked

Defined in

src/edge-agent/Agent.ts:137


parseInvitation

parseInvitation(str): Promise<InvitationType>

Asyncronously parse an invitation from a valid json string

Parameters

NameType
strstring

Returns

Promise<InvitationType>

Async

Implementation of

AgentInvitations.parseInvitation

Defined in

src/edge-agent/Agent.ts:386


parseOOBInvitation

parseOOBInvitation(str): Promise<OutOfBandInvitation>

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

Parameters

NameType
strURL

Returns

Promise<OutOfBandInvitation>

Async

Implementation of

AgentInvitations.parseOOBInvitation

Defined in

src/edge-agent/Agent.ts:431


parsePrismInvitation

parsePrismInvitation(str): Promise<PrismOnboardingInvitation>

Asyncronously parse a prismOnboarding invitation from a string

Parameters

NameType
strstring

Returns

Promise<PrismOnboardingInvitation>

Async

Implementation of

AgentInvitations.parsePrismInvitation

Defined in

src/edge-agent/Agent.ts:420


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

Implementation of

AgentCredentials.prepareRequestCredentialWithIssuer

Defined in

src/edge-agent/Agent.ts:513


processIssuedCredentialMessage

processIssuedCredentialMessage(message): Promise<Credential>

Extract the verifiableCredential object from the Issue credential message asyncronously

Parameters

NameType
messageIssueCredential

Returns

Promise<Credential>

Async

Implementation of

AgentCredentials.processIssuedCredentialMessage

Defined in

src/edge-agent/Agent.ts:526


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/Agent.ts:502


revealCredentialFields

revealCredentialFields(credential, fields, linkSecret): Promise<{ [name: 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<{ [name: string]: any; }>

Implementation of

AgentCredentials.revealCredentialFields

Defined in

src/edge-agent/Agent.ts:268


sendMessage

sendMessage(message): Promise<undefined | Message>

Asyncronously send a didcomm Message

Parameters

NameType
messageMessage

Returns

Promise<undefined | Message>

Defined in

src/edge-agent/Agent.ts:472


signWith

signWith(did, message): Promise<Signature>

Asyncronously sign a message with a DID

Parameters

NameType
didDID
messageUint8Array

Returns

Promise<Signature>

Async

Implementation of

AgentDIDHigherFunctions.signWith

Defined in

src/edge-agent/Agent.ts:409


start

start(): Promise<AgentState>

Asyncronously start the agent

Returns

Promise<AgentState>

Async

Defined in

src/edge-agent/Agent.ts:283


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/Agent.ts:455


stop

stop(): Promise<void>

Asyncronously stop the agent and any side task that is running

Returns

Promise<void>

Async

Defined in

src/edge-agent/Agent.ts:330


stopFetchingMessages

stopFetchingMessages(): void

Stops fetching messages

Returns

void

Defined in

src/edge-agent/Agent.ts:462


verifiableCredentials

verifiableCredentials(): Promise<Credential[]>

Asyncronously get all verifiable credentials

Returns

Promise<Credential[]>

Implementation of

AgentCredentials.verifiableCredentials

Defined in

src/edge-agent/Agent.ts:481


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/Agent.ts:155


instanceFromConnectionManager

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

Mainly for testing purposes but instantiating the Agent from a ConnectionManager directly

Parameters

NameType
apolloApollo
castorCastor
plutoPluto
mercuryMercury
connectionManagerConnectionsManager
seed?Seed
api?Api
options?AgentOptions

Returns

Agent

Static

Defined in

src/edge-agent/Agent.ts:237