silverbullet/plugos/syscalls/jwt.ts

23 lines
504 B
TypeScript
Raw Normal View History

2022-04-09 20:28:41 +08:00
import jwt, { Algorithm } from "jsonwebtoken";
2022-10-08 22:29:43 +08:00
import { SysCallMapping } from "../system.ts";
2022-04-09 20:28:41 +08:00
export function jwtSyscalls(): SysCallMapping {
return {
"jwt.jwt": (
ctx,
hexSecret: string,
id: string,
algorithm: Algorithm,
expiry: string,
audience: string
): string => {
return jwt.sign({}, Buffer.from(hexSecret, "hex"), {
keyid: id,
algorithm: algorithm,
expiresIn: expiry,
audience: audience,
});
},
};
}