Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors thrown from getRandomValues in WebCrypto incompatible with current proposal #5

Open
rbuckton opened this issue Feb 6, 2020 · 0 comments

Comments

@rbuckton
Copy link
Collaborator

rbuckton commented Feb 6, 2020

We need to discuss error compatibility with the Web Cryptography API. The WebCrypto definition of getRandomValues specifies the following exceptions are thrown:

  1. If array is not of an integer type (i.e., Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array or Uint8ClampedArray), throw a TypeMismatchError and terminate the algorithm.

  2. If the byteLength of array is greater than 65536, throw a QuotaExceededError and terminate the algorithm.

The current proposal uses TypeError instead of TypeMismatchError and RangeError instead of QuotaExceededError, so as not to introduce new Error classes that have only one use in the spec. However, should #2 land this deviation could be considered a web-compat issue.

I am looking for suggestions to address this, either from TC39 members or from those involved with the WebCrypto specification.

Ideally, I would like to avoid redundancy (i.e. TypeMismatchError seems like a redundant form of TypeError), but I also do not want to break existing user code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant