π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use api.ente.com as Rust production API
Manav Rathi8612db849fa3
diff --git a/rust/accounts/src/types.rs b/rust/accounts/src/types.rsindex 71437fc06f..d94e706af2 100644--- a/rust/accounts/src/types.rs+++ b/rust/accounts/src/types.rs@@ -1,13 +1,13 @@//! Shared reusable types for account clients.-use ente_core::http::HttpConfig;+use ente_core::{http::HttpConfig, urls::PRODUCTION_API_BASE_URL};use futures_timer::Delay;use serde::{Deserialize, Serialize};use std::{future::Future, pin::Pin, sync::Arc, time::Duration};use zeroize::Zeroize;/// Default base URL for Ente's public API.-pub const DEFAULT_API_BASE_URL: &str = "https://api.ente.io";+pub const DEFAULT_API_BASE_URL: &str = PRODUCTION_API_BASE_URL;/// Default base URL for Ente's accounts broker.pub const DEFAULT_ACCOUNTS_URL: &str = "https://accounts.ente.io";diff --git a/rust/cli/src/api/client.rs b/rust/cli/src/api/client.rsindex e215f54ef8..dfda4839a2 100644--- a/rust/cli/src/api/client.rs+++ b/rust/cli/src/api/client.rs@@ -2,6 +2,7 @@use crate::api::retry::RetryConfig;use crate::models::error::{Error, Result};+use ente_core::urls::PRODUCTION_API_BASE_URL;use reqwest::{Client, RequestBuilder, Response, StatusCode};use serde::{Deserialize, Serialize};use std::collections::HashMap;@@ -9,7 +10,6 @@ use std::sync::{Arc, RwLock};use std::time::Duration;use tokio::time::sleep;-const ENTE_API_ENDPOINT: &str = "https://api.ente.io";const TOKEN_HEADER: &str = "X-Auth-Token";const CLIENT_PKG_HEADER: &str = "X-Client-Package";const DEFAULT_CLIENT_PACKAGE: &str = "io.ente.photos";@@ -96,7 +96,7 @@ impl ApiClient {Ok(Self {client,download_client,- base_url: base_url.unwrap_or_else(|| ENTE_API_ENDPOINT.to_string()),+ base_url: base_url.unwrap_or_else(|| PRODUCTION_API_BASE_URL.to_string()),client_package: client_package.into(),tokens: Arc::new(RwLock::new(HashMap::new())),retry_config: RetryConfig::default(),diff --git a/rust/cli/src/api/methods.rs b/rust/cli/src/api/methods.rsindex d9e9609d03..5832e8f8e0 100644--- a/rust/cli/src/api/methods.rs+++ b/rust/cli/src/api/methods.rs@@ -4,6 +4,7 @@ use crate::api::models::{GetThumbnailUrlResponse, UserDetails,};use crate::models::error::Result;+use ente_core::urls::file_download_url;/// API methods for interacting with Ente servicespub struct ApiMethods<'a> {@@ -102,16 +103,7 @@ impl<'a> ApiMethods<'a> {/// Get download URL for a filepub async fn get_file_url(&self, _account_id: &str, file_id: i64) -> Result<String> {- // Check if we're using the default API endpoint- let base_url = &self.api.base_url;- if base_url == "https://api.ente.io" {- // Use the CDN URL for production- Ok(format!("https://files.ente.io/?fileID={file_id}"))- } else {- // For custom/dev environments, use direct download URL- // The Go implementation shows this is the pattern- Ok(format!("{base_url}/files/download/{file_id}"))- }+ Ok(file_download_url(&self.api.base_url, file_id))}/// Get thumbnail URL for a filediff --git a/rust/cli/src/cli/account.rs b/rust/cli/src/cli/account.rsindex bd0ceac8f8..9cb830ca77 100644--- a/rust/cli/src/cli/account.rs+++ b/rust/cli/src/cli/account.rs@@ -26,8 +26,8 @@ pub enum AccountSubcommands {#[arg(long, default_value = "photos")]app: String,- /// API endpoint (defaults to https://api.ente.io)- #[arg(long, default_value = "https://api.ente.io")]+ /// API endpoint (defaults to https://api.ente.com)+ #[arg(long, default_value = "https://api.ente.com")]endpoint: String,/// Export directory path@@ -62,8 +62,8 @@ pub enum AccountSubcommands {#[arg(long, default_value = "photos")]app: String,- /// API endpoint (defaults to https://api.ente.io)- #[arg(long, default_value = "https://api.ente.io")]+ /// API endpoint (defaults to https://api.ente.com)+ #[arg(long, default_value = "https://api.ente.com")]endpoint: String,/// Export directory pathdiff --git a/rust/cli/src/commands/account.rs b/rust/cli/src/commands/account.rsindex f4a2a96b8d..5e43ed68da 100644--- a/rust/cli/src/commands/account.rs+++ b/rust/cli/src/commands/account.rs@@ -14,6 +14,7 @@ use ente_accounts::{SecondFactorMethod, SetupTwoFactorParams, TotpPurpose,};use ente_core::crypto::SecretVec;+use ente_core::urls::PRODUCTION_API_BASE_URL;use std::{path::PathBuf, str::FromStr};use zeroize::Zeroizing;@@ -227,8 +228,8 @@ async fn list_accounts(storage: &Storage) -> Result<()> {println!("{}", "-".repeat(110));for account in accounts {- let endpoint_display = if account.endpoint == "https://api.ente.io" {- "api.ente.io (prod)".to_string()+ let endpoint_display = if account.endpoint == PRODUCTION_API_BASE_URL {+ "api.ente.com (prod)".to_string()} else if account.endpoint.starts_with("http://localhost") {format!("localhost:{}",diff --git a/rust/cli/src/storage/schema.rs b/rust/cli/src/storage/schema.rsindex 41e4fdcbd7..46b8826563 100644--- a/rust/cli/src/storage/schema.rs+++ b/rust/cli/src/storage/schema.rs@@ -11,7 +11,7 @@ pub fn create_tables(conn: &Connection) -> Result<()> {user_id INTEGER NOT NULL,app TEXT NOT NULL,email TEXT NOT NULL,- endpoint TEXT NOT NULL DEFAULT 'https://api.ente.io',+ endpoint TEXT NOT NULL DEFAULT 'https://api.ente.com',export_dir TEXT,created_at INTEGER NOT NULL,updated_at INTEGER NOT NULL,diff --git a/rust/core/examples/ping.rs b/rust/core/examples/ping.rsindex 07d41532ab..8e41359f5d 100644--- a/rust/core/examples/ping.rs+++ b/rust/core/examples/ping.rs@@ -1,7 +1,7 @@//! Example: ping the Ente API.//!//! ```sh-//! cargo run --example ping -- https://api.ente.io+//! cargo run --example ping -- https://api.ente.com//! ```use ente_core::http::HttpClient;diff --git a/rust/core/src/http.rs b/rust/core/src/http.rsindex bf6dac50eb..8adc33e2fb 100644--- a/rust/core/src/http.rs+++ b/rust/core/src/http.rs@@ -885,8 +885,8 @@ mod tests {#[test]fn test_client_creation() {- let client = test_client("https://api.ente.io/");- assert_eq!(client.base_url, "https://api.ente.io");+ let client = test_client("https://api.ente.com/");+ assert_eq!(client.base_url, "https://api.ente.com");}#[test]@@ -913,16 +913,16 @@ mod tests {#[test]fn test_request_url_uses_string_join() {- let client = test_client("https://api.ente.io/v1");+ let client = test_client("https://api.ente.com/v1");let url = client.request_url("/ping").unwrap();- assert_eq!(url, "https://api.ente.io/v1/ping");+ assert_eq!(url, "https://api.ente.com/v1/ping");}#[test]fn test_request_url_preserves_query_and_special_bytes() {- let client = test_client("https://api.ente.io/v1");+ let client = test_client("https://api.ente.com/v1");let url = client.request_url("/%2e%2e%5cadmin?fresh=true").unwrap();- assert_eq!(url, "https://api.ente.io/v1/%2e%2e%5cadmin?fresh=true");+ assert_eq!(url, "https://api.ente.com/v1/%2e%2e%5cadmin?fresh=true");}#[test]@@ -935,7 +935,7 @@ mod tests {#[test]fn test_request_url_rejects_missing_leading_slash() {- let client = test_client("https://api.ente.io");+ let client = test_client("https://api.ente.com");let err = client.request_url("ping").unwrap_err();assert!(matches!(err, Error::InvalidUrl(_)));}@@ -949,21 +949,21 @@ mod tests {#[test]fn test_request_url_rejects_base_url_with_query() {- let client = test_client("https://api.ente.io/v1?stale=true");+ let client = test_client("https://api.ente.com/v1?stale=true");let err = client.request_url("/ping").unwrap_err();assert!(matches!(err, Error::InvalidUrl(_)));}#[test]fn test_request_url_rejects_base_url_with_fragment() {- let client = test_client("https://api.ente.io/v1#old");+ let client = test_client("https://api.ente.com/v1#old");let err = client.request_url("/ping").unwrap_err();assert!(matches!(err, Error::InvalidUrl(_)));}#[test]fn test_set_auth_token_replaces_token() {- let client = test_client("https://api.ente.io");+ let client = test_client("https://api.ente.com");client.set_auth_token(Some("token-1".to_string()));assert_eq!(clientdiff --git a/rust/core/src/urls.rs b/rust/core/src/urls.rsindex 772ecdf9f8..47ad8693a6 100644--- a/rust/core/src/urls.rs+++ b/rust/core/src/urls.rs@@ -1,8 +1,11 @@//! URL construction utilities.+/// Production API base URL.+pub const PRODUCTION_API_BASE_URL: &str = "https://api.ente.com";+/// Generate the download URL for a file.pub fn file_download_url(api_base_url: &str, file_id: i64) -> String {- if api_base_url == "https://api.ente.io" {+ if api_base_url == PRODUCTION_API_BASE_URL {format!("https://files.ente.io/?fileID={}", file_id)} else {format!("{}/files/download/{}", api_base_url, file_id)@@ -15,7 +18,7 @@ mod tests {#[test]fn test_production_url() {- let url = file_download_url("https://api.ente.io", 12345);+ let url = file_download_url(PRODUCTION_API_BASE_URL, 12345);assert_eq!(url, "https://files.ente.io/?fileID=12345");}diff --git a/rust/ensu/sync/src/http.rs b/rust/ensu/sync/src/http.rsindex 98bc93f025..0c2ca759d5 100644--- a/rust/ensu/sync/src/http.rs+++ b/rust/ensu/sync/src/http.rs@@ -1,5 +1,6 @@use std::time::Duration;+use ente_core::urls::PRODUCTION_API_BASE_URL;use reqwest::Url;use reqwest::blocking::{Client, Response};use reqwest::header::{HeaderMap, HeaderName, HeaderValue, LOCATION};@@ -10,7 +11,7 @@ use uuid::Uuid;use crate::errors::SyncError;-const DEFAULT_BASE_URL: &str = "https://api.ente.io";+const DEFAULT_BASE_URL: &str = PRODUCTION_API_BASE_URL;#[derive(Debug, Clone)]pub struct HttpConfig {diff --git a/web/packages/wasm/tests/urls.test.ts b/web/packages/wasm/tests/urls.test.tsindex 6463d078ca..31397883c8 100644--- a/web/packages/wasm/tests/urls.test.ts+++ b/web/packages/wasm/tests/urls.test.ts@@ -2,7 +2,7 @@ import { expect, test } from "vitest";import { file_download_url } from "../pkg/ente_wasm.js";test("generates CDN URL for production", () => {- const url = file_download_url("https://api.ente.io", BigInt(12345));+ const url = file_download_url("https://api.ente.com", BigInt(12345));expect(url).toBe("https://files.ente.io/?fileID=12345");});