diff options
author | Matthew Miller <matthew@millerti.me> | 2020-07-28 18:13:57 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-07-28 18:13:57 -0700 |
commit | a457a4aaf930ded31ec9454e64ace95361c6477e (patch) | |
tree | 63bfb06d147cb118d79d89adf92608bd3d65b6b1 /packages/browser/src/helpers | |
parent | bc9ad0f68fc49c4ac23cd22428248faa26d3f9b6 (diff) |
Use TextEncoder to encode UTF-8 to a buffer
Diffstat (limited to 'packages/browser/src/helpers')
-rw-r--r-- | packages/browser/src/helpers/toUint8Array.ts | 4 |
1 files changed, 3 insertions, 1 deletions
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); } |