New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-extra-plugin-session

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-extra-plugin-session

A puppeteer plugin to dump and inject session data.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
78
decreased by-82.35%
Maintainers
1
Weekly downloads
 
Created
Source

puppeteer-extra-plugin-session

A puppeteer-extra plugin to export and import session data (cookies, localStorage, sessionStorage, indexedDb)

Introduction

Dump and restore session data from your puppeteer pages.

This plugin supports:

  • cookies
  • localStorage
  • sessionStorage
  • IndexedDB (currently, only the securityOrigin of the current page will get dumped)

Installation

yarn add puppeteer-extra-plugin-session
# or
npm install puppeteer-extra-plugin-session

Usage

Basic usage

First of all, you have to register the plugin with puppeteer-extra.

JavaScript:

puppeteer.use(require('puppeteer-extra-plugin-session').default());

TypeScript:

import SessionPlugin from 'puppeteer-extra-plugin-session';
puppeteer.use(SessionPlugin());

Then, you'll have access to session data helpers:

const sessionData = await page.session.dump(); // or page.session.dumpString()

// [...]

await page.session.restore(sessionData); // or page.session.restoreString(sessionData)

Selecting storage backends

You may wish to exclude certain storage backends from being dumped or restored. This can be done by passing an options object to the dump and restore methods:

import { StorageProviderName } from 'puppeteer-extra-plugin-session';

const sessionData = await page.session.dump({
  storageProviders: [
    StorageProviderName.Cookie,
    StorageProviderName.LocalStorage,
  ], // only dump cookies and LocalStorage
});

// Here is the list of StorageProviderName:
//  * StorageProviderName.Cookie
//  * StorageProviderName.LocalStorage
//  * StorageProviderName.SessionStorage
//  * StorageProviderName.IndexedDB

// You can also filter what gets restored:
await page.session.restore(sessionData, {
  storageProviders: [StorageProviderName.Cookie], // only restore cookies (the previous dump also contained LocalStorage)
});

Testing

Tests are defined in *.spec.ts files.

You can run the tests watcher using yarn test or npm run test

Debugging

You can see the package's logs by setting the DEBUG=puppeteer-extra-plugin:session env variable.

Example: DEBUG=puppeteer-extra-plugin:session npm test

Base Puppeteer-Extra Plugin System

See the core Puppeteer-Extra Plugin docs for additional information: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin

Contributing

We appreciate all contributions.

See TODO.md

License

MIT

Resources

Keywords

FAQs

Package last updated on 24 Sep 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc