Allows sharing of local storage across domains.
Use a host to give access to local storage.
Use a guest to gain access to the local storage on a host.
Install
npm i cross-domain-storage
Usage
Host
var createHost = ;
host(allowedDomains)
Call with an array of allowed domains.
var storageHost = ;
host.close()
storageHost;// storageHost will no longer allow access from guests and can no longer be used.
Guest
var createGuest = ;
guest(hostURL)
Create a guest and connect to the host.
Any methods that are called while connecting are queued up and handled seamlessly.
// Hosted on http://www.foo.comvar bazStorage = ;
guest.get(key, callback)
bazStorage;
guest.set(key, value, callback)
NOTE: The keys and the values in localStorage are always strings thus objects, numbers etc used as keys or values will be automatically converted to strings.
bazStorage;
guest.remove(key, callback)
bazStorage;
guest.close()
bazStorage;//connection is now closed and bazStorage can no longer be used.