Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typed-chrome-webstore-api

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-chrome-webstore-api

Typed Chrome Webstore API to upload/publish extensions

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Introduction

Typed Chrome Webstore API to upload/publish extensions and downloading crx file

Installation

npm install typed-chrome-webstore-api

How to use

See https://developer.chrome.com/webstore/using_webstore_api to understand methods meaning and know how to get client_id, client_secret and refresh_token strings needed for authentication.

To work with Webstore API you need to get token first:

const fetchToken = require('typed-chrome-webstore-api').fetchToken;
const token = fetchToken('clientId', 'clientSecret', 'refreshToken');

Then create WebstoreApi instance initialized with token:

const WebstoreApi = require('typed-chrome-webstore-api').WebstoreApi;
const api = new WebstoreApi(token);
Upload new extension
// Any Readable stream or Buffer
const zip = fs.createReadStream('./mypackage.zip');
// Result format is defined as IWebstoreResource in d.ts file 
const result = await api.upload(zip);
Upload existed extension

appId is the ID of the existing Web Store item (could be found in admin panel)

// Any Readable stream or Buffer
const zip = fs.createReadStream('./mypackage.zip');
// Result format is defined as IWebstoreResource in .d.ts file 
const result = await api.upload(zip, appId);
Check uploaded app/extension status
// Result format is defined as IWebstoreResource in .d.ts file 
const result = await api.get(appId);
Publish item
// 'default' or 'trustedTesters', defined in PublishTarget enum in .d.ts file
const target = 'default';
// Result format is defined as IPublishResponse in .d.ts file 
const result = await api.publish(appId, target);

Be aware of API's undocumented behaviour. For example, extension had a version = '1.10.0' Then we successfully published a new one with version = '1.20.0' (status = 'OK') 'get upload' request returns version '1.20.0' after it. But this version is still in publishing progress Now we are publishing '1.30.0' but 'publish' and request fails with 500 error, but (!) actually Our version have been accepted, and after some time out extension increases it's version to '1.30.0'!

Download extension crx

This feature is experimental because of API is not documented

// A bit ugly, looks better if you use TypeScript :)
const downloadCrx = require('typed-chrome-webstore-api').DownloadCrx.downloadCrx;
const fs = require('fs');

const fstream = fs.createWriteStream('file.crx');
const readStream = await downloadCrx('extensionId');
readStream.pipe(fstream);

downloadCrx() also accepts additional options, look at downloadCrx.d.ts file for details

Licence

MIT License

Keywords

FAQs

Package last updated on 10 Mar 2019

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