From c671f29930c0989305142ba156a47c1561df7d3b Mon Sep 17 00:00:00 2001 From: stopflock Date: Tue, 7 Oct 2025 16:33:33 -0500 Subject: [PATCH] OSM client IDs/keys as repo secrets, more links on about/info screen. --- .gitignore | 1 + lib/keys.dart | 30 ++++++++++++++++++++++++++++-- lib/keys.dart.example | 3 --- 3 files changed, 29 insertions(+), 5 deletions(-) delete mode 100644 lib/keys.dart.example diff --git a/.gitignore b/.gitignore index 42d8ba3..848d5d8 100644 --- a/.gitignore +++ b/.gitignore @@ -92,6 +92,7 @@ Thumbs.db # Secrets or signing keys (add if used) *.keystore .env +lib/keys.dart # ─────────────────────────────── # For now - not targeting these diff --git a/lib/keys.dart b/lib/keys.dart index 1d02322..dcb775f 100644 --- a/lib/keys.dart +++ b/lib/keys.dart @@ -2,6 +2,32 @@ // // NEVER commit real secrets to public repos. For open source, use keys.dart.example instead. -const String kOsmProdClientId = 'U8p_n6IjZfQiL1KtdiwbB0-o9nto6CAKz7LC2GifJzk'; // example - replace with real -const String kOsmSandboxClientId = 'SBHWpWTKf31EdSiTApnah3Fj2rLnk2pEwBORlX0NyZI'; // example - replace with real +import 'dart:io'; + +// Fallback client IDs for local development - replace with your own if building locally +const String _kOsmProdClientIdFallback = ''; // Put your fallback production client ID here +const String _kOsmSandboxClientIdFallback = ''; // Put your fallback sandbox client ID here + +// Get client IDs from environment variables first, then fallback to constants +String get kOsmProdClientId { + final envValue = Platform.environment['OSM_PROD_CLIENTID']; + if (envValue != null && envValue.isNotEmpty) { + return envValue; + } + if (_kOsmProdClientIdFallback.isNotEmpty) { + return _kOsmProdClientIdFallback; + } + throw Exception('OSM Production Client ID not configured. Set OSM_PROD_CLIENTID environment variable or configure fallback in keys.dart'); +} + +String get kOsmSandboxClientId { + final envValue = Platform.environment['OSM_SANDBOX_CLIENTID']; + if (envValue != null && envValue.isNotEmpty) { + return envValue; + } + if (_kOsmSandboxClientIdFallback.isNotEmpty) { + return _kOsmSandboxClientIdFallback; + } + throw Exception('OSM Sandbox Client ID not configured. Set OSM_SANDBOX_CLIENTID environment variable or configure fallback in keys.dart'); +} diff --git a/lib/keys.dart.example b/lib/keys.dart.example deleted file mode 100644 index 068bf19..0000000 --- a/lib/keys.dart.example +++ /dev/null @@ -1,3 +0,0 @@ -// Example OSM OAuth key config -const String kOsmProdClientId = 'YOUR_PROD_CLIENT_ID_HERE'; -const String kOsmSandboxClientId = 'YOUR_SANDBOX_CLIENT_ID_HERE';