Skip to content

feat: support Blob, File, CryptoKey, and DOMException in JSON utils - #11

Open
kitsonk wants to merge 1 commit into
denoland:mainfrom
kitsonk:feat-web-serialize
Open

feat: support Blob, File, CryptoKey, and DOMException in JSON utils#11
kitsonk wants to merge 1 commit into
denoland:mainfrom
kitsonk:feat-web-serialize

Conversation

@kitsonk

@kitsonk kitsonk commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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.

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.
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

Successfully merging this pull request may close these issues.

1 participant