Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Usage with browserify causes errors #18

Closed
czardoz opened this issue Feb 1, 2016 · 4 comments
Closed

Usage with browserify causes errors #18

czardoz opened this issue Feb 1, 2016 · 4 comments

Comments

@czardoz
Copy link

czardoz commented Feb 1, 2016

This is not really a problem with this library, but could be fixed here, so I opened an issue here.

If I use "aws4" with browserify, the library throws this error:

TypeError: querystring.unescape is not a function
    at /tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:3245:45
    at Array.map (native)
    at RequestSigner.parsePath (/tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:3244:28)
    at RequestSigner.prepareRequest (/tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:3040:8)
    at RequestSigner.sign (/tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:3090:30)
    at Object.aws4.sign (/tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:3270:50)
    at Object.module.exports.sign (/tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:1593:23)
    at Object.module.exports.authorize (/tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:1555:27)
    at Context.<anonymous> (/tmp/5aec8ddf88b695d277e0f6c174b57e6c.browserify:53837:39)

The issue is that browserify's "querystring" module does not contain the "unescape" method (see mike-spainhower/querystring#4)

Some kind soul is providing a library that actually works: https://github.com/mathiasvr/querystring

Can "aws4" use that implementation? (It would involve depending on the above library, and adding a "browser" directive to the package.json here.)

I don't mind opening a PR, if this change is acceptable :)

@mhart
Copy link
Owner

mhart commented Feb 1, 2016

Yeah, I feel your pain, but that's not really the right solution to this problem IMO – devs shouldn't be swapping out core Node.js modules because of issues with bundling tools/libs.

The correct solution to this is just to change your browserify config to use the querystring module you'd prefer instead of the default one browserify uses – use the opts.builtins option for this with browserify: https://github.com/substack/node-browserify#methods

@mhart mhart closed this as completed Feb 1, 2016
@czardoz
Copy link
Author

czardoz commented Feb 1, 2016

Haha, true. Thanks for the workaround though :)

@mhart
Copy link
Owner

mhart commented Feb 1, 2016

No problem, hope it works! 😸

@mhart
Copy link
Owner

mhart commented Mar 1, 2016

FWIW, I've added an example of how to use this module with browserify here: https://github.com/mhart/aws4/tree/master/browser

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants