File size: 635 Bytes
8919651
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58b1ffb
 
8919651
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { jwtVerify } from "jose"

import { secretKey } from "./config"
import { parseToken } from "./parseToken"

export async function throwIfInvalidToken(input?: any): Promise<boolean> {

  // note: this performs a decodeURI, but I'm not sure we need to
  const token = parseToken(input)

  // verify token
  const { payload, protectedHeader } = await jwtVerify(token, secretKey, {
    issuer: `${process.env.API_SECRET_JWT_ISSUER || ""}`, // issuer
    audience: `${process.env.API_SECRET_JWT_AUDIENCE || ""}`, // audience
  })

  // log values to console
  // console.log(payload)
  // console.log(protectedHeader)

  return true
}