From fda6cecf0709533f89f455524b154664f05f34b8 Mon Sep 17 00:00:00 2001 From: Craig Kaiser Date: Mon, 24 Jun 2024 13:03:16 -0400 Subject: [PATCH] patch https://github.com/supabase/auth-js/issues/888 --- vite.config.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 37b6a84..8a930b2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,8 +2,36 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vitest/config'; export default defineConfig({ - plugins: [sveltekit()], + plugins: [sveltekit(), myErrorFilterPlugin()], test: { include: ['src/**/*.{test,spec}.{js,ts}'] } }); + +export function myErrorFilterPlugin(): Plugin { + return { + name: 'error-filter-plugin', + configureServer(server) { + const filterMessage = + 'Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and many not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server.'; + + // Intercept console.warn + const originalWarn = console.warn; + console.warn = (...args: any[]) => { + if (args[0] && typeof args[0] === 'string' && args[0].includes(filterMessage)) { + return; + } + originalWarn(...args); + }; + + // Intercept console.log + const originalLog = console.log; + console.log = (...args: any[]) => { + if (args[0] && typeof args[0] === 'string' && args[0].includes(filterMessage)) { + return; + } + originalLog(...args); + }; + } + }; +}