From a4b3f97c97e1c143a60afe75e00ff56c0ee2900b Mon Sep 17 00:00:00 2001 From: Mark Bumiller Date: Mon, 18 Mar 2024 07:00:39 -0400 Subject: [PATCH] moving from zlib to minizlib --- lib/utils/miam.test.ts | 2 +- lib/utils/miam.ts | 7 +++++-- package.json | 6 ++++-- yarn.lock | 32 +++++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/lib/utils/miam.test.ts b/lib/utils/miam.test.ts index 62e2b46..266e2a3 100644 --- a/lib/utils/miam.test.ts +++ b/lib/utils/miam.test.ts @@ -59,5 +59,5 @@ test('v1, compressed, acars, incomplete', () => { expect(decodeResult.message.data.acars.label).toBe('H1'); expect(decodeResult.message.data.acars.sublabel).toBe('DF'); expect(decodeResult.message.data.acars.mfi).toBe(undefined); - expect(decodeResult.message.data.acars.text).toBe(undefined); + expect(decodeResult.message.data.acars.text).toBe('A350,000130,1,1,TB000000/REP019,24,02;H01,019,24,02,6400,00175,B-18910,3,0,03,11,19,08,07,01,070/H02,NZAA YBBN,CAL054 ,S'); }) diff --git a/lib/utils/miam.ts b/lib/utils/miam.ts index c97b0c2..0e541c2 100644 --- a/lib/utils/miam.ts +++ b/lib/utils/miam.ts @@ -1,5 +1,5 @@ import * as Base85 from 'base85'; -import * as Zlib from 'zlib'; +import * as zlib from "minizlib"; enum MIAMFid { SingleTransfer = 'T', @@ -398,7 +398,10 @@ export class MIAMCoreUtils { if (body !== undefined && body.length > 0) { if ([MIAMCoreV1Compression.Deflate, MIAMCoreV2Compression.Deflate].indexOf(pduCompression) >= 0) { try { - pduData = Zlib.inflateRawSync(body, { windowBits: 15 }); + const decompress = new zlib.InflateRaw({windowBits: 15}); + decompress.write(body); + decompress.flush(zlib.constants.Z_SYNC_FLUSH); + pduData = decompress.read(); } catch (e) { pduErrors.push('Inflation failed for body: ' + e); } diff --git a/package.json b/package.json index 177ed61..eb7ef48 100644 --- a/package.json +++ b/package.json @@ -27,14 +27,16 @@ "author": "Kevin Elliott ", "license": "UNLICENSED", "dependencies": { - "@types/node": "^20.11.20", - "base85": "^3.1.0" + "@types/node": "^20.11.28", + "base85": "^3.1.0", + "minizlib": "^2.1.2" }, "devDependencies": { "@babel/core": "^7.18.13", "@babel/preset-env": "^7.18.10", "@babel/preset-typescript": "^7.18.6", "@types/jest": "^28.1.7", + "@types/minizlib": "^2.1.7", "babel-jest": "^29.7.0", "jest": "^28.1.3", "ts-jest": "^28.0.8", diff --git a/yarn.lock b/yarn.lock index 65ebe7f..84f4ffa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1630,13 +1630,28 @@ expect "^28.0.0" pretty-format "^28.0.0" -"@types/node@*", "@types/node@^20.11.20": +"@types/minizlib@^2.1.7": + version "2.1.7" + resolved "https://registry.yarnpkg.com/@types/minizlib/-/minizlib-2.1.7.tgz#7223874a8f31754a0d801cb194429b56e5ffcfaa" + integrity sha512-oKlyUX7bfj3zG6AM8rMleBHnr1X+gEx4XlQ5zByKS39gbtQmnu4nyQ3w2Agv7qinU+v8ChhFxtDUAySkCexQ+Q== + dependencies: + "@types/node" "*" + minipass "^3.3.5" + +"@types/node@*": version "20.11.25" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.25.tgz#0f50d62f274e54dd7a49f7704cc16bfbcccaf49f" integrity sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw== dependencies: undici-types "~5.26.4" +"@types/node@^20.11.28": + version "20.11.28" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.28.tgz#4fd5b2daff2e580c12316e457473d68f15ee6f66" + integrity sha512-M/GPWVS2wLkSkNHVeLkrF2fD5Lx5UC4PxA0uZcKc6QqbIQUJyW1jVjueJYi1z8n0I5PxYrtpnPnWglE+y9A0KA== + dependencies: + undici-types "~5.26.4" + "@types/prettier@^2.1.5": version "2.7.3" resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f" @@ -3150,11 +3165,26 @@ minimatch@^9.0.1: dependencies: brace-expansion "^2.0.1" +minipass@^3.0.0, minipass@^3.3.5: + version "3.3.6" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.6.tgz#7bba384db3a1520d18c9c0e5251c3444e95dd94a" + integrity sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw== + dependencies: + yallist "^4.0.0" + "minipass@^5.0.0 || ^6.0.2 || ^7.0.0": version "7.0.4" resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== +minizlib@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" + integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== + dependencies: + minipass "^3.0.0" + yallist "^4.0.0" + ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"