From 15df785723dbd7f853feb8fa26464357e4fd7680 Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Tue, 19 Nov 2019 01:13:43 -0800 Subject: [PATCH] Use UTF-8 only TextEncoder polyfill --- lib/utils/serialize.js | 4 ++-- package.json | 2 +- src.ts/utils/serialize.ts | 4 ++-- yarn.lock | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/utils/serialize.js b/lib/utils/serialize.js index aa10bfa3b7..86ac78878e 100644 --- a/lib/utils/serialize.js +++ b/lib/utils/serialize.js @@ -19,11 +19,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); const bs58_1 = __importDefault(require("bs58")); const bn_js_1 = __importDefault(require("bn.js")); // TODO: Make sure this polyfill not included when not required -const encoding = __importStar(require("text-encoding")); +const encoding = __importStar(require("text-encoding-utf-8")); if (typeof global.TextDecoder !== 'function') { global.TextDecoder = encoding.TextDecoder; } -const textDecoder = new TextDecoder('utf8', { fatal: true }); +const textDecoder = new TextDecoder('utf-8', { fatal: true }); function base_encode(value) { if (typeof (value) === 'string') { value = Buffer.from(value, 'utf8'); diff --git a/package.json b/package.json index 6da4898a8d..49a1a2aace 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "http-errors": "^1.7.2", "js-sha256": "^0.9.0", "node-fetch": "^2.3.0", - "text-encoding": "^0.7.0", + "text-encoding-utf-8": "^1.0.2", "tweetnacl": "^1.0.1", "typescript": "^3.5.1" }, diff --git a/src.ts/utils/serialize.ts b/src.ts/utils/serialize.ts index 61122e991c..0f821bb0cd 100644 --- a/src.ts/utils/serialize.ts +++ b/src.ts/utils/serialize.ts @@ -4,12 +4,12 @@ import bs58 from 'bs58'; import BN from 'bn.js'; // TODO: Make sure this polyfill not included when not required -import * as encoding from 'text-encoding'; +import * as encoding from 'text-encoding-utf-8'; if (typeof (global as any).TextDecoder !== 'function') { (global as any).TextDecoder = encoding.TextDecoder; } -const textDecoder = new TextDecoder('utf8', { fatal: true }); +const textDecoder = new TextDecoder('utf-8', { fatal: true }); export function base_encode(value: Uint8Array | string): string { if (typeof(value) === 'string') { diff --git a/yarn.lock b/yarn.lock index b780d21d52..ab0fb81b1f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4561,10 +4561,10 @@ test-exclude@^5.2.3: read-pkg-up "^4.0.0" require-main-filename "^2.0.0" -text-encoding@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643" - integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA== +text-encoding-utf-8@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" + integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== text-table@^0.2.0: version "0.2.0"