Abusing prototype CryptoKey in `node:crypto`
Is there any way that I can set the prototype of an object to specifically
CryptoKey as defined by node:crypto? I am trying to get around some nasty instanceof check in a third-party library which is getting in the way.
The above gives me this error:
3 Replies
I also tried just
..., krypto.webcrypto.CryptoKey) but it's still undefined obviously and i'm not quite sure why
I'm basically trying to get the type as found in [npm]/@types/node/18.11.18/crypto.d.ts:
Actually, looking back at how I even got here makes me question why I'm even doing it, because I'm calling krypto.webcrypto.subtle.importKey and then the return value of that should already be krypto.webcrypto.CryptoKey but this third-party library code does instanceof CryptoKey and says it's "a different" CryptoKey
And so does krypto.KeyObject.from:
In this case, I suspect we're not actually exporting the CryptoKey prototype from the node:crypto polyfill which is probably a bug. We do export
CryptoKey in the global namespace -- does this work?
oof, sorry, didn't see your message until now! the whole problem is no more tbh, not exactly sure why, but if it pops back up, i will make sure to give that a try. (but i'm like 90% sure i tried it before and it failed!)