diff --git a/agent-swagger.json b/agent-swagger.json index 2294a84feee4974b8f77df20e7853d4c2ccf4338..5b647efcfd93c6273a8ec27b6847beca53ee6c6b 100644 --- a/agent-swagger.json +++ b/agent-swagger.json @@ -1 +1 @@ -{"openapi":"3.0.0","paths":{"/api/v1/invitation":{"post":{"operationId":"RestController_createInvitation","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}}}}},"/api/v1/invitation/accept":{"post":{"operationId":"RestController_acceptInvitation","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AcceptInvitationResponseDto"}}}}}}},"/api/v1/connections":{"get":{"operationId":"RestController_connections","parameters":[],"responses":{"200":{"description":""}}}},"/api/v1/schema":{"post":{"operationId":"RestController_createSchema","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSchemaRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSchemaResponseDto"}}}}}}},"/api/v1/credential/definition":{"post":{"operationId":"RestController_createCredentialDefinition","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCredentialDefinitionRequsetDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCredentialDefinitionResponseDto"}}}}}}},"/api/v1/credential/issue":{"post":{"operationId":"RestController_issueCredential","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}},"/api/v1/credentials":{"get":{"operationId":"RestController_credentials","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}}},"/api/v1/credential/offers":{"get":{"operationId":"RestController_getCredentialOffers","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}}},"/api/v1/credential/{credential_record_id}/accept":{"post":{"operationId":"RestController_acceptCredential","parameters":[{"name":"credential_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialResponseDto"}}}}}}},"/api/v1/credential/proof":{"get":{"operationId":"RestController_proofs","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IssueProofResponseDto"}}}}}}}},"/api/v1/credential/proof/issue":{"post":{"operationId":"RestController_issueProof","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofResponseDto"}}}}}}},"/api/v1/credential/proof/{proof_record_id}/accept":{"post":{"operationId":"RestController_acceptProof","parameters":[{"name":"proof_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofResponseDto"}}}}}}},"/api/v1/resolve":{"post":{"operationId":"RestController_resolve","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/messages":{"post":{"operationId":"RestController_sendMeesage","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MakeBasicMessageRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MakeBasicMessageResponseDto"}}}}}}}},"info":{"title":"Agent","description":"Agent API","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"CreateInvitationResponseDto":{"type":"object","properties":{"invitationUrl":{"type":"string","description":"A list of user's roles","example":"http://0.0.0.0:8001?oob=eyJAdHlwZSI6Imh0dHBzOi8vZGlkY29tbS5vcmcvb3V0LW9mLWJhbmQvMS4xL2ludml0YXRpb24iLCJAaWQiOiIzYWExNGIzNC04YTk5LTQxY2UtYTY3NC1jODUxYmVhMTIxMWEiLCJsYWJlbCI6IkRFeGNWYXNkX0FHRU5UXzQ1IiwiYWNjZXB0IjpbImRpZGNvbW0vYWlwMSIsImRpZGNvbW0vYWlwMjtlbnY9cmZjMTkiXSwiaGFuZHNoYWtlX3Byb3RvY29scyI6WyJodHRwczovL2RpZGNvbW0ub3JnL2RpZGV4Y2hhbmdlLzEuMCIsImh0dHBzOi8vZGlkY29tbS5vcmcvY29ubmVjdGlvbnMvMS4wIl0sInNlcnZpY2VzIjpbeyJpZCI6IiNpbmxpbmUtMCIsInNlcnZpY2VFbmRwb2ludCI6Imh0dHA6Ly8wLjAuMC4wOjgwMDEiLCJ0eXBlIjoiZGlkLWNvbW11bmljYXRpb24iLCJyZWNpcGllbnRLZXlzIjpbImRpZDprZXk6ejZNa3VFcHllc1pNa3k0a1BpQzhEOEplZERlcm55YTFuaTREMUF3ZmdnWWt6YmR4Il0sInJvdXRpbmdLZXlzIjpbXX1dfQ"}},"required":["invitationUrl"]},"AcceptInvitationResponseDto":{"type":"object","properties":{"connectionId":{"type":"string"},"connectionName":{"type":"string"},"did":{"type":"string"},"invitationDid":{"type":"string"},"outOfBandId":{"type":"string"},"createdAt":{"format":"date-time","type":"string"}},"required":["connectionId","createdAt"]},"CreateSchemaRequestDto":{"type":"object","properties":{"name":{"type":"string","example":"my test schema"},"attributes":{"example":["first_name, last_name"],"type":"array","items":{"type":"string"}},"version":{"type":"string","example":"1.0.2","pattern":"/^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$/"}},"required":["name","attributes","version"]},"CreateSchemaResponseDto":{"type":"object","properties":{"schemaId":{"type":"string"},"issuerId":{"type":"string"},"name":{"type":"string"},"version":{"type":"string"},"attributes":{"type":"array","items":{"type":"string"}}},"required":["schemaId","issuerId","name","version","attributes"]},"CreateCredentialDefinitionRequsetDto":{"type":"object","properties":{"schemaId":{"type":"string"},"tag":{"type":"string"}},"required":["schemaId","tag"]},"CreateCredentialDefinitionResponseDto":{"type":"object","properties":{"credentialDefinitionId":{"type":"string"},"schemaId":{"type":"string"},"isserId":{"type":"string"},"tag":{"type":"string"}},"required":["credentialDefinitionId","schemaId","isserId","tag"]},"IssueCredentialAttributes":{"type":"object","properties":{"name":{"type":"string"},"value":{"type":"string"}},"required":["name","value"]},"IssueCredentialRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"credentialDefinitionId":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}}},"required":["connectionId","credentialDefinitionId","attributes"]},"Credential":{"type":"object","properties":{"credentialRecordType":{"type":"string"},"credentialRecordId":{"type":"string"}},"required":["credentialRecordType","credentialRecordId"]},"IssueCredentialResponseDto":{"type":"object","properties":{"credentials":{"type":"array","items":{"$ref":"#/components/schemas/Credential"}},"credentialId":{"type":"string"},"connectionId":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}},"createdAt":{"format":"date-time","type":"string"}},"required":["credentialId","createdAt"]},"IssueProofResponseDto":{"type":"object","properties":{"proofId":{"type":"string"},"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"state":{"type":"string"},"updatedAt":{"format":"date-time","type":"string"},"createdAt":{"format":"date-time","type":"string"}},"required":["proofId","state","createdAt"]},"IssueProofAttribute":{"type":"object","properties":{"attributeName":{"type":"string"},"credentialDefinitionId":{"type":"string"},"schemaId":{"type":"string"}},"required":["attributeName","credentialDefinitionId","schemaId"]},"IssueProofRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueProofAttribute"}}},"required":["attributes"]},"MakeBasicMessageRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"message":{"type":"string","example":"hello world"}},"required":["connectionId","message"]},"MakeBasicMessageResponseDto":{"type":"object","properties":{"id":{"type":"string"},"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"from":{"type":"string","example":"example-ocm-name"},"to":{"type":"string","example":"example-ocm-name"},"message":{"type":"string","example":"hello world"}},"required":["id","connectionId","message"]}}}} \ No newline at end of file +{"openapi":"3.0.0","paths":{"/api/v1/invitation":{"post":{"operationId":"RestController_createInvitation","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}}}}},"/api/v1/invitation/accept":{"post":{"operationId":"RestController_acceptInvitation","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvitationResponseDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionRecordDto"}}}}}}},"/api/v1/connections":{"get":{"operationId":"RestController_connections","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ConnectionRecordDto"}}}}}}}},"/api/v1/schema":{"post":{"operationId":"RestController_createSchema","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSchemaRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SchemaRecordDto"}}}}}}},"/api/v1/credential/definition":{"post":{"operationId":"RestController_createCredentialDefinition","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCredentialDefinitionRequsetDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreddefRecordDto"}}}}}}},"/api/v1/credential/issue":{"post":{"operationId":"RestController_issueCredential","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueCredentialRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}},"/api/v1/credentials":{"get":{"operationId":"RestController_credentials","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}}},"/api/v1/credential/offers":{"get":{"operationId":"RestController_getCredentialOffers","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}}},"/api/v1/credential/{credential_record_id}/accept":{"post":{"operationId":"RestController_acceptCredential","parameters":[{"name":"credential_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialRecordDto"}}}}}}},"/api/v1/credential/proof":{"get":{"operationId":"RestController_proofs","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ProofRecordDto"}}}}}}}},"/api/v1/credential/proof/issue":{"post":{"operationId":"RestController_issueProof","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueProofRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/credential/proof/{proof_record_id}":{"get":{"operationId":"RestController_getProof","parameters":[{"required":true,"name":"id","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/credential/c/proof/accept":{"post":{"operationId":"RestController_acceptProof","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProofReqDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProofRecordDto"}}}}}}},"/api/v1/credential/proof/{proof_record_id}/decline":{"post":{"operationId":"RestController_declineProofRequest","parameters":[{"name":"proof_record_id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProofRecordDto"}}}}}}},"/api/v1/resolve":{"post":{"operationId":"RestController_resolve","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/messages":{"post":{"operationId":"RestController_sendMeesage","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MakeBasicMessageRequestDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageRecordDto"}}}}}}}},"info":{"title":"Agent","description":"Agent API","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"CreateInvitationResponseDto":{"type":"object","properties":{"invitationUrl":{"type":"string","description":"Example of long invitation url","example":"http://0.0.0.0:8001?oob=eyJAdHlwZSI6Imh0dHBzOi8vZGlkY29tbS5vcmcvb3V0LW9mLWJhbmQvMS4xL2ludml0YXRpb24iLCJAaWQiOiIzYWExNGIzNC04YTk5LTQxY2UtYTY3NC1jODUxYmVhMTIxMWEiLCJsYWJlbCI6IkRFeGNWYXNkX0FHRU5UXzQ1IiwiYWNjZXB0IjpbImRpZGNvbW0vYWlwMSIsImRpZGNvbW0vYWlwMjtlbnY9cmZjMTkiXSwiaGFuZHNoYWtlX3Byb3RvY29scyI6WyJodHRwczovL2RpZGNvbW0ub3JnL2RpZGV4Y2hhbmdlLzEuMCIsImh0dHBzOi8vZGlkY29tbS5vcmcvY29ubmVjdGlvbnMvMS4wIl0sInNlcnZpY2VzIjpbeyJpZCI6IiNpbmxpbmUtMCIsInNlcnZpY2VFbmRwb2ludCI6Imh0dHA6Ly8wLjAuMC4wOjgwMDEiLCJ0eXBlIjoiZGlkLWNvbW11bmljYXRpb24iLCJyZWNpcGllbnRLZXlzIjpbImRpZDprZXk6ejZNa3VFcHllc1pNa3k0a1BpQzhEOEplZERlcm55YTFuaTREMUF3ZmdnWWt6YmR4Il0sInJvdXRpbmdLZXlzIjpbXX1dfQ"},"shortInvitationUrl":{"type":"string","example":"http://0.0.0.0:8001/invitations/85a7c179-122b-4d2d-9a86-d92ad31cef2b"}},"required":["invitationUrl","shortInvitationUrl"]},"ConnectionRecordDto":{"type":"object","properties":{"state":{"type":"string"},"connectionName":{"type":"string"},"alias":{"type":"string"},"did":{"type":"string"},"invitationDid":{"type":"string"},"outOfBandId":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["state","id","createdAt"]},"CreateSchemaRequestDto":{"type":"object","properties":{"name":{"type":"string","example":"my test schema"},"attributes":{"example":["first_name, last_name"],"type":"array","items":{"type":"string"}},"version":{"type":"string","example":"1.0.2","pattern":"/^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$/"}},"required":["name","attributes","version"]},"SchemaRecordDto":{"type":"object","properties":{"name":{"type":"string"},"attributes":{"type":"array","items":{"type":"string"}},"version":{"type":"string"},"issuerId":{"type":"string"},"methodName":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["name","attributes","version","id","createdAt"]},"CreateCredentialDefinitionRequsetDto":{"type":"object","properties":{"schemaId":{"type":"string"},"tag":{"type":"string"}},"required":["schemaId","tag"]},"CreddefRecordDto":{"type":"object","properties":{"schemaId":{"type":"string"},"issuerId":{"type":"string"},"tag":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["schemaId","issuerId","tag","id","createdAt"]},"IssueCredentialAttributes":{"type":"object","properties":{"name":{"type":"string"},"value":{"type":"string"}},"required":["name","value"]},"IssueCredentialRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"credentialDefinitionId":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}}},"required":["connectionId","credentialDefinitionId","attributes"]},"CredentialRecordDto":{"type":"object","properties":{"credentialRecordType":{"type":"string"},"connectionId":{"type":"string"},"state":{"type":"string"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueCredentialAttributes"}},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["credentialRecordType","state","id","createdAt"]},"ProofRecordDto":{"type":"object","properties":{"connectionId":{"type":"string"},"state":{"type":"string"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["state","id","createdAt"]},"IssueProofAttribute":{"type":"object","properties":{"attributeName":{"type":"string"},"credentialDefinitionId":{"type":"string"},"schemaId":{"type":"string"}},"required":["attributeName","credentialDefinitionId","schemaId"]},"IssueProofRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/IssueProofAttribute"}}},"required":["attributes"]},"ProofReqDto":{"type":"object","properties":{"proofId":{"type":"string"},"proofUrl":{"type":"string"}},"required":["proofId","proofUrl"]},"MakeBasicMessageRequestDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"message":{"type":"string","example":"hello world"}},"required":["connectionId","message"]},"MessageRecordDto":{"type":"object","properties":{"connectionId":{"type":"string","example":"6464b521-005a-4379-91e0-a3692b31cafd"},"from":{"type":"string","example":"example-ocm-name"},"to":{"type":"string","example":"example-ocm-name"},"message":{"type":"string","example":"hello world"},"id":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"updatedAt":{"format":"date-time","type":"string"}},"required":["connectionId","message","id","createdAt"]}}}} \ No newline at end of file diff --git a/libs/askar/src/agent.utils.ts b/libs/askar/src/agent.utils.ts index 2b6ab20aa84dc335d5fc850bf328951b4406351b..3a7f86554f827ba69270a94e3854b30ce067ee37 100644 --- a/libs/askar/src/agent.utils.ts +++ b/libs/askar/src/agent.utils.ts @@ -50,7 +50,7 @@ import { lastValueFrom, map, Observable, - ReplaySubject, + BehaviorSubject, Subject, take, timeout, @@ -58,7 +58,7 @@ import { import { SubjectInboundTransport } from "./askar/transports/agent.subject.inbound.transport"; import { SubjectOutboundTransport } from "./askar/transports/agent.subject.outbound.transport"; -export type EventReplaySubject = ReplaySubject<BaseEvent>; +export type EventBehaviorSubject = BehaviorSubject<BaseEvent>; export type SubjectMessage = { message: EncryptedMessage; replySubject?: Subject<SubjectMessage>; @@ -171,23 +171,31 @@ export const getAskarAnonCredsIndyModules = (networks: any) => { } as const; }; -export const setupEventReplaySubjects = ( +const INITIAL_EVENT: BaseEvent = { + type: "unknown", + payload: {}, + metadata: { + contextCorrelationId: "-1", + }, +}; + +export const setupEventBehaviorSubjects = ( agents: Agent[], eventTypes: string[], -): ReplaySubject<BaseEvent>[] => { - const replaySubjects: EventReplaySubject[] = []; +): BehaviorSubject<BaseEvent>[] => { + const behaviorSubjects: EventBehaviorSubject[] = []; for (const agent of agents) { - const replaySubject = new ReplaySubject<BaseEvent>(); + const behaviorSubject = new BehaviorSubject<BaseEvent>(INITIAL_EVENT); for (const eventType of eventTypes) { - agent.events.observable(eventType).subscribe(replaySubject); + agent.events.observable(eventType).subscribe(behaviorSubject); } - replaySubjects.push(replaySubject); + behaviorSubjects.push(behaviorSubject); } - return replaySubjects; + return behaviorSubjects; }; export const setupSubjectTransports = (agents: Agent[]) => { @@ -335,7 +343,7 @@ export const isProofStateChangedEvent = ( ): e is ProofStateChangedEvent => e.type === ProofEventTypes.ProofStateChanged; export const waitForProofExchangeRecordSubject = ( - subject: ReplaySubject<BaseEvent> | Observable<BaseEvent>, + subject: BehaviorSubject<BaseEvent> | Observable<BaseEvent>, { threadId, parentThreadId, @@ -353,7 +361,7 @@ export const waitForProofExchangeRecordSubject = ( }, ) => { const observable: Observable<BaseEvent> = - subject instanceof ReplaySubject ? subject.asObservable() : subject; + subject instanceof BehaviorSubject ? subject.asObservable() : subject; return lastValueFrom( observable.pipe( filter(isProofStateChangedEvent), diff --git a/libs/askar/src/askar/askar.service.ts b/libs/askar/src/askar/askar.service.ts index 6c81286a8174881bab6b98ad823f2dc564eb3a5c..9314aa3889c0b192c1ec457b82feec81b29d00dc 100644 --- a/libs/askar/src/askar/askar.service.ts +++ b/libs/askar/src/askar/askar.service.ts @@ -25,17 +25,17 @@ import { getAskarAnonCredsIndyModules, importDidsToWallet, attachShortUrlHandler, - setupEventReplaySubjects, + setupEventBehaviorSubjects, setupSubjectTransports, } from "../agent.utils"; import { IConfAgent } from "@ocm-engine/config"; -import { ReplaySubject } from "rxjs"; +import { BehaviorSubject } from "rxjs"; import express from "express"; @Injectable() export class AskarService implements OnModuleInit, OnModuleDestroy { public agent: Agent<ReturnType<typeof getAskarAnonCredsIndyModules>>; - public agentR: ReplaySubject<BaseEvent>; + public agentR: BehaviorSubject<BaseEvent>; public agentConfig: IConfAgent; private readonly logger: Logger = new Logger(AskarService.name); private readonly server = express(); @@ -90,7 +90,7 @@ export class AskarService implements OnModuleInit, OnModuleDestroy { setupSubjectTransports([this.agent]); - const [agentR] = setupEventReplaySubjects( + const [agentR] = setupEventBehaviorSubjects( [this.agent], [ProofEventTypes.ProofStateChanged], );