0.9.2 • Published 2 years ago

inspect-browser-storage v0.9.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

⚗️ inspect-browser-storage

npm version npm downloads Github Actions

With this package you can locally and programmatically modify the LocalStorage and SessionStorage of a browser. This also applies to an Browser based Electron app.

⚠️ The default paths currently belong to chromium, other browsers will be added in the next versions. But you can set dbPath option for other databases. ⚠️

Usage

Install package:

# npm
npm install inspect-browser-storage

# yarn
yarn install inspect-browser-storage

# pnpm
pnpm install inspect-browser-storage

Import:

// ESM
import { writeToStorage, readFromStorage } from 'inspect-browser-storage'

// CommonJS
const { writeToStorage, readFromStorage } = require('inspect-browser-storage')

readFromStorage(domain, key, options?)

Example:

const data = await readFromStorage('test-application.de', 'auth_token')
// -> Returns the value of the key 'auth_token' in the localStorage of 'https://test-application.de/'

Options:

  • dbPath: (string) The domain in the storage.
  • key: (string) the key of the item in storage
  • options?: (object) Options are defaults and get merged with the default options.
    • dbPath: (string) Path to the database, default is the chromium path on your system
    • autoUnlink: (boolean) If true, the package will try to unlock the database LOCK File. Default is true
    • protocol: (string) Which protocol should be added to the domain, can be https:// or http://. Default is https://
    • storage: (string) Define which storage it should use, can be localStorage or sessionStorage. Default is localStorage

writeToStorage(domain, key, value, options?)

Example:

const data = await writeToStorage('test-application.de', 'auth_token', 'eyDasdlok.......')

Options:

  • dbPath: (string) The domain in the storage.
  • key: (string) the key of the item in storage
  • value: (string) the value which should set to the key in storage
  • options?: (object) Options are defaults and get merged with the default options.
    • dbPath: (string) Path to the database, default is the chromium path on your system
    • autoUnlink: (boolean) If true, the package will try to unlock the database LOCK File. Default is true
    • protocol: (string) Which protocol should be added to the domain, can be https:// or http://. Default is https://
    • storage: (string) Define which storage it should use, can be localStorage or sessionStorage. Default is localStorage

💻 Development

  • Clone this repository
  • Install dependencies using yarn install
  • Run watcher build yarn dev

License

Made with 💚 by Conner Bachmann. The idea originally comes from Jan Bölsche and his package chrome-localstorage

Published under MIT License.