From 9e4e2794cdc9f71454f62c4b90a191c8f91fe191 Mon Sep 17 00:00:00 2001 From: Corentin Mors Date: Tue, 14 May 2024 10:01:49 +0200 Subject: [PATCH] Fix tests --- package.json | 2 +- src/modules/crypto/decrypt.ts | 6 +-- src/modules/crypto/encrypt.ts | 6 +-- src/modules/crypto/test.ts | 8 ++-- yarn.lock | 75 +++++++++++++++-------------------- 5 files changed, 42 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index ed062cac..f4467ff0 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "@yao-pkg/pkg": "^5.11.5", - "chai": "^4.4.1", + "chai": "^5.1.1", "esbuild": "^0.21.2", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", diff --git a/src/modules/crypto/decrypt.ts b/src/modules/crypto/decrypt.ts index 6cf631cd..27337f62 100644 --- a/src/modules/crypto/decrypt.ts +++ b/src/modules/crypto/decrypt.ts @@ -1,12 +1,12 @@ import * as argon2 from '@node-rs/argon2'; import winston from 'winston'; import * as xmlJs from 'xml-js'; -import * as crypto from 'crypto'; +import crypto from 'crypto'; import { promisify } from 'util'; import zlib from 'zlib'; import { CipherData, EncryptedData } from './types'; -import { hmacSha256, sha512 } from './hash'; -import { deserializeEncryptedData } from './encryptedDataDeserialization'; +import { hmacSha256, sha512 } from './hash.js'; +import { deserializeEncryptedData } from './encryptedDataDeserialization.js'; import { BackupEditTransaction, LocalConfiguration, SymmetricKeyGetter } from '../../types'; interface DecryptAesCbcHmac256Params { diff --git a/src/modules/crypto/encrypt.ts b/src/modules/crypto/encrypt.ts index d60cab27..6c62cd66 100644 --- a/src/modules/crypto/encrypt.ts +++ b/src/modules/crypto/encrypt.ts @@ -1,6 +1,6 @@ -import * as crypto from 'crypto'; -import { serializeEncryptedData } from './encryptedDataSerialization'; -import { hmacSha256, sha512 } from './hash'; +import crypto from 'crypto'; +import { serializeEncryptedData } from './encryptedDataSerialization.js'; +import { hmacSha256, sha512 } from './hash.js'; import { EncryptedData } from './types'; export const encryptAesCbcHmac256 = (originalKey: Buffer, content: Buffer): string => { diff --git a/src/modules/crypto/test.ts b/src/modules/crypto/test.ts index 5ee449e1..07bb5460 100644 --- a/src/modules/crypto/test.ts +++ b/src/modules/crypto/test.ts @@ -1,8 +1,8 @@ import { assert } from 'chai'; -import * as crypto from 'crypto'; -import { decrypt } from './decrypt'; -import { encryptAesCbcHmac256 } from './encrypt'; -import { deserializeEncryptedData } from './encryptedDataDeserialization'; +import crypto from 'crypto'; +import { decrypt } from './decrypt.js'; +import { encryptAesCbcHmac256 } from './encrypt.js'; +import { deserializeEncryptedData } from './encryptedDataDeserialization.js'; describe('Encrypt and decrypt using random symmetric key', () => { it('ciphering params parsed after encryption are correct', () => { diff --git a/yarn.lock b/yarn.lock index f5c469f2..97cce017 100644 --- a/yarn.lock +++ b/yarn.lock @@ -147,7 +147,7 @@ __metadata: "@typescript-eslint/parser": "npm:^7.8.0" "@yao-pkg/pkg": "npm:^5.11.5" better-sqlite3: "npm:^10.0.0" - chai: "npm:^4.4.1" + chai: "npm:^5.1.1" commander: "npm:^12.0.0" esbuild: "npm:^0.21.2" eslint: "npm:^8.57.0" @@ -1692,10 +1692,10 @@ __metadata: languageName: node linkType: hard -"assertion-error@npm:^1.1.0": - version: 1.1.0 - resolution: "assertion-error@npm:1.1.0" - checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf +"assertion-error@npm:^2.0.1": + version: 2.0.1 + resolution: "assertion-error@npm:2.0.1" + checksum: a0789dd882211b87116e81e2648ccb7f60340b34f19877dd020b39ebb4714e475eb943e14ba3e22201c221ef6645b7bfe10297e76b6ac95b48a9898c1211ce66 languageName: node linkType: hard @@ -1896,18 +1896,16 @@ __metadata: languageName: node linkType: hard -"chai@npm:^4.4.1": - version: 4.4.1 - resolution: "chai@npm:4.4.1" +"chai@npm:^5.1.1": + version: 5.1.1 + resolution: "chai@npm:5.1.1" dependencies: - assertion-error: "npm:^1.1.0" - check-error: "npm:^1.0.3" - deep-eql: "npm:^4.1.3" - get-func-name: "npm:^2.0.2" - loupe: "npm:^2.3.6" - pathval: "npm:^1.1.1" - type-detect: "npm:^4.0.8" - checksum: c6d7aba913a67529c68dbec3673f94eb9c586c5474cc5142bd0b587c9c9ec9e5fbaa937e038ecaa6475aea31433752d5fabdd033b9248bde6ae53befcde774ae + assertion-error: "npm:^2.0.1" + check-error: "npm:^2.1.1" + deep-eql: "npm:^5.0.1" + loupe: "npm:^3.1.0" + pathval: "npm:^2.0.0" + checksum: ee67279a5613bd36dc1dc13660042429ae2f1dc5a9030a6abcf381345866dfb5bce7bc10b9d74c8de86b6f656489f654bbbef3f3361e06925591e6a00c72afff languageName: node linkType: hard @@ -1953,12 +1951,10 @@ __metadata: languageName: node linkType: hard -"check-error@npm:^1.0.3": - version: 1.0.3 - resolution: "check-error@npm:1.0.3" - dependencies: - get-func-name: "npm:^2.0.2" - checksum: e2131025cf059b21080f4813e55b3c480419256914601750b0fee3bd9b2b8315b531e551ef12560419b8b6d92a3636511322752b1ce905703239e7cc451b6399 +"check-error@npm:^2.1.1": + version: 2.1.1 + resolution: "check-error@npm:2.1.1" + checksum: d785ed17b1d4a4796b6e75c765a9a290098cf52ff9728ce0756e8ffd4293d2e419dd30c67200aee34202463b474306913f2fcfaf1890641026d9fc6966fea27a languageName: node linkType: hard @@ -2222,12 +2218,10 @@ __metadata: languageName: node linkType: hard -"deep-eql@npm:^4.1.3": - version: 4.1.3 - resolution: "deep-eql@npm:4.1.3" - dependencies: - type-detect: "npm:^4.0.0" - checksum: 12ce93ae63de187e77b076d3d51bfc28b11f98910a22c18714cce112791195e86a94f97788180994614b14562a86c9763f67c69f785e4586f806b5df39bf9301 +"deep-eql@npm:^5.0.1": + version: 5.0.1 + resolution: "deep-eql@npm:5.0.1" + checksum: f8846820213462cdca23700873810c8bc01263dcc6a1e0f8694964b64f48a6dcb1f323ef7bb8678b15553f4b82420eda19092d4ae2e2709c56af7ea77bd8e6ab languageName: node linkType: hard @@ -3080,7 +3074,7 @@ __metadata: languageName: node linkType: hard -"get-func-name@npm:^2.0.1, get-func-name@npm:^2.0.2": +"get-func-name@npm:^2.0.1": version: 2.0.2 resolution: "get-func-name@npm:2.0.2" checksum: 3f62f4c23647de9d46e6f76d2b3eafe58933a9b3830c60669e4180d6c601ce1b4aa310ba8366143f55e52b139f992087a9f0647274e8745621fa2af7e0acf13b @@ -4028,12 +4022,12 @@ __metadata: languageName: node linkType: hard -"loupe@npm:^2.3.6": - version: 2.3.7 - resolution: "loupe@npm:2.3.7" +"loupe@npm:^3.1.0": + version: 3.1.1 + resolution: "loupe@npm:3.1.1" dependencies: get-func-name: "npm:^2.0.1" - checksum: 635c8f0914c2ce7ecfe4e239fbaf0ce1d2c00e4246fafcc4ed000bfdb1b8f89d05db1a220054175cca631ebf3894872a26fffba0124477fcb562f78762848fb1 + checksum: 56d71d64c5af109aaf2b5343668ea5952eed468ed2ff837373810e417bf8331f14491c6e4d38e08ff84a29cb18906e06e58ba660c53bd00f2989e1873fa2f54c languageName: node linkType: hard @@ -4725,10 +4719,10 @@ __metadata: languageName: node linkType: hard -"pathval@npm:^1.1.1": - version: 1.1.1 - resolution: "pathval@npm:1.1.1" - checksum: b50a4751068aa3a5428f5a0b480deecedc6f537666a3630a0c2ae2d5e7c0f4bf0ee77b48404441ec1220bef0c91625e6030b3d3cf5a32ab0d9764018d1d9dbb6 +"pathval@npm:^2.0.0": + version: 2.0.0 + resolution: "pathval@npm:2.0.0" + checksum: b91575bf9cdf01757afd7b5e521eb8a0b874a49bc972d08e0047cfea0cd3c019f5614521d4bc83d2855e3fcc331db6817dfd533dd8f3d90b16bc76fad2450fc1 languageName: node linkType: hard @@ -5661,13 +5655,6 @@ __metadata: languageName: node linkType: hard -"type-detect@npm:^4.0.0, type-detect@npm:^4.0.8": - version: 4.0.8 - resolution: "type-detect@npm:4.0.8" - checksum: 5179e3b8ebc51fce1b13efb75fdea4595484433f9683bbc2dca6d99789dba4e602ab7922d2656f2ce8383987467f7770131d4a7f06a26287db0615d2f4c4ce7d - languageName: node - linkType: hard - "type-fest@npm:^0.20.2": version: 0.20.2 resolution: "type-fest@npm:0.20.2"