Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix auth app to send correct client_pkg header

Prateek Sunal75db9c2c45c5
diff --git a/mobile/packages/configuration/lib/base_configuration.dart b/mobile/packages/configuration/lib/base_configuration.dart
index d934faea08..00f9c3fa72 100644
--- a/mobile/packages/configuration/lib/base_configuration.dart
+++ b/mobile/packages/configuration/lib/base_configuration.dart
@@ -280,6 +280,13 @@ class BaseConfiguration {
return _preferences.getString(endPointKey) ?? endpoint;
}
+ // isEnteProduction checks if the current endpoint is the default production
+ // endpoint. This is used to determine if the app is in production mode or
+ // not. The default production endpoint is set in the environment variable
+ bool isEnteProduction() {
+ return getHttpEndpoint() == kDefaultProductionEndpoint;
+ }
+
Future<void> setHttpEndpoint(String endpoint) async {
await _preferences.setString(endPointKey, endpoint);
Bus.instance.fire(EndpointUpdatedEvent());
diff --git a/mobile/packages/network/lib/network.dart b/mobile/packages/network/lib/network.dart
index d36a3e721b..257fd33d43 100644
--- a/mobile/packages/network/lib/network.dart
+++ b/mobile/packages/network/lib/network.dart
@@ -24,7 +24,31 @@ class Network {
}
final packageInfo = await PackageInfo.fromPlatform();
final version = packageInfo.version;
- final packageName = packageInfo.packageName;
+ String packageName = packageInfo.packageName;
+
+ // Fix package name for auth app on Windows/Linux only
+ // On Linux, packageInfo returns "ente_auth" from pubspec.yaml (via version.json)
+ // On Windows, packageInfo returns "Ente Auth" from Runner.rc InternalName field
+ // We need to normalize both to "io.ente.auth" to match Android/iOS/macOS
+ if (Platform.isWindows || Platform.isLinux) {
+ if (packageName == 'ente_auth' || packageName == 'Ente Auth') {
+ packageName = 'io.ente.auth';
+ }
+ }
+
+ // Validate package name for production endpoint
+ // This ensures we catch any edge cases where the package name is still incorrect
+ if (configuration.isEnteProduction()) {
+ if (!packageName.startsWith('io.ente.')) {
+ throw Exception(
+ 'Invalid client package name "$packageName" for production endpoint. '
+ 'Expected package name to start with "io.ente." but got "$packageName". '
+ 'This indicates the package name normalization failed. '
+ 'Please check the platform-specific configuration.',
+ );
+ }
+ }
+
final endpoint = configuration.getHttpEndpoint();
_dio = Dio(