@ledgerhq/device-core 0.2.1-next.1 → 0.2.1-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
 
2
- > @ledgerhq/device-core@0.2.1-next.0 build /home/runner/work/ledger-live/ledger-live/libs/device-core
2
+ > @ledgerhq/device-core@0.2.1-next.1 build /home/runner/work/ledger-live/ledger-live/libs/device-core
3
3
  > tsc && tsc -m ES6 --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ledgerhq/device-core
2
2
 
3
+ ## 0.2.1-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#7173](https://github.com/LedgerHQ/ledger-live/pull/7173) [`19c02ce`](https://github.com/LedgerHQ/ledger-live/commit/19c02cead22422b4a2e94aef74ebc67e992ab54d) Thanks [@jdabbech-ledger](https://github.com/jdabbech-ledger)! - Revert deletion get name fix apdu
8
+
3
9
  ## 0.2.1-next.1
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"getDeviceName.d.ts","sourceRoot":"","sources":["../../../src/commands/use-cases/getDeviceName.ts"],"names":[],"mappings":"AAAA,OAAO,SAA0B,MAAM,wBAAwB,CAAC;AAOhE,wBAAsB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAczE"}
1
+ {"version":3,"file":"getDeviceName.d.ts","sourceRoot":"","sources":["../../../src/commands/use-cases/getDeviceName.ts"],"names":[],"mappings":"AAAA,OAAO,SAA0B,MAAM,wBAAwB,CAAC;AAehE,wBAAsB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBzE"}
@@ -13,6 +13,13 @@ exports.getDeviceName = void 0;
13
13
  const hw_transport_1 = require("@ledgerhq/hw-transport");
14
14
  const logs_1 = require("@ledgerhq/logs");
15
15
  const parseGetDeviceNameResponse_1 = require("./parseGetDeviceNameResponse");
16
+ /**
17
+ * A first APDU that we send because getDeviceName sometimes misbehaves on LNX
18
+ * if it's not sent.
19
+ * cf. https://github.com/LedgerHQ/ledger-live/pull/2250 where it was removed
20
+ * cf. https://github.com/LedgerHQ/ledger-live/pull/2401 where it was added back
21
+ */
22
+ const CLEANING_APDU = [0xe0, 0x50, 0x00, 0x00, undefined];
16
23
  const GET_DEVICE_NAME_APDU = [0xe0, 0xd2, 0x00, 0x00, Buffer.from([])];
17
24
  function getDeviceName(transport) {
18
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -21,6 +28,14 @@ function getDeviceName(transport) {
21
28
  function: "getDeviceName",
22
29
  });
23
30
  tracer.trace("Start");
