diff --git a/packages/transport-ble/CHANGELOG.md b/packages/transport-ble/CHANGELOG.md index c7025aa3..fde65a61 100644 --- a/packages/transport-ble/CHANGELOG.md +++ b/packages/transport-ble/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [0.2.1](https://www.github.com/hyperledger/aries-framework-javascript-ext/compare/transport-ble-v0.2.0...transport-ble-v0.2.1) (2023-09-18) + + +### Bug Fixes + +* loosen types on ble inbound and outbound transport and session ([#226](https://www.github.com/hyperledger/aries-framework-javascript-ext/issues/226)) ([17c6203](https://www.github.com/hyperledger/aries-framework-javascript-ext/commit/17c6203b398ad2fd613bc237e2c852a86f44c444)) + ## [0.2.0](https://www.github.com/hyperledger/aries-framework-javascript-ext/compare/transport-ble-v0.1.0...transport-ble-v0.2.0) (2023-06-29) diff --git a/packages/transport-ble/package.json b/packages/transport-ble/package.json index 14a155e3..56eb33e0 100644 --- a/packages/transport-ble/package.json +++ b/packages/transport-ble/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/transport-ble", "main": "build/index", "types": "build/index", - "version": "0.2.0", + "version": "0.2.1", "files": [ "build" ], diff --git a/packages/transport-ble/src/transports/BleInboundTransport.ts b/packages/transport-ble/src/transports/BleInboundTransport.ts index a56f5d21..bd4b7836 100644 --- a/packages/transport-ble/src/transports/BleInboundTransport.ts +++ b/packages/transport-ble/src/transports/BleInboundTransport.ts @@ -1,4 +1,4 @@ -import type { Central } from '@animo-id/react-native-ble-didcomm' +import type { Ble } from '@animo-id/react-native-ble-didcomm' import type { Agent, InboundTransport, Logger } from '@aries-framework/core' import type { EmitterSubscription } from 'react-native' @@ -8,14 +8,14 @@ import { BleTransportSession } from './BleTransportSession' export class BleInboundTransport implements InboundTransport { public supportedSchemes: string[] = ['ble'] - private central: Central + private messenger: Ble private messageListener?: EmitterSubscription private session!: BleTransportSession private disconnectionListener?: EmitterSubscription private logger?: Logger - public constructor(central: Central) { - this.central = central + public constructor(messenger: Ble) { + this.messenger = messenger } public async start(agent: Agent): Promise { @@ -23,7 +23,7 @@ export class BleInboundTransport implements InboundTransport { this.logger.debug('Starting BLE inbound transport') const sessionId = utils.uuid() - this.session = new BleTransportSession(sessionId, this.central, agent) + this.session = new BleTransportSession(sessionId, this.messenger, agent.context) const messageListener = async (data: { message: string }) => { const message = data.message @@ -37,11 +37,11 @@ export class BleInboundTransport implements InboundTransport { session: this.session, }) } catch (error) { - agent.config.logger.error(`Error processing message: ${error}`) + this.logger?.error(`Error processing message: ${error}`) } } - this.messageListener = this.central.registerMessageListener(messageListener) + this.messageListener = this.messenger.registerMessageListener(messageListener) const disconnectionListener = async (data: { identifier: string }) => { this.logger?.debug('BLE disconnection detected', { data }) @@ -50,7 +50,7 @@ export class BleInboundTransport implements InboundTransport { transportService.removeSession(this.session) } - this.disconnectionListener = this.central.registerOnDisconnectedListener(disconnectionListener) + this.disconnectionListener = this.messenger.registerOnDisconnectedListener(disconnectionListener) } public async stop(): Promise { @@ -58,6 +58,6 @@ export class BleInboundTransport implements InboundTransport { this.messageListener?.remove() this.disconnectionListener?.remove() - await this.central.shutdown() + await this.messenger.shutdown() } } diff --git a/packages/transport-ble/src/transports/BleOutboundTransport.ts b/packages/transport-ble/src/transports/BleOutboundTransport.ts index 92dd44e5..8b578e30 100644 --- a/packages/transport-ble/src/transports/BleOutboundTransport.ts +++ b/packages/transport-ble/src/transports/BleOutboundTransport.ts @@ -1,21 +1,21 @@ -import type { Peripheral } from '@animo-id/react-native-ble-didcomm' +import type { Ble } from '@animo-id/react-native-ble-didcomm' import type { Agent, Logger, OutboundPackage, OutboundTransport } from '@aries-framework/core' import { AriesFrameworkError } from '@aries-framework/core' export class BleOutboundTransport implements OutboundTransport { public supportedSchemes: string[] = ['ble'] - private peripheral: Peripheral + private messenger: Ble private logger?: Logger - public constructor(peripheral: Peripheral) { - this.peripheral = peripheral + public constructor(messenger: Ble) { + this.messenger = messenger } public async start(agent: Agent): Promise { this.logger = agent.config.logger - agent.config.logger.debug('Starting BLE outbound transport') + this.logger.debug('Starting BLE outbound transport') } public async sendMessage(outboundPackage: OutboundPackage): Promise { @@ -31,11 +31,11 @@ export class BleOutboundTransport implements OutboundTransport { const serializedMessage = JSON.stringify(payload) this.logger?.debug('Sending BLE outbound message') - await this.peripheral.sendMessage(serializedMessage) + await this.messenger.sendMessage(serializedMessage) } public async stop(): Promise { this.logger?.debug('Stopping BLE outbound transport') - await this.peripheral.shutdown() + await this.messenger.shutdown() } } diff --git a/packages/transport-ble/src/transports/BleTransportSession.ts b/packages/transport-ble/src/transports/BleTransportSession.ts index 27e1942d..c7e279d7 100644 --- a/packages/transport-ble/src/transports/BleTransportSession.ts +++ b/packages/transport-ble/src/transports/BleTransportSession.ts @@ -1,28 +1,29 @@ -import type { Central } from '@animo-id/react-native-ble-didcomm' -import type { Agent, AgentContext, EncryptedMessage, TransportSession } from '@aries-framework/core' +import type { Ble } from '@animo-id/react-native-ble-didcomm' +import type { AgentContext, EncryptedMessage, TransportSession } from '@aries-framework/core' import { utils } from '@aries-framework/core' export class BleTransportSession implements TransportSession { public readonly type = 'ble' public id: string - private agent: Agent - private central: Central - public constructor(id: string, central: Central, agent: Agent) { + private agentContext: AgentContext + private messenger: Ble + + public constructor(id: string, messenger: Ble, agentContext: AgentContext) { this.id = id ?? utils.uuid() - this.agent = agent - this.central = central + this.messenger = messenger + this.agentContext = agentContext } public async send(agentContext: AgentContext, encryptedMessage: EncryptedMessage): Promise { const serializedMessage = JSON.stringify(encryptedMessage) - this.agent.config.logger.debug('Sending BLE inbound message via session') - await this.central.sendMessage(serializedMessage) + agentContext.config.logger.debug('Sending BLE inbound message via session') + await this.messenger.sendMessage(serializedMessage) } public async close(): Promise { - this.agent.config.logger.debug('Stopping BLE inbound session') + this.agentContext.config.logger.debug('Stopping BLE inbound session') } }