summary refs log tree commit diff
path: root/api/src/test/jwt2.ts
blob: e231233dd5b24850ba3badd5d21f8c94e646b885 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import jwt from "jsonwebtoken";

const algorithm = "HS256";
const iat = Math.floor(Date.now() / 1000);

// @ts-ignore
const token = jwt.sign({ id: "311129357362135041" }, "secret", {
	algorithm,
});
console.log(token);

const decoded = jwt.verify(token, "secret", { algorithms: [algorithm] });
console.log(decoded);