31
+ try {
32
+ // Legacy: prevents bad apdu response for LNX
33
+ yield transport.send(...CLEANING_APDU);
34
+ }
35
+ catch (error) {
36
+ tracer.trace(`Error on 0xe0500000: ${error}`, { error });
37
+ }
38
+ tracer.trace("Sent cleaning 0xe0500000");
24
39
  const res = yield transport.send(...GET_DEVICE_NAME_APDU, [
25
40
  hw_transport_1.StatusCodes.OK,
26
41
  hw_transport_1.StatusCodes.DEVICE_NOT_ONBOARDED,
@@ -1 +1 @@
1
- {"version":3,"file":"getDeviceName.js","sourceRoot":"","sources":["../../../src/commands/use-cases/getDeviceName.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAgE;AAChE,yCAA6C;AAE7C,6EAA0E;AAE1E,MAAM,oBAAoB,GAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7E,SAAsB,aAAa,CAAC,SAAoB;;QACtD,MAAM,MAAM,GAAG,IAAI,kBAAW,CAAC,IAAI,EAAE;YACnC,SAAS,EAAE,SAAS,CAAC,eAAe,EAAE;YACtC,QAAQ,EAAE,eAAe;SAC1B,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,C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YACxD,0BAAW,CAAC,EAAE;YACd,0BAAW,CAAC,oBAAoB;YAChC,0BAAW,CAAC,sBAAsB;SACnC,CAAC,CAAC;QAEH,OAAO,IAAA,uDAA0B,EAAC,GAAG,CAAC,CAAC;IACzC,CAAC;CAAA;AAtBD,sCAsBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDeviceName.d.ts","sourceRoot":"","sources":["../../../src/commands/use-cases/getDeviceName.ts"],"names":[],"mappings":"AAAA,OAAO,SAA0B,MAAM,wBAAwB,CAAC;AAOhE,wBAAsB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAczE"}
1
+ {"version":3,"file":"getDeviceName.d.ts","sourceRoot":"","sources":["../../../src/commands/use-cases/getDeviceName.ts"],"names":[],"mappings":"AAAA,OAAO,SAA0B,MAAM,wBAAwB,CAAC;AAehE,wBAAsB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBzE"}
@@ -10,6 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { StatusCodes } from "@ledgerhq/hw-transport";
11
11
  import { LocalTracer } from "@ledgerhq/logs";
12
12
  import { parseGetDeviceNameResponse } from "./parseGetDeviceNameResponse";
13
+ /**
14
+ * A first APDU that we send because getDeviceName sometimes misbehaves on LNX
15
+ * if it's not sent.
16
+ * cf. https://github.com/LedgerHQ/ledger-live/pull/2250 where it was removed
17
+ * cf. https://github.com/LedgerHQ/ledger-live/pull/2401 where it was added back
18
+ */
19
+ const CLEANING_APDU = [0xe0, 0x50, 0x00, 0x00, undefined];
13
20
  const GET_DEVICE_NAME_APDU = [0xe0, 0xd2, 0x00, 0x00, Buffer.from([])];
14
21
  export function getDeviceName(transport) {
15
22
  return __awaiter(this, void 0, void 0, function* () {
@@ -18,6 +25,14 @@ export function getDeviceName(transport) {
18
25
  function: "getDeviceName",
19
26
  });
20
27
  tracer.trace("Start");
28
+ try {
29
+ // Legacy: prevents bad apdu response for LNX
30
+ yield transport.send(...CLEANING_APDU);
31
+ }
32
+ catch (error) {
33
+ tracer.trace(`Error on 0xe0500000: ${error}`, { error });
34
+ }
35
+ tracer.trace("Sent cleaning 0xe0500000");
21
36
  const res = yield transport.send(...GET_DEVICE_NAME_APDU, [
22
37
  StatusCodes.OK,
23
38
  StatusCodes.DEVICE_NOT_ONBOARDED,
@@ -1 +1 @@
1
- {"version":3,"file":"getDeviceName.js","sourceRoot":"","sources":["../../../src/commands/use-cases/getDeviceName.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAkB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,MAAM,oBAAoB,GAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7E,MAAM,UAAgB,aAAa,CAAC,SAAoB;;QACtD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE;YACnC,SAAS,EAAE,SAAS,CAAC,eAAe,EAAE;YACtC,QAAQ,EAAE,eAAe;SAC1B,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEtB,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,oBAAoB,EAAE;YACxD,WAAW,CAAC,EAAE;YACd,WAAW,CAAC,oBAAoB;YAChC,WAAW,CAAC,sBAAsB;SACnC,CAAC,CAAC;QAEH,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;CAAA"}
1
+ {"version":3,"file":"getDeviceName.js","sourceRoot":"","sources":["../../../src/commands/use-cases/getDeviceName.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAkB,EAAE,W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next.2",
4
4
  "description": "Ledger Live device core module",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -3,6 +3,14 @@ import { LocalTracer } from "@ledgerhq/logs";
3
3
  import { APDU } from "../entities/APDU";
4
4
  import { parseGetDeviceNameResponse } from "./parseGetDeviceNameResponse";
5
5
 
6
+ /**
7
+ * A first APDU that we send because getDeviceName sometimes misbehaves on LNX
8
+ * if it's not sent.
9
+ * cf. https://github.com/LedgerHQ/ledger-live/pull/2250 where it was removed
10
+ * cf. https://github.com/LedgerHQ/ledger-live/pull/2401 where it was added back
11
+ */
12
+ const CLEANING_APDU: APDU = [0xe0, 0x50, 0x00, 0x00, undefined];
13
+
6
14
  const GET_DEVICE_NAME_APDU: APDU = [0xe0, 0xd2, 0x00, 0x00, Buffer.from([])];
7
15
 
8
16
  export async function getDeviceName(transport: Transport): Promise<string> {
@@ -12,6 +20,14 @@ export async function getDeviceName(transport: Transport): Promise<string> {
12
20
  });
13
21
  tracer.trace("Start");
14
22
 
23
+ try {
24
+ // Legacy: prevents bad apdu response for LNX
25
+ await transport.send(...CLEANING_APDU);
26
+ } catch (error) {
27
+ tracer.trace(`Error on 0xe0500000: ${error}`, { error });
28
+ }
29
+ tracer.trace("Sent cleaning 0xe0500000");
30
+
15
31
  const res = await transport.send(...GET_DEVICE_NAME_APDU, [
16
32
  StatusCodes.OK,
17
33
  StatusCodes.DEVICE_NOT_ONBOARDED,