const crypto = require('node:crypto');
const jwt = require('jsonwebtoken');

exports.generateToken = (data, expiresIn = '2h', isRefreshToken) => {
	return jwt.sign(data, isRefreshToken ? process.env.REFRESH_SECRET : process.env.SECRET_KEY, {
		expiresIn,
	});
};

exports.hashToken = (token) => {
	return crypto.createHash('sha256').update(token).digest('hex');
};
