CloudServices/Sync/FxSync/Developer/ClientAPI: Difference between revisions

Jump to navigation Jump to search
Line 30: Line 30:
A Record object is a wrapper around a single instance of whatever data it is that you are syncing -- a single bookmark in the case of the bookmark engine, a single browser tab in the case of the tab engine, and so on.
A Record object is a wrapper around a single instance of whatever data it is that you are syncing -- a single bookmark in the case of the bookmark engine, a single browser tab in the case of the tab engine, and so on.


There's a class called <tt>CryptoWrapper</tt> defined in <tt>weave/modules/base_records/crypto.js</tt>, which handles all the encryption and decryption of your record for you.  All you have to do is write a class that extends <tt>CryptoWrapper</tt> and maintains a property called <tt>cleartext</tt>.  <tt>cleartext</tt> must be a JSON-dictionary-style object; put into it all values that you want to have encrypted, stored on the server, decrypted, and synced up.
There's a class called <tt>CryptoWrapper</tt> defined in <tt>services/sync/modules/base_records/crypto.js</tt>, which handles all the encryption and decryption of your record for you.  All you have to do is write a class that extends <tt>CryptoWrapper</tt> and maintains a property called <tt>cleartext</tt>.  <tt>cleartext</tt> must be a JSON-dictionary-style object; put into it all values that you want to have encrypted, stored on the server, decrypted, and synced up.


You may find it useful to write getters and setters for various properties of your Record class.
You may find it useful to write getters and setters for various properties of your Record class.
Line 37: Line 37:


<pre>
<pre>
  function FooRecord() {
  function FooRecord(uri) {
   this._FooRecord_init();
   CryptoWrapper.call(this, uri);
  }
  }
  FooRecord.prototype = {
  FooRecord.prototype = {
   __proto__: CryptoWrapper.prototype,
   __proto__: CryptoWrapper.prototype,
   _logname: "Record.Foo",  
   _logname: "Record.Foo",  
  _FooRecord_init: function FooItem_init(uri) {
    this._CryptoWrap_init(uri);
    this.cleartext = {};
  },


   get bar() this.cleartext.bar,  
   get bar() this.cleartext.bar,  
canmove, Confirmed users
725

edits

Navigation menu