whale-code 6.5.3 → 6.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { createClient } from "@supabase/supabase-js";
|
|
|
19
19
|
import { createRequire } from "module";
|
|
20
20
|
import { startUpdateLoop } from "./updater.js";
|
|
21
21
|
import { resolveConfig, loadConfig, updateConfig } from "./cli/services/config-store.js";
|
|
22
|
-
import { getValidToken, getStoresForUser, selectStore } from "./cli/services/auth-service.js";
|
|
22
|
+
import { getValidToken, getStoresForUser, selectStore, SUPABASE_ANON_KEY } from "./cli/services/auth-service.js";
|
|
23
23
|
import { signInWithBrowser } from "./cli/services/browser-auth.js";
|
|
24
24
|
import { LocalAgentConnection } from "./local-agent/connection.js";
|
|
25
25
|
import { initErrorLogger, setErrorLoggerUser, captureError } from "./cli/services/error-logger.js";
|
|
@@ -68,10 +68,21 @@ if (!IS_SERVICE_ROLE && rawConfig.access_token && rawConfig.refresh_token) {
|
|
|
68
68
|
let isAuthenticated = !!(SUPABASE_URL && INITIAL_SUPABASE_KEY);
|
|
69
69
|
let supabase = null;
|
|
70
70
|
if (isAuthenticated) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
if (IS_SERVICE_ROLE) {
|
|
72
|
+
// Service role key — use directly as apiKey (full access)
|
|
73
|
+
supabase = createClient(SUPABASE_URL, INITIAL_SUPABASE_KEY, {
|
|
74
|
+
auth: { persistSession: false, autoRefreshToken: false },
|
|
75
|
+
});
|
|
76
|
+
if (!USER_ID) {
|
|
77
|
+
console.error("[MCP] WARNING: Using service role key without user login. Tools will work but store scoping is disabled.");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// User JWT — use anon key as apiKey, pass JWT via Authorization header
|
|
82
|
+
supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
|
83
|
+
auth: { persistSession: false, autoRefreshToken: false },
|
|
84
|
+
global: { headers: { Authorization: `Bearer ${INITIAL_SUPABASE_KEY}` } },
|
|
85
|
+
});
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
else {
|