@ledgerhq/hw-transport-mocker
Advanced tools
Comparing version 6.27.20-tag-word.0 to 6.27.20
# @ledgerhq/hw-transport-mocker | ||
## 6.27.20-tag-word.0 | ||
## 6.27.20 | ||
### Patch Changes | ||
- Updated dependencies [[`9e2d32aec4`](https://github.com/LedgerHQ/ledger-live/commit/9e2d32aec4ebd8774880f94e3ef0e805ebb172ac), [`6b7fc5d071`](https://github.com/LedgerHQ/ledger-live/commit/6b7fc5d0711a83ed2fcacacd02795862a4a3bf1d), [`9e2d32aec4`](https://github.com/LedgerHQ/ledger-live/commit/9e2d32aec4ebd8774880f94e3ef0e805ebb172ac)]: | ||
- @ledgerhq/logs@6.11.0-tag-word.0 | ||
- @ledgerhq/hw-transport@6.29.0-tag-word.0 | ||
- [#5142](https://github.com/LedgerHQ/ledger-live/pull/5142) [`7968dfc551`](https://github.com/LedgerHQ/ledger-live/commit/7968dfc551acca00b7fabf00a726758d74be33de) Thanks [@alexandremgo](https://github.com/alexandremgo)! - chore: new mock fixture aTransportBuilder | ||
For unit tests where a real implementation of a Transport is not necessary. | ||
- [#5232](https://github.com/LedgerHQ/ledger-live/pull/5232) [`f3b2e7d0eb`](https://github.com/LedgerHQ/ledger-live/commit/f3b2e7d0eb1413781fc45e27c690e73c1058fec6) Thanks [@alexandremgo](https://github.com/alexandremgo)! - fix: ignore web socket messages coming from the HSM once a bulk message has been received | ||
- Added unit/snapshot case test on receiving a message after a bulk message | ||
- Enabled a blocker on exchange method on mocked TransportReplayer | ||
- Updated dependencies [[`9e2d32aec4`](https://github.com/LedgerHQ/ledger-live/commit/9e2d32aec4ebd8774880f94e3ef0e805ebb172ac), [`7968dfc551`](https://github.com/LedgerHQ/ledger-live/commit/7968dfc551acca00b7fabf00a726758d74be33de), [`6b7fc5d071`](https://github.com/LedgerHQ/ledger-live/commit/6b7fc5d0711a83ed2fcacacd02795862a4a3bf1d), [`9e2d32aec4`](https://github.com/LedgerHQ/ledger-live/commit/9e2d32aec4ebd8774880f94e3ef0e805ebb172ac)]: | ||
- @ledgerhq/logs@6.11.0 | ||
- @ledgerhq/hw-transport@6.29.0 | ||
## 6.27.20-next.0 | ||
### Patch Changes | ||
- [#5142](https://github.com/LedgerHQ/ledger-live/pull/5142) [`7968dfc551`](https://github.com/LedgerHQ/ledger-live/commit/7968dfc551acca00b7fabf00a726758d74be33de) Thanks [@alexandremgo](https://github.com/alexandremgo)! - chore: new mock fixture aTransportBuilder | ||
For unit tests where a real implementation of a Transport is not necessary. | ||
- [#5232](https://github.com/LedgerHQ/ledger-live/pull/5232) [`f3b2e7d0eb`](https://github.com/LedgerHQ/ledger-live/commit/f3b2e7d0eb1413781fc45e27c690e73c1058fec6) Thanks [@alexandremgo](https://github.com/alexandremgo)! - fix: ignore web socket messages coming from the HSM once a bulk message has been received | ||
- Added unit/snapshot case test on receiving a message after a bulk message | ||
- Enabled a blocker on exchange method on mocked TransportReplayer | ||
- Updated dependencies [[`9e2d32aec4`](https://github.com/LedgerHQ/ledger-live/commit/9e2d32aec4ebd8774880f94e3ef0e805ebb172ac), [`7968dfc551`](https://github.com/LedgerHQ/ledger-live/commit/7968dfc551acca00b7fabf00a726758d74be33de), [`6b7fc5d071`](https://github.com/LedgerHQ/ledger-live/commit/6b7fc5d0711a83ed2fcacacd02795862a4a3bf1d), [`9e2d32aec4`](https://github.com/LedgerHQ/ledger-live/commit/9e2d32aec4ebd8774880f94e3ef0e805ebb172ac)]: | ||
- @ledgerhq/logs@6.11.0-next.0 | ||
- @ledgerhq/hw-transport@6.29.0-next.0 | ||
## 6.27.19 | ||
@@ -12,0 +38,0 @@ |
@@ -7,2 +7,3 @@ export * from "./RecordStore"; | ||
export { createTransportRecorder, createTransportReplayer, openTransportReplayer, MockTransport }; | ||
export * from "./fixtures/aTransport"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,2 +7,3 @@ export * from "./RecordStore"; | ||
export { createTransportRecorder, createTransportReplayer, openTransportReplayer, MockTransport }; | ||
export * from "./fixtures/aTransport"; | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
import { Subject } from "rxjs"; | ||
import Transport from "@ledgerhq/hw-transport"; | ||
@@ -7,2 +8,3 @@ import type { RecordStore } from "./RecordStore"; | ||
artificialExchangeDelay: number; | ||
exchangeBlocker: null | Subject<number>; | ||
constructor(recordStore: RecordStore); | ||
@@ -18,2 +20,10 @@ static isSupported: () => Promise<boolean>; | ||
close(): Promise<void>; | ||
/** | ||
* Sets an observable blocking an exchange until `unblockExchange` is called | ||
*/ | ||
enableExchangeBlocker(): void; | ||
/** | ||
* Unblock exchange by emitting an event (if enabled), and remove the exchange blocker | ||
*/ | ||
unblockExchange(): void; | ||
exchange(apdu: Buffer): Promise<Buffer>; | ||
@@ -20,0 +30,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { Subject, firstValueFrom, map } from "rxjs"; | ||
import Transport from "@ledgerhq/hw-transport"; | ||
@@ -8,2 +9,3 @@ import { log } from "@ledgerhq/logs"; | ||
this.recordStore = recordStore; | ||
this.exchangeBlocker = null; | ||
} | ||
@@ -17,2 +19,17 @@ setArtificialExchangeDelay(delay) { | ||
} | ||
/** | ||
* Sets an observable blocking an exchange until `unblockExchange` is called | ||
*/ | ||
enableExchangeBlocker() { | ||
this.exchangeBlocker = new Subject(); | ||
} | ||
/** | ||
* Unblock exchange by emitting an event (if enabled), and remove the exchange blocker | ||
*/ | ||
unblockExchange() { | ||
if (this.exchangeBlocker) { | ||
this.exchangeBlocker.next(1); | ||
this.exchangeBlocker = null; | ||
} | ||
} | ||
exchange(apdu) { | ||
@@ -31,2 +48,9 @@ log("apdu", apdu.toString("hex")); | ||
} | ||
else if (this.exchangeBlocker) { | ||
return firstValueFrom( | ||
// The exchange is unblocked once `exchangeBlocker` emits a value | ||
this.exchangeBlocker.pipe(map(_ => { | ||
return buffer; | ||
}))); | ||
} | ||
else { | ||
@@ -33,0 +57,0 @@ return Promise.resolve(buffer); |
@@ -7,2 +7,3 @@ export * from "./RecordStore"; | ||
export { createTransportRecorder, createTransportReplayer, openTransportReplayer, MockTransport }; | ||
export * from "./fixtures/aTransport"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -30,2 +30,3 @@ "use strict"; | ||
exports.MockTransport = MockTransport_1.default; | ||
__exportStar(require("./fixtures/aTransport"), exports); | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
import { Subject } from "rxjs"; | ||
import Transport from "@ledgerhq/hw-transport"; | ||
@@ -7,2 +8,3 @@ import type { RecordStore } from "./RecordStore"; | ||
artificialExchangeDelay: number; | ||
exchangeBlocker: null | Subject<number>; | ||
constructor(recordStore: RecordStore); | ||
@@ -18,2 +20,10 @@ static isSupported: () => Promise<boolean>; | ||
close(): Promise<void>; | ||
/** | ||
* Sets an observable blocking an exchange until `unblockExchange` is called | ||
*/ | ||
enableExchangeBlocker(): void; | ||
/** | ||
* Unblock exchange by emitting an event (if enabled), and remove the exchange blocker | ||
*/ | ||
unblockExchange(): void; | ||
exchange(apdu: Buffer): Promise<Buffer>; | ||
@@ -20,0 +30,0 @@ } |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.TransportReplayer = void 0; | ||
const rxjs_1 = require("rxjs"); | ||
const hw_transport_1 = __importDefault(require("@ledgerhq/hw-transport")); | ||
@@ -15,2 +16,3 @@ const logs_1 = require("@ledgerhq/logs"); | ||
this.recordStore = recordStore; | ||
this.exchangeBlocker = null; | ||
} | ||
@@ -24,2 +26,17 @@ setArtificialExchangeDelay(delay) { | ||
} | ||
/** | ||
* Sets an observable blocking an exchange until `unblockExchange` is called | ||
*/ | ||
enableExchangeBlocker() { | ||
this.exchangeBlocker = new rxjs_1.Subject(); | ||
} | ||
/** | ||
* Unblock exchange by emitting an event (if enabled), and remove the exchange blocker | ||
*/ | ||
unblockExchange() { | ||
if (this.exchangeBlocker) { | ||
this.exchangeBlocker.next(1); | ||
this.exchangeBlocker = null; | ||
} | ||
} | ||
exchange(apdu) { | ||
@@ -38,2 +55,9 @@ (0, logs_1.log)("apdu", apdu.toString("hex")); | ||
} | ||
else if (this.exchangeBlocker) { | ||
return (0, rxjs_1.firstValueFrom)( | ||
// The exchange is unblocked once `exchangeBlocker` emits a value | ||
this.exchangeBlocker.pipe((0, rxjs_1.map)(_ => { | ||
return buffer; | ||
}))); | ||
} | ||
else { | ||
@@ -40,0 +64,0 @@ return Promise.resolve(buffer); |
{ | ||
"name": "@ledgerhq/hw-transport-mocker", | ||
"version": "6.27.20-tag-word.0", | ||
"version": "6.27.20", | ||
"description": "Ledger Hardware Wallet mocker utilities used for tests", | ||
@@ -28,4 +28,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^6.29.0-tag-word.0", | ||
"@ledgerhq/logs": "^6.11.0-tag-word.0" | ||
"rxjs": "^7.8.1", | ||
"@ledgerhq/hw-transport": "^6.29.0", | ||
"@ledgerhq/logs": "^6.11.0" | ||
}, | ||
@@ -50,4 +51,5 @@ "gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec", | ||
"lint:fix": "pnpm lint --fix", | ||
"test": "jest" | ||
"test": "jest", | ||
"unimported": "unimported" | ||
} | ||
} |
@@ -7,1 +7,2 @@ export * from "./RecordStore"; | ||
export { createTransportRecorder, createTransportReplayer, openTransportReplayer, MockTransport }; | ||
export * from "./fixtures/aTransport"; |
@@ -0,1 +1,2 @@ | ||
import { Subject, firstValueFrom, map } from "rxjs"; | ||
import Transport from "@ledgerhq/hw-transport"; | ||
@@ -8,2 +9,3 @@ import { log } from "@ledgerhq/logs"; | ||
artificialExchangeDelay = 0; | ||
exchangeBlocker: null | Subject<number>; | ||
@@ -13,2 +15,3 @@ constructor(recordStore: RecordStore) { | ||
this.recordStore = recordStore; | ||
this.exchangeBlocker = null; | ||
} | ||
@@ -46,2 +49,19 @@ | ||
/** | ||
* Sets an observable blocking an exchange until `unblockExchange` is called | ||
*/ | ||
enableExchangeBlocker() { | ||
this.exchangeBlocker = new Subject(); | ||
} | ||
/** | ||
* Unblock exchange by emitting an event (if enabled), and remove the exchange blocker | ||
*/ | ||
unblockExchange() { | ||
if (this.exchangeBlocker) { | ||
this.exchangeBlocker.next(1); | ||
this.exchangeBlocker = null; | ||
} | ||
} | ||
exchange(apdu: Buffer): Promise<Buffer> { | ||
@@ -61,2 +81,11 @@ log("apdu", apdu.toString("hex")); | ||
}); | ||
} else if (this.exchangeBlocker) { | ||
return firstValueFrom( | ||
// The exchange is unblocked once `exchangeBlocker` emits a value | ||
this.exchangeBlocker.pipe( | ||
map(_ => { | ||
return buffer; | ||
}), | ||
), | ||
); | ||
} else { | ||
@@ -63,0 +92,0 @@ return Promise.resolve(buffer); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
101229
71
1751
0
3
+ Addedrxjs@^7.8.1
Updated@ledgerhq/logs@^6.11.0