1

I'm using the paseto npm package for generating a secret key and further using that key to create a token.

I might be going wrong with understanding something here, how do I store the key generated?

The following is the code:

V2.generateKey("local").then(mySecret => {
        let payload = {
            user: req.body.user
        }

        V2.encrypt(payload, mySecret, {
            expiresIn: '2 hours'
        }).then(result => {
            console.log(result);
            res.json({
                result
            })
        }).catch(err => {
            console.log(err);
            res.json({
                error: err
            })
        })
    })

How do I know what "mySecret" is and how to store it?

1 Answers1

1

Thanks to my friend, I found out that this is the way to go:

mySecret.export()

This prints a buffer that can be stored.

I wanted to find out the stored token so that I could share the secret with another application, even though that's not a best practice in general.