@wireapp/cryptobox
Version:
High-level API with persistent storage for Proteus.
33 lines (32 loc) • 1.1 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var ReadOnlyStore = (function () {
function ReadOnlyStore(store) {
this.store = store;
this.prekeys = [];
}
ReadOnlyStore.prototype.get_prekeys = function () {
return this.store.load_prekeys();
};
ReadOnlyStore.prototype.release_prekeys = function (deletedPreKeyIds) {
var _this = this;
deletedPreKeyIds.forEach(function (id) {
var index = _this.prekeys.indexOf(id);
if (index > -1) {
_this.prekeys.splice(index, 1);
}
});
};
ReadOnlyStore.prototype.get_prekey = function (prekey_id) {
if (this.prekeys.indexOf(prekey_id) !== -1) {
return Promise.reject(new Error("PreKey \"" + prekey_id + "\" not found."));
}
return this.store.load_prekey(prekey_id);
};
ReadOnlyStore.prototype.remove = function (prekey_id) {
this.prekeys.push(prekey_id);
return Promise.resolve();
};
return ReadOnlyStore;
}());
exports.default = ReadOnlyStore;
;