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

Remove Buffer API usage #9

Closed
tfalencar opened this issue Nov 14, 2022 · 6 comments
Closed

Remove Buffer API usage #9

tfalencar opened this issue Nov 14, 2022 · 6 comments

Comments

@tfalencar
Copy link

In some environments, the Node.js Buffer API as used by this project is not available. I'm not super familiar with node/js, but I noticed some projects replace it with packages like https://www.npmjs.com/package/safer-buffer .

This project is a dependency from a library I'm trying to use (https://github.com/spruceid/siwe). Would it be desired/conceivable to adapt this project to drop the native Buffer API usage?

@ldthomas
Copy link
Owner

apg-js was designed to have zero dependencies and to work with Node.js (developed with version 15.11.0). So adding a dependency would break one of my primary design features. I haven't worked with JavaScript for a couple of years now and don't have the time or motivation to understand what the underlying problem is and make any significant changes anyway. But thanks for your interest in apg-js.

@tfalencar
Copy link
Author

Thanks for the feedback; Closing this issue.

@mrose17
Copy link

mrose17 commented Mar 22, 2023

@ldthomas - sorry to chime in on this. so, what is the preferred solution for putting Buffer into something that's going to use apg-js in the browser? Here's what I'm doing:

    global.Buffer = require("buffer/").Buffer;

which seems kind of "hacky"... thanks!

@ldthomas
Copy link
Owner

As I mentioned above, it's been a couple of years since I've worked with this. As far as I can reconstruct (and I haven't spent a lot of time on this) the Node.js Buffer is only exported in:
apg-js/src/apg-conv-api/web-exports.js

However, apg-conv-api is used by all of the other libraries so it will get pulled in with apg-api-bundle.js.

I've only used browserify for bundling. It gets bundled for use in a web browser in :
apg-js/bin/apg-conv-api-bundle.sh

You can see an example of how that is used in a web page at:
apg-js-examples/src/apg-api/web-apg-api.js
and
apg-js-examples/src/apg-api/web-apg-api.html

Don't know if that helps but that is the way I did it.

@ldthomas ldthomas reopened this Mar 23, 2023
@mrose17
Copy link

mrose17 commented Mar 24, 2023

Thank you! I've gone through several permutations of requiring web-exports and apg-js, and haven't hit the right permutation yet. it may be something with TypeScript, etc., and eventually I can figure it out.

Regardless, let's close this issue. I have a solution, and more importantly you've already dealt with it in the package. So I think we're good!

@ldthomas
Copy link
Owner

Good luck with your project and thanks for using APG.

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

3 participants