Add 'SyncedMap' (fixes #43)
The SyncedMap class implements a simple key-value store on top of
PrefixTree.
Fix getKeys test, add incoming updates test
The order in which getKeys gives its results is not deterministic,
so better to check that there are exactly two elements and both the ones
we want are there.
The incoming updates test works together with the load test to test
the actual loading of the data from the PrefixTree. Load should call
fireInitial, and then the PrefixTree will fire local events to fill
the SyncedMap. Also, the PrefixTree will pass on incoming events from
remote, and it's also tested that SyncedMap updates its data for this
then.
Add 'CredentialsStore' class (fixes #44)
The CredentialsStore can be used in any module that stores some
kind of config or credentials. It offers the option to do client-side
encryption.
For now, the module needs to supply the password both when setting and
when getting, but in the future, the widget may take care of letting
the user enter their client-side encryption password. As soon as that
code lands in rs.js master, we can update this class so that it calls
something like `remoteStorage.widget.getPassword` instead.
The password must be a string or undefined for no encryption. Setting
will always work; getting will only work if the password matches the one
that was used the last time when setting. Even though the password does
not leave the device, it is not a per-device password; it is of course
necessary to use the same password on all your devices, because they
all sync and if one device writes an encrypted config, all other devices
will receive that same encrypted config when they read from the remote
storage.
Add change handler and first test
I forgot that it would actually be good to have a change handler
which warns when the config is changed from another device. It
does not give you a change event because it may not be able to
decrypt the change without you giving it the password, so you can
just do a getConfig from the handler when this is fired.
This commit also adds a first unit test and makes sure the @context
field is deleted when you read the config back.
Add naturaldocs documentation
As per @silverbucket's review comment https://github.com/remotestorage/modules/pull/45#issuecomment-43075841
naturaldocs comments and fix typo
Documented the class, also fixed a typo in the `on` function
make it a proper object, fix the incoming changes test
I moved the three functions to the prototype, and the changeHandler, moduleName
and privClient variables to the `this`. I also fixed the incoming changes test
Improved error reporting and added tests for it
I found that at some points I was throwing Error objects, and at others
I was throwing strings. I changed them all to strings for consistency,
and because if a string works, then why construct a useless object around
it.
Fix sjcl check, test all documented exceptions
If you check for !sjcl then that check will in itself error. Checking
whether its type is undefined does have the desired effect, though.
I took the exceptions documented in the naturaldocs comments and added
a test for each one, seeing that they are actually being thrown.
Put secret inside register to match actual sockethub-client syntax
When giving the config to sockethub-client, the secret should be inside
an object called register, so we might as well store it directly in
that format.
Move irc credentials into CredentialsStore, update schema
It is better to have credentials as a separate OAuth scope, and to
be able to encrypt them with a master password. So far only sockethub
credentials were in a separate module, this PR does the same for irc
credentials, which were tagged onto the messages module until now.

This commit also switches to the new CredentialsStore class, and updates
the schema to match the latest API changes in sockethub.
Add twitter module
This PR adds the Twitter module. To do:

* [ ] add schema
* [ ] add API docs
* [ ] add unit tests
irc -> irc-credentials
twitter -> twitter-credentials
add -credentials suffix to moduleName
document adding -credentials suffix to moduleName
add tests for irc-credentials module
add schema
add unit tests
Merge branch 'feature/43-SyncedMap' into ahead