-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
I'm trying to generate a key and use that for the token, but everything below the encrypt method doesn't work.
"paseto.js": "^0.1.3",
const crypto = require("crypto")
const Paseto = require("paseto.js")
const uuid = require("uuid/v4")
async function generateToken() {
const message = {
tokenId: uuid(), // Token Id
}
// Generate key
//const key = crypto.randomBytes(32)
const keyRaw = Buffer.from(
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
"hex"
)
const sk = new Paseto.SymmetricKey(new Paseto.V2())
await sk.inject(keyRaw)
console.log(sk) // <-- output key object
const encoder = sk.protocol()
const token = await encoder.encrypt(message, sk)
// No output below --v--
console.log(message)
console.log(token)
return token
}
generateToken()
Output:
# node auth.js
SymmetricKey {
INFO_ENCRYPTION: 'paseto-encryption-key',
INFO_AUTHENTICATION: 'paseto-auth-key-for-aead',
_protocol: V2 { _repr: 'v2', _constants: { SYMMETRIC_KEY_BYTES: 32 } },
_key:
<Buffer de ad be ef de ad be ef de ad be ef de ad be ef de ad be ef de ad be ef de ad be ef de ad be ef> }
It may just be me but I find it as difficult as JWT to use for now 😆
solancer
Metadata
Metadata
Assignees
Labels
No labels