From a457a4aaf930ded31ec9454e64ace95361c6477e Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Tue, 28 Jul 2020 18:13:57 -0700 Subject: Use TextEncoder to encode UTF-8 to a buffer --- packages/browser/src/helpers/toUint8Array.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'packages/browser/src') diff --git a/packages/browser/src/helpers/toUint8Array.ts b/packages/browser/src/helpers/toUint8Array.ts index ed4aa5d..1855dd7 100644 --- a/packages/browser/src/helpers/toUint8Array.ts +++ b/packages/browser/src/helpers/toUint8Array.ts @@ -1,7 +1,9 @@ +const utf8Encoder = new TextEncoder(); + /** * A helper method to convert an arbitrary string sent from the server to a Uint8Array the * authenticator will expect. */ export default function toUint8Array(value: string): Uint8Array { - return Uint8Array.from(value, c => c.charCodeAt(0)); + return utf8Encoder.encode(value); } -- cgit v1.2.3