Firefox/Kinto: Difference between revisions
< Firefox
Jump to navigation
Jump to search
(Remove obsolete and duplicate information) |
(Minor formatting) |
||
Line 25: | Line 25: | ||
|- | |- | ||
|<code>storage.sync</code> | |<code>storage.sync</code> | ||
|[[WebExtensions]] | |[[WebExtensions]] API for user data storage. Every users have their own bucket (''default bucket'' plugin), the allowed amount of data is limited (''quotas'' plugin), and the data is encrypted using Firefox Accounts keys. See also [[CloudServices/Sync/ExtensionStorage_Design_Doc]] | ||
|Ethan Glasser Camp — :glasserc | |Ethan Glasser Camp — :glasserc | ||
|- | |- |
Revision as of 09:35, 26 April 2018
Kinto Integration in Firefox
Kinto is a simple JSON storage service that was integrated into Firefox, mainly for RemoteSettings and the storage.sync
API.
Key features
- Diff-based data synchronization
- Offline persistence
- Data integrity/signing
- Peer review to publish data changes
- Admin panel UI
- Built-in Telemetry
- Firefox Accounts Integration
Use Cases
Component | Description | Contact |
---|---|---|
RemoteSettings | Firefox/RemoteSettings allows to ship data and files to Firefox. It is used for blocklists, security state, Activity Stream, Fennec assets and experiments etc. | Mathieu Leplatre — :leplatrem |
storage.sync
|
WebExtensions API for user data storage. Every users have their own bucket (default bucket plugin), the allowed amount of data is limited (quotas plugin), and the data is encrypted using Firefox Accounts keys. See also CloudServices/Sync/ExtensionStorage_Design_Doc | Ethan Glasser Camp — :glasserc |
Test Pilot | Some experiments (like Notes) require user data to be saved remotely and synchronized across devices. A Kinto server was deployed with Firefox Accounts login support, and kinto.js library is used to encrypt and sync data. | Senior Software Engineer — :vladikoff |
See also Kinto at Mozilla
Feel free to come and discuss on #storage
:)
Usage
Two client libraries are vendored in Firefox:
- Kinto HTTP client: for direct interactions with the Kinto HTTP API
- Kinto offline client: for offline persistence in internal SQLite or IndexedDB
HTTP client
const { KintoHttpClient } = Cu.import("resource://services-common/kinto-http-client.js", {}); const remote = "https://kinto.dev.mozaws.net/v1"; const headers = { Authorization: "Basic " + btoa("user:pass") }; const client = new KintoHttpClient(remote, {headers}); const records = await client.bucket("a-bucket") .collection("a-collection") .listRecords();
Offline client
const { Kinto } = Cu.import("resource://services-common/kinto-offline-client.js", {}); const remote = "https://kinto.dev.mozaws.net/v1"; const headers = { Authorization: "Basic " + btoa("user:pass") }; const kinto = new Kinto(); const bucket = "a-bucket"; const collection = kinto.collection("a-collection"); // Fetch/Publish changes. const { ok } = await collection.sync({ bucket, remote, headers }); // Read local collection of records. const records = await collection.list();
Contribute
Generate bundles
The Kinto client libraries are developed independently on Github:
- kinto-http is the HTTP client for the Kinto REST API;
- kinto.js is the offline-first client for Kinto.
With the help of Babel and browserify, a bundle is generated for Firefox with the minimum transpilation possible (eg. CommonJS require, ES7 decorators).
kinto.js
From the kinto.js repo, generate the moz-kinto-offline-client.js
file:
$ npm run dist-fx
And overwrite it in the Firefox code base:
$ cp dist/moz-kinto-offline-client.js ../mozilla-central/services/common/kinto-offline-client.js
kinto-http.js
From the kinto-http.js repo, generate the moz-kinto-http-client.js
file:
$ npm run dist-fx
And overwrite it in the Firefox code base:
$ cp dist/moz-kinto-http-client.js ../mozilla-central/services/common/kinto-http-client.js