chrome-webstore-upload 2.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +33 -19
- package/package.json +8 -7
- package/readme.md +1 -1
package/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// API documentation:
|
|
2
|
+
// https://developer.chrome.com/docs/webstore/api
|
|
3
|
+
// https://developer.chrome.com/docs/webstore/using-api
|
|
2
4
|
|
|
3
5
|
const rootURI = 'https://www.googleapis.com';
|
|
4
|
-
const refreshTokenURI = 'https://www.googleapis.com/oauth2/v4/token';
|
|
6
|
+
export const refreshTokenURI = 'https://www.googleapis.com/oauth2/v4/token';
|
|
5
7
|
const uploadExistingURI = id =>
|
|
6
8
|
`${rootURI}/upload/chromewebstore/v1.1/items/${id}`;
|
|
7
9
|
const publishURI = (id, target) =>
|
|
@@ -33,32 +35,36 @@ class APIClient {
|
|
|
33
35
|
|
|
34
36
|
const { extensionId } = this;
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const request = await fetch(uploadExistingURI(extensionId), {
|
|
39
|
+
method: 'PUT',
|
|
40
|
+
headers: this._headers(await token),
|
|
41
|
+
duplex: 'half',
|
|
42
|
+
body: readStream,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return request.json();
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
async publish(target = 'default', token = this.fetchToken()) {
|
|
45
49
|
const { extensionId } = this;
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const request = await fetch(publishURI(extensionId, target), {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: this._headers(await token),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return request.json();
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
async get(projection = 'DRAFT', token = this.fetchToken()) {
|
|
55
60
|
const { extensionId } = this;
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
const request = await fetch(getURI(extensionId, projection), {
|
|
63
|
+
method: 'GET',
|
|
64
|
+
headers: this._headers(await token),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return request.json();
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
async fetchToken() {
|
|
@@ -73,7 +79,15 @@ class APIClient {
|
|
|
73
79
|
json.client_secret = clientSecret;
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
const
|
|
82
|
+
const request = await fetch(refreshTokenURI, {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
body: JSON.stringify(json),
|
|
85
|
+
headers: {
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const response = await request.json();
|
|
77
91
|
|
|
78
92
|
return response.access_token;
|
|
79
93
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-webstore-upload",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Upload Chrome Extensions to the Chrome Web Store",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chrome",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"index.js"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"test": "xo &&
|
|
28
|
+
"test": "xo && vitest"
|
|
29
29
|
},
|
|
30
30
|
"xo": {
|
|
31
31
|
"rules": {
|
|
@@ -37,15 +37,16 @@
|
|
|
37
37
|
},
|
|
38
38
|
"space": 4
|
|
39
39
|
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"got": "^14.0.0"
|
|
42
|
-
},
|
|
43
40
|
"devDependencies": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
41
|
+
"fetch-mock": "^9.11.0",
|
|
42
|
+
"node-fetch": "^2.7.0",
|
|
43
|
+
"vitest": "^1.0.4",
|
|
46
44
|
"xo": "^0.56.0"
|
|
47
45
|
},
|
|
48
46
|
"engines": {
|
|
49
47
|
"node": ">=18"
|
|
48
|
+
},
|
|
49
|
+
"webExt": {
|
|
50
|
+
"sourceDir": "live-test"
|
|
50
51
|
}
|
|
51
52
|
}
|
package/readme.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install --save-dev chrome-webstore-upload
|
|
|
12
12
|
|
|
13
13
|
## Setup
|
|
14
14
|
|
|
15
|
-
You will need a Google API `clientId`, `clientSecret` and `refreshToken`.
|
|
15
|
+
You will need a Google API `clientId`, `clientSecret` and `refreshToken`. Use [the guide]( https://github.com/fregante/chrome-webstore-upload-keys).
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|