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

Drop native node Buffer API dependency #136

Open
tfalencar opened this issue Nov 14, 2022 · 12 comments
Open

Drop native node Buffer API dependency #136

tfalencar opened this issue Nov 14, 2022 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@tfalencar
Copy link
Contributor

tfalencar commented Nov 14, 2022

After #115 was merged, I gave SIWE release version 2.1.3 a try.
However, it turns out the 'apg-js' package (one of the few dependencies of this project), seems to make use of the Buffer API as well, as can be seen here:

https://github.com/ldthomas/apg-js/search?q=buffer

I've opened a ticket there to see if there's positive feedback on solving this: ldthomas/apg-js#9

I think this is the last missing piece to get siwe working without workarounds in frameworks like Sveltekit. If the mentioned library can't be changed, it would be interesting to know if there is any other alternative.

@hbriese
Copy link

hbriese commented Nov 28, 2022

@tfalencar's issue has been closed as unfortunately apg-js is unwilling to find an alternative to Buffer.

Removing dependence on Buffer is incredibly important for portability

@twtaylor
Copy link

yeah this doesn't work in a FE for some functions

tfalencar added a commit to tfalencar/siwe that referenced this issue Dec 3, 2022
@tfalencar
Copy link
Contributor Author

tfalencar commented Dec 4, 2022

I created a fork of apg-js, and added safer-buffer to the project. Then I pushed it as a new packaged to npm: buffer-apg-js. I tested in my application and finally the application doesn't crash anymore and I'm able to use siwe in the browser with Vite / SvelteKit. If you'd like to test it as well you can replace the 'siwe' dependency with '@crowdtainer/siwe' (another package I pushed to npm which is a fork of siwe replacing apg-js with buffer-apg-js in the siwe-parser package). I'd like to eventually deprecate my custom fork though (@crowdtainer/siwe), so would be happy to see this solved in this repo (either by using the buffer-apg-js fork, or if spruce decides to create its own npm package with a fork.

I'm no longer using this approach - and not maintaining this package.

tfalencar added a commit to crowdtainer/dapp-web that referenced this issue Dec 5, 2022
…issue

- See spruceid/siwe#136 (comment) for details.
- Changed message verification to use SIWE libraries.
@w4ll3
Copy link
Member

w4ll3 commented Dec 5, 2022

@tfalencar Thanks for your contribution, I'll bring up the discussion with the team today, we'll probably have our own fork as you mentioned but we'll make sure to credit your contribution. Will update the results soon.

@w4ll3 w4ll3 self-assigned this Dec 5, 2022
@w4ll3 w4ll3 added the enhancement New feature or request label Dec 5, 2022
ghTravis pushed a commit to ghTravis/siwe that referenced this issue Apr 30, 2023
@au2001
Copy link

au2001 commented Jun 15, 2023

Any update on this?

@bradwbradw
Copy link

I created a fork of apg-js, and added safer-buffer to the project. Then I pushed it as a new packaged to npm: buffer-apg-js. I tested in my application and finally the application doesn't crash anymore and I'm able to use siwe in the browser with Vite / SvelteKit.

If you'd like to test it as well you can replace the 'siwe' dependency with '@crowdtainer/siwe' (another package I pushed to npm which is a fork of siwe replacing apg-js with buffer-apg-js in the siwe-parser package).

I'd like to eventually deprecate my custom fork though (@crowdtainer/siwe), so would be happy to see this solved in this repo (either by using the buffer-apg-js fork, or if spruce decides to create its own npm package with a fork.

I tried importing your fork in vite using import { SiweMessage } from '@crowdtainer/siwe' but i get "failed to resolve entry for package "@crowdtainer/siwe""

@tfalencar
Copy link
Contributor Author

tfalencar commented Jun 16, 2023

I tried importing your fork in vite using import { SiweMessage } from '@crowdtainer/siwe' but i get "failed to resolve entry for package "@crowdtainer/siwe""

Please check with the Spruce team, it seems they have another library now (SSX), maybe it doesn't have this issue. I don't know if this problem will be solved in spruce/siwe.

@bradwbradw
Copy link

hey @tfalencar I would consider SSX but i'm doing a hackathon and I only have a couple days and I need siwe :) I'm not sure if your Buffer-friendly clone can be installed / imported using vite JS, but if you have any tips, I'd really appreciate it. I promise I won't leave it in a prod environment, it's just for a proof of concept

@niconiahi
Copy link

hey! I'm needing this as well. It's important to understand that many applications (everytime gets bigger) are running on the edge runtime, meaning that we don't have NodeAPIs. To me, it's a must for an application to remove all dependencies from Node and replace them with Web APIs

can at least the mantainer hint what changes would this include? I could take a look at it. The codebase seems small enough to work on

@dankcellar
Copy link

For anyone seeing this in 2024, I got it working: https://www.npmjs.com/package/cloudflare-siwe
import { SiweMessage, generateNonce } from 'cloudflare-siwe';

@jwcheon
Copy link

jwcheon commented Mar 29, 2024

@dankcellar will you open source this in the future? would love to use it!

@dankcellar
Copy link

@jwcheon https://github.com/dankcellar/siwe here it is, and I am using parcel now, I had to redo the npm package as well 😭

https://www.npmjs.com/package/siwe-cloudflare
import { SiweMessage, generateNonce } from 'siwe-cloudflare';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants