refactor(auth): migrate to new Supabase JWT Signing keys (#303)

* refactor(auth): replace Supabase `User` type with new `JWTUserData` type across the codebase

- Replaced usage of Supabase's `User` type with the newly defined `JWTUserData` type for better type mapping and alignment with JWT claims.
- Refactored session-related components and hooks (`useUser`, `requireUser`) to use the updated user structure.
- Updated Supabase client keys to use `publicKey` instead of `anonKey`.
- Adjusted multi-factor authentication logic and components to use `aal` and additional properties.
- Applied consistent naming for Supabase secret key functions.
- Incremented version to 2.12.0.

- Introduced a new `deprecated` property in the `EnvVariableModel` type to handle deprecated environment variables.
- Updated the `EnvList` component to display a warning badge for deprecated variables, including reason and alternative suggestions.
- Enhanced filtering logic to allow users to toggle the visibility of deprecated variables.
- Added new deprecated variables for Supabase keys with appropriate reasons and alternatives.

- Added support for filtering deprecated environment variables in the `FilterSwitcher` component.
- Updated the `Summary` component to display a badge for the count of deprecated variables.
- Introduced a button to filter and display only deprecated variables.
- Adjusted filtering logic to include deprecated variables in the overall state management.

add BILLING_MODE configuration to environment variables

- Introduced a new environment variable `BILLING_MODE` to configure billing options for the application.
- The variable supports two values: `subscription` and `one-time`.
- Marked as deprecated with a reason indicating that this configuration is no longer required, as billing mode is now automatically determined.
- Added validation logic for the new variable to ensure correct value parsing.
This commit is contained in:
Giancarlo Buomprisco
2025-07-16 16:17:10 +07:00
committed by GitHub
parent da8a3a903d
commit 9104ce9a2c
30 changed files with 313 additions and 118 deletions

View File

@@ -2,13 +2,12 @@ import 'server-only';
import { redirect } from 'next/navigation';
import type { User } from '@supabase/supabase-js';
import { ZodType, z } from 'zod';
import { verifyCaptchaToken } from '@kit/auth/captcha/server';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { JWTUserData } from '@kit/supabase/types';
import { zodParseFactory } from '../utils';
@@ -30,14 +29,14 @@ export function enhanceAction<
>(
fn: (
params: Config['schema'] extends ZodType ? z.infer<Config['schema']> : Args,
user: Config['auth'] extends false ? undefined : User,
user: Config['auth'] extends false ? undefined : JWTUserData,
) => Response | Promise<Response>,
config: Config,
) {
return async (
params: Config['schema'] extends ZodType ? z.infer<Config['schema']> : Args,
) => {
type UserParam = Config['auth'] extends false ? undefined : User;
type UserParam = Config['auth'] extends false ? undefined : JWTUserData;
const requireAuth = config.auth ?? true;
let user: UserParam = undefined as UserParam;

View File

@@ -3,13 +3,12 @@ import 'server-only';
import { redirect } from 'next/navigation';
import { NextRequest, NextResponse } from 'next/server';
import { User } from '@supabase/supabase-js';
import { z } from 'zod';
import { verifyCaptchaToken } from '@kit/auth/captcha/server';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { JWTUserData } from '@kit/supabase/types';
import { zodParseFactory } from '../utils';
@@ -24,7 +23,7 @@ interface HandlerParams<
RequireAuth extends boolean | undefined,
> {
request: NextRequest;
user: RequireAuth extends false ? undefined : User;
user: RequireAuth extends false ? undefined : JWTUserData;
body: Schema extends z.ZodType ? z.infer<Schema> : undefined;
params: Record<string, string>;
}
@@ -75,7 +74,7 @@ export const enhanceRouteHandler = <
params: Promise<Record<string, string>>;
},
) {
type UserParam = Params['auth'] extends false ? undefined : User;
type UserParam = Params['auth'] extends false ? undefined : JWTUserData;
let user: UserParam = undefined as UserParam;