refactor: saasMode 분기 제거 — 항상 SaaS(OAuth only)로 동작
Mac/Windows 환경 불일치 해소. BUILD_TIME 상수, CONFIGURE 채널, 개발자 모드 UI 전부 제거. Supabase 설정은 supabase-config.ts SSOT.
This commit is contained in:
parent
feb82abbf7
commit
541f04d02b
12 changed files with 566 additions and 9587 deletions
|
|
@ -13,7 +13,8 @@ import {
|
|||
} from '@supabase/supabase-js'
|
||||
import { eq, gt } from 'drizzle-orm'
|
||||
import { getLogger } from './LoggerService'
|
||||
import { configGet, isSupabaseBuildTimeConfigured } from './ConfigService'
|
||||
import { configGet } from './ConfigService'
|
||||
import { SUPABASE_URL, SUPABASE_ANON_KEY } from '@d3ro/core/supabase-config'
|
||||
import { getDatabase, openForUser, openLocal, closeCurrent } from '../db'
|
||||
import { history, dictionary, meetingSessions, meetingMemos, meetingDocuments } from '../db/schema'
|
||||
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
|
||||
|
|
@ -41,11 +42,6 @@ interface CloudSyncState {
|
|||
userEmail: string | null
|
||||
lastSyncAt: number | null
|
||||
syncing: boolean
|
||||
/**
|
||||
* SaaS 빌드 타임 모드: Supabase URL/Key가 빌드 시점에 박혀있는지 여부.
|
||||
* true이면 사용자는 OAuth 로그인만 하면 됨 (URL/Key 입력 화면 노출 금지).
|
||||
*/
|
||||
saasMode: boolean
|
||||
}
|
||||
|
||||
interface CloudSyncEvents {
|
||||
|
|
@ -78,15 +74,7 @@ class CloudSyncService extends EventEmitter {
|
|||
if (this._initialized) return
|
||||
this._initialized = true
|
||||
|
||||
const url = configGet('supabaseUrl') as string | undefined
|
||||
const anonKey = configGet('supabaseAnonKey') as string | undefined
|
||||
|
||||
if (!url || !anonKey) {
|
||||
logger.info('CloudSync disabled — Supabase URL/key not configured')
|
||||
return
|
||||
}
|
||||
|
||||
this._client = createClient(url, anonKey, {
|
||||
this._client = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
||||
auth: {
|
||||
persistSession: false, // 직접 관리
|
||||
autoRefreshToken: true,
|
||||
|
|
@ -486,8 +474,7 @@ class CloudSyncService extends EventEmitter {
|
|||
authenticated: this.isAuthenticated(),
|
||||
userEmail: this._session?.user?.email ?? null,
|
||||
lastSyncAt: this._lastSyncAt,
|
||||
syncing: this._syncing,
|
||||
saasMode: isSupabaseBuildTimeConfigured()
|
||||
syncing: this._syncing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,28 +7,6 @@ import { getLogger } from './LoggerService'
|
|||
|
||||
const logger = getLogger('ConfigService')
|
||||
|
||||
// ============================================================
|
||||
// SaaS 빌드 타임 주입 (electron.vite.config.ts의 define으로 박힘)
|
||||
// ============================================================
|
||||
// D3RO_SUPABASE_URL / D3RO_SUPABASE_ANON_KEY가 비어있지 않으면
|
||||
// 데스크톱 사용자가 Settings에서 직접 입력할 필요 없이 SaaS 인스턴스에 자동 연결.
|
||||
// 빈 문자열이면 기존 동작(사용자 입력) fallback.
|
||||
|
||||
const BUILD_TIME_SUPABASE_URL: string = process.env.D3RO_SUPABASE_URL ?? ''
|
||||
const BUILD_TIME_SUPABASE_ANON_KEY: string = process.env.D3RO_SUPABASE_ANON_KEY ?? ''
|
||||
|
||||
export function isSupabaseBuildTimeConfigured(): boolean {
|
||||
return BUILD_TIME_SUPABASE_URL.length > 0 && BUILD_TIME_SUPABASE_ANON_KEY.length > 0
|
||||
}
|
||||
|
||||
export function getBuildTimeSupabaseUrl(): string {
|
||||
return BUILD_TIME_SUPABASE_URL
|
||||
}
|
||||
|
||||
export function getBuildTimeSupabaseAnonKey(): string {
|
||||
return BUILD_TIME_SUPABASE_ANON_KEY
|
||||
}
|
||||
|
||||
// electron-store v10은 ESM 전용이므로 동적 import 필요
|
||||
interface ElectronStore<T extends Record<string, unknown>> {
|
||||
get<K extends keyof T>(key: K): T[K]
|
||||
|
|
@ -118,14 +96,6 @@ export function getConfigService(): ElectronStore<AppConfig> | null {
|
|||
}
|
||||
|
||||
export function configGet<K extends keyof AppConfig>(key: K): AppConfig[K] {
|
||||
// SaaS 빌드 타임 주입은 사용자 설정보다 우선.
|
||||
if (key === 'supabaseUrl' && BUILD_TIME_SUPABASE_URL.length > 0) {
|
||||
return BUILD_TIME_SUPABASE_URL as AppConfig[K]
|
||||
}
|
||||
if (key === 'supabaseAnonKey' && BUILD_TIME_SUPABASE_ANON_KEY.length > 0) {
|
||||
return BUILD_TIME_SUPABASE_ANON_KEY as AppConfig[K]
|
||||
}
|
||||
|
||||
if (!store) {
|
||||
logger.warn(`ConfigService not initialized, returning default for "${key}"`)
|
||||
return CONFIG_DEFAULTS[key]
|
||||
|
|
@ -134,15 +104,6 @@ export function configGet<K extends keyof AppConfig>(key: K): AppConfig[K] {
|
|||
}
|
||||
|
||||
export function configSet<K extends keyof AppConfig>(key: K, value: AppConfig[K]): void {
|
||||
// SaaS 빌드 타임 주입된 값은 변경 차단 (사용자가 잘못된 값으로 덮어쓰는 것 방지).
|
||||
if (
|
||||
(key === 'supabaseUrl' || key === 'supabaseAnonKey') &&
|
||||
isSupabaseBuildTimeConfigured()
|
||||
) {
|
||||
logger.warn(`Refusing to override build-time SaaS config: "${key}"`)
|
||||
return
|
||||
}
|
||||
|
||||
if (!store) {
|
||||
logger.warn(`ConfigService not initialized, cannot set "${key}"`)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue