91adb8661d
* Add example with Magic and Passport.js * Tweaked wording on README * Fixed lint error * Fixed prettier error * Update examples/magic/README.md Removed Download manually section from README Co-Authored-By: Joe Haddad <timer150@gmail.com> * Removed dependency on passport and express + cleanup * Changed ZEIT brand to Vercel * Updated readme instructions and secrets * Renamed example * Changed db comment Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Luis Alvarez <luis@zeit.co>
14 lines
480 B
JavaScript
14 lines
480 B
JavaScript
import Iron from '@hapi/iron'
|
|
import { getTokenCookie } from './auth-cookies'
|
|
|
|
// Use an environment variable here instead of a hardcoded value for production
|
|
const TOKEN_SECRET = 'this-is-a-secret-value-with-at-least-32-characters'
|
|
|
|
export function encryptSession(session) {
|
|
return Iron.seal(session, TOKEN_SECRET, Iron.defaults)
|
|
}
|
|
|
|
export async function getSession(req) {
|
|
const token = getTokenCookie(req)
|
|
return token && Iron.unseal(token, TOKEN_SECRET, Iron.defaults)
|
|
}
|