Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions components/logins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ default = []
keydb = ["nss/keydb", "dep:async-trait", "dep:futures"]

[dependencies]
# TODO: we've enabled the "standalone-sync" feature - see the description
# of this feature in sync15's Cargo.toml for what we should do instead.
sync15 = { path = "../sync15", features=["standalone-sync"] }
sync15 = { path = "../sync15" }
serde = "1"
serde_derive = "1"
serde_json = "1"
Expand Down
25 changes: 0 additions & 25 deletions components/logins/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub use error_support::{debug, error, info, trace, warn};

use error_support::{ErrorHandling, GetErrorHandling};
use jwcrypto::JwCryptoError;
use sync15::Error as Sync15Error;

// Errors we return via the public interface.
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -50,9 +49,6 @@ pub enum LoginsApiError {
#[error("{reason}")]
Interrupted { reason: String },

#[error("SyncAuthInvalid error {reason}")]
SyncAuthInvalid { reason: String },

#[error("Unexpected Error: {reason}")]
UnexpectedLoginsApiError { reason: String },
}
Expand Down Expand Up @@ -87,9 +83,6 @@ pub enum Error {
#[error("decryption failed: {0:?}")]
DecryptionFailed(String),

#[error("Error synchronizing: {0}")]
SyncAdapterError(#[from] sync15::Error),

#[error("Error parsing JSON data: {0}")]
JsonError(#[from] serde_json::Error),

Expand Down Expand Up @@ -171,24 +164,6 @@ impl GetErrorHandling for Error {
Self::Interrupted(_) => ErrorHandling::convert(LoginsApiError::Interrupted {
reason: self.to_string(),
}),
Self::SyncAdapterError(e) => match e {
Sync15Error::TokenserverHttpError(401) | Sync15Error::BadKeyLength(..) => {
ErrorHandling::convert(LoginsApiError::SyncAuthInvalid {
reason: e.to_string(),
})
.log_warning()
}
Sync15Error::RequestError(_) => {
ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
reason: e.to_string(),
})
.log_warning()
}
_ => ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
reason: self.to_string(),
})
.report_error("logins-sync"),
},
Error::SqlError(rusqlite::Error::SqliteFailure(err, _)) => match err.code {
rusqlite::ErrorCode::DatabaseCorrupt => {
ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
Expand Down
4 changes: 0 additions & 4 deletions components/logins/src/logins.udl
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ interface LoginsApiError {
/// An operation was interrupted at the request of the consuming app.
Interrupted(string reason);

/// Sync reported that authentication failed and the user should re-enter their FxA password.
// TODO: remove this at the same time as remove the sync() method in favour of the SyncManager.
SyncAuthInvalid(string reason);

/// something internal went wrong which doesn't have a public error value
/// because the consuming app can not reasonably take any action to resolve it.
/// The underlying error will have been logged and reported.
Expand Down
9 changes: 1 addition & 8 deletions components/logins/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,9 @@
//! This table was added (by this rust crate) in version 4, and so is not
//! present in firefox-ios.
//!
//! Currently it is used to store two items:
//!
//! 1. The last sync timestamp is stored under [LAST_SYNC_META_KEY], a
//! Currently it is used to store the last sync timestamp, under [LAST_SYNC_META_KEY], a
//! `sync15::ServerTimestamp` stored in integer milliseconds.
//!
//! 2. The persisted sync state machine information is stored under
//! [GLOBAL_STATE_META_KEY]. This is a `sync15::GlobalState` stored as
//! JSON.
//!

use crate::error::*;
use lazy_static::lazy_static;
Expand Down Expand Up @@ -197,7 +191,6 @@ const CREATE_DELETED_ORIGIN_INDEX_SQL: &str = "
";

pub(crate) static LAST_SYNC_META_KEY: &str = "last_sync_time";
pub(crate) static GLOBAL_STATE_META_KEY: &str = "global_state_v2";
pub(crate) static GLOBAL_SYNCID_META_KEY: &str = "global_sync_id";
pub(crate) static COLLECTION_SYNCID_META_KEY: &str = "passwords_sync_id";
pub(crate) static CHECKPOINT_KEY: &str = "checkpoint";
Expand Down
15 changes: 0 additions & 15 deletions components/logins/src/sync/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,20 +297,6 @@ impl LoginsSyncEngine {
Ok(Some(ServerTimestamp(millis)))
}

pub fn set_global_state(&self, state: &Option<String>) -> Result<()> {
let to_write = match state {
Some(ref s) => s,
None => "",
};
let db = self.store.lock_db()?;
db.put_meta(schema::GLOBAL_STATE_META_KEY, &to_write)
}

pub fn get_global_state(&self) -> Result<Option<String>> {
let db = self.store.lock_db()?;
db.get_meta::<String>(schema::GLOBAL_STATE_META_KEY)
}

fn mark_as_synchronized(&self, guids: &[&str], ts: ServerTimestamp) -> Result<()> {
let db = self.store.lock_db()?;
let tx = db.unchecked_transaction()?;
Expand Down Expand Up @@ -378,7 +364,6 @@ impl LoginsSyncEngine {
db.put_meta(schema::COLLECTION_SYNCID_META_KEY, &ids.coll)?;
}
};
db.delete_meta(schema::GLOBAL_STATE_META_KEY)?;
tx.commit()?;
Ok(())
}
Expand Down
4 changes: 1 addition & 3 deletions components/places/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ exclude = ["/android", "/ios"]
default = []

[dependencies]
# TODO: we've enabled the "standalone-sync" feature - see the description
# of this feature in sync15's Cargo.toml for what we should do instead.
sync15 = { path = "../sync15", features=["standalone-sync"] }
sync15 = { path = "../sync15" }
serde = "1"
serde_derive = "1"
serde_json = "1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,6 @@ class PlacesApi(path: String) : PlacesManager, AutoCloseable {
override fun close() {
this.writeConn.apiRef.clear()
}

override fun syncHistory(syncInfo: SyncAuthInfo): SyncTelemetryPing {
val pingJSONString = this.api.historySync(
syncInfo.kid,
syncInfo.fxaAccessToken,
syncInfo.syncKey,
syncInfo.tokenserverURL,
)
return SyncTelemetryPing.fromJSONString(pingJSONString)
}

override fun syncBookmarks(syncInfo: SyncAuthInfo): SyncTelemetryPing {
val pingJSONString = this.api.bookmarksSync(
syncInfo.kid,
syncInfo.fxaAccessToken,
syncInfo.syncKey,
syncInfo.tokenserverURL,
)
return SyncTelemetryPing.fromJSONString(pingJSONString)
}

override fun resetHistorySyncMetadata() {
this.api.resetHistory()
}

override fun resetBookmarkSyncMetadata() {
return this.api.bookmarksReset()
}
}

@Suppress("TooGenericExceptionCaught")
Expand Down Expand Up @@ -530,50 +502,6 @@ interface PlacesManager {
* This should always return the same object.
*/
fun getWriter(): WritableHistoryConnection

/**
* Syncs the places history store, returning a telemetry ping.
*
* Note that this function blocks until the sync is complete, which may
* take some time due to the network etc. Because only 1 thread can be
* using a PlacesAPI at a time, it is recommended, but not enforced, that
* you have all connections you intend using open before calling this.
*/
fun syncHistory(syncInfo: SyncAuthInfo): SyncTelemetryPing

/**
* Syncs the places bookmarks store, returning a telemetry ping.
*
* Note that this function blocks until the sync is complete, which may
* take some time due to the network etc. Because only 1 thread can be
* using a PlacesAPI at a time, it is recommended, but not enforced, that
* you have all connections you intend using open before calling this.
*/
fun syncBookmarks(syncInfo: SyncAuthInfo): SyncTelemetryPing

/**
* Resets all sync metadata for history, including change flags,
* sync statuses, and last sync time. The next sync after reset
* will behave the same way as a first sync when connecting a new
* device.
*
* This method only needs to be called when the user disconnects
* from Sync. There are other times when Places resets sync metadata,
* but those are handled internally in the Rust code.
*/
fun resetHistorySyncMetadata()

/**
* Resets all sync metadata for bookmarks, including change flags,
* sync statuses, and last sync time. The next sync after reset
* will behave the same way as a first sync when connecting a new
* device.
*
* This method only needs to be called when the user disconnects
* from Sync. There are other times when Places resets sync metadata,
* but those are handled internally in the Rust code.
*/
fun resetBookmarkSyncMetadata()
}

interface InterruptibleConnection : AutoCloseable {
Expand Down
Loading