From 4a39e7476d7dc82fb1e98b95b59ac631840f99dc Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Thu, 24 Aug 2023 15:10:30 -0300 Subject: [PATCH] fix: remove references to CommunicationPolicy Signed-off-by: Ariel Gentile --- src/UserProfileApi.ts | 55 +------- src/UserProfileModule.ts | 9 ++ src/UserProfileModuleConfig.ts | 28 ++++ src/index.ts | 1 + src/model/ConnectionMetadata.ts | 2 +- src/repository/CommunicationPolicyRecord.ts | 57 -------- .../CommunicationPolicyRepository.ts | 14 -- src/repository/CommunicationPolicyState.ts | 10 -- src/repository/ConnectionAcceptancePolicy.ts | 5 - src/repository/UserProfileRecord.ts | 2 - src/repository/index.ts | 4 - src/services/CommunicationPolicyEvents.ts | 15 -- src/services/CommunicationPolicyService.ts | 128 ------------------ src/services/UserProfileEvents.ts | 1 - src/services/UserProfileService.ts | 60 ++------ src/services/index.ts | 2 - test/profile.test.ts | 18 +-- 17 files changed, 59 insertions(+), 352 deletions(-) create mode 100644 src/UserProfileModuleConfig.ts delete mode 100644 src/repository/CommunicationPolicyRecord.ts delete mode 100644 src/repository/CommunicationPolicyRepository.ts delete mode 100644 src/repository/CommunicationPolicyState.ts delete mode 100644 src/repository/ConnectionAcceptancePolicy.ts delete mode 100644 src/services/CommunicationPolicyEvents.ts delete mode 100644 src/services/CommunicationPolicyService.ts diff --git a/src/UserProfileApi.ts b/src/UserProfileApi.ts index 4cf121a..dc375be 100644 --- a/src/UserProfileApi.ts +++ b/src/UserProfileApi.ts @@ -1,36 +1,24 @@ import { - ConnectionService, injectable, - Dispatcher, MessageSender, AgentContext, ConnectionRecord, OutboundMessageContext, } from '@aries-framework/core' import { ProfileHandler, RequestProfileHandler } from './handlers' -import { CommunicationPolicyBaseProps, CommunicationPolicyRecord, UserProfileData } from './repository' +import { UserProfileData } from './repository' import { UserProfileService } from './services' -import { CommunicationPolicyService } from './services/CommunicationPolicyService' @injectable() export class UserProfileApi { private messageSender: MessageSender private userProfileService: UserProfileService - private communicationPolicyService: CommunicationPolicyService private agentContext: AgentContext - public constructor( - agentContext: AgentContext, - dispatcher: Dispatcher, - messageSender: MessageSender, - userProfileService: UserProfileService, - connectionService: ConnectionService, - communicationPolicyService: CommunicationPolicyService - ) { + public constructor(agentContext: AgentContext, messageSender: MessageSender, userProfileService: UserProfileService) { this.agentContext = agentContext this.messageSender = messageSender this.userProfileService = userProfileService - this.communicationPolicyService = communicationPolicyService this.agentContext.dependencyManager.registerMessageHandlers([ new ProfileHandler(this.userProfileService), @@ -62,25 +50,6 @@ export class UserProfileApi { ) } - public async getCommunicationPolicies(): Promise { - return await this.communicationPolicyService.getAll(this.agentContext) - } - - public async createCommunicationPolicy(props: CommunicationPolicyBaseProps) { - return await this.communicationPolicyService.create(this.agentContext, props) - } - - public async updateCommunicationPolicy( - communicationPolicyRecord: CommunicationPolicyRecord, - props: CommunicationPolicyBaseProps - ) { - await this.communicationPolicyService.update(this.agentContext, communicationPolicyRecord, props) - } - - public async deleteCommunicationPolicy(communicationPolicyRecord: CommunicationPolicyRecord) { - await this.communicationPolicyService.delete(this.agentContext, communicationPolicyRecord) - } - /** * Update editable properties of user profile record and persist in repository * @@ -96,29 +65,9 @@ export class UserProfileApi { public async getUserProfileData(): Promise { const userProfile = await this.userProfileService.getUserProfile(this.agentContext) return { - defaultCommunicationPolicyId: userProfile.defaultCommunicationPolicyId, displayName: userProfile.displayName, displayPicture: userProfile.displayPicture, description: userProfile.description, } } - - /** - * Update default communication policy record for new connections, persisting it in repository - * - * @param communicationPolicyRecord new default communication policy record - * - * @returns updated User Profile Record - */ - public async setDefaultCommunicationPolicy(communicationPolicyRecord: CommunicationPolicyRecord) { - await this.userProfileService.updateUserProfile(this.agentContext, { - defaultCommunicationPolicyId: communicationPolicyRecord.id, - }) - - return await this.userProfileService.getUserProfile(this.agentContext) - } - - public async getDefaultCommunicationPolicy() { - return await this.userProfileService.getDefaultCommunicationPolicy(this.agentContext) - } } diff --git a/src/UserProfileModule.ts b/src/UserProfileModule.ts index b87de9b..8d1aefb 100644 --- a/src/UserProfileModule.ts +++ b/src/UserProfileModule.ts @@ -4,10 +4,16 @@ import { Protocol } from '@aries-framework/core' import { UserProfileApi } from './UserProfileApi' import { UserProfileService } from './services' +import { UserProfileModuleConfig } from './UserProfileModuleConfig' export class UserProfileModule implements Module { + public readonly config: UserProfileModuleConfig public readonly api = UserProfileApi + public constructor(config?: UserProfileModuleConfig) { + this.config = new UserProfileModuleConfig(config) + } + /** * Registers the dependencies of the question answer module on the dependency manager. */ @@ -15,6 +21,9 @@ export class UserProfileModule implements Module { // Api dependencyManager.registerContextScoped(UserProfileApi) + // Config + dependencyManager.registerInstance(UserProfileModuleConfig, this.config) + // Services dependencyManager.registerSingleton(UserProfileService) diff --git a/src/UserProfileModuleConfig.ts b/src/UserProfileModuleConfig.ts new file mode 100644 index 0000000..597f9e3 --- /dev/null +++ b/src/UserProfileModuleConfig.ts @@ -0,0 +1,28 @@ +/** + * UserProfileModuleConfigOptions defines the interface for the options of the UserProfileModuleConfig class. + * This can contain optional parameters that have default values in the config class itself. + */ +export interface UserProfileModuleConfigOptions { + /** + * Whether to automatically send our profile when asked to do so. + * + * @default true + */ + autoSendProfile?: boolean +} + +export class UserProfileModuleConfig { + #autoSendProfile?: boolean + + private options: UserProfileModuleConfigOptions + + public constructor(options?: UserProfileModuleConfigOptions) { + this.options = options ?? {} + this.#autoSendProfile = this.options.autoSendProfile + } + + /** See {@link UserProfileModuleConfigOptions.autoSendProfile} */ + public get autoSendProfile() { + return this.#autoSendProfile ?? true + } +} diff --git a/src/index.ts b/src/index.ts index 2ccb43b..36f2d72 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ export * from './UserProfileApi' export * from './UserProfileModule' +export * from './UserProfileModuleConfig' export * from './handlers' export * from './messages' export * from './repository' diff --git a/src/model/ConnectionMetadata.ts b/src/model/ConnectionMetadata.ts index af499ca..71fc349 100644 --- a/src/model/ConnectionMetadata.ts +++ b/src/model/ConnectionMetadata.ts @@ -1,4 +1,4 @@ -import { ConnectionRecord, JsonTransformer } from '@aries-framework/core' +import { ConnectionRecord } from '@aries-framework/core' import { UserProfileData } from '../repository' export const getConnectionProfile = (record: ConnectionRecord) => record.metadata.get('UserProfile') as UserProfileData diff --git a/src/repository/CommunicationPolicyRecord.ts b/src/repository/CommunicationPolicyRecord.ts deleted file mode 100644 index 00ce31c..0000000 --- a/src/repository/CommunicationPolicyRecord.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { BaseRecord } from '@aries-framework/core' -import { v4 as uuid } from 'uuid' -import { CommunicationPolicyState } from './CommunicationPolicyState' -import { ConnectionAcceptancePolicy } from './ConnectionAcceptancePolicy' - -export interface CommunicationPolicyBaseProps { - displayName?: string - state?: CommunicationPolicyState - lifeTime?: number - allowChats?: boolean - allowVideoCalls?: boolean - allowAudioCalls?: boolean - connectionAcceptance?: ConnectionAcceptancePolicy - autoSendProfile?: boolean -} - -export interface CommunicationPolicyStorageProps extends CommunicationPolicyBaseProps { - id?: string - createdAt?: Date -} - -export class CommunicationPolicyRecord extends BaseRecord implements CommunicationPolicyStorageProps { - public displayName!: string - public lifeTime!: number - public allowChats!: boolean - public allowVideoCalls!: boolean - public allowAudioCalls!: boolean - public connectionAcceptance!: ConnectionAcceptancePolicy - public autoSendProfile!: boolean - public state!: CommunicationPolicyState - - public static readonly type = 'CommunicationPolicyRecord' - public readonly type = CommunicationPolicyRecord.type - - public constructor(props: CommunicationPolicyStorageProps) { - super() - - if (props) { - this.id = props.id ?? uuid() - this.state = props.state ?? CommunicationPolicyState.Init - this.createdAt = props.createdAt ?? new Date() - this.displayName = props.displayName || '' - this.lifeTime = props.lifeTime || 24 * 60 - this.allowChats = props.allowChats || true - this.allowVideoCalls = props.allowVideoCalls || false - this.allowAudioCalls = props.allowAudioCalls || false - this.autoSendProfile = props.autoSendProfile || true - this.connectionAcceptance = props.connectionAcceptance || ConnectionAcceptancePolicy.AutoAccept - } - } - - public getTags() { - return { - ...this._tags, - } - } -} diff --git a/src/repository/CommunicationPolicyRepository.ts b/src/repository/CommunicationPolicyRepository.ts deleted file mode 100644 index 3b2c0ec..0000000 --- a/src/repository/CommunicationPolicyRepository.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { EventEmitter, InjectionSymbols } from '@aries-framework/core' -import { Repository, StorageService } from '@aries-framework/core' -import { inject, scoped, Lifecycle } from 'tsyringe' -import { CommunicationPolicyRecord } from './CommunicationPolicyRecord' - -@scoped(Lifecycle.ContainerScoped) -export class CommunicationPolicyRepository extends Repository { - public constructor( - @inject(InjectionSymbols.StorageService) storageService: StorageService, - eventEmitter: EventEmitter - ) { - super(CommunicationPolicyRecord, storageService, eventEmitter) - } -} diff --git a/src/repository/CommunicationPolicyState.ts b/src/repository/CommunicationPolicyState.ts deleted file mode 100644 index c78e75f..0000000 --- a/src/repository/CommunicationPolicyState.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Communication Policy states as defined in - * https://gitlab.mobiera.com/2060/2060-spec/-/blob/master/concepts/communication-policy.md - */ - -export enum CommunicationPolicyState { - Init = 'init', - Enabled = 'enabled', - Disabled = 'disabled', -} diff --git a/src/repository/ConnectionAcceptancePolicy.ts b/src/repository/ConnectionAcceptancePolicy.ts deleted file mode 100644 index 0ef0650..0000000 --- a/src/repository/ConnectionAcceptancePolicy.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum ConnectionAcceptancePolicy { - AutoAccept = 'auto-accept', - Manual = 'manual-accept', - RejectAll = 'reject', -} diff --git a/src/repository/UserProfileRecord.ts b/src/repository/UserProfileRecord.ts index 9f1e161..ae696a1 100644 --- a/src/repository/UserProfileRecord.ts +++ b/src/repository/UserProfileRecord.ts @@ -6,7 +6,6 @@ export interface UserProfileData { displayName?: string displayPicture?: DisplayPictureData description?: string - defaultCommunicationPolicyId?: string } export interface UserProfileStorageProps extends UserProfileData { @@ -18,7 +17,6 @@ export class UserProfileRecord extends BaseRecord implements UserProfileStorageP public displayName?: string public displayPicture?: DisplayPictureData public description?: string - public defaultCommunicationPolicyId?: string public static readonly type = 'UserProfileRecord' public readonly type = UserProfileRecord.type diff --git a/src/repository/index.ts b/src/repository/index.ts index c682438..173e52b 100644 --- a/src/repository/index.ts +++ b/src/repository/index.ts @@ -1,6 +1,2 @@ -export * from './CommunicationPolicyRecord' -export * from './CommunicationPolicyRepository' -export * from './CommunicationPolicyState' -export * from './ConnectionAcceptancePolicy' export * from './UserProfileRecord' export * from './UserProfileRepository' diff --git a/src/services/CommunicationPolicyEvents.ts b/src/services/CommunicationPolicyEvents.ts deleted file mode 100644 index fd24d7b..0000000 --- a/src/services/CommunicationPolicyEvents.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { CommunicationPolicyRecord } from '../repository/CommunicationPolicyRecord' -import { CommunicationPolicyState } from '../repository/CommunicationPolicyState' -import { BaseEvent } from '@aries-framework/core' - -export enum CommunicationPolicyEventTypes { - StateChanged = 'CommunicationPolicyStateChanged', -} - -export interface CommunicationPolicyStateChangedEvent extends BaseEvent { - type: CommunicationPolicyEventTypes.StateChanged - payload: { - communicationPolicyRecord: CommunicationPolicyRecord - previousState: CommunicationPolicyState | null - } -} diff --git a/src/services/CommunicationPolicyService.ts b/src/services/CommunicationPolicyService.ts deleted file mode 100644 index f68b26c..0000000 --- a/src/services/CommunicationPolicyService.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { Lifecycle, scoped } from 'tsyringe' -import { CommunicationPolicyBaseProps, CommunicationPolicyRecord } from '../repository/CommunicationPolicyRecord' -import { AgentContext, EventEmitter } from '@aries-framework/core' -import { CommunicationPolicyRepository } from '../repository/CommunicationPolicyRepository' -import { CommunicationPolicyEventTypes, CommunicationPolicyStateChangedEvent } from './CommunicationPolicyEvents' -import { CommunicationPolicyState } from '../repository/CommunicationPolicyState' - -@scoped(Lifecycle.ContainerScoped) -export class CommunicationPolicyService { - private communicationPolicyRepository: CommunicationPolicyRepository - private eventEmitter: EventEmitter - - public constructor(communicationPolicyRepository: CommunicationPolicyRepository, eventEmitter: EventEmitter) { - this.communicationPolicyRepository = communicationPolicyRepository - this.eventEmitter = eventEmitter - } - - /** Create and persist a new communication policy record based on properties - * - * @param props new record properties - * - * @returns newly created record - */ - public async create(agentContext: AgentContext, props: CommunicationPolicyBaseProps) { - const record = new CommunicationPolicyRecord({ ...props, state: CommunicationPolicyState.Init }) - await this.communicationPolicyRepository.save(agentContext, record) - - this.eventEmitter.emit(agentContext, { - type: CommunicationPolicyEventTypes.StateChanged, - payload: { communicationPolicyRecord: record, previousState: null }, - }) - - return record - } - - /** Update and persist an existing communication policy record. Only fields defined in props - * are changed. - * - * @param props fields to update - * - * @return updated record - */ - public async update( - agentContext: AgentContext, - communicationPolicyRecord: CommunicationPolicyRecord, - props: CommunicationPolicyBaseProps - ) { - Object.assign(communicationPolicyRecord, props) - await this.communicationPolicyRepository.update(agentContext, communicationPolicyRecord) - - return communicationPolicyRecord - } - - /** - * Delete a communication policy - * - */ - public async delete(agentContext: AgentContext, communicationPolicyRecord: CommunicationPolicyRecord) { - await this.communicationPolicyRepository.delete(agentContext, communicationPolicyRecord) - } - - /** - * Retrieve all communication policy records - * - * @returns List containing all communication policy records - */ - public getAll(agentContext: AgentContext): Promise { - return this.communicationPolicyRepository.getAll(agentContext) - } - - /** - * Retrieve a communication policy record by id - * - * @param communicationPolicyRecordId The communication policy record id - * @throws {RecordNotFoundError} If no record is found - * @return The communication policy record - * - */ - public getById(agentContext: AgentContext, communicationPolicyRecordId: string): Promise { - return this.communicationPolicyRepository.getById(agentContext, communicationPolicyRecordId) - } - - /** - * Find a communication policy record by id - * - * @param communicationPolicyRecordId the communication policy record id - * @returns The communication policy record or null if not found - */ - public findById( - agentContext: AgentContext, - communicationPolicyRecordId: string - ): Promise { - return this.communicationPolicyRepository.findById(agentContext, communicationPolicyRecordId) - } - - /** - * Delete a communication policy record by id - * - * @param communicationPolicyId the communication policy record id - */ - public async deleteById(agentContext: AgentContext, communicationPolicyId: string) { - const communicationPolicyRecord = await this.getById(agentContext, communicationPolicyId) - return this.communicationPolicyRepository.delete(agentContext, communicationPolicyRecord) - } - - /** - * Update the record to a new state and emit an state changed event. Also updates the record - * in storage. - * - * @param communicationPolicyRecord The proof record to update the state for - * @param newState The state to update to - * - */ - public async updateState( - agentContext: AgentContext, - communicationPolicyRecord: CommunicationPolicyRecord, - newState: CommunicationPolicyState - ) { - const previousState = communicationPolicyRecord.state - communicationPolicyRecord.state = newState - await this.communicationPolicyRepository.update(agentContext, communicationPolicyRecord) - - this.eventEmitter.emit(agentContext, { - type: CommunicationPolicyEventTypes.StateChanged, - payload: { communicationPolicyRecord, previousState: previousState }, - }) - } -} diff --git a/src/services/UserProfileEvents.ts b/src/services/UserProfileEvents.ts index 04947dc..69df03a 100644 --- a/src/services/UserProfileEvents.ts +++ b/src/services/UserProfileEvents.ts @@ -1,5 +1,4 @@ import { BaseEvent, ConnectionRecord } from '@aries-framework/core' -import { UserProfile } from '../model' import { ConnectionProfileKey } from '../messages' import { UserProfileData, UserProfileRecord } from '../repository' diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 1b70694..5d80940 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -1,5 +1,4 @@ import { Lifecycle, scoped } from 'tsyringe' -import { CommunicationPolicyRecord } from '../repository/CommunicationPolicyRecord' import { AgentContext, ConnectionRecord, @@ -9,34 +8,29 @@ import { } from '@aries-framework/core' import { UserProfileRepository } from '../repository/UserProfileRepository' import { UserProfileRecord, UserProfileData } from '../repository/UserProfileRecord' -import { RecordNotFoundError } from '@aries-framework/core' -import { ConnectionAcceptancePolicy } from '../repository/ConnectionAcceptancePolicy' import { ConnectionProfileUpdatedEvent, ProfileEventTypes, UserProfileRequestedEvent, UserProfileUpdatedEvent, } from './UserProfileEvents' -import { CommunicationPolicyService } from './CommunicationPolicyService' import { RequestProfileMessage, GetProfileMessageOptions, ProfileMessage, ProfileMessageOptions } from '../messages' import { getConnectionProfile, setConnectionProfile } from '../model' +import { UserProfileModuleConfig } from '../UserProfileModuleConfig' @scoped(Lifecycle.ContainerScoped) export class UserProfileService { private userProfileRepository: UserProfileRepository - private communicationPolicyService: CommunicationPolicyService private connectionService: ConnectionService private eventEmitter: EventEmitter private _userProfileRecord?: UserProfileRecord public constructor( userProfileRepository: UserProfileRepository, - communicationPolicyService: CommunicationPolicyService, connectionService: ConnectionService, eventEmitter: EventEmitter ) { this.userProfileRepository = userProfileRepository - this.communicationPolicyService = communicationPolicyService this.connectionService = connectionService this.eventEmitter = eventEmitter } @@ -53,7 +47,6 @@ export class UserProfileService { const previousUserProfileData = { displayName: userProfile.displayName, displayPicture: userProfile.displayPicture, - defaultCommunicationPolicyId: userProfile.defaultCommunicationPolicyId, } Object.assign(userProfile, props) @@ -90,14 +83,6 @@ export class UserProfileService { userProfileRecord = new UserProfileRecord({ id: this.userProfileRepository.DEFAULT_USER_PROFILE_RECORD, }) - - // Create default communication policy - const defaultCommPolicy = await this.communicationPolicyService.create(agentContext, { - displayName: 'default', - connectionAcceptance: ConnectionAcceptancePolicy.AutoAccept, - autoSendProfile: false, - }) - userProfileRecord.defaultCommunicationPolicyId = defaultCommPolicy.id await this.userProfileRepository.save(agentContext, userProfileRecord) } @@ -106,23 +91,6 @@ export class UserProfileService { return this._userProfileRecord } - /** - * Retrieve default communication policy - * - * @throws {RecordNotFoundError} If no record is found - * @return The communication policy record - * - */ - public async getDefaultCommunicationPolicy(agentContext: AgentContext): Promise { - const defaultCommunicationPolicyId = (await this.getUserProfile(agentContext)).defaultCommunicationPolicyId - if (!defaultCommunicationPolicyId) { - throw new RecordNotFoundError('Default communication policy not defined', { - recordType: CommunicationPolicyRecord.type, - }) - } - return await this.communicationPolicyService.getById(agentContext, defaultCommunicationPolicyId) - } - public async processProfile(messageContext: InboundMessageContext) { const connection = messageContext.assertReadyConnection() @@ -161,8 +129,8 @@ export class UserProfileService { profile: getConnectionProfile(connection) ?? {}, }, }) - - if (messageContext.message.sendBackYours) { + const config = messageContext.agentContext.dependencyManager.resolve(UserProfileModuleConfig) + if (messageContext.message.sendBackYours && config.autoSendProfile) { return this.createProfileMessageAsReply(agentContext, connection, messageContext.message.threadId) } } @@ -182,18 +150,6 @@ export class UserProfileService { public async processRequestProfile(messageContext: InboundMessageContext) { const connection = messageContext.assertReadyConnection() - const policyId = (connection.getTag('communicationPolicyId') as string) ?? null - if (policyId) { - const policy = await this.communicationPolicyService.findById(messageContext.agentContext, policyId) - - if (policy && policy.autoSendProfile) { - return await this.createProfileMessageAsReply( - messageContext.agentContext, - connection, - messageContext.message.threadId - ) - } - } this.eventEmitter.emit(messageContext.agentContext, { type: ProfileEventTypes.UserProfileRequested, payload: { @@ -201,6 +157,16 @@ export class UserProfileService { query: messageContext.message.query, }, }) + + const config = messageContext.agentContext.dependencyManager.resolve(UserProfileModuleConfig) + + if (config.autoSendProfile) { + return await this.createProfileMessageAsReply( + messageContext.agentContext, + connection, + messageContext.message.threadId + ) + } } private async createProfileMessageAsReply( diff --git a/src/services/index.ts b/src/services/index.ts index c9121b8..fe1ceb3 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,4 +1,2 @@ -export * from './CommunicationPolicyEvents' -export * from './CommunicationPolicyService' export * from './UserProfileEvents' export * from './UserProfileService' diff --git a/test/profile.test.ts b/test/profile.test.ts index 7ef1bdf..605ba13 100644 --- a/test/profile.test.ts +++ b/test/profile.test.ts @@ -15,23 +15,15 @@ import { filter, firstValueFrom, map, Subject, timeout } from 'rxjs' import { UserProfileModule } from '../src/UserProfileModule' import { SubjectOutboundTransport } from './transport/SubjectOutboundTransport' import { SubjectInboundTransport } from './transport/SubjectInboundTransport' -import { MessageState } from '../src/messages' -import { - ConnectionProfileUpdatedEvent, - MessageReceiptsReceivedEvent, - ProfileEventTypes, - ReceiptsEventTypes, - RequestReceiptsReceivedEvent, - UserProfileRequestedEvent, -} from '../src/services' +import { ConnectionProfileUpdatedEvent, ProfileEventTypes, UserProfileRequestedEvent } from '../src/services' const logger = new ConsoleLogger(LogLevel.info) export type SubjectMessage = { message: EncryptedMessage; replySubject?: Subject } describe('receipts test', () => { - let aliceAgent: Agent<{ profile: UserProfileModule }> - let bobAgent: Agent<{ profile: UserProfileModule }> + let aliceAgent: Agent<{ askar: AskarModule; profile: UserProfileModule }> + let bobAgent: Agent<{ askar: AskarModule; profile: UserProfileModule }> let aliceWalletId: string let aliceWalletKey: string let bobWalletId: string @@ -151,7 +143,7 @@ describe('receipts test', () => { }) test('Request profile', async () => { - const profileReceivedPromise = firstValueFrom( + const profileRequestedPromise = firstValueFrom( aliceAgent.events.observable(ProfileEventTypes.UserProfileRequested).pipe( filter((event: UserProfileRequestedEvent) => event.payload.connection.id === aliceConnectionRecord.id), map((event: UserProfileRequestedEvent) => event.payload.query), @@ -161,7 +153,7 @@ describe('receipts test', () => { await bobAgent.modules.profile.requestUserProfile(bobConnectionRecord) - const profileRequestQuery = await profileReceivedPromise + const profileRequestQuery = await profileRequestedPromise expect(profileRequestQuery).toBeUndefined() })