Skip to content

Instantly share code, notes, and snippets.

View jayg-hive's full-sized avatar

Jay G jayg-hive

View GitHub Profile
@jayg-hive
jayg-hive / token.ts
Created February 9, 2022 07:02
Cognito JWT Validation via JOSE
import { createRemoteJWKSet, jwtVerify } from "jose";
import type { JWTPayload } from "jose";
import { AWS_REGION, COGNITO_USER_POOL_ID, COGNITO_WEB_CLIENT_ID } from "../utils/consts";
const cognitoIssuer = `https://cognito-idp.${AWS_REGION}.amazonaws.com/${COGNITO_USER_POOL_ID}`;
const cognitoPublicJwks = `${cognitoIssuer}/.well-known/jwks.json`;
interface AWSAuth extends JWTPayload {