From 1a4c8ab2ab4bcb27b83b2be6d8d0fddaaa56ba50 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Thu, 15 Apr 2021 21:37:46 -0700 Subject: Convert assertion userHandle back to UTF-8 string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the opposite of how `user.id` is converted to an ArrayBuffer prior to being passed into `navigator.credentials.create()`, so when this value is returned to the RP in an assertion it will now look like the string value originally specified in attestation options, instead of the base64url-encoded version of that string “for some reason”. --- packages/browser/jest-environment.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'packages/browser/jest-environment.js') diff --git a/packages/browser/jest-environment.js b/packages/browser/jest-environment.js index c3a9135..3d33072 100644 --- a/packages/browser/jest-environment.js +++ b/packages/browser/jest-environment.js @@ -16,6 +16,14 @@ class CustomTestEnvironment extends Environment { const { TextEncoder } = require('util'); this.global.TextEncoder = TextEncoder; } + + /** + * Add support for TextDecoder to JSDOM + */ + if (typeof this.global.TextDecoder === 'undefined') { + const { TextDecoder } = require('util'); + this.global.TextDecoder = TextDecoder; + } } } -- cgit v1.2.3