text: 'use strict';
  const jwt = require('jsonwebtoken');
  
  exports.verifyJWTToken = function(token) {
    return new Promise((resolve, reject) => {
      jwt.verify(token, process.env.JWT_SECRET, (err, decodedToken) => {
        if (err || !decodedToken) {
          return reject(err);
        }
  
        resolve(decodedToken);
      });
    });
  };
  
  exports.createJWToken = function(details) {
    if (!details.maxAge || typeof details.maxAge !== 'number') {
      details.maxAge = 3600;
    }
  
    let token = jwt.sign({
       data: details.sessionData
      }, process.env.JWT_SECRET, {
        expiresIn: details.maxAge,
        algorithm: 'HS256'
    });
  
    return token;
  };