ponshu-room-lite/lib/secrets.dart

83 lines
3.0 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'secrets.local.dart' as local;
/// アプリケーションの機密情報と設定を管理するクラス
///
/// ビルド時に環境変数を使って値を上書きできます:
/// ```bash
/// flutter build apk --dart-define=AI_PROXY_URL=http://your-server:8080
/// ```
///
/// ローカル開発時:
/// 1. lib/secrets.local.dart.example をコピーして lib/secrets.local.dart を作成
/// 2. 新しく発行したAPIキーを設定
/// 3. secrets.local.dart は .gitignore に含まれているため安全
class Secrets {
/// AI Proxy サーバーのベースURL
///
/// デフォルト: Synology NAS上のAI Proxyサーバー (Tailscale IP)
/// ビルド時の上書き: --dart-define=AI_PROXY_URL=...
static const String aiProxyBaseUrl = String.fromEnvironment(
'AI_PROXY_URL',
defaultValue: 'http://100.76.7.3:8080',
);
/// AI Mode: Proxy(Home) vs Direct(Cloud)
/// If false, connects directly to Google Gemini API (Works anywhere).
/// Development (with Tailscale): --dart-define=USE_PROXY=true
/// General distribution: false (each user provides their own Gemini API key)
static const bool useProxy = bool.fromEnvironment(
'USE_PROXY',
defaultValue: false, // ← 一般配布用: Direct API各自がAPIキー設定
);
/// AI Proxy サーバーの解析エンドポイントURL
static const String aiProxyAnalyzeUrl = '$aiProxyBaseUrl/analyze';
/// AI Proxy 認証トークン
/// Proxy経由モード(useProxy=true)時に使用するBearer Token
/// ビルド時の上書き: --dart-define=PROXY_AUTH_TOKEN=...
static const String _proxyAuthTokenEnv = String.fromEnvironment(
'PROXY_AUTH_TOKEN',
defaultValue: '',
);
/// 実際に使用するProxy認証トークン
/// 優先順位: 環境変数 > ローカル設定ファイル
static String get proxyAuthToken {
if (_proxyAuthTokenEnv.isNotEmpty) {
return _proxyAuthTokenEnv;
}
return local.SecretsLocal.proxyAuthToken;
}
/// Gemini API Key
/// ⚠️ セキュリティのため、defaultValueは空です
/// ローカル開発時: lib/secrets.local.dart を作成してキーを設定
/// ビルド時の上書き: --dart-define=GEMINI_API_KEY=...
static const String _geminiApiKeyEnv = String.fromEnvironment(
'GEMINI_API_KEY',
defaultValue: '', // セキュリティのため空文字列
);
/// 実際に使用するGemini APIキー
/// 優先順位: 環境変数 > ローカル設定ファイル
static String get geminiApiKey {
// 1. 環境変数が設定されていればそれを使用
if (_geminiApiKeyEnv.isNotEmpty) {
return _geminiApiKeyEnv;
}
// 2. ローカル設定ファイルから取得
return local.SecretsLocal.geminiApiKey;
}
/// Posimai メインサーバーのベースURLライセンス検証に使用
static const String posimaiBaseUrl = String.fromEnvironment(
'POSIMAI_BASE_URL',
defaultValue: 'https://api.soar-enrich.com',
);
// static const String driveClientId = String.fromEnvironment('DRIVE_CLIENT_ID', defaultValue: '');
}