paulmillr / noble-ed25519

Fastest 4KB JS implementation of ed25519 signatures
https://paulmillr.com/noble
MIT License
414 stars 50 forks source link

Deno import error #71

Closed caramboleyo closed 1 year ago

caramboleyo commented 1 year ago

As described here https://deno.land/x/ed25519@1.0.1

i just do a import * as ed from 'https://deno.land/x/ed25519/mod.ts'; resulting in this:

error: Relative import path "crypto" not prefixed with / or ./ or ../
    at https://deno.land/x/ed25519@1.7.1/index.ts:11:29

Looks like you try to import npm packages in deno but in index.ts you seem to know that deno has built in webcrypto support since you are doing crypto.subtle.digestSync('SHA-512'... Is this a bug?

EDIT: Also this: import { crypto } from 'https://deno.land/std@0.153.0/crypto/mod.ts'; is unnecessary, crypto.subtle works in deno out of the box, no import needed. But maybe thats a recent development.

paulmillr commented 1 year ago

Version 1.0.1 is not supported. Use the latest version.

caramboleyo commented 1 year ago

I am actually using the main branch from here and all i had to do is replace line 11 in index.ts with const nodeCrypto = null; and then import from index.ts directly.

paulmillr commented 1 year ago

If you are using main branch from here, you should have looked in the readme to understand how to make it run with Deno, without adjusting the code.

caramboleyo commented 1 year ago

@paulmillr this is an example how the deno guys make conditional imports: https://deno.land/std@0.160.0/path/mod.ts?source

(forget the import maps, they kinda break common deno usage)

EDIT: forget that, they also end up importing both posix and win32 on a linux system, so not conditional at all

paulmillr commented 1 year ago

we need to support all platforms, that includes node.js, node.js esm, webpack/rollup/browserify/react-native, deno, etc - so we got what we got here. Use import maps.