diff --git a/package.json b/package.json index 46e87b3..936a2b7 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "packageManager": "pnpm@7.17.0", "dependencies": { "bson": "^4.7.2", - "byte-base64": "^1.1.0", + "js-base64": "^3.7.5", "lodash.clonedeep": "^4.5.0", "lz4js": "^0.2.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9a6a0f..790d427 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,11 +17,11 @@ specifiers: "@typescript-eslint/eslint-plugin": ^5.55.0 "@typescript-eslint/parser": ^5.55.0 bson: ^4.7.2 - byte-base64: ^1.1.0 concurrently: ^7.6.0 eslint: ^8.36.0 husky: ^8.0.3 jest: ^29.5.0 + js-base64: ^3.7.5 lodash.clonedeep: ^4.5.0 lz4js: ^0.2.0 prettier: ^2.8.4 @@ -35,7 +35,7 @@ specifiers: dependencies: bson: 4.7.2 - byte-base64: 1.1.0 + js-base64: 3.7.5 lodash.clonedeep: 4.5.0 lz4js: 0.2.0 @@ -2649,13 +2649,6 @@ packages: engines: { node: ">=6" } dev: true - /byte-base64/1.1.0: - resolution: - { - integrity: sha512-56cXelkJrVMdCY9V/3RfDxTh4VfMFCQ5km7B7GkIGfo4bcPL9aACyJLB0Ms3Ezu5rsHmLB2suis96z4fLM03DA==, - } - dev: false - /callsites/3.1.0: resolution: { @@ -4942,6 +4935,13 @@ packages: - ts-node dev: true + /js-base64/3.7.5: + resolution: + { + integrity: sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA==, + } + dev: false + /js-sdsl/4.3.0: resolution: { diff --git a/src/parse.ts b/src/parse.ts index c5ff3ef..fabaef4 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -1,5 +1,5 @@ import { EJSON } from 'bson'; -import { base64ToBytes } from 'byte-base64'; +import { Base64 } from 'js-base64'; import { decompress } from 'lz4js'; export type ParseTypeGuardFunction = (obj: any) => obj is T; @@ -165,7 +165,7 @@ function unminifyKeys( export function decompressString(str: string): string { try { return new TextDecoder().decode( - Uint8Array.from(decompress(base64ToBytes(str))) + Uint8Array.from(decompress(Base64.toUint8Array(str))) ); } catch (err: unknown) { // str is not a base64 encoded string of a byte array diff --git a/src/stringify.ts b/src/stringify.ts index c255ad2..d3fc9bc 100644 --- a/src/stringify.ts +++ b/src/stringify.ts @@ -1,5 +1,5 @@ import { EJSON } from 'bson'; -import { bytesToBase64 } from 'byte-base64'; +import { Base64 } from 'js-base64'; import cloneDeep from 'lodash.clonedeep'; import { compress } from 'lz4js'; import { @@ -251,5 +251,7 @@ function minifyKeys( } export function compressString(str: string): string { - return bytesToBase64(compress(new TextEncoder().encode(str))); + return Base64.fromUint8Array( + compress(new TextEncoder().encode(str)) as Uint8Array + ); }