mirror of
https://github.com/nestriness/nestri.git
synced 2026-09-21 10:15:20 +03:00
feat: Sync to OSS repo
This commit is contained in:
13
packages/auth/src/jwt.ts
Normal file
13
packages/auth/src/jwt.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { JWTPayload, jwtVerify, KeyLike, SignJWT } from 'jose';
|
||||
|
||||
export namespace jwt {
|
||||
export function create(payload: JWTPayload, algorithm: string, privateKey: KeyLike) {
|
||||
return new SignJWT(payload)
|
||||
.setProtectedHeader({ alg: algorithm, typ: 'JWT', kid: 'sst' })
|
||||
.sign(privateKey);
|
||||
}
|
||||
|
||||
export function verify<T>(token: string, publicKey: KeyLike) {
|
||||
return jwtVerify<T>(token, publicKey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user