I am trying to create a WebWorker, and pass a CryptoKey to it. The idea is that the Web Worker should not be able to extract the key, so I generate the key with extractable === false. However, trying to pass a clone of a CryptoKey fails.
CryptoKey objects can be stored using the structured clone algorithm, meaning that you can store and retrieve them using standard web storage APIs. The specification expects that most developers will use the IndexedDB API to store CryptoKey objects.
Here is a small snippet that demonstrates the problem. After calling structuredClone an empty object is returned.
I am trying to create a WebWorker, and pass a CryptoKey to it. The idea is that the Web Worker should not be able to extract the key, so I generate the key with
extractable === false
. However, trying to pass a clone of a CryptoKey fails.According to the MDN, this should be possible.
Here is a small snippet that demonstrates the problem. After calling
structuredClone
an empty object is returned.