Firefox/Kinto: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with "= Kinto Integration in Firefox = == Use Cases == == Upgrade client libraries ==")
 
(Remove decommissioned use-cases)
 
(28 intermediate revisions by 9 users not shown)
Line 1: Line 1:
= Kinto Integration in Firefox =
= Kinto Integration in Firefox =


[http://www.kinto-storage.org Kinto] is a simple JSON storage service that was integrated into Firefox, and currently used for RemoteSettings.


== Use Cases ==
= Key features =


==  
* Diff-based data synchronization
Upgrade client libraries ==
* Offline persistence
* Data integrity/signing
* Peer review to publish data changes
* Admin panel UI
* Built-in Telemetry
* Firefox Accounts Integration
 
= Use Cases =
 
{|class="wikitable"
! 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
|-
|}
 
It used be supporting more use-cases in the past. See also [https://github.com/mozilla-services/servicedenuages.fr/blob/master/content/2017.12.kinto-at-mozilla.rst Kinto at Mozilla]
 
= Usage =
 
Two client libraries are vendored in Firefox:
 
* [https://github.com/Kinto/kinto-http.js Kinto HTTP client]: for direct interactions with the Kinto HTTP API
* [https://github.com/Kinto/kinto.js Kinto offline client]: for offline persistence in internal SQLite or IndexedDB
 
== HTTP client ==
 
<pre>
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();
</pre>
 
== Offline client ==
 
<pre>
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();
</pre>
 
= Resources =
 
* [https://remote-settings.readthedocs.io Remote Settings docs]
* [https://blog.mathieu-leplatre.info/the-history-of-firefox-remote-settings.html The History of Remote Settings]
* [https://github.com/mozilla-services/servicedenuages.fr/blob/master/content/2017.12.kinto-at-mozilla.rst Kinto at Mozilla] (blog post) -- see also [https://web.archive.org/web/20180111085958/https://www.servicedenuages.fr/en/kinto-at-mozilla the published version, no longer available at its initial location]
 
= Contribute =
 
=== Generate bundles ===
 
The Kinto client libraries are developed independently on Github:
 
* [https://github.com/Kinto/kinto-http.js kinto-http] is the HTTP client for the Kinto REST API;
* [https://github.com/Kinto/kinto.js 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 <code>moz-kinto-offline-client.js</code> file:
 
<pre>
$ npm run dist-fx
</pre>
 
And overwrite it in the Firefox code base:
   
<pre>
$ cp dist/moz-kinto-offline-client.js ../mozilla-central/services/common/kinto-offline-client.js
</pre>
 
==== kinto-http.js ====
 
From the kinto-http.js repo, generate the <code>moz-kinto-http-client.js</code> file:
 
<pre>
$ npm run dist-fx
</pre>
 
And overwrite it in the Firefox code base:
 
<pre>
$ cp dist/moz-kinto-http-client.js ../mozilla-central/services/common/kinto-http-client.js
</pre>

Latest revision as of 09:58, 19 February 2021

Kinto Integration in Firefox

Kinto is a simple JSON storage service that was integrated into Firefox, and currently used for RemoteSettings.

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

It used be supporting more use-cases in the past. See also Kinto at Mozilla

Usage

Two client libraries are vendored in Firefox:

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();

Resources

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