Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
indexeddb-export-import
Advanced tools
Changelog
v2.1.5
Readme
IndexedDB is a client-side database API available in modern browsers and https://electron.atom.io/. During development and testing of an web / desktop app which uses IndexedDB, it can be helpful to save, load, or clear the contents of an IndexedDB database - this package provides that capability.
You can use indexeddb-export-import in a Node.js environment imported as a module (eg. for use with an Electron app). You may also use it in a browser environment by simply including via a <script>
tag.
You will need an open IDBDatabase connection.
The following example exports a database, clears all object stores, then re-imports the database. It uses Dexie.js to initiate the database, but this is not required.
const Dexie = require('dexie');
const IDBExportImport = require('indexeddb-export-import');
const db = new Dexie('MyDB');
db.version(1).stores({
things: 'id++, thing_name, thing_description',
});
db.open().then(function() {
const idbDatabase = db.backendDB(); // get native IDBDatabase object from Dexie wrapper
// export to JSON, clear database, and import from JSON
IDBExportImport.exportToJsonString(idbDatabase, function(err, jsonString) {
if (err) {
console.error(err);
} else {
console.log('Exported as JSON: ' + jsonString);
IDBExportImport.clearDatabase(idbDatabase, function(err) {
if (!err) { // cleared data successfully
IDBExportImport.importFromJsonString(idbDatabase, jsonString, function(err) {
if (!err) {
console.log('Imported data successfully');
}
});
}
});
}
});
}).catch(function(e) {
console.error('Could not connect. ' + e);
});
Export all data from an IndexedDB database
Param | Type | Description |
---|---|---|
idbDatabase | IDBDatabase | |
cb | function | callback with signature (error, jsonString) |
Import data from JSON into an IndexedDB database. This does not delete any existing data from the database, so keys could clash
Param | Type | Description |
---|---|---|
idbDatabase | IDBDatabase | |
jsonString | string | data to import, one key per object store |
cb | function | callback with signature (error), where error is null on success |
Clears a database of all data
Param | Type | Description |
---|---|---|
idbDatabase | IDBDatabase | |
cb | function | callback with signature (error), where error is null on success |
$ npm install indexeddb-export-import
MIT
FAQs
Export/import an IndexedDB database to/from JSON
The npm package indexeddb-export-import receives a total of 1,605 weekly downloads. As such, indexeddb-export-import popularity was classified as popular.
We found that indexeddb-export-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.