npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typed-chrome-webstore-api

v0.4.16

Published

Typed Chrome Webstore API to upload/publish extensions

Downloads

40

Readme

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'!

Get Licenses
const result = await api.getLicenses(appId, userId);
Get User Licenses
const result = await api.getUserLicenses(appId);
Get Payments
const result = await api.getPayments(itemId);
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