import { it } from 'node:test'; import { initJwt, generateJwtToken, validateJwtToken } from './jwtUtils.js'; import * as dotenv from 'dotenv'; import { tmpdir } from 'node:os'; import { mkdtemp } from 'node:fs/promises'; import * as assert from 'node:assert'; dotenv.config(); const user = { _id: 'meow', username: 'testuser' }; await it('Should be able to generate new secrets', async () => { process.env.JWT_SECRET_PATH = await mkdtemp(tmpdir()); await initJwt(); }); await it('Should be able to load the JWT utils', async () => { process.env.JWT_SECRET_PATH = await mkdtemp(tmpdir()); await initJwt(); await initJwt(); }); it('Should be able to create a JWT token', async () => { await initJwt(); await generateJwtToken(user); }); it('Should be able to validate a JWT token', async () => { await initJwt(); const token = await generateJwtToken(user); const result = await validateJwtToken(token); console.log(result); });