Add generateDefaultKey, r?markh draft
authorEthan Glasser-Camp <eglassercamp@mozilla.com>
Wed, 24 Aug 2016 13:42:50 -0400
changeset 405196 0cd5905bb941b7e8592761b9d00f860ad00f6f63
parent 405195 7c6dce93823c3b210855efa2b42313b7d4d9c8e0
child 405197 56d268732e2c7d04764a4a4a586e7d1098508bff
push id27431
push usereglassercamp@mozilla.com
push dateThu, 25 Aug 2016 02:36:08 +0000
reviewersmarkh
milestone50.0a1
Add generateDefaultKey, r?markh All CollectionKeyManagers need to have default keys, but I didn't want to expose the mechanism whereby default keys are created (with a special "[default]" name). MozReview-Commit-ID: AfD90IQTh6f
services/sync/modules/record.js
--- a/services/sync/modules/record.js
+++ b/services/sync/modules/record.js
@@ -406,16 +406,24 @@ CollectionKeyManager.prototype = {
   generateNewKeysWBO: function(collections) {
     let newDefaultKey, newColls;
     [newDefaultKey, newColls] = this.newKeys(collections);
 
     return this._makeWBO(newColls, newDefaultKey);
   },
 
   /**
+   * Generate a new default key, since without one you cannot use setContents.
+   */
+  generateDefaultKey: function() {
+    this._default = new BulkKeyBundle(DEFAULT_KEYBUNDLE_NAME);
+    this._default.generateRandom();
+  },
+
+  /**
    * Return true if keys are already present for each of the given
    * collections.
    */
   hasKeysFor: function(collections) {
     // We can't use filter() here because sometimes collections is an iterator.
     for (let collection of collections) {
       if (!this._collections[collection]) return false;
     }