Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vanilla createSpace failed at nodejs v22 with error in SubtleCrypto #1591

Open
debuggingfuture opened this issue Nov 28, 2024 · 1 comment
Open

Comments

@debuggingfuture
Copy link

Running the hello world example at nodejs (v22), it fails with below error in downstream dependencies
Attached workaround with latest @noble/ed25519

error

import { create } from "@web3-storage/w3up-client";

const client = await create();
const space = await client.createSpace("my-awesome-space");
TypeError: Failed to execute 'digest' on 'SubtleCrypto': 2nd argument is not instance of ArrayBuffer, Buffer, TypedArray, or DataView.
 ❯ Object.sha512 ../../node_modules/.pnpm/@noble+ed25519@1.7.3/node_modules/@noble/ed25519/lib/esm/index.js:860:52
 ❯ getExtendedPublicKey ../../node_modules/.pnpm/@noble+ed25519@1.7.3/node_modules/@noble/ed25519/lib/esm/index.js:674:39
 ❯ Module.getPublicKey ../../node_modules/.pnpm/@noble+ed25519@1.7.3/node_modules/@noble/ed25519/lib/esm/index.js:680:19
 ❯ derive ../../node_modules/.pnpm/@ucanto+principal@9.0.1/node_modules/@ucanto/principal/src/ed25519/signer.js:42:35
 ❯ Module.generate ../../node_modules/.pnpm/@ucanto+principal@9.0.1/node_modules/@ucanto/principal/src/ed25519/signer.js:28:31
 ❯ Module.generate ../../node_modules/.pnpm/@web3-storage+access@20.1.0/node_modules/@web3-storage/access/src/space.js:26:36
  • environment: node v22, vitest
  • @web3-storage/w3up-client@16.5.1
  • @noble/ed25519@1.7.3
  • @ucanto/principal@9.0.1

workaround

import * as ed from "@noble/ed25519";
import { sha512 } from "@noble/hashes/sha512";
//@ts-ignore
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
@debuggingfuture
Copy link
Author

shall we apply workaround for now or iterate https://github.com/storacha/ucanto?

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

No branches or pull requests

1 participant