Socket
Socket
Sign inDemoInstall

node-chrome-webstore

Package Overview
Dependencies
24
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-chrome-webstore

Update and publish chrome extension automatically.


Version published
Maintainers
1
Install size
975 kB
Created

Readme

Source

node chrome webstore

Update and publish chrome extension automatically.

Prepare

If you have refresh_token, you can visit Subsequent calls directly.

Else please follow Using the Chrome Web Store Publish API instructions and come back when you get client id, client secret and code.

Code can only be used once, mainly use refresh token later.

Installation

npm i node-chrome-webstore

Usage

First call

Save refresh token and use it in subsequent calls

const webstore = require('node-chrome-webstore');

const client_id = '';
const client_secret = '';
const code = '';

webstore.auth({
  client_id,
  client_secret,
  code,
});

webstore.items.getRefreshToken().then((token) => {
  console.log(token); // save it
});

Subsequent calls

const webstore = require('node-chrome-webstore');

const client_id = '';
const client_secret = '';
const refresh_token = '';
const itemId = '';
const zipPath = '';

webstore.auth({
  client_id,
  client_secret,
  refresh_token,
});

// update
webstore.items.update(itemId, zipPath).then(res => {
    console.log(res);
});

// publish
webstore.items.publish(itemId).then(res => {
    console.log(res);
});

With dotenv example

dotenv can help to save auth info to .env in project root.

Strongly recommend against committing your .env file to version control. It should be in .gitignore.

.env

client_id=9867219971
client_secret=5d21TdajfIcK
refresh_token=1/jBtQRAjjy
code=4/lgAZRFXy
itemId=eppeghhopeo
zipPath=path/to/zip

Read auth info from .env

const webstore = require('node-chrome-webstore');

require('dotenv').config();

const {
  client_id,
  client_secret,
  refresh_token,
  itemId,
  zipPath,
} = process.env;

webstore.auth({
  client_id,
  client_secret,
  refresh_token,
});

webstore.items.update(itemId, zipPath).then((res) => {
  if (res.uploadState === 'SUCCESS') {
    webstore.items.publish(itemId).then((res) => {
      console.log(res);
    });
  } else {
    console.log(res);
  }
});

Development

Test

npm test

FAQs

Last updated on 25 Dec 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc