You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I naively replaced new TextDecoder(data).decode() with uint8ArrayToString(data), in hopes of making use of the decoder cache and keeping my code concise and consistent (i.e. always use the library's decoder or always my own, not mix and match).
However, I immediately ran into an error:
error: Uncaught (in promise) TypeError: Expected `Uint8Array`, got `object
This was caused by the fact that data was not a Uint8Array but rather an ArrayBuffer, as returned by the Web Crypto API encrypt() / decrypt() methods.
Given the function name, I suppose I should've anticipated this, but because TextDecoder handles ArrayBuffers, I thought it would be fine.
How necessary is the assertion in that function? Maybe there could be a new method or option for bypassing that assertion?
The text was updated successfully, but these errors were encountered:
sholladay
changed the title
uint8ArrayToString is too strict
Allow ArrayBuffer in uint8ArrayToString or add a similar method
Jul 16, 2024
sholladay
changed the title
Allow ArrayBuffer in uint8ArrayToString or add a similar method
Allow ArrayBuffer in uint8ArrayToString() or add a similar method
Jul 16, 2024
I naively replaced
new TextDecoder(data).decode()
withuint8ArrayToString(data)
, in hopes of making use of the decoder cache and keeping my code concise and consistent (i.e. always use the library's decoder or always my own, not mix and match).However, I immediately ran into an error:
This was caused by the fact that
data
was not aUint8Array
but rather anArrayBuffer
, as returned by the Web Crypto APIencrypt()
/decrypt()
methods.Given the function name, I suppose I should've anticipated this, but because
TextDecoder
handlesArrayBuffer
s, I thought it would be fine.How necessary is the assertion in that function? Maybe there could be a new method or option for bypassing that assertion?
The text was updated successfully, but these errors were encountered: