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

updates oauth-1.0a example in readme #225

Merged
merged 2 commits into from
Oct 14, 2016
Merged

updates oauth-1.0a example in readme #225

merged 2 commits into from
Oct 14, 2016

Conversation

thisconnect
Copy link
Contributor

signature_method: 'HMAC-SHA1'
signature_method: 'HMAC-SHA1',
hash_function: (base_string, key) => {
return crypto.createHmac('sha1', key).update(base_string).digest('base64');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make it an inline arrow function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like that: hash_function: (base_string, key) => crypto.createHmac('sha1', key).update(base_string).digest('base64') ? I'm ok with, but it's slightly harder to read or not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I tend to write things like this:

hash_function: (base_string, key) => crypto
    .createHmac('sha1', key)
    .update(base_string)
    .digest('base64')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or const { createHmac } = require('crypto') then hash_function: (base_string, key) => createHmac('sha1', key).update(base_string).digest('base64')

and maybe base_string to base ?

shortest 1liner hash_function: (base, key) => createHmac('sha1', key).update(base).digest('base64')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my comments are hard to read.. sorry :)

Copy link
Contributor

@kevva kevva Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructuring isn't supported in Node.js 4. Also, use camelCase instead of snake case.

secret: process.env.CONSUMER_SECRET
},
signature_method: 'HMAC-SHA1'
signature_method: 'HMAC-SHA1',
hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ; is a syntax error.

@sindresorhus sindresorhus merged commit d6096eb into sindresorhus:master Oct 14, 2016
sindresorhus pushed a commit that referenced this pull request Oct 14, 2016
@thisconnect
Copy link
Contributor Author

thanks

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

Successfully merging this pull request may close these issues.

None yet

4 participants