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 - npm Package Compare versions

Comparing version 0.2.2 to 0.3.2

22

dist/authApi.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {

@@ -10,16 +13,15 @@ if (mod && mod.__esModule) return mod;

Object.defineProperty(exports, "__esModule", { value: true });
const got = __importStar(require("got"));
const axios_1 = __importDefault(require("axios"));
const consts = __importStar(require("./consts"));
async function fetchToken(clientId, clientSecret, refreshToken) {
const result = await got.post(consts.urls.refreshTokenPost(), {
body: {
client_id: clientId,
client_secret: clientSecret,
refresh_token: refreshToken,
grant_type: 'refresh_token',
},
json: true,
const result = await axios_1.default.post(consts.urls.refreshTokenPost(), {
client_id: clientId,
client_secret: clientSecret,
refresh_token: refreshToken,
grant_type: 'refresh_token',
}, {
responseType: 'json',
});
return result.body.access_token;
return result.data.access_token;
}
exports.fetchToken = fetchToken;

@@ -6,11 +6,7 @@ "use strict";

*/
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const got = __importStar(require("got"));
const axios_1 = __importDefault(require("axios"));
var DownloadCrx;

@@ -70,16 +66,9 @@ (function (DownloadCrx) {

async function downloadCrx(extensionId, prodVersion = '72.0.3626.121', acceptFormat = [CrxAcceptFormat.CRX2, CrxAcceptFormat.CRX3], platform) {
return new Promise((resolve, reject) => {
got
.stream(getUrl(extensionId, prodVersion, acceptFormat, platform), { throwHttpErrors: false })
.once('response', response => {
if (response.statusCode === 200) {
resolve(response);
}
else {
reject(new Error(`Server answered with ${response.statusCode} ${response.statusMessage}`));
}
});
const response = await axios_1.default.get(getUrl(extensionId, prodVersion, acceptFormat, platform), {
responseType: 'stream',
validateStatus: status => status === 200
});
return response.data;
}
DownloadCrx.downloadCrx = downloadCrx;
})(DownloadCrx = exports.DownloadCrx || (exports.DownloadCrx = {}));
/// <reference types="node" />
import { AxiosInstance, AxiosRequestConfig } from 'axios';
import { Readable } from 'stream';

@@ -6,3 +7,4 @@ import * as consts from './consts';

protected _token: string;
constructor(token: string);
protected readonly _client: AxiosInstance;
constructor(token: string, axiosConfig?: AxiosRequestConfig);
setToken(token: string): void;

@@ -9,0 +11,0 @@ upload(readStream: Buffer | Readable, appId?: string): Promise<consts.IWebstoreResource>;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {

@@ -10,8 +13,9 @@ if (mod && mod.__esModule) return mod;

Object.defineProperty(exports, "__esModule", { value: true });
const got = __importStar(require("got"));
const axios_1 = __importDefault(require("axios"));
const consts = __importStar(require("./consts"));
// noinspection JSUnusedGlobalSymbols
class WebstoreApi {
constructor(token) {
constructor(token, axiosConfig) {
this._token = token;
this._client = axios_1.default.create(axiosConfig);
}

@@ -25,28 +29,30 @@ // noinspection JSUnusedGlobalSymbols

const url = appId ? consts.urls.uploadPut(appId) : consts.urls.uploadPost();
const action = appId ? got.put.bind(got) : got.post.bind(got);
const result = await action(url, {
const result = await this._client.request({
url,
method: appId ? 'PUT' : 'POST',
headers: this.getHeaders(),
body: readStream
responseType: 'json',
data: readStream
});
return JSON.parse(result.body);
return result.data;
}
// noinspection JSUnusedGlobalSymbols
async getUpload(appId) {
const result = await got.get(consts.urls.uploadGet(appId), {
const result = await this._client.get(consts.urls.uploadGet(appId), {
headers: this.getHeaders(),
json: true,
responseType: 'json',
});
return result.body;
return result.data;
}
// noinspection JSUnusedGlobalSymbols
async publish(appId, target = consts.PublishTarget.DEFAULT) {
const result = await got.post(consts.urls.publishPost(appId, target), {
headers: this.getHeaders(),
json: true,
const result = await this._client.post(consts.urls.publishPost(appId, target), undefined, {
responseType: 'json',
headers: this.getHeaders()
});
return result.body;
return result.data;
}
getHeaders() {
return {
Authorization: `Bearer ${this._token}`,
'Authorization': `Bearer ${this._token}`,
'x-goog-api-version': '2',

@@ -53,0 +59,0 @@ };

{
"name": "typed-chrome-webstore-api",
"version": "0.2.2",
"version": "0.3.2",
"description": "Typed Chrome Webstore API to upload/publish extensions",

@@ -31,6 +31,7 @@ "main": "dist/index.js",

"dependencies": {
"got": "^9.6.0"
"axios": "^0.18.0"
},
"devDependencies": {
"@types/got": "^9.4.1",
"@types/node": "^11.11.3",
"@types/axios": "^0.14.0",
"prettier": "^1.16.3",

@@ -37,0 +38,0 @@ "tslint": "^5.12.1",

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