Home / Function/ generateKeys() — supabase Function Reference

generateKeys() — supabase Function Reference

Architecture documentation for the generateKeys() function in JwtGeneratorSimple.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  3431b1af_4217_9400_15cc_2f2734269fce["generateKeys()"]
  1edb3f71_cb68_1526_8e24_5b60cc7a931f["JwtGeneratorSimple()"]
  1edb3f71_cb68_1526_8e24_5b60cc7a931f -->|calls| 3431b1af_4217_9400_15cc_2f2734269fce
  75de995c_0476_2c0a_9a5e_2fe2411c0ad5["generateRandomString()"]
  3431b1af_4217_9400_15cc_2f2734269fce -->|calls| 75de995c_0476_2c0a_9a5e_2fe2411c0ad5
  style 3431b1af_4217_9400_15cc_2f2734269fce fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/components/JwtGenerator/JwtGeneratorSimple.tsx lines 27–41

const generateKeys = () => {
  const now = new Date()
  const today = new Date(now.getFullYear(), now.getMonth(), now.getDate())
  const fiveYears = new Date(now.getFullYear() + 5, now.getMonth(), now.getDate())
  const iat = Math.floor(today.valueOf() / 1000)
  const exp = Math.floor(fiveYears.valueOf() / 1000)

  const anonToken = { role: 'anon', iss: 'supabase', iat, exp }
  const serviceToken = { role: 'service_role', iss: 'supabase', iat, exp }

  const secret = generateRandomString(40)
  const anonKey = KJUR.jws.JWS.sign(null, JWT_HEADER, anonToken, secret)
  const serviceRoleKey = KJUR.jws.JWS.sign(null, JWT_HEADER, serviceToken, secret)
  return { secret, anonKey, serviceRoleKey }
}

Subdomains

Frequently Asked Questions

What does generateKeys() do?
generateKeys() is a function in the supabase codebase.
What does generateKeys() call?
generateKeys() calls 1 function(s): generateRandomString.
What calls generateKeys()?
generateKeys() is called by 1 function(s): JwtGeneratorSimple.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free