Skip to content

How do I import a HS256 secret in Deno? #465

Answered by vicary
vicary asked this question in Q&A
Discussion options

You must be logged in to vote

I just found the answer so I'll my own quesiton here. I am working in a deno environment but you may use the corresponding native API of your runtime.

Supabase's secret is a simple HS256 buffer, which can be copied from their dashboard. It may looks like a base64 encoded string but it's not, so don't atob() it.

Convert the secret into a buffer and jose will happily accept it.

import { jwtVerify } from "jose";

const SUPABASE_JWT_SECRET = Deno.env.get("SUPABASE_JWT_SECRET");

const verifiedPayload = await jwtVerify(jwt, new TextEncoder().encode(SUPABASE_JWT_SECRET));

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@panva
Comment options

@vicary
Comment options

Comment options

You must be logged in to vote
4 replies
@panva
Comment options

@vicary
Comment options

@panva
Comment options

@vicary
Comment options

Answer selected by vicary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants