
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
cross-domain-storage
Advanced tools
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.
npm i cross-domain-storage
var createHost = require('cross-domain-storage/host');
Call with an array of allowed domains.
var storageHost = createHost([
{
origin: 'http://www.foo.com',
allowedMethods: ['get', 'set', 'remove'],
},
{
origin: 'http://www.bar.com',
allowedMethods: ['get'],
},
]);
storageHost.close();
// storageHost will no longer allow access from guests and can no longer be used.
var createGuest = require('cross-domain-storage/guest');
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.com
var bazStorage = createGuest('http://www.baz.com/accessStorage');
bazStorage.get('fizz', function(error, value) {
// value for the key of 'fizz' will be retrieved from localStorage on www.baz.com
});
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.set('foo', 'bar', function(error, data) {
// foo is now set to 'bar'
});
bazStorage.remove('foo', function(error, data) {
// foo is now removed
});
bazStorage.close();
//connection is now closed and bazStorage can no longer be used.
FAQs
Cross domain local storage
The npm package cross-domain-storage receives a total of 819 weekly downloads. As such, cross-domain-storage popularity was classified as not popular.
We found that cross-domain-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.