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
--- 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;
}