Implement rust credit card storage adapter
Categories
(Toolkit :: Form Autofill, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox158 | --- | fixed |
People
(Reporter: dimi, Assigned: dimi)
References
(Blocks 1 open bug)
Details
Attachments
(2 external files)
| Assignee | ||
Comment 1•2 months ago
|
||
Present the AutofillRecords credit card interface over the Application Services
autofill Store, so it can later back FormAutofillStorage.getCreditCards().
Nothing constructs it yet.
Shaped after RustAutofillAddressStorage: the same method surface in the same
order, and the same two pure module-level conversion functions either side of
it. What differs follows from the Rust credit card schema rather than from a
different design.
The number is stored encrypted and only its last four digits in the clear, so
this store derives the masked cc-number on read where the JSON store stores it
and derives the ciphertext instead. #stripComputedFields and #encryptNumber are
the two ends of that, and they sit where CreditCardsBase puts them: the stored
record is decrypted before it can be merged from, and the merged record is
validated, because a number the caller did not restate arrives from the stored
side. update() recomputes before writing, as the JSON store does before it
saves -- normalizeFields derives cc-type from the number, so an edit that did
not carry one would otherwise clear the stored type.
#stripComputedFields drops the mask before it tries to restore the number, and
puts it back only on a decryption that succeeded. scrubEncryptedData() blanks
cc_number_enc and leaves cc_number_last_4, so a record can hold a mask with no
number behind it; keeping that mask through the merge would encrypt it and
store it as the card number.
The encryption is interim. It uses OSKeyStore, the same mechanism and the same
key as the JSON store's cc-number-encrypted, so a number written here is
readable by every existing consumer and no new key is introduced; the store
treats cc_number_enc as an opaque string on every path this adapter uses. The
Application Services key API is deliberately unused: nothing in the tree
consumes it, and who owns that key is being settled separately.
isStoredCreditCardField() excludes the fields derived on read, cc-type and
cc-number among them, so a later comparison against the JSON store does not read
a changed detection table or a rebuilt mask as an unfaithful copy. Only the last
four digits survive, so that mask is rebuilt at a fixed width and a 14- or
15-digit card reads back wider than it was written.
The store has no bulk import, no tombstone import, no delete-all and no bridged
sync engine for credit cards, and no column for billingAddressGUID, so unlike
the address adapter this one has no addManyWithMeta(), addManyTombstones(),
wipe() or bridgedEngine(). A migration and a sync engine need those from
application-services first.
test_rust_autofill_credit_card_adapter.js covers the round trip with the number
encrypted and read back masked, an edit that does not restate the number, one
that replaces it, an update after a scrub, and get() telling a missing record
from an unreadable one.
| Assignee | ||
Comment 2•2 months ago
|
||
Brings in the credit card bulk-import APIs P2 needs: add_credit_card_with_meta,
add_many_credit_cards_with_meta, update_credit_card_with_meta,
add_many_credit_card_tombstones and delete_all_credit_cards. They mirror the
address with-meta API, so an application copying a credit card collection into
this store keeps each record's guid, timestamps and change counter rather than
having the store generate them. Autofill also now sanitizes timestamps from
untrusted sources, as logins did in bug 2066257.
The revision this replaces, 5a011ab3, was a feature branch tip rather than a
commit on main. Both of its code changes are on main verbatim, so returning to
main reverts nothing. The other eight commits in the delta are unrelated to this
work: the logins half of bug 2066257, an ads-client refactor and its new
blocks request parameter, an address time_last_modified fix, and refreshed
search-config dumps.
No new crates, so Cargo.lock only gains the types dependency logins picked up.
The regenerated bindings add autofill doc comments and the ads-client field, and
the UniFFI function table moves only for the autofill methods added here.
Updated•2 months ago
|
Updated•2 months ago
|
Comment 4•2 months ago
|
||
| bugherder | ||
Updated•2 months ago
|
Description
•