Skip to content

Instantly share code, notes, and snippets.

@chientrm
Created September 23, 2024 11:49
Show Gist options
  • Save chientrm/2b99fbd91caae8c0e8874be4c32af26d to your computer and use it in GitHub Desktop.
Save chientrm/2b99fbd91caae8c0e8874be4c32af26d to your computer and use it in GitHub Desktop.
Decrypt Payload
import { PUBLIC_SPKI } from '$env/static/public';
import { audience, issuer } from '$lib/constants';
import { importSPKI, jwtVerify } from 'jose';
const forPublicKey = importSPKI(PUBLIC_SPKI, 'RS512');
export const verify = async <T>(jwt: string) =>
jwtVerify(jwt, await forPublicKey, { issuer, audience }).then((result) => result.payload as T);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment