EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
builderKey.js
Go to the documentation of this file.
1const jwt = require("jsonwebtoken");
2
3const SECRET = process.env.BUILDER_KEY_SECRET || "builder_super_secret";
4
5/**
6 *
7 * @param payload
8 */
9function createBuilderKey(payload) {
10 return jwt.sign(payload, SECRET, { expiresIn: "7d" });
11}
12
13/**
14 *
15 * @param key
16 */
17function validateBuilderKey(key) {
18 try {
19 return jwt.verify(key, SECRET);
20 } catch (err) {
21 return null;
22 }
23}
24
25module.exports = {
26 createBuilderKey,
27 validateBuilderKey
28};