vawogbemi / moneytalks

email address with a forwarding config that bounces everything without a TipLink above some threshold
1 stars 0 forks source link

libsodium in cloudflare worker #1

Open vawogbemi opened 1 year ago

vawogbemi commented 1 year ago

Was getting "TypeError: Cannot read properties of undefined (reading 'href')" in logs and eventually isolated it to the libsodium package that Tiplink uses to decrypt link into keypair because of the way cloudflare workers work.

Was able to fix that error through: https://github.com/jedisct1/libsodium.js/issues/212

ended up blocked at

image

but couldn't find a solution so just considering another way to decrypt

wisefool769 commented 1 year ago

what do your deps look like? You need the "sumo" version of libsodium (https://www.npmjs.com/package/libsodium-wrappers-sumo). See this question that looks like your error: https://stackoverflow.com/questions/65194012/trying-to-use-libsodium-with-web-worker-error-typeerror-sodium-crypto-pwhash-is

vawogbemi commented 1 year ago

@wisefool769 hey

libsodium-sumo is in the package.json so I don't think that's the issue.

https://github.com/vawogbemi/moneytalks/blob/main/package.json

and I also I found out that cloudflare worker just reads the import statements then downloads builds the module and all its dependancies locally in the cloud. So the packages don't even need to be in the package.json.

image

their version of libsodium-sumo has no crypto_pwhash so I guess that's why im getting the error

whenever I try to use libsodium-wrappers-sumo I get this error

Uncaught Error: Both wasm and asm failed to loadNo secure random number generator found
at worker.js:15686:21
[code: 10021]

im not sure libsodium-wrappers-sumo of libsodium-sumo, but I assume libsodium-sumo as it has sumo and its is in the package.json so im not sure if that's the problem or that libsodium-wrappers-sumo will also not have crypto_pwhash

I tried reading this https://github.com/jedisct1/libsodium.js/issues/202, but it seems like a react-native issue and im not sure how to apply it or if it applies to this

jwcheon commented 12 months ago

@vawogbemi Facing the same issue. Did you reach a solution for this?

vawogbemi commented 12 months ago

@jwcheon Yeah I couldn't figure it out T.T

jwcheon commented 12 months ago

@wisefool769 Yeah.. I ended up replacing sodium with the crypto api instead

vawogbemi commented 12 months ago

@jwcheon Could you show me ur crypto api implementation?