feat: support Blob, File, CryptoKey, and DOMException in JSON utils - #11
Open
kitsonk wants to merge 1 commit into
Open
feat: support Blob, File, CryptoKey, and DOMException in JSON utils#11kitsonk wants to merge 1 commit into
kitsonk wants to merge 1 commit into
Conversation
Deno 2.8.1 added support for serializing and deserializing several web objects via Deno KV: Blob, File, CryptoKey, and DOMException. Since reading a Blob/File and exporting a CryptoKey are inherently asynchronous, new *Async variants are added alongside the existing sync API: - valueToJSONAsync / toValueAsync - entryToJSONAsync / entryMaybeToJSONAsync - toEntryAsync / toEntryMaybeAsync The sync valueToJSON / toValue functions throw a TypeError when given a Blob, File, or CryptoKey, and continue to round-trip DOMException. CryptoKey serialization uses crypto.subtle.exportKey with the format chosen from key.type (public -> spki, private -> pkcs8, secret -> raw); non-extractable keys surface the underlying DOMException from exportKey unchanged. exportEntries and importEntries are switched to the async variants internally so they transparently handle the new types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Deno 2.8.1 added support for serializing and deserializing several web objects via Deno KV:
Blob,File,CryptoKey, andDOMException. Since reading aBlob/Fileand exporting aCryptoKeyare inherently asynchronous, new*Asyncvariants are added alongside the existing sync API:valueToJSONAsync/toValueAsyncentryToJSONAsync/entryMaybeToJSONAsynctoEntryAsync/toEntryMaybeAsyncThe sync
valueToJSON/toValuefunctions throw aTypeErrorwhen given aBlob,File, orCryptoKey, and continue to round-tripDOMException.CryptoKeyserialization usescrypto.subtle.exportKeywith the format chosen fromkey.type(public->spki,private->pkcs8,secret->raw); non-extractable keys surface the underlyingDOMExceptionfromexportKeyunchanged.exportEntriesandimportEntriesare switched to the async variants internally so they transparently handle the new types.