@equicord/publish-browser-extension 4.0.3 → 4.0.5
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/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/{init-CB96xhAw.js → init-CeaZntzI.js} +39 -60
- package/package.json +1 -2
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { d as chromeStatus, n as submit, t as init, u as chromeSetDeployPercentage } from "./init-
|
|
1
|
+
import { d as chromeStatus, n as submit, t as init, u as chromeSetDeployPercentage } from "./init-CeaZntzI.js";
|
|
2
2
|
import { cac } from "cac";
|
|
3
3
|
import { consola as consola$1 } from "consola";
|
|
4
4
|
import { config } from "dotenv";
|
|
5
5
|
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version = "4.0.
|
|
7
|
+
var version = "4.0.5";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/cli.ts
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as FirefoxAddonStoreOptions, c as EdgeAddonStoreOptions, d as chromeStatus, f as ChromeWebStore, i as FirefoxAddonStore, l as EdgeApi, m as CwsApi, n as submit, o as AddonsApi, p as ChromeWebStoreOptions, r as InlineConfig, s as EdgeAddonStore, t as init, u as chromeSetDeployPercentage } from "./init-
|
|
1
|
+
import { a as FirefoxAddonStoreOptions, c as EdgeAddonStoreOptions, d as chromeStatus, f as ChromeWebStore, i as FirefoxAddonStore, l as EdgeApi, m as CwsApi, n as submit, o as AddonsApi, p as ChromeWebStoreOptions, r as InlineConfig, s as EdgeAddonStore, t as init, u as chromeSetDeployPercentage } from "./init-CeaZntzI.js";
|
|
2
2
|
|
|
3
3
|
export { AddonsApi, ChromeWebStore, ChromeWebStoreOptions, CwsApi, EdgeAddonStore, EdgeAddonStoreOptions, EdgeApi, FirefoxAddonStore, FirefoxAddonStoreOptions, InlineConfig, chromeSetDeployPercentage, chromeStatus, init, submit };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { Listr } from "listr2";
|
|
3
|
-
import {
|
|
3
|
+
import { fileFromPath } from "formdata-node/file-from-path";
|
|
4
|
+
import { createFetch, ofetch } from "ofetch";
|
|
4
5
|
import { z } from "zod/v4";
|
|
5
6
|
import fs, { copyFile, readFile, writeFile } from "node:fs/promises";
|
|
6
7
|
import consola, { consola as consola$1 } from "consola";
|
|
7
8
|
import fs$1 from "fs";
|
|
8
|
-
import { FormData } from "formdata-node";
|
|
9
|
-
import { fileFromPath } from "formdata-node/file-from-path";
|
|
9
|
+
import { FormData as FormData$1 } from "formdata-node";
|
|
10
10
|
import { FormDataEncoder } from "form-data-encoder";
|
|
11
11
|
import { Readable } from "node:stream";
|
|
12
|
-
import http from "http";
|
|
13
12
|
|
|
14
13
|
//#region rolldown:runtime
|
|
15
14
|
var __create = Object.create;
|
|
@@ -39,7 +38,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
39
38
|
|
|
40
39
|
//#endregion
|
|
41
40
|
//#region src/utils/fetch.ts
|
|
42
|
-
const fetch
|
|
41
|
+
const fetch = createFetch({ defaults: { onResponseError: (ctx) => {
|
|
43
42
|
console.log("Request:", ctx.request);
|
|
44
43
|
console.log("Response:", JSON.stringify(ctx.response, null, 2));
|
|
45
44
|
} } });
|
|
@@ -71,9 +70,12 @@ var CwsApi = class {
|
|
|
71
70
|
}
|
|
72
71
|
async uploadZip(params) {
|
|
73
72
|
const Authorization = this.getAuthHeader(params.token);
|
|
74
|
-
|
|
73
|
+
const form = new FormData();
|
|
74
|
+
const file = await fileFromPath(params.zipFile);
|
|
75
|
+
form.append("image", file);
|
|
76
|
+
return fetch(this.uploadEndpoint(params.extensionId), {
|
|
75
77
|
method: "POST",
|
|
76
|
-
body:
|
|
78
|
+
body: form,
|
|
77
79
|
headers: {
|
|
78
80
|
Authorization,
|
|
79
81
|
"X-Goog-Upload-Protocol": "raw"
|
|
@@ -86,7 +88,7 @@ var CwsApi = class {
|
|
|
86
88
|
if (params.publishType) body.publishType = params.publishType;
|
|
87
89
|
if (params.deployPercentage != null) body.deployInfos = [{ deployPercentage: params.deployPercentage }];
|
|
88
90
|
if (params.skipReview != null) body.skipReview = params.skipReview;
|
|
89
|
-
return fetch
|
|
91
|
+
return fetch(this.publishEndpoint(params.extensionId), {
|
|
90
92
|
method: "POST",
|
|
91
93
|
headers: {
|
|
92
94
|
Authorization,
|
|
@@ -97,21 +99,21 @@ var CwsApi = class {
|
|
|
97
99
|
}
|
|
98
100
|
async fetchStatus(params) {
|
|
99
101
|
const Authorization = this.getAuthHeader(params.token);
|
|
100
|
-
return fetch
|
|
102
|
+
return fetch(this.fetchStatusEndpoint(params.extensionId), {
|
|
101
103
|
method: "GET",
|
|
102
104
|
headers: { Authorization }
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
async cancelSubmission(params) {
|
|
106
108
|
const Authorization = this.getAuthHeader(params.token);
|
|
107
|
-
await fetch
|
|
109
|
+
await fetch(this.cancelSubmissionEndpoint(params.extensionId), {
|
|
108
110
|
method: "POST",
|
|
109
111
|
headers: { Authorization }
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
async setPublishedDeployPercentage(params) {
|
|
113
115
|
const Authorization = this.getAuthHeader(params.token);
|
|
114
|
-
await fetch
|
|
116
|
+
await fetch(this.setDeployPercentageEndpoint(params.extensionId), {
|
|
115
117
|
method: "POST",
|
|
116
118
|
headers: {
|
|
117
119
|
Authorization,
|
|
@@ -121,7 +123,7 @@ var CwsApi = class {
|
|
|
121
123
|
});
|
|
122
124
|
}
|
|
123
125
|
getToken() {
|
|
124
|
-
return fetch
|
|
126
|
+
return fetch(this.tokenEndpoint(), {
|
|
125
127
|
method: "POST",
|
|
126
128
|
body: JSON.stringify({
|
|
127
129
|
client_id: this.options.clientId,
|
|
@@ -256,7 +258,7 @@ var EdgeApi = class {
|
|
|
256
258
|
async uploadDraft(params) {
|
|
257
259
|
const endpoint = `https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions/draft/package`;
|
|
258
260
|
const file = fs$1.createReadStream(params.zipFile);
|
|
259
|
-
const operationId = (await fetch
|
|
261
|
+
const operationId = (await fetch.raw(endpoint, {
|
|
260
262
|
method: "POST",
|
|
261
263
|
body: file,
|
|
262
264
|
headers: {
|
|
@@ -271,14 +273,14 @@ var EdgeApi = class {
|
|
|
271
273
|
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#checking-the-status-of-a-package-upload
|
|
272
274
|
*/
|
|
273
275
|
uploadDraftOperation(params) {
|
|
274
|
-
return fetch
|
|
276
|
+
return fetch(`https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions/draft/package/operations/${params.operationId}`, { headers: this.getAuthHeaders(params.token) });
|
|
275
277
|
}
|
|
276
278
|
/**
|
|
277
279
|
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#publishing-the-submission
|
|
278
280
|
*/
|
|
279
281
|
async publish(params) {
|
|
280
282
|
const endpoint = `https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions`;
|
|
281
|
-
const res = await fetch
|
|
283
|
+
const res = await fetch.raw(endpoint, {
|
|
282
284
|
method: "POST",
|
|
283
285
|
body: JSON.stringify({}),
|
|
284
286
|
headers: this.getAuthHeaders(params.token)
|
|
@@ -3836,18 +3838,18 @@ var AddonsApi = class {
|
|
|
3836
3838
|
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#detail
|
|
3837
3839
|
*/
|
|
3838
3840
|
details(params) {
|
|
3839
|
-
return fetch
|
|
3841
|
+
return fetch(this.addonDetailEndpoint(params.extensionId).href, { headers: { Authorization: this.getAuthHeader() } });
|
|
3840
3842
|
}
|
|
3841
3843
|
/**
|
|
3842
3844
|
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#upload-create
|
|
3843
3845
|
*/
|
|
3844
3846
|
async uploadCreate(params) {
|
|
3845
3847
|
const endpoint = this.addonsUploadCreateEndpoint();
|
|
3846
|
-
const form = new FormData();
|
|
3848
|
+
const form = new FormData$1();
|
|
3847
3849
|
form.set("channel", params.channel);
|
|
3848
3850
|
form.set("upload", await fileFromPath(params.file));
|
|
3849
3851
|
const encoder = new FormDataEncoder(form);
|
|
3850
|
-
return await fetch
|
|
3852
|
+
return await fetch(endpoint.href, {
|
|
3851
3853
|
method: "POST",
|
|
3852
3854
|
body: Readable.from(encoder),
|
|
3853
3855
|
headers: {
|
|
@@ -3860,16 +3862,16 @@ var AddonsApi = class {
|
|
|
3860
3862
|
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#upload-detail
|
|
3861
3863
|
*/
|
|
3862
3864
|
uploadDetail(params) {
|
|
3863
|
-
return fetch
|
|
3865
|
+
return fetch(this.addonsUploadDetailsEndpoint(params.uuid).href, { headers: { Authorization: this.getAuthHeader() } });
|
|
3864
3866
|
}
|
|
3865
3867
|
async versionCreate(params) {
|
|
3866
3868
|
const endpoint = this.addonVersionCreateEndpoint(params.extensionId);
|
|
3867
|
-
const form = new FormData();
|
|
3869
|
+
const form = new FormData$1();
|
|
3868
3870
|
form.set("upload", params.uploadUuid);
|
|
3869
3871
|
if (params.sourceFile) form.set("source", await fileFromPath(params.sourceFile));
|
|
3870
3872
|
else form.set("source", "");
|
|
3871
3873
|
const encoder = new FormDataEncoder(form);
|
|
3872
|
-
return await fetch
|
|
3874
|
+
return await fetch(endpoint.href, {
|
|
3873
3875
|
method: "POST",
|
|
3874
3876
|
body: Readable.from(encoder),
|
|
3875
3877
|
headers: {
|
|
@@ -4122,44 +4124,6 @@ async function submit(config) {
|
|
|
4122
4124
|
//#endregion
|
|
4123
4125
|
//#region src/init.ts
|
|
4124
4126
|
const envFile = ".env.submit";
|
|
4125
|
-
async function generateRefreshTokenViaOAuth(clientId, clientSecret) {
|
|
4126
|
-
let resolveCode;
|
|
4127
|
-
const codePromise = new Promise((resolve) => resolveCode = resolve);
|
|
4128
|
-
const server = http.createServer((req, res) => {
|
|
4129
|
-
const code$1 = new URL(req.url || "", `http://localhost`).searchParams.get("code");
|
|
4130
|
-
if (code$1) {
|
|
4131
|
-
resolveCode(code$1);
|
|
4132
|
-
res.writeHead(200, { "Content-Type": "text/html" });
|
|
4133
|
-
res.end("Success! You can close this tab. <script>window.close()<\/script>");
|
|
4134
|
-
server.close();
|
|
4135
|
-
} else {
|
|
4136
|
-
res.writeHead(400);
|
|
4137
|
-
res.end("No code found");
|
|
4138
|
-
}
|
|
4139
|
-
});
|
|
4140
|
-
server.listen(0, () => {
|
|
4141
|
-
const redirectUri = `http://127.0.0.1:${server.address().port}`;
|
|
4142
|
-
const authUrl = new URL("https://accounts.google.com/o/oauth2/auth");
|
|
4143
|
-
authUrl.searchParams.set("response_type", "code");
|
|
4144
|
-
authUrl.searchParams.set("access_type", "offline");
|
|
4145
|
-
authUrl.searchParams.set("client_id", clientId);
|
|
4146
|
-
authUrl.searchParams.set("scope", "https://www.googleapis.com/auth/chromewebstore");
|
|
4147
|
-
authUrl.searchParams.set("redirect_uri", redirectUri);
|
|
4148
|
-
console.log("Open this URL in your browser to authorize:");
|
|
4149
|
-
console.log(authUrl.href);
|
|
4150
|
-
});
|
|
4151
|
-
const code = await codePromise;
|
|
4152
|
-
return (await (await fetch("https://accounts.google.com/o/oauth2/token", {
|
|
4153
|
-
method: "POST",
|
|
4154
|
-
body: new URLSearchParams({
|
|
4155
|
-
client_id: clientId,
|
|
4156
|
-
client_secret: clientSecret,
|
|
4157
|
-
code,
|
|
4158
|
-
grant_type: "authorization_code",
|
|
4159
|
-
redirect_uri: `http://127.0.0.1:${server.address().port}`
|
|
4160
|
-
})
|
|
4161
|
-
})).json()).refresh_token;
|
|
4162
|
-
}
|
|
4163
4127
|
async function init(config) {
|
|
4164
4128
|
consola$1.info(`Initialize or update an existing \`${envFile}\` file.`);
|
|
4165
4129
|
const previousConfig = resolveConfig(config);
|
|
@@ -4223,7 +4187,22 @@ async function initChrome(previousOptions) {
|
|
|
4223
4187
|
const clientSecret = await prompt("Enter your client secret:", { type: "text" }, previousOptions?.clientSecret);
|
|
4224
4188
|
entries.push(["CHROME_CLIENT_SECRET", clientSecret]);
|
|
4225
4189
|
if (await prompt("Generate new refresh token?", { type: "confirm" })) {
|
|
4226
|
-
const
|
|
4190
|
+
const authCodeUrl = `https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://www.googleapis.com/auth/chromewebstore&client_id=${clientId}&redirect_uri=urn:ietf:wg:oauth:2.0:oob`;
|
|
4191
|
+
consola$1.log(authCodeUrl);
|
|
4192
|
+
const authCode = await consola$1.prompt("Open the above URL, login, and enter the auth code:", {
|
|
4193
|
+
type: "text",
|
|
4194
|
+
required: true
|
|
4195
|
+
});
|
|
4196
|
+
const data = new URLSearchParams();
|
|
4197
|
+
data.set("client_id", clientId);
|
|
4198
|
+
data.set("client_secret", clientSecret);
|
|
4199
|
+
data.set("code", authCode);
|
|
4200
|
+
data.set("grant_type", "authorization_code");
|
|
4201
|
+
data.set("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
|
|
4202
|
+
const refreshToken = (await ofetch(`https://accounts.google.com/o/oauth2/token`, {
|
|
4203
|
+
method: "POST",
|
|
4204
|
+
body: data
|
|
4205
|
+
})).refresh_token;
|
|
4227
4206
|
consola$1.info(`Refresh token: \`${refreshToken}\``);
|
|
4228
4207
|
entries.push(["CHROME_REFRESH_TOKEN", refreshToken]);
|
|
4229
4208
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equicord/publish-browser-extension",
|
|
3
3
|
"description": "Easily publish web extensions to their stores",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.5",
|
|
5
5
|
"packageManager": "bun@1.3.4",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"dotenv": "^17.2.3",
|
|
25
25
|
"form-data-encoder": "^4.1.0",
|
|
26
26
|
"formdata-node": "^6.0.3",
|
|
27
|
-
"http": "^0.0.1-security",
|
|
28
27
|
"listr2": "^8.3.3",
|
|
29
28
|
"ofetch": "^1.4.1",
|
|
30
29
|
"zod": "^3.25.76 || ^4.0.0"
|