Source code
Revision control
Copy as Markdown
Other Tools
namespace autofill {
// We expose the crypto primitives on the namespace
/// Create a new, random, encryption key.
[Throws=AutofillApiError]
string create_autofill_key();
/// Encrypt an arbitrary string - `key` must have come from `create_key()`
[Throws=AutofillApiError]
string encrypt_string(string key, string cleartext);
/// Decrypt an arbitrary string - `key` must have come from `create_key()`
/// and `ciphertext` must have come from `encrypt_string()`
[Throws=AutofillApiError]
string decrypt_string(string key, string ciphertext);
};
/// What you pass to create or update a credit-card.
dictionary UpdatableCreditCardFields {
string cc_name;
string cc_number_enc;
string cc_number_last_4;
i64 cc_exp_month;
i64 cc_exp_year;
string cc_type;
};
/// What you get back as a credit-card.
dictionary CreditCard {
string guid;
string cc_name;
string cc_number_enc;
string cc_number_last_4;
i64 cc_exp_month;
i64 cc_exp_year;
string cc_type;
i64 time_created;
i64? time_last_used;
i64 time_last_modified;
i64 times_used;
};
/// What you pass to create or update an address.
dictionary UpdatableAddressFields {
string name;
string organization;
string street_address;
string address_level3;
string address_level2;
string address_level1;
string postal_code;
string country;
string tel;
string email;
};
/// What you get back as an address.
dictionary Address {
string guid;
string name;
string organization;
string street_address;
string address_level3;
string address_level2;
string address_level1;
string postal_code;
string country;
string tel;
string email;
i64 time_created;
i64? time_last_used;
i64 time_last_modified;
i64 times_used;
};
/// What you pass to create or update a passport.
dictionary UpdatablePassportFields {
string name;
string country;
string passport_number;
i64 issue_date_month;
i64 issue_date_day;
i64 issue_date_year;
i64 expiry_date_month;
i64 expiry_date_day;
i64 expiry_date_year;
};
/// What you get back as a passport.
dictionary Passport {
string guid;
string name;
string country;
string passport_number;
i64 issue_date_month;
i64 issue_date_day;
i64 issue_date_year;
i64 expiry_date_month;
i64 expiry_date_day;
i64 expiry_date_year;
i64 time_created;
i64? time_last_used;
i64 time_last_modified;
i64 times_used;
};
/// Metadata fields managed internally by the library: the guid, timestamps and
/// local sync state. These are automatically set on `add_credit_card` and
/// updated on operations like `touch` and `update_credit_card`. Not included in
/// `UpdatableCreditCardFields`; use `add_credit_card_with_meta` when importing
/// records that already have metadata.
dictionary CreditCardMeta {
string guid;
i64 time_created;
i64? time_last_used;
i64 time_last_modified;
i64 times_used;
i64 sync_change_counter;
};
/// A credit card together with its metadata, passed to `add_credit_card_with_meta`
/// and `update_credit_card_with_meta` when importing a record from another store.
dictionary UpdatableCreditCardFieldsWithMeta {
UpdatableCreditCardFields fields;
CreditCardMeta meta;
};
/// A bulk insert result entry, returned per input record by `add_many_credit_cards_with_meta`
[Enum]
interface CreditCardBulkResultEntry {
Success(CreditCard credit_card);
Error(string message);
};
/// A tombstone for a record deleted locally but not yet uploaded, supplied to
/// `add_many_credit_card_tombstones` when migrating from another store.
dictionary CreditCardTombstone {
string guid;
i64 time_deleted;
};
/// Per-record result of `add_many_credit_card_tombstones`.
[Enum]
interface CreditCardBulkTombstoneResultEntry {
Success(string guid);
Error(string message);
};
/// Metadata fields managed internally by the library: the guid, timestamps and
/// local sync state. These are automatically set on `add_address` and updated on
/// operations like `touch` and `update_address`. Not included in
/// `UpdatableAddressFields`; use `add_address_with_meta` when importing records
/// that already have metadata.
dictionary AddressMeta {
string guid;
i64 time_created;
i64? time_last_used;
i64 time_last_modified;
i64 times_used;
i64 sync_change_counter;
};
/// An address together with its metadata, passed to `add_address_with_meta` and
/// `update_address_with_meta` when importing a record from another store.
dictionary UpdatableAddressFieldsWithMeta {
UpdatableAddressFields fields;
AddressMeta meta;
};
/// A bulk insert result entry, returned per input record by `add_many_addresses_with_meta`
[Enum]
interface AddressBulkResultEntry {
Success(Address address);
Error(string message);
};
/// A tombstone for a record deleted locally but not yet uploaded, supplied to
/// `add_many_address_tombstones` when migrating from another store.
dictionary AddressTombstone {
string guid;
i64 time_deleted;
};
/// Per-record result of `add_many_address_tombstones`.
[Enum]
interface AddressBulkTombstoneResultEntry {
Success(string guid);
Error(string message);
};
/// Metrics tracking scrubbing of credit cards that cannot be decrypted, see
// `scrub_undecryptable_credit_card_data_for_remote_replacement` for more details
dictionary CreditCardsDeletionMetrics {
u64 total_scrubbed_records;
};
[Error]
interface AutofillApiError {
SqlError(string reason);
InterruptedError();
CryptoError(string reason);
NoSuchRecord(string guid);
UnexpectedAutofillApiError(string reason);
};
interface Store {
[Throws=AutofillApiError]
constructor(string dbpath);
[Throws=AutofillApiError]
CreditCard add_credit_card(UpdatableCreditCardFields cc);
[Throws=AutofillApiError]
CreditCard get_credit_card(string guid);
[Throws=AutofillApiError]
sequence<CreditCard> get_all_credit_cards();
[Throws=AutofillApiError]
i64 count_all_credit_cards();
[Throws=AutofillApiError]
void update_credit_card(string guid, UpdatableCreditCardFields cc);
[Throws=AutofillApiError]
boolean delete_credit_card(string guid);
[Throws=AutofillApiError]
void touch_credit_card(string guid);
[Throws=AutofillApiError]
CreditCard add_credit_card_with_meta(UpdatableCreditCardFieldsWithMeta entry_with_meta);
[Throws=AutofillApiError]
sequence<CreditCardBulkResultEntry> add_many_credit_cards_with_meta(sequence<UpdatableCreditCardFieldsWithMeta> entries_with_meta);
[Throws=AutofillApiError]
sequence<CreditCardBulkTombstoneResultEntry> add_many_credit_card_tombstones(sequence<CreditCardTombstone> tombstones);
/// Removes every credit card and every credit card tombstone.
///
/// A migration primitive: it leaves the sync mirror intact and produces no
/// tombstones, so the deletions are never uploaded and a synced profile gets
/// the records back on the next sync. Use `delete_credit_card` to delete on the
/// user's behalf.
[Throws=AutofillApiError]
void delete_all_credit_cards();
[Throws=AutofillApiError]
void update_credit_card_with_meta(UpdatableCreditCardFieldsWithMeta entry_with_meta);
[Throws=AutofillApiError]
Address add_address(UpdatableAddressFields a);
[Throws=AutofillApiError]
Address add_address_with_meta(UpdatableAddressFieldsWithMeta entry_with_meta);
[Throws=AutofillApiError]
sequence<AddressBulkResultEntry> add_many_addresses_with_meta(sequence<UpdatableAddressFieldsWithMeta> entries_with_meta);
[Throws=AutofillApiError]
sequence<AddressBulkTombstoneResultEntry> add_many_address_tombstones(sequence<AddressTombstone> tombstones);
/// Removes every address and every address tombstone.
///
/// A migration primitive: it leaves the sync mirror intact and produces no
/// tombstones, so the deletions are never uploaded and a synced profile gets
/// the records back on the next sync. Use `delete_address` to delete on the
/// user's behalf.
[Throws=AutofillApiError]
void delete_all_addresses();
[Throws=AutofillApiError]
Address get_address(string guid);
[Throws=AutofillApiError]
sequence<Address> get_all_addresses();
[Throws=AutofillApiError]
i64 count_all_addresses();
[Throws=AutofillApiError]
void update_address(string guid, UpdatableAddressFields a);
[Throws=AutofillApiError]
void update_address_with_meta(UpdatableAddressFieldsWithMeta entry_with_meta);
[Throws=AutofillApiError]
boolean delete_address(string guid);
[Throws=AutofillApiError]
void touch_address(string guid);
[Throws=AutofillApiError]
Passport add_passport(UpdatablePassportFields p);
[Throws=AutofillApiError]
Passport get_passport(string guid);
[Throws=AutofillApiError]
sequence<Passport> get_all_passports();
[Throws=AutofillApiError]
i64 count_all_passports();
[Throws=AutofillApiError]
void update_passport(string guid, UpdatablePassportFields p);
[Throws=AutofillApiError]
boolean delete_passport(string guid);
[Throws=AutofillApiError]
void touch_passport(string guid);
[Throws=AutofillApiError, Self=ByArc]
void scrub_encrypted_data();
/// The `scrub_undecryptable_credit_card_data_for_remote_replacement` function locally scrubs credit cards
/// that cannot be decrypted, sets the record's metadata to their default values, and resets the credit card
/// engine so any existing server records can overwrite the locally scrubbed records.
///
/// NB: This function was created to unblock iOS credit card users who are unable to sync records and should not be used
/// outside of this use case.
[Throws=AutofillApiError, Self=ByArc]
CreditCardsDeletionMetrics scrub_undecryptable_credit_card_data_for_remote_replacement(string local_encryption_key);
/// Run maintenance on the DB
///
/// This is intended to be run during idle time and will take steps / to clean up / shrink the
/// database.
[Throws=AutofillApiError]
void run_maintenance();
void shutdown();
[Self=ByArc]
void register_with_sync_manager();
/// Returns a bridged sync engine for addresses, for use by Desktop's Sync
/// framework. Constructing it only assembles structs and never touches the
/// DB, so it cannot fail.
[Self=ByArc]
AddressesBridgedEngine addresses_bridged_engine();
};
/// The bridged sync engine for addresses. The canonical docs are in
/// services/interfaces/mozIBridgedSyncEngine.idl.
/// NOTE: all timestamps here are milliseconds.
interface AddressesBridgedEngine {
[Throws=AutofillApiError]
i64 last_sync();
[Throws=AutofillApiError]
string? sync_id();
[Throws=AutofillApiError]
string reset_sync_id();
[Throws=AutofillApiError]
string ensure_current_sync_id([ByRef]string new_sync_id);
[Throws=AutofillApiError]
void sync_started();
[Throws=AutofillApiError]
void store_incoming(sequence<string> incoming_envelopes_as_json);
[Throws=AutofillApiError]
sequence<string> apply(i64 server_modified_millis);
[Throws=AutofillApiError]
void set_uploaded(i64 new_timestamp, sequence<string> uploaded_ids);
[Throws=AutofillApiError]
void sync_finished();
[Throws=AutofillApiError]
void reset();
[Throws=AutofillApiError]
void wipe();
};