@ledgerhq/device-core 0.7.0 → 0.8.0-nightly.20260115024415

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @ledgerhq/device-core
2
2
 
3
+ ## 0.8.0-nightly.20260115024415
4
+
5
+ ### Minor Changes
6
+
7
+ - [#13396](https://github.com/LedgerHQ/ledger-live/pull/13396) [`b9a3e43`](https://github.com/LedgerHQ/ledger-live/commit/b9a3e431be33943ab4feb4294d6a7f27b966e61b) Thanks [@gre-ledger](https://github.com/gre-ledger)! - Update Jest to v30
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`8754614`](https://github.com/LedgerHQ/ledger-live/commit/87546149a62b81f8a25bb6222626592ead629f62), [`b9a3e43`](https://github.com/LedgerHQ/ledger-live/commit/b9a3e431be33943ab4feb4294d6a7f27b966e61b), [`3ac5f26`](https://github.com/LedgerHQ/ledger-live/commit/3ac5f26111f8596327fa7e588e514509de3f8a59), [`7f05536`](https://github.com/LedgerHQ/ledger-live/commit/7f0553665e9c8721f263825cc79994bfc6729d9b)]:
12
+ - @ledgerhq/types-live@6.93.0-nightly.20260115024415
13
+ - @ledgerhq/hw-transport@6.32.0-nightly.20260115024415
14
+ - @ledgerhq/devices@8.10.0-nightly.20260115024415
15
+ - @ledgerhq/errors@6.29.0-nightly.20260115024415
16
+ - @ledgerhq/logs@6.14.0-nightly.20260115024415
17
+ - @ledgerhq/live-network@2.2.0-nightly.20260115024415
18
+
3
19
  ## 0.7.0
4
20
 
5
21
  ### Minor Changes
package/jest.config.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "transform": {
3
- "^.+\\.(ts|tsx)?$": [
4
- "ts-jest",
3
+ "^.+\\.(t|j)sx?$": [
4
+ "@swc/jest",
5
5
  {
6
- "globals": {
7
- "isolatedModules": true
6
+ "jsc": {
7
+ "target": "esnext"
8
8
  }
9
9
  }
10
10
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/device-core",
3
- "version": "0.7.0",
3
+ "version": "0.8.0-nightly.20260115024415",
4
4
  "description": "Ledger Live device core module",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -20,22 +20,24 @@
20
20
  "dependencies": {
21
21
  "@noble/hashes": "1.8.0",
22
22
  "semver": "7.7.3",
23
- "@ledgerhq/devices": "8.9.0",
24
- "@ledgerhq/errors": "^6.28.0",
25
- "@ledgerhq/hw-transport": "6.31.16",
26
- "@ledgerhq/live-network": "^2.1.5",
27
- "@ledgerhq/logs": "^6.13.0",
28
- "@ledgerhq/types-live": "^6.92.0"
23
+ "@ledgerhq/devices": "8.10.0-nightly.20260115024415",
24
+ "@ledgerhq/errors": "^6.29.0-nightly.20260115024415",
25
+ "@ledgerhq/hw-transport": "6.32.0-nightly.20260115024415",
26
+ "@ledgerhq/live-network": "^2.2.0-nightly.20260115024415",
27
+ "@ledgerhq/logs": "^6.14.0-nightly.20260115024415",
28
+ "@ledgerhq/types-live": "^6.93.0-nightly.20260115024415"
29
29
  },
30
30
  "devDependencies": {
31
- "@testing-library/react": "14",
32
- "@types/jest": "^29.5.10",
31
+ "@testing-library/dom": "10.4.1",
32
+ "@testing-library/react": "16.3.1",
33
+ "@types/jest": "30.0.0",
33
34
  "@types/node": "^22.10.10",
34
35
  "@types/semver": "7.7.1",
35
36
  "@types/sha.js": "^2.4.4",
36
- "jest": "^29.7.0",
37
- "jest-environment-jsdom": "^29.7.0",
38
- "ts-jest": "^29.1.1"
37
+ "jest": "30.2.0",
38
+ "jest-environment-jsdom": "30.2.0",
39
+ "@swc/jest": "0.2.39",
40
+ "@swc/core": "1.15.8"
39
41
  },
40
42
  "typesVersions": {
41
43
  "*": {
@@ -8,19 +8,29 @@ import {
8
8
  } from "../entities/LanguagePackageEntity";
9
9
  import { HttpManagerApiRepository } from "./HttpManagerApiRepository";
10
10
 
11
- const getUserHashesModule = jest.requireActual("../use-cases/getUserHashes");
12
- const networkModule = jest.requireActual("@ledgerhq/live-network/network");
11
+ jest.mock("../use-cases/getUserHashes", () => ({
12
+ ...jest.requireActual("../use-cases/getUserHashes"),
13
+ getUserHashes: jest.fn(),
14
+ }));
15
+
16
+ jest.mock("@ledgerhq/live-network/network", () => ({
17
+ __esModule: true,
18
+ default: jest.fn(),
19
+ }));
20
+
21
+ import { getUserHashes } from "../use-cases/getUserHashes";
22
+ import network from "@ledgerhq/live-network/network";
23
+
24
+ const mockedGetUserHashes = jest.mocked(getUserHashes);
25
+ const mockedNetwork = jest.mocked(network);
13
26
 
14
27
  describe("HttpManagerApiRepository", () => {
15
28
  let httpManagerApiRepository: HttpManagerApiRepository;
16
- let getUserHashesSpy: jest.SpyInstance;
17
- let networkSpy: jest.SpyInstance;
18
29
 
19
30
  beforeEach(() => {
20
31
  httpManagerApiRepository = new HttpManagerApiRepository("http://managerApiBase.com", "1.2.3");
21
- getUserHashesSpy = jest.spyOn(getUserHashesModule, "getUserHashes");
22
- networkSpy = jest.spyOn(networkModule, "default");
23
- networkSpy.mockImplementation(jest.fn());
32
+ mockedNetwork.mockImplementation(jest.fn());
33
+ jest.clearAllMocks();
24
34
  });
25
35
 
26
36
  afterEach(() => {
@@ -28,7 +38,7 @@ describe("HttpManagerApiRepository", () => {
28
38
  });
29
39
 
30
40
  test("fetchLatestFirmware should call network() with the correct parameters", async () => {
31
- getUserHashesSpy.mockReturnValue({
41
+ mockedGetUserHashes.mockReturnValue({
32
42
  firmwareSalt: "mockedFirmwareSalt",
33
43
  });
34
44
  const params: Parameters<typeof httpManagerApiRepository.fetchLatestFirmware>[0] = {
@@ -42,7 +52,7 @@ describe("HttpManagerApiRepository", () => {
42
52
  // ignore the error in this test case
43
53
  });
44
54
 
45
- expect(networkSpy).toHaveBeenCalledWith({
55
+ expect(mockedNetwork).toHaveBeenCalledWith({
46
56
  method: "GET",
47
57
  url:
48
58
  "http://managerApiBase.com/get_latest_firmware" +
@@ -55,7 +65,7 @@ describe("HttpManagerApiRepository", () => {
55
65
  });
56
66
 
57
67
  test("fetchLatestFirmware should return null if data.result is null", async () => {
58
- getUserHashesSpy.mockReturnValue({
68
+ mockedGetUserHashes.mockReturnValue({
59
69
  firmwareSalt: "mockedFirmwareSalt",
60
70
  });
61
71
  const params: Parameters<typeof httpManagerApiRepository.fetchLatestFirmware>[0] = {
@@ -64,7 +74,7 @@ describe("HttpManagerApiRepository", () => {
64
74
  providerId: 12,
65
75
  userId: "userId",
66
76
  };
67
- networkSpy.mockResolvedValue({
77
+ mockedNetwork.mockResolvedValue({
68
78
  data: {
69
79
  result: "null",
70
80
  },
@@ -76,7 +86,7 @@ describe("HttpManagerApiRepository", () => {
76
86
  });
77
87
 
78
88
  test("fetchLatestFirmware should return data.se_firmware_osu_version", async () => {
79
- getUserHashesSpy.mockReturnValue({
89
+ mockedGetUserHashes.mockReturnValue({
80
90
  firmwareSalt: "mockedFirmwareSalt",
81
91
  });
82
92
  const params: Parameters<typeof httpManagerApiRepository.fetchLatestFirmware>[0] = {
@@ -85,7 +95,7 @@ describe("HttpManagerApiRepository", () => {
85
95
  providerId: 12,
86
96
  userId: "userId",
87
97
  };
88
- networkSpy.mockResolvedValue({
98
+ mockedNetwork.mockResolvedValue({
89
99
  data: {
90
100
  result: "mockedResult",
91
101
  se_firmware_osu_version: "mockedOsuFirmware",
@@ -102,14 +112,14 @@ describe("HttpManagerApiRepository", () => {
102
112
  // ignore the error in this test case
103
113
  });
104
114
 
105
- expect(networkSpy).toHaveBeenCalledWith({
115
+ expect(mockedNetwork).toHaveBeenCalledWith({
106
116
  method: "GET",
107
117
  url: "http://managerApiBase.com/mcu_versions?livecommonversion=1.2.3",
108
118
  });
109
119
  });
110
120
 
111
121
  test("fetchMcus should return data", async () => {
112
- networkSpy.mockResolvedValue({
122
+ mockedNetwork.mockResolvedValue({
113
123
  data: "mockedData",
114
124
  });
115
125
 
@@ -128,7 +138,7 @@ describe("HttpManagerApiRepository", () => {
128
138
  // ignore the error in this test case
129
139
  });
130
140
 
131
- expect(networkSpy).toHaveBeenCalledWith({
141
+ expect(mockedNetwork).toHaveBeenCalledWith({
132
142
  method: "GET",
133
143
  url:
134
144
  "http://managerApiBase.com/get_device_version" +
@@ -139,7 +149,7 @@ describe("HttpManagerApiRepository", () => {
139
149
  });
140
150
 
141
151
  test("getDeviceVersion should throw a FirmwareNotRecognized error if status is 404", async () => {
142
- networkSpy.mockRejectedValue({
152
+ mockedNetwork.mockRejectedValue({
143
153
  status: 404,
144
154
  });
145
155
 
@@ -152,7 +162,7 @@ describe("HttpManagerApiRepository", () => {
152
162
  });
153
163
 
154
164
  test("getDeviceVersion should throw a FirmwareNotRecognized error if response.status is 404", async () => {
155
- networkSpy.mockRejectedValue({
165
+ mockedNetwork.mockRejectedValue({
156
166
  response: {
157
167
  status: 404,
158
168
  },
@@ -167,7 +177,7 @@ describe("HttpManagerApiRepository", () => {
167
177
  });
168
178
 
169
179
  test("getDeviceVersion should return data", async () => {
170
- networkSpy.mockResolvedValue({
180
+ mockedNetwork.mockResolvedValue({
171
181
  data: "mockedData",
172
182
  });
173
183
 
@@ -190,7 +200,7 @@ describe("HttpManagerApiRepository", () => {
190
200
  // ignore the error in this test case
191
201
  });
192
202
 
193
- expect(networkSpy).toHaveBeenCalledWith({
203
+ expect(mockedNetwork).toHaveBeenCalledWith({
194
204
  method: "GET",
195
205
  url:
196
206
  "http://managerApiBase.com/get_osu_version" +
@@ -202,7 +212,7 @@ describe("HttpManagerApiRepository", () => {
202
212
  });
203
213
 
204
214
  test("getCurrentOSU should return data", async () => {
205
- networkSpy.mockResolvedValue({
215
+ mockedNetwork.mockResolvedValue({
206
216
  data: "mockedData",
207
217
  });
208
218
 
@@ -226,7 +236,7 @@ describe("HttpManagerApiRepository", () => {
226
236
  // ignore the error in this test case
227
237
  });
228
238
 
229
- expect(networkSpy).toHaveBeenCalledWith({
239
+ expect(mockedNetwork).toHaveBeenCalledWith({
230
240
  method: "GET",
231
241
  url:
232
242
  "http://managerApiBase.com/get_firmware_version" +
@@ -238,7 +248,7 @@ describe("HttpManagerApiRepository", () => {
238
248
  });
239
249
 
240
250
  test("getCurrentFirmware should throw a FirmwareNotRecognized error if status is 404", async () => {
241
- networkSpy.mockRejectedValue({
251
+ mockedNetwork.mockRejectedValue({
242
252
  status: 404,
243
253
  });
244
254
 
@@ -252,7 +262,7 @@ describe("HttpManagerApiRepository", () => {
252
262
  });
253
263
 
254
264
  test("getCurrentFirmware should throw a FirmwareNotRecognized error if response.status is 404", async () => {
255
- networkSpy.mockRejectedValue({
265
+ mockedNetwork.mockRejectedValue({
256
266
  response: {
257
267
  status: 404,
258
268
  },
@@ -268,7 +278,7 @@ describe("HttpManagerApiRepository", () => {
268
278
  });
269
279
 
270
280
  test("getCurrentFirmware should return data", async () => {
271
- networkSpy.mockResolvedValue({
281
+ mockedNetwork.mockResolvedValue({
272
282
  data: "mockedData",
273
283
  });
274
284
 
@@ -286,14 +296,14 @@ describe("HttpManagerApiRepository", () => {
286
296
  // ignore the error in this test case
287
297
  });
288
298
 
289
- expect(networkSpy).toHaveBeenCalledWith({
299
+ expect(mockedNetwork).toHaveBeenCalledWith({
290
300
  method: "GET",
291
301
  url: "http://managerApiBase.com/firmware_final_versions/123?livecommonversion=1.2.3",
292
302
  });
293
303
  });
294
304
 
295
305
  test("getFinalFirmwareById should return data", async () => {
296
- networkSpy.mockResolvedValue({
306
+ mockedNetwork.mockResolvedValue({
297
307
  data: "mockedData",
298
308
  });
299
309
 
@@ -308,7 +318,7 @@ describe("HttpManagerApiRepository", () => {
308
318
  // ignore the error in this test case
309
319
  });
310
320
 
311
- expect(networkSpy).toHaveBeenCalledWith({
321
+ expect(mockedNetwork).toHaveBeenCalledWith({
312
322
  method: "POST",
313
323
  url: "http://managerApiBase.com/v2/apps/hash?livecommonversion=1.2.3",
314
324
  data: mockHashes,
@@ -316,7 +326,7 @@ describe("HttpManagerApiRepository", () => {
316
326
  });
317
327
 
318
328
  test("getAppsByHash should throw a NetworkDown error if data is null", async () => {
319
- networkSpy.mockResolvedValue({
329
+ mockedNetwork.mockResolvedValue({
320
330
  data: null,
321
331
  });
322
332
 
@@ -326,7 +336,7 @@ describe("HttpManagerApiRepository", () => {
326
336
  });
327
337
 
328
338
  test("getAppsByHash should throw a NetworkDown error if data is not an array", async () => {
329
- networkSpy.mockResolvedValue({
339
+ mockedNetwork.mockResolvedValue({
330
340
  data: "mockedData",
331
341
  });
332
342
 
@@ -336,7 +346,7 @@ describe("HttpManagerApiRepository", () => {
336
346
  });
337
347
 
338
348
  test("getAppsByHash should return data if it's an array", async () => {
339
- networkSpy.mockResolvedValue({
349
+ mockedNetwork.mockResolvedValue({
340
350
  data: ["mockedData"],
341
351
  });
342
352
 
@@ -356,14 +366,14 @@ describe("HttpManagerApiRepository", () => {
356
366
  // ignore the error in this test case
357
367
  });
358
368
 
359
- expect(networkSpy).toHaveBeenCalledWith({
369
+ expect(mockedNetwork).toHaveBeenCalledWith({
360
370
  method: "GET",
361
371
  url: "http://managerApiBase.com/v2/apps/by-target?livecommonversion=1.2.3&provider=12&target_id=123&firmware_version_name=mockedFirmwareVersion",
362
372
  });
363
373
  });
364
374
 
365
375
  test("catalogForDevice should throw a NetworkDown error if data is null", async () => {
366
- networkSpy.mockResolvedValue({
376
+ mockedNetwork.mockResolvedValue({
367
377
  data: null,
368
378
  });
369
379
 
@@ -377,7 +387,7 @@ describe("HttpManagerApiRepository", () => {
377
387
  });
378
388
 
379
389
  test("catalogForDevice should throw a NetworkDown error if data is not an array", async () => {
380
- networkSpy.mockResolvedValue({
390
+ mockedNetwork.mockResolvedValue({
381
391
  data: "mockedData",
382
392
  });
383
393
 
@@ -391,7 +401,7 @@ describe("HttpManagerApiRepository", () => {
391
401
  });
392
402
 
393
403
  test("catalogForDevice should return data if it's an array", async () => {
394
- networkSpy.mockResolvedValue({
404
+ mockedNetwork.mockResolvedValue({
395
405
  data: ["mockedData"],
396
406
  });
397
407
 
@@ -428,7 +438,7 @@ describe("HttpManagerApiRepository", () => {
428
438
  expect(getDeviceVersionSpy).toHaveBeenCalledWith({ targetId: 2, providerId: 12 });
429
439
  expect(getCurrentFirmwareSpy).toHaveBeenCalledWith({ deviceId: 4, providerId: 12, version: 1 });
430
440
 
431
- expect(networkSpy).toHaveBeenCalledWith({
441
+ expect(mockedNetwork).toHaveBeenCalledWith({
432
442
  method: "GET",
433
443
  url: "http://managerApiBase.com/language-package?livecommonversion=1.2.3",
434
444
  });
@@ -445,7 +455,7 @@ describe("HttpManagerApiRepository", () => {
445
455
  .spyOn(httpManagerApiRepository, "getCurrentFirmware")
446
456
  .mockReturnValue(Promise.resolve({ id: mockedCurrentFirmwareId } as FinalFirmware));
447
457
 
448
- networkSpy.mockResolvedValue({
458
+ mockedNetwork.mockResolvedValue({
449
459
  data: [
450
460
  {
451
461
  language: "french",