-
Notifications
You must be signed in to change notification settings - Fork 5
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
Example typo? #1
Comments
Ah yes, that is a typo, but I also realise now that there are a couple of other issues with the example, eg. Map checking by reference identity. Here's what a barebones example would look like (pardon the bad var names): var secureToken = require('secure-token')
var sessionToken = secureToken.create()
// => This conversion to a string is important for our Map database
var saveToDb = secureToken.hash(sessionToken, 'session').toString('base64')
db.set(saveToDb, true)
var sendThisToClient = sessionToken.toString('base64')
// -----------------------------------------
var receivedToken = Buffer.from(sendThisToClient, 'base64')
var checkInDb = secureToken.hash(receivedToken, 'session').toString('base64')
if (db.has(checkInDb)) {
console.log('Authorized')
} else {
console.log('Unauthorized')
} Thanks for reporting this! |
No problem I'm glad I can help. Thanks for making the library! 👍
…On Thu, Mar 15, 2018, 18:11 Emil Bay ***@***.***> wrote:
Ah yes, that is a typo, but I also realise now that there are a couple of
other issues with the example, eg. Map checking by reference identity.
Here's what a barebones example would look like:
var secureToken = require('secure-token')
var sessionToken = secureToken.create()
// => This conversion to a string is important for our Map databasedb.set(secureToken.hash(sessionToken, 'session').toString('base64'), true)
var sendThisToClient = sessionToken.toString('base64')
// -----------------------------------------
var receivedToken = Buffer.from(sendThisToClient, 'base64')
if (db.has(secureToken.hash(receivedToken, 'session'))) {
console.log('Authorized')
} else {
console.log('Unauthorized')
}
Thanks for reporting this!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANY6RqWEXKmDJ76L7EoTkwD43Znm9BMLks5teq7ngaJpZM4SsB0N>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello I'm having issues with the example and using the library...
do you mean...
Would it be possible to add an example.js file (without a http server or anything) just to get a working example to go on?
Here is the code I'm running:
The text was updated successfully, but these errors were encountered: