diff --git a/plugin/package-lock.json b/plugin/package-lock.json index e0970e56..3b2792a2 100644 --- a/plugin/package-lock.json +++ b/plugin/package-lock.json @@ -12,6 +12,7 @@ "@types/jest": "^29.5.14", "@types/node": "^16.11.6", "builtin-modules": "3.3.0", + "byte-base64": "^1.1.0", "css-loader": "^7.1.2", "date-fns": "^4.1.0", "dayjs": "^1.11.13", @@ -3209,6 +3210,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/byte-base64": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/byte-base64/-/byte-base64-1.1.0.tgz", + "integrity": "sha512-56cXelkJrVMdCY9V/3RfDxTh4VfMFCQ5km7B7GkIGfo4bcPL9aACyJLB0Ms3Ezu5rsHmLB2suis96z4fLM03DA==", + "dev": true, + "license": "MIT" + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", diff --git a/plugin/package.json b/plugin/package.json index 474bb233..7e977562 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -23,6 +23,7 @@ "@types/jest": "^29.5.14", "@types/node": "^16.11.6", "builtin-modules": "3.3.0", + "byte-base64": "^1.1.0", "css-loader": "^7.1.2", "date-fns": "^4.1.0", "dayjs": "^1.11.13", diff --git a/plugin/src/utils/deserialize.ts b/plugin/src/utils/deserialize.ts index c02e18f2..4255479f 100644 --- a/plugin/src/utils/deserialize.ts +++ b/plugin/src/utils/deserialize.ts @@ -1,3 +1,5 @@ +import { base64ToBytes } from "byte-base64"; + export function deserialize(data: string): Uint8Array { - return Buffer.from(data, "base64"); + return base64ToBytes(data); } diff --git a/plugin/src/utils/serialize.ts b/plugin/src/utils/serialize.ts index be9a9abc..79eedaab 100644 --- a/plugin/src/utils/serialize.ts +++ b/plugin/src/utils/serialize.ts @@ -1,3 +1,5 @@ +import { bytesToBase64 } from "byte-base64"; + export function serialize(data: Uint8Array): string { - return Buffer.from(data).toString("base64"); + return bytesToBase64(data); }