From adb6408428cf800017412c8391d19dde4d5bdfc2 Mon Sep 17 00:00:00 2001 From: NI Date: Sun, 15 Sep 2019 07:42:58 +0800 Subject: [PATCH] Well it turned out, TextEncoder does NOT accept encoding label --- ui/app.js | 2 +- ui/commands/ssh.js | 4 ++-- ui/control/ssh.js | 2 +- ui/socket.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/app.js b/ui/app.js index d13d676..2588a1f 100644 --- a/ui/app.js +++ b/ui/app.js @@ -116,7 +116,7 @@ function startApp(rootEl) { return this.authErr.length > 0 || this.loadErr.length > 0; }, async getSocketAuthKey(privateKey, randomKey) { - const enc = new TextEncoder("utf-8"); + const enc = new TextEncoder(); return new Uint8Array( await cipher.hmac512(enc.encode(privateKey), enc.encode(randomKey)) diff --git a/ui/commands/ssh.js b/ui/commands/ssh.js index f6be139..c30db00 100644 --- a/ui/commands/ssh.js +++ b/ui/commands/ssh.js @@ -752,7 +752,7 @@ class Wizard { if (config.credential.length > 0) { sd.send( CLIENT_CONNECT_RESPOND_CREDENTIAL, - new TextEncoder("utf-8").encode(config.credential) + new TextEncoder().encode(config.credential) ); return this.stepContinueWaitForEstablishWait(); @@ -782,7 +782,7 @@ class Wizard { sd.send( CLIENT_CONNECT_RESPOND_CREDENTIAL, - new TextEncoder("utf-8").encode(vv) + new TextEncoder().encode(vv) ); newCredential(vv); diff --git a/ui/control/ssh.js b/ui/control/ssh.js index 9ff320b..beb3004 100644 --- a/ui/control/ssh.js +++ b/ui/control/ssh.js @@ -91,7 +91,7 @@ class Control { return; } - return this.sender(new TextEncoder("utf-8").encode(data)); + return this.sender(new TextEncoder().encode(data)); } color() { diff --git a/ui/socket.js b/ui/socket.js index 74ba284..96faaa3 100644 --- a/ui/socket.js +++ b/ui/socket.js @@ -97,7 +97,7 @@ class Dial { * */ async buildKeyString() { - const enc = new TextEncoder("utf-8"); + const enc = new TextEncoder(); let rTime = Number(Math.trunc(new Date().getTime() / 100000)), key = await crypt.hmac512(