canmove, Confirmed users
725
edits
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> | 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) { | ||
CryptoWrapper.call(this, uri); | |||
} | } | ||
FooRecord.prototype = { | FooRecord.prototype = { | ||
__proto__: CryptoWrapper.prototype, | __proto__: CryptoWrapper.prototype, | ||
_logname: "Record.Foo", | _logname: "Record.Foo", | ||
get bar() this.cleartext.bar, | get bar() this.cleartext.bar, |