Skip to content

Commit

Permalink
Added autofill component
Browse files Browse the repository at this point in the history
  • Loading branch information
lougeniaC64 committed Sep 18, 2020
1 parent 7762c4b commit c4c12a7
Show file tree
Hide file tree
Showing 16 changed files with 1,340 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
@@ -1,6 +1,7 @@
[workspace]
# Note: Any additions here should be repeated in default-members below.
members = [
"components/autofill",
"components/fxa-client",
"components/fxa-client/ffi",
"components/logins",
Expand All @@ -24,6 +25,7 @@ members = [
"components/support/rc_crypto/nss/systest",
"components/support/sql",
"components/support/sync15-traits",
"components/support/types",
"components/support/viaduct-reqwest",
"components/sync_manager",
"components/sync_manager/ffi",
Expand Down Expand Up @@ -68,6 +70,7 @@ members = [
# To be clear: passing the `--all` or `--workspace` arg to cargo will make it
# use the full member set.
default-members = [
"components/autofill",
"components/fxa-client",
"components/fxa-client/ffi",
"components/logins",
Expand All @@ -88,6 +91,7 @@ default-members = [
"components/support/rc_crypto/nss/nss_sys",
"components/support/sql",
"components/support/sync15-traits",
"components/support/types",
"components/support/viaduct-reqwest",
"components/sync_manager",
"components/sync_manager/ffi",
Expand Down
33 changes: 33 additions & 0 deletions components/autofill/Cargo.toml
@@ -0,0 +1,33 @@
[package]
name = "autofill"
edition = "2018"
version = "0.1.0"
authors = ["application-services@mozilla.com"]
license = "MPL-2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
error-support = { path = "../support/error" }
interrupt-support = { path = "../support/interrupt" }
log = "0.4"
serde = "1"
serde_derive = "1"
serde_json = "1"
sql-support = { path = "../support/sql" }
sync-guid = { path = "../support/guid", features = ["rusqlite_support", "random"] }
sync15-traits = {path = "../support/sync15-traits"}
thiserror = "1.0"
types = { path = "../support/types" }
url = { version = "2.1", features = ["serde"] }

[dependencies.rusqlite]
version = "0.23.1"
features = ["functions", "bundled", "serde_json", "unlock_notify"]

[dev-dependencies]
env_logger = { version = "0.7", default-features = false }
libsqlite3-sys = "0.18.0"

[build-dependencies]
nss_build_common = { path = "../support/rc_crypto/nss/nss_build_common" }
16 changes: 16 additions & 0 deletions components/autofill/build.rs
@@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

//! Work around the fact that `sqlcipher` might get enabled by a cargo feature
//! another crate in the workspace needs, without setting up nss. (This is a
//! gross hack).

fn main() {
println!("cargo:rerun-if-changed=build.rs");
// Ugh. This is really really dumb. We don't care about sqlcipher at all. really
if nss_build_common::env_str("DEP_SQLITE3_LINK_TARGET") == Some("sqlcipher".into()) {
// If NSS_DIR isn't set, we don't really care, ignore the Err case.
let _ = nss_build_common::link_nss();
}
}
99 changes: 99 additions & 0 deletions components/autofill/sql/create_shared_schema.sql
@@ -0,0 +1,99 @@
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.

CREATE TABLE IF NOT EXISTS addresses_data (
guid TEXT NOT NULL PRIMARY KEY,
given_name TEXT NOT NULL,
additional_name TEXT NOT NULL,
family_name TEXT NOT NULL,
organization TEXT NOT NULL, -- Company
street_address TEXT NOT NULL, -- (Multiline)
address_level3 TEXT NOT NULL, -- Suburb/Sublocality
address_level2 TEXT NOT NULL, -- City/Town
address_level1 TEXT NOT NULL, -- Province (Standardized code if possible)
postal_code TEXT NOT NULL,
country TEXT NOT NULL, -- ISO 3166
tel TEXT NOT NULL, -- Stored in E.164 format
email TEXT NOT NULL,

time_created INTEGER NOT NULL,
time_last_used INTEGER,
time_last_modified INTEGER NOT NULL,
times_used INTEGER NOT NULL DEFAULT 0,

sync_change_counter INTEGER NOT NULL DEFAULT 1
);

CREATE TABLE IF NOT EXISTS addresses_mirror (
guid TEXT NOT NULL PRIMARY KEY,
given_name TEXT NOT NULL,
additional_name TEXT NOT NULL,
family_name TEXT NOT NULL,
organization TEXT NOT NULL, -- Company
street_address TEXT NOT NULL, -- (Multiline)
address_level3 TEXT NOT NULL, -- Suburb/Sublocality
address_level2 TEXT NOT NULL, -- City/Town
address_level1 TEXT NOT NULL, -- Province (Standardized code if possible)
postal_code TEXT NOT NULL,
country TEXT NOT NULL, -- ISO 3166
tel TEXT NOT NULL, -- Stored in E.164 format
email TEXT NOT NULL,

time_created INTEGER NOT NULL,
time_last_used INTEGER,
time_last_modified INTEGER NOT NULL,
times_used INTEGER NOT NULL DEFAULT 0
);

CREATE TABLE IF NOT EXISTS addresses_tombstones (
guid TEXT PRIMARY KEY,
time_deleted INTEGER NOT NULL
) WITHOUT ROWID;

-- NOTE: The credit card tables below are not being implemented as there are still outstanding
-- questions around how we address security model.

-- CREATE TABLE IF NOT EXISTS credit_cards_data (
-- guid TEXT NOT NULL PRIMARY KEY,
-- cc_name TEXT NOT NULL, -- full name
-- cc_given_name TEXT NOT NULL,
-- cc_additonal_name TEXT NOT NULL,
-- cc_family_name TEXT NOT NULL,
-- cc_number TEXT NOT NULL,
-- cc_exp_month INTEGER,
-- cc_exp_year INTEGER,
-- cc_type TEXT NOT NULL,
-- cc_exp TEXT NOT NULL, -- text format of the expiration date e.g. "[cc_exp_year]-[cc_exp_month]"

-- time_created INTEGER NOT NULL,
-- time_last_used INTEGER,
-- time_last_modified INTEGER NOT NULL,
-- times_used INTEGER NOT NULL DEFAULT 0,

-- /* Same "sync change counter" strategy used by other components. */
-- sync_change_counter INTEGER NOT NULL DEFAULT 1
-- );

-- CREATE TABLE IF NOT EXISTS credit_cards_mirror (
-- guid TEXT NOT NULL PRIMARY KEY,
-- cc_name TEXT NOT NULL, -- full name
-- cc_given_name TEXT NOT NULL,
-- cc_additonal_name TEXT NOT NULL,
-- cc_family_name TEXT NOT NULL,
-- cc_number TEXT NOT NULL,
-- cc_exp_month INTEGER,
-- cc_exp_year INTEGER,
-- cc_type TEXT NOT NULL,
-- cc_exp TEXT NOT NULL, -- text format of the expiration date e.g. "[cc_exp_year]-[cc_exp_month]"

-- time_created INTEGER NOT NULL,
-- time_last_used INTEGER,
-- time_last_modified INTEGER NOT NULL,
-- times_used INTEGER NOT NULL DEFAULT 0
-- );

-- CREATE TABLE IF NOT EXISTS credit_cards_tombstones (
-- guid TEXT PRIMARY KEY,
-- time_deleted INTEGER NOT NULL
-- ) WITHOUT ROWID;
20 changes: 20 additions & 0 deletions components/autofill/sql/create_shared_triggers.sql
@@ -0,0 +1,20 @@

-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.

-- This file defines triggers shared between the main and Sync connections.

CREATE TEMP TRIGGER addresses_data_afterinsert_trigger
AFTER INSERT ON addresses_data
FOR EACH ROW WHEN NEW.guid IN (SELECT guid FROM addresses_tombstones)
BEGIN
SELECT RAISE(FAIL, 'guid exists in `addresses_tombstones`');
END;

CREATE TEMP TRIGGER addresses_tombstones_afterinsert_trigger
AFTER INSERT ON addresses_tombstones
WHEN NEW.guid IN (SELECT guid FROM addresses_data)
BEGIN
SELECT RAISE(FAIL, 'guid exists in `addresses_data`');
END;

0 comments on commit c4c12a7

Please sign in to comment.