Given a moduleName and a privateClient, this class provides a getConfig and a setConfig function which you can directly use in your module. It also deals with optional client-side encryption, and exposes a change event for the config you store in it. It assumes your module declares a type called ‘config’ using BaseClient.declareType. Other than that, you will be able to pretty much expose the three methods directly on your module.
moduleName | String, the name of the module in which you are using it, but without the “-credentials” suffix. |
privClient | The private BaseClient for your module, you get this from the callback call in remoteStorage.defineModule |
CredentialsStore | Given a moduleName and a privateClient, this class provides a getConfig and a setConfig function which you can directly use in your module. |
Functions | |
setConfig | Set the config/credentials |
getConfig | Get the config/credentials |
on | Register an event handler. |
CredentialsStore.prototype.setConfig = function( pwd, config )
Set the config/credentials
pwd | String value of the password for client-side encryption, or undefined. |
config | object, the config/credentials to be saved. |
’config should be an object’ ‘please include sjcl.js (the Stanford JS Crypto Library) in your app’ ‘Schema Not Found’ (if you didn’t call declareType first) ‘Please follow the config schema - (followed by the schema from your declareType)’
CredentialsStore.prototype.getConfig = function( pwd )
Get the config/credentials
pwd | String value of the password for client-side encryption, or undefined. |
’please include sjcl.js (the Stanford JS Crypto Library) in your app’ ‘could not decrypt (moduleName)-config with that password’ ‘could not parse (moduleName)-config as unencrypted JSON’ ‘(moduleName)-config is encrypted, please specify a password for decryption’ ‘(moduleName)-config is not encrypted, or encrypted with a different algorithm’
Set the config/credentials
CredentialsStore.prototype.setConfig = function( pwd, config )
Get the config/credentials
CredentialsStore.prototype.getConfig = function( pwd )
Register an event handler.
CredentialsStore.prototype.on = function( eventName, handler )