mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Step 5: rename lowercase local vars stackApp/stackServerApp/stackClientApp/ stackAdminApp -> hexclave* across SDK source, apps, examples, and docs-mintlify (docs/ excluded). Public StackServerApp/StackClientApp classes and the useStackApp hook are unchanged. typecheck + lint green.
26 lines
580 B
TypeScript
26 lines
580 B
TypeScript
'use server';
|
|
|
|
import { hexclaveServerApp } from "@/hexclave";
|
|
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 hexclaveServerApp.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;
|
|
}; |