169
edits
m (→Sync Now) |
No edit summary |
||
| Line 1: | Line 1: | ||
The Client Agent supports an RPC-like API which allows clients to register themselves with the notification service, as well as create and remove subscriptions to web app notifications. | The Client Agent supports an RPC-like API which allows clients to register themselves with the notification service, as well as create and remove subscriptions to web app notifications. | ||
= | = Scenarios = | ||
== New (Potentially First) Client == | |||
<ol> | <ol> | ||
| Line 42: | Line 44: | ||
</ol> | </ol> | ||
= | == New Subscription == | ||
<ol> | <ol> | ||
<li> | <li> | ||
| Line 54: | Line 56: | ||
C: Authorization: Basic BASE64== | C: Authorization: Basic BASE64== | ||
C: | C: | ||
C: {"token": " | C: {"token": "BASE64=="} | ||
</pre> | </pre> | ||
</li> | </li> | ||
| Line 65: | Line 67: | ||
</li> | </li> | ||
<li>Client uploads new notifications/subscriptions WBO to Sync | <li>Client uploads new notifications/subscriptions WBO to Sync. | ||
</li> | </li> | ||
<li>Client passes key ''K'', token ''T'', and POST Office URL to web app | <li>Client passes key ''K'', token ''T'', and POST Office URL to web app. | ||
</li> | </li> | ||
</ol> | </ol> | ||
= | == Terminate Subscription == | ||
<ol> | <ol> | ||
| Line 93: | Line 95: | ||
</ol> | </ol> | ||
= | == Broadcast to Other Clients == | ||
<ol> | <ol> | ||
<li>Client broadcasts message to other clients of the authorized user. The format is very similar to that of the POST Office API. | <li>Client broadcasts message to other clients of the authorized user. The format is very similar to that of the POST Office API. | ||
| Line 101: | Line 103: | ||
C: | C: | ||
C: { | C: { | ||
"body":"{\"IV\":\"IV in Base 64\",...", | "body": "{\"IV\":\"IV in Base 64\",...", | ||
"HMAC":"BASE64==" | "HMAC": "BASE64==" | ||
} | } | ||
S: HTTP/1.1 200 OK | S: HTTP/1.1 200 OK | ||
</pre></li> | </pre> | ||
</li> | |||
<li>Body is a JSON serialization of: | <li>Body is a JSON serialization of: | ||
<pre> | <pre> | ||
{ | |||
"timestamp": ######## (in seconds UTC), // Optional, | |||
"ttl": ######## (in seconds), // Optional | |||
"ciphertext": "BASE64==", | |||
"IV": "BASE64==", | |||
} | } | ||
</pre> | </pre> | ||
</li> | |||
<li>Ciphertext is the payload encrypted using AES-256-CBC and base-64 encoded. For an example of what payloads would look like, see [[#Broadcast Messages|Broadcast Messages]] | |||
</li> | </li> | ||
| Line 134: | Line 128: | ||
</ol> | </ol> | ||
== Broadcast Messages == | === Broadcast Messages === | ||
Each broadcast message is encrypted and contained entirely within the ciphertext attribute of the message body. The following is a list of the type of broadcast messages supported by clients. | Each broadcast message is encrypted and contained entirely within the "ciphertext" attribute of the message body. The following is a list of the type of broadcast messages supported by browser clients. | ||
=== Send Tab To Client === | ==== Send Tab To Client ==== | ||
Copies a tab from one client and sends it to another client. | Copies a tab from one client and sends it to another client. | ||
<pre> | <pre> | ||
{ | { | ||
"type": "send_tab", | |||
"client_id": "BASE64==", // Sync client ID | |||
"url": "...", | |||
// | // OPTIONAL: Implement either one of the following fields to transfer tab history and form data | ||
"moztabinfo": "{Serialized Tab State}" // Value returned by nsISessionStore.getTabState() | |||
"tabinfo": [{"url":"...", "title":"...", "formdata":"..."}] // Generic format (STILL NEEDS SPECING) | |||
} | } | ||
</pre> | </pre> | ||
=== Sync Now === | Note that this message is broadcasted, so the "client_id" field must be compared against the client's own ID to make sure the message was intended for it. | ||
==== Sync Now ==== | |||
Send a message to clients indicating that important data has been synced, and so all clients should sync ASAP. | Send a message to clients indicating that important data has been synced, and so all clients should sync ASAP. | ||
<pre> | <pre> | ||
{ | { | ||
"type": "sync_now", | |||
"sender_id": "BASE64==", // Sync client ID of client who sent this message | |||
"engines": ["bookmarks", "tabs", ...] // Optional list of engines to sync | |||
} | } | ||
</pre> | </pre> | ||
edits