Constructor
new LocalStorageAdapter(username, password)
Create a new LocalStorageAdapter
Parameters:
Name | Type | Description |
---|---|---|
username |
string |
The username of the account you wish to use |
password |
string |
The password of the account you wish to use |
Extends
Methods
(async) _save(account_data, identifier) → {Promise.<Object>}
Internal Save function to Save an Account to LocalStorage
Parameters:
Name | Type | Description |
---|---|---|
account_data |
Object |
The new Account Data you wish to save |
identifier |
Identifier |
The Identifier of the account you wish to save |
Returns:
Returns a Promise that will resolve to the Account Data of the updated account if successful
- Type:
- Promise.<Object>
(async) check() → {Promise.<Identifier>}
Check if the Account exists in LocalStorage. This matches an email to an identifier if the username being used is an email.
- Overrides:
- Source:
Returns:
Returns a Promsie that will resolve to the Accounts Identifier if set
- Type:
- Promise.<Identifier>
(async) checkForMnemonic() → {Promise.<Identifier>}
Check if the Account exists in LocalStorage by searching for mnemonic in encrypted data.
Returns:
Returns a Promsie that will resolve to the Accounts Identifier if set
- Type:
- Promise.<Identifier>
(async) create(account_data, emailopt) → {Promise.<Identifier>}
Create an account using the StorageAdapter
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
account_data |
Object |
The Account Data you wish to save |
|
email |
string |
<optional> |
The Email you wish to attach to your account |
- Inherited From:
- Source:
Returns:
The Identifier of the Created Account
- Type:
- Promise.<Identifier>
decrypt(encrypted_data) → {Object}
Decrypt the Account data
Parameters:
Name | Type | Description |
---|---|---|
encrypted_data |
string |
The Encrypted Data string to Decrypt |
- Inherited From:
- Source:
Throws:
-
If there is an error decrypting the encrypted data using the Password
- Type
- InvalidPassword
Returns:
Returns the decrypted data as a JSON Object
- Type:
- Object
encrypt(decrypted_data) → {string}
Encrypt the Account data
Parameters:
Name | Type | Description |
---|---|---|
decrypted_data |
Object |
A JSON object of the data you would like to encrypt |
- Inherited From:
- Source:
Returns:
Returns the Encrypted Data as a String
- Type:
- string
generateIdentifier() → {Identifier}
Generate a valid Identifier
- Inherited From:
- Source:
Returns:
Returns a newly generated identifier
- Type:
- Identifier
(async) load() → {Promise.<Object>}
Load the Account from LocalStorage
- Overrides:
- Source:
Throws:
-
-
If the password being used for login is invalid
- Type
- InvalidPassword
-
-
-
If the Account cannot beb found on the storage server
- Type
- AccountNotFoundError
-
Returns:
Returns a Promise that will resolve to the Decrypted Account Data if successful
- Type:
- Promise.<Object>
(async) save(account_data, identifieropt) → {Promise.<Identifier>}
Save an Account using the StorageAdapter
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
account_data |
Object |
The Account Data you wish to save |
|
identifier |
Identifier |
<optional> |
The Identifier of the Account you wish to save to |
- Inherited From:
- Source:
Returns:
Returns the Identifier of the saved account
- Type:
- Promise.<Identifier>