Upgrade project to Deno v2.4 #717
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors @simplewebauthn/browser and @simplewebauthn/server to support use in Deno projects running Deno v2.2+.
Deno v2.2 launched with TypeScript 5.7. In this version of TypeScript,
Uint8Arraywas made generic, to be of typeUint8Array<ArrayBufferLike>. Existing values typed simply asUint8Arraynow needed to be refactored to specify the type of their array buffer:Before
After
Unfortunately "simply refactoring all instances of Uint8Array" to specify a buffer type would break the code in Deno v2.1 and earlier where Uint8Array is not generic.
To support both runtimes, I took a page out of Deno's handbook and defined a new
Uint8Array_type instead. This type is equivalent to non-genericUint8Arrayin Deno v2.1 and earlier, and equivalent toUint8Array<ArrayBuffer>in Deno v2.2 and beyond.I'm not entirely happy with how this bit of Deno runtime changes gets exposed in the public API of the project. I'm keeping my fingers crossed that it'll be transparent to most everyone. A more succinct copy of all of the context above has been included in the docstring for
Uint8Array_for those who go digging.