Skip to content

Example typo? #1

Open
Open
@m-onz

Description

@m-onz

Hello I'm having issues with the example and using the library...

`sessionToken=${secureToken.toString('base64')}`,
// secureToken.toString() returns... [object Object]

do you mean...

`sessionToken=${sessionToken.toString('base64')}`, ?

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:

/*

  test for secure tokens...

*/

var secureToken = require ('secure-token')

var db = new Map ()

var session_token = secureToken.create()

//
db.set(secureToken.hash(session_token, 'session'), true)

var new_session_token = secureToken.hash(session_token).toString('base64')

// ---------------------------------------------------------------

var _session_token = Buffer.from(new_session_token, 'base64')
var _hash          = secureToken.hash(_session_token, 'session')

if (!db.get(_hash)) {
  return console.log('ALWAYS UNAUTHORIZED! but i thought this would work... ')
}

console.log('AUTHORIZATION SUCCESSFUL -- doesnt see me. : (')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions