From b9cb80771f441a2a14360d6e5abeb60e94a067b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?txb=C3=AC?= <46839250+0xTxbi@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:58:57 +0100 Subject: [PATCH] chore(deps): Update `pdfmake` version to `0.2.15` (#15230) * fix(deps): update dependency pdfmake to v0.2.15 * fix usage in receipts * add mocks in tests --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .../v2/eventCasterController.test.ts | 16 ++++++++ .../controllers/v2/keyController.test.ts | 16 ++++++++ locksmith/package.json | 2 +- locksmith/src/utils/receipts.ts | 3 +- yarn.lock | 40 +++++++++++-------- 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/locksmith/__tests__/controllers/v2/eventCasterController.test.ts b/locksmith/__tests__/controllers/v2/eventCasterController.test.ts index abfcaf75c05..6006a4de26a 100644 --- a/locksmith/__tests__/controllers/v2/eventCasterController.test.ts +++ b/locksmith/__tests__/controllers/v2/eventCasterController.test.ts @@ -55,6 +55,22 @@ vi.mock('../../../src/worker/worker', () => ({ addJob: vi.fn().mockResolvedValue(Promise.resolve(true)), })) +// mock pdfmake +vi.mock('pdfmake/build/pdfmake', () => ({ + default: { + vfs: {}, + createPdf: vi.fn(), + }, +})) + +vi.mock('pdfmake/build/vfs_fonts', () => ({ + default: { + pdfMake: { + vfs: {}, + }, + }, +})) + // https://events.xyz/api/v1/event?event_id=195ede7f const eventCasterEvent = { contract: { diff --git a/locksmith/__tests__/controllers/v2/keyController.test.ts b/locksmith/__tests__/controllers/v2/keyController.test.ts index 570d03f8d6e..293b39eeb5c 100644 --- a/locksmith/__tests__/controllers/v2/keyController.test.ts +++ b/locksmith/__tests__/controllers/v2/keyController.test.ts @@ -3,6 +3,22 @@ import { loginRandomUser } from '../../test-helpers/utils' import app from '../../app' import { vi, expect } from 'vitest' +// mock pdfmake +vi.mock('pdfmake/build/pdfmake', () => ({ + default: { + vfs: {}, + createPdf: vi.fn(), + }, +})) + +vi.mock('pdfmake/build/vfs_fonts', () => ({ + default: { + pdfMake: { + vfs: {}, + }, + }, +})) + const lockAddress = '0x62CcB13A72E6F991dE53b9B7AC42885151588Cd2' const wrongLockAddress = '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' const network = 4 diff --git a/locksmith/package.json b/locksmith/package.json index 0c9c809c735..e9f8b246560 100644 --- a/locksmith/package.json +++ b/locksmith/package.json @@ -80,7 +80,7 @@ "p-retry": "6.2.1", "passkit-generator": "3.2.0", "path-to-regexp": "8.2.0", - "pdfmake": "0.2.14", + "pdfmake": "0.2.15", "pg": "8.13.1", "rate-limiter-flexible": "5.0.4", "react": "18.3.1", diff --git a/locksmith/src/utils/receipts.ts b/locksmith/src/utils/receipts.ts index a57698b85f7..e9d68a9833e 100644 --- a/locksmith/src/utils/receipts.ts +++ b/locksmith/src/utils/receipts.ts @@ -8,7 +8,8 @@ import { TDocumentDefinitions } from 'pdfmake/interfaces' import { Receipt, ReceiptBase } from '../models' import { getWeb3Service } from '../initializers' -pdfmake.vfs = pdfFonts.pdfMake.vfs +// @ts-ignore +pdfmake.vfs = pdfFonts.pdfMake ? pdfFonts.pdfMake.vfs : pdfFonts.vfs export const getAllReceipts = async ({ network, diff --git a/yarn.lock b/yarn.lock index 946980b6b2d..4ea7b056131 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6288,7 +6288,7 @@ __metadata: languageName: node linkType: hard -"@foliojs-fork/fontkit@npm:^1.9.1": +"@foliojs-fork/fontkit@npm:^1.9.2": version: 1.9.2 resolution: "@foliojs-fork/fontkit@npm:1.9.2" dependencies: @@ -6304,7 +6304,7 @@ __metadata: languageName: node linkType: hard -"@foliojs-fork/linebreak@npm:^1.1.1": +"@foliojs-fork/linebreak@npm:^1.1.1, @foliojs-fork/linebreak@npm:^1.1.2": version: 1.1.2 resolution: "@foliojs-fork/linebreak@npm:1.1.2" dependencies: @@ -6314,15 +6314,16 @@ __metadata: languageName: node linkType: hard -"@foliojs-fork/pdfkit@npm:^0.14.0": - version: 0.14.0 - resolution: "@foliojs-fork/pdfkit@npm:0.14.0" +"@foliojs-fork/pdfkit@npm:^0.15.1": + version: 0.15.1 + resolution: "@foliojs-fork/pdfkit@npm:0.15.1" dependencies: - "@foliojs-fork/fontkit": "npm:^1.9.1" + "@foliojs-fork/fontkit": "npm:^1.9.2" "@foliojs-fork/linebreak": "npm:^1.1.1" crypto-js: "npm:^4.2.0" + jpeg-exif: "npm:^1.1.4" png-js: "npm:^1.0.0" - checksum: 10/d0670a3510287376dedd72deddd2980b8c2394685c5ec057afc35148987befb5a45a99bc07942dcd5fe4044933caeba028e169dfc562bf69848fb9d8d33e49c6 + checksum: 10/00c9cfbbde97a0c2d0cfd4521df55106683f2561eba1253d10e5d790af38ed6fe141fa333ef245f6386f65adb26e9839102cde09f4a106b0920c543259733a1d languageName: node linkType: hard @@ -18383,7 +18384,7 @@ __metadata: parse-data-uri: "npm:0.2.0" passkit-generator: "npm:3.2.0" path-to-regexp: "npm:8.2.0" - pdfmake: "npm:0.2.14" + pdfmake: "npm:0.2.15" pg: "npm:8.13.1" rate-limiter-flexible: "npm:5.0.4" react: "npm:18.3.1" @@ -34574,6 +34575,13 @@ __metadata: languageName: node linkType: hard +"jpeg-exif@npm:^1.1.4": + version: 1.1.4 + resolution: "jpeg-exif@npm:1.1.4" + checksum: 10/75699bd7161de1be99e847166917957bfb405ed736655361c58f0390e7182cc28999b2cbc31e650b71b6d2ad38843789439a121ac64988b2ccaa00f6832bb3d9 + languageName: node + linkType: hard + "js-beautify@npm:^1.14.5": version: 1.15.1 resolution: "js-beautify@npm:1.15.1" @@ -41367,15 +41375,15 @@ __metadata: languageName: node linkType: hard -"pdfmake@npm:0.2.14": - version: 0.2.14 - resolution: "pdfmake@npm:0.2.14" +"pdfmake@npm:0.2.15": + version: 0.2.15 + resolution: "pdfmake@npm:0.2.15" dependencies: - "@foliojs-fork/linebreak": "npm:^1.1.1" - "@foliojs-fork/pdfkit": "npm:^0.14.0" + "@foliojs-fork/linebreak": "npm:^1.1.2" + "@foliojs-fork/pdfkit": "npm:^0.15.1" iconv-lite: "npm:^0.6.3" - xmldoc: "npm:^1.1.2" - checksum: 10/28cff311198fc464e25ff7110bc07ef5e990288fa2b3f2d1442a91d198eb2ea36d595c2a5d5c9a368c43106020c55899cb71d6bd418a5461206fab0a5768ed23 + xmldoc: "npm:^1.3.0" + checksum: 10/f279f3829684857e100485cc10740806c4c0c296d531fc1aef1e0f571ec306f30e29b000eb6c514c09a340ff151528757cb215b9f8fcd0dfe601cf2ed9123c2d languageName: node linkType: hard @@ -52404,7 +52412,7 @@ __metadata: languageName: node linkType: hard -"xmldoc@npm:^1.1.2": +"xmldoc@npm:^1.3.0": version: 1.3.0 resolution: "xmldoc@npm:1.3.0" dependencies: