I am trying to implement the ability to encrypt/decrypt values being stored in a Deno KV datastore.
Currently, if the source data is byte based (ArrayBuffer, typed array, DataView) this is relatively trivial. When trying to deal with out cloneable values this becomes difficult.
When cloning, V8 uses its ability to serailize and deserialize objects. The Deno runtime does provides this V8 capability through the non-public API Deno.core.serialize() and Deno.core.deserialize() but also provides it through the v8 node built-in polyfill, but neither of these are available on Deploy.
This makes it difficult to store arbitrary cloneable values in an encrypted format that works seamlessly between Deno runtime and Deploy.
Describe the solution you'd like
I would like Deploy to expose the V8 serialization functions in some fashion.
Describe alternatives you've considered
Using other user land serialization options that can handle arbitrary values. These are highly inefficient, both from a processing speed perspective but also the resulting size of the serialized object. Some experiments have shown between 10 and 100 times slower than using the V8 serialization APIs in Deno runtime.
Documentation, Adoption, Migration Strategy
Gaining parity with the Deno runtime would be effectively transparent migration. That being said, formalising Deno.core APIs in Deploy is likely not a good idea. Obviously a consistent API could be provided via node:v8 but again that does feel silly to create a direct dependency on node polyfills. The team should possibly consider formalizing the API was Deno.v8.serialize() and Deno.v8.deserialize() across both runtime and Deploy.
What problem are you trying to solve?
I am trying to implement the ability to encrypt/decrypt values being stored in a Deno KV datastore.
Currently, if the source data is byte based (
ArrayBuffer
, typed array,DataView
) this is relatively trivial. When trying to deal with out cloneable values this becomes difficult.When cloning, V8 uses its ability to serailize and deserialize objects. The Deno runtime does provides this V8 capability through the non-public API
Deno.core.serialize()
andDeno.core.deserialize()
but also provides it through the v8 node built-in polyfill, but neither of these are available on Deploy.This makes it difficult to store arbitrary cloneable values in an encrypted format that works seamlessly between Deno runtime and Deploy.
Describe the solution you'd like
I would like Deploy to expose the V8 serialization functions in some fashion.
Describe alternatives you've considered
Using other user land serialization options that can handle arbitrary values. These are highly inefficient, both from a processing speed perspective but also the resulting size of the serialized object. Some experiments have shown between 10 and 100 times slower than using the V8 serialization APIs in Deno runtime.
Documentation, Adoption, Migration Strategy
Gaining parity with the Deno runtime would be effectively transparent migration. That being said, formalising
Deno.core
APIs in Deploy is likely not a good idea. Obviously a consistent API could be provided vianode:v8
but again that does feel silly to create a direct dependency on node polyfills. The team should possibly consider formalizing the API wasDeno.v8.serialize()
andDeno.v8.deserialize()
across both runtime and Deploy.