storage.EncryptedStorage Extends goog.storage.CollectableStorage
Provides an encrypted storage. The keys are hashed with a secret, so their existence cannot be verified without the knowledge of the secret. The values are encrypted using the key, a salt, and the secret, so stream cipher initialization varies for each stored value.

Inheritance

Constructor

goog.storage.EncryptedStorage(mechanismsecret)

Parameters

mechanism : !goog.storage.mechanism.IterableMechanism
The underlying storage mechanism.
secret : string
The secret key used to encrypt the storage.

Instance Methods

Public Protected Private
decryptValue_(saltkeyvalue) string
Decrypts a value using a key, a salt, and the secret.
Arguments:
salt : !Array.<number>
The salt.
key : string
The key.
value : string
The encrypted value.
Returns: string  The decrypted value.
code »
encryptValue_(saltkeyvalue) string
Encrypts a value using a key, a salt, and the secret.
Arguments:
salt : !Array.<number>
The salt.
key : string
The key.
value : string
The cleartext value.
Returns: string  The encrypted value.
code »
getWrapper()
No description.
code »
hashKeyWithSecret_(key) string
Hashes a key using the secret.
Arguments:
key : string
The key.
Returns: string  The hash.
code »
remove()
No description.
code »
set()
No description.
code »
collect(opt_strict)
Cleans up the storage by removing expired keys.
Arguments:
opt_strict : boolean=
Also remove invalid keys.
code »
collectInternal(keysopt_strict) !Array.<string>
Cleans up the storage by removing expired keys.
Arguments:
keys : Array.<string>
List of all keys.
opt_strict : boolean=
Also remove invalid keys.
Returns: !Array.<string>  a list of expired keys.
code »
getExpiredKeys_(keysopt_strict) !Array.<string>
Iterate over keys and returns those that expired.
Arguments:
keys : goog.iter.Iterable
keys to iterate over.
opt_strict : boolean=
Also return invalid keys.
Returns: !Array.<string>  Keys of values that expired.
code »
getWrapper(keyopt_expired) ⇒ (!Object | undefined)
Get an item wrapper (the item and its metadata) from the storage.
Arguments:
key : string
The key to get.
opt_expired : boolean=
If true, return expired wrappers as well.
Returns: (!Object | undefined)  The wrapper, or undefined if not found.
code »
set(keyvalueopt_expiration)
Set an item in the storage.
Arguments:
key : string
The key to set.
value : *
The value to serialize to a string and save.
opt_expiration : number=
The number of miliseconds since epoch (as in goog.now()) when the value is to expire. If the expiration time is not provided, the value will persist as long as possible.
code »
get()
No description.
code »
getWrapper(key) ⇒ (!Object | undefined)
Get an item wrapper (the item and its metadata) from the storage. WARNING: This returns an Object, which once used to be goog.storage.RichStorage.Wrapper. This is due to the fact that deserialized objects lose type information and it is hard to do proper typecasting in JavaScript. Be sure you know what you are doing when using the returned value.
Arguments:
key : string
The key to get.
Returns: (!Object | undefined)  The wrapper, or undefined if not found.
code »
set()
No description.
code »
get(key) *
Gets an item from the data storage.
Arguments:
key : string
The key to get.
Returns: *  Deserialized value or undefined if not found.
code »
remove(key)
Removes an item from the data storage.
Arguments:
key : string
The key to remove.
code »
set(keyvalue)
Sets an item in the data storage.
Arguments:
key : string
The key to set.
value : *
The value to serialize to a string and save.
code »

Instance Properties

cleartextSerializer_ : goog.json.Serializer
The JSON serializer used to serialize values before encryption. This can be potentially different from serializing for the storage mechanism (see goog.storage.Storage), so a separate serializer is kept here.
Code »
constructor :
No description.
Code »
secret_ :
The secret used to encrypt the storage.
Code »
constructor :
No description.
Code »
constructor :
No description.
Code »
constructor :
No description.
Code »
The mechanism used to persist key-value pairs.
Code »

Static Properties

goog.storage.EncryptedStorage.SALT_KEY :
Metadata key under which the salt is stored.
Code »
goog.storage.EncryptedStorage.superClass_ :
No description.
Code »

Package storage

Package Reference