-
Notifications
You must be signed in to change notification settings - Fork 130
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
Request: Support for non-node runtimes #223
Comments
hi 👋 there's a couple of things i notice here, but the main thing is that this function doesn't accept a node:buffer as an argument. it's a Uint8Array. perhaps you could test using something like |
ah, if you wish the result to be the same each time, you need to take away the randomness added by default by salting. you can do this like so: i'm not a Deno or Bun guy, but if Deno & Bun are producing consistent results, perhaps they are using a default saltLength = 0.
|
Hey! Thanks for the help. It seems that crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN is Updated Exampleimport Arweave from "arweave";
import { readFileSync } from "node:fs";
import crypto from "node:crypto";
async function test() {
const arweave = Arweave.init({});
const keyfile = JSON.parse(readFileSync("./keyfile.json").toString());
const sign = await arweave.crypto.sign(
keyfile,
new Uint8Array([1, 2, 3, 4]),
{ saltLength: -2 }
); // Explicit for bun
const result = [];
for (const i of sign.values()) {
result.push(i);
}
console.log(result);
}
test(); I'll try to narrow it down more, seems a bun/deno issue. |
I'm reopening this as I'd like to further investigate patching this. Supporting bun/deno would be nice! |
Cool I'll link the associated issues for tracking: |
I got it working by using the Bun supports Web Crypto, which doesn't seem to have the compat issues from their It seems these are the exports that Bun can use:
So, in theory it should be possible to tell Bun to use the Deno also supports Web Crypto, so I would assume this could also be a solution for Deno. |
Fantastic @kay-is ! I have a plan to switch everything over to webcrypto anyhow |
Hey @kay-is, |
Yes. The following defines a special browser export, but Bun ignores it because it isn't a browser. Line 7 in 29901f4
When I changed the following line to use Line 5 in 29901f4
|
Thanks for instant reply, @kay-is!
damn, I'm using Deno v2.1.5. Not sure how to configure it properly. Should I import Thank you for the assistance. Upd.
|
Not sure, but have you tried:
That file defines a global Arweave object, an esm default export, and a named Arweave export. |
it says:
I guess it's not just that simple with Deno for some reason... |
I'm thinking to extract our I would also like to see this library @ jsr.io as Deno/Bun library in the future. |
Just wanted to mention that this issue with bun should be fixed in a later release. If you want to open a separate issue for demo we can take a look at that @Nehoko |
There might be an issue not with your library at the first place. I'm trying to communicate with arlocal by your library: maybe there is something wrong with it. I'll investigate and let you know about the results (I think you might be interested). Upd. |
Currently,
arweave.crypto.sign()
returns different results in runtimes other than node like bun and deno.Minimum Reproducible Example
Node v21.6.0
(changes every time)Bun v1.0.26
(consistent)Deno v1.40.4
(consistent)A lot of downstream libraries seem to be using the crypto driver from this library
Including
warp-contracts/warp-arbundles
.This is creating a bit problem since trying to sign a bundled data item seems to fail on non-node runtimes.
Any help with regards to this issue will be appreciated.
The text was updated successfully, but these errors were encountered: