webcontainer-core
webcontainer-core copied to clipboard
Operation Unsupported in node crypto
Describe the bug
For reference, here is how we make use of the (node) built-in crypto library: https://github.com/tkhq/sdk/blob/89d9999757e004ce6f15ca5c91ea7378774c4ee2/packages/api-key-stamper/src/nodecrypto.ts#L11-L19. Note we use the jwk format. Also worth noting is that the following line const sign = crypto.createSign("SHA256"); is not working; (addressed separately, here)
Full error:
Error: Unsupported
at _0x2e6389.initJwk (https://github4gfbpg-gzqm.w-credentialless.staticblitz.com/blitz.7259293c.js:334:265251)
at getKeyObjectHandleFromJwk (https://github4gfbpg-gzqm.w-credentialless.staticblitz.com/blitz.7259293c.js:55:5635)
at prepareAsymmetricKey (https://github4gfbpg-gzqm.w-credentialless.staticblitz.com/blitz.7259293c.js:55:6368)
at Object.createPrivateKey (https://github4gfbpg-gzqm.w-credentialless.staticblitz.com/blitz.7259293c.js:55:8214)
at signWithApiKey (file:///home/projects/github-4gfbpg/packages/api-key-stamper/dist/nodecrypto.js:2:1238)
at ApiKeyStamper.stamp (file:///home/projects/github-4gfbpg/packages/api-key-stamper/dist/index.js:2:698)
at TurnkeyClient.request (file:///home/projects/github-4gfbpg/packages/http/dist/__generated__/services/coordinator/public/v1/public_api.client.js:2:11870)
at TurnkeyClient.getPrivateKey (file:///home/projects/github-4gfbpg/packages/http/dist/__generated__/services/coordinator/public/v1/public_api.client.js:2:1908)
at TurnkeySigner.getAddress (file:///home/projects/github-4gfbpg/packages/ethers/dist/index.js:2:1081)
at main (file:///home/projects/github-4gfbpg/examples/with-ethers/src/index.ts:2:2131)
Link to the blitz that caused the error
https://stackblitz.com/edit/github-4gfbpg?file=examples%2Fwith-ethers%2Fsrc%2Findex.ts
Steps to reproduce
- Create a Turnkey account via https://app.turnkey.com/dashboard/auth/initial
- Navigate to
examples/with-ethers - Create
.env.local(following.env.local.example) - Run
pnpm run start
Expected behavior
Expect the script to successfully run, leading to an output like: https://github.com/tkhq/sdk/tree/main/examples/with-ethers#3-running-the-scripts. Under the hood, the script/example should be using node crypto libraries to sign API requests.
Parity with Local
- [X] I have run the project in my local machine and I could not reproduce the issue.
Screenshots
No response
Platform
Browser name = Chrome
Full version = 115.0.0.0
Major version = 115
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
performance.memory = {
"totalJSHeapSize": 557092447,
"usedJSHeapSize": 537581587,
"jsHeapSizeLimit": 4294705152
}
Hash = 7259293c
Additional context
No response
hi! :wave: thanks for reporting this issue!
This API is not currently supported, I have created an issue in our tracker and will reply if there are further updates!
👋 Hi there, any updates on this? Thanks!
Hi there, just wanted to follow up on this again :) hope all is well