stack/examples/supabase/utils/actions.ts
Bilal Godil d4f6f58735 feat(hexclave): PR 2 — visible rebrand to Hexclave
Rebased onto dev after PR 1475 (cl/hexclave-pr1) was squash-merged.
Squashes the original 46-commit branch (including PR1-duplicate commits
that arrived via cherry-picks/merges) into a single commit containing
only PR2's net delta over dev.

Original PR 1481 head: 94872de407873a1cabd4085deb21b69afe8d7699
(kept locally at backup/cl-romantic-mendel-5a2c25-pre-rebase)
2026-05-23 17:35:08 -07:00

26 lines
571 B
TypeScript

'use server';
import { stackServerApp } from "@/stack";
import * as jose from "jose";
/*
This is a server action that returns a Supabase JWT with the Hexclave user ID
*/
export const getSupabaseJwt = async () => {
const user = await stackServerApp.getUser();
if (!user) {
return null;
}
const token = await new jose.SignJWT({
sub: user.id,
role: "authenticated",
})
.setProtectedHeader({ alg: "HS256" })
.setIssuedAt()
.setExpirationTime('1h')
.sign(new TextEncoder().encode(process.env.SUPABASE_JWT_SECRET));
return token;
};