The persistence strategy we use does not work well or at all with what we need for a spending limit permission and the associated uintLimit caveat type. Specifically:
We use a single storage key for the entire state, writing to it once per second.
We want to persist a subset of the rpc-cap state, and we only want rpc-cap to touch it.
There are probably security concerns here (storage.local can probably be accessed through accident or malice), but we can save that for later.
It's a little all over the place and I don't like it.
Here's what I want to do:
[ ] Pop out the extension's lib/local-store.js into an ExtensionStore class in obs-store
Or at the very least, implement that class and leave the extension as is.
[ ] Write a PersistentController class in gaba with a parallel (or total?) disk store for stuff that has to be persisted
[ ] Write some kind of abstract PersistentStorage class in obs-store or gaba that is used to implement LocalStorage and ExtensionStorage classes for use in PersistentController
Its get and set methods will be async as in the extension's local-store, and we'll have to use a mutex (await-semaphore as used elsewhere?) or I'll have to use IndexedDB (see this MDN link)
[ ] Make the CapabilitiesController in rpc-cap extend PersistentController and start persisting
Adding a sendTransaction permission requires:
2019-09-04 I've made progress on defining the caveat that will be used to implement spending limits. Persistence is the big problem.
Some findings after researching storage APIs and our current state persistence solution:
storage.local
in this snippet inbackground.js
, which uses a class implemented in the extension.window.localStorage
through LocalStorageStore fromobs-store
, although per the MDN link above, only very old browsers do not supportstorage.local
.uintLimit
caveat type. Specifically:storage.local
can probably be accessed through accident or malice), but we can save that for later.Here's what I want to do:
lib/local-store.js
into anExtensionStore
class inobs-store
PersistentController
class ingaba
with a parallel (or total?) disk store for stuff that has to be persistedPersistentStorage
class inobs-store
orgaba
that is used to implementLocalStorage
andExtensionStorage
classes for use inPersistentController
get
andset
methods will be async as in the extension'slocal-store
, and we'll have to use a mutex (await-semaphore
as used elsewhere?) or I'll have to useIndexedDB
(see this MDN link)CapabilitiesController
in rpc-cap extendPersistentController
and start persisting