-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
Conversation
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: (base_string, key) => { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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')
There was a problem hiding this comment.
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')
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
thanks |
see v2.0.0 https://github.com/ddo/oauth-1.0a/releases/tag/2.0.0