@equicord/publish-browser-extension 4.0.2 → 4.0.3
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-DY8IxpMl.js → init-CB96xhAw.js} +47 -47
- package/package.json +2 -1
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-CB96xhAw.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.3";
|
|
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-CB96xhAw.js";
|
|
2
2
|
|
|
3
3
|
export { AddonsApi, ChromeWebStore, ChromeWebStoreOptions, CwsApi, EdgeAddonStore, EdgeAddonStoreOptions, EdgeApi, FirefoxAddonStore, FirefoxAddonStoreOptions, InlineConfig, chromeSetDeployPercentage, chromeStatus, init, submit };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { Listr } from "listr2";
|
|
3
|
-
import { createFetch
|
|
3
|
+
import { createFetch } from "ofetch";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
import fs, { copyFile, readFile, writeFile } from "node:fs/promises";
|
|
6
6
|
import consola, { consola as consola$1 } from "consola";
|
|
@@ -9,6 +9,7 @@ import { FormData } from "formdata-node";
|
|
|
9
9
|
import { fileFromPath } from "formdata-node/file-from-path";
|
|
10
10
|
import { FormDataEncoder } from "form-data-encoder";
|
|
11
11
|
import { Readable } from "node:stream";
|
|
12
|
+
import http from "http";
|
|
12
13
|
|
|
13
14
|
//#region rolldown:runtime
|
|
14
15
|
var __create = Object.create;
|
|
@@ -38,7 +39,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
38
39
|
|
|
39
40
|
//#endregion
|
|
40
41
|
//#region src/utils/fetch.ts
|
|
41
|
-
const fetch = createFetch({ defaults: { onResponseError: (ctx) => {
|
|
42
|
+
const fetch$1 = createFetch({ defaults: { onResponseError: (ctx) => {
|
|
42
43
|
console.log("Request:", ctx.request);
|
|
43
44
|
console.log("Response:", JSON.stringify(ctx.response, null, 2));
|
|
44
45
|
} } });
|
|
@@ -70,7 +71,7 @@ var CwsApi = class {
|
|
|
70
71
|
}
|
|
71
72
|
async uploadZip(params) {
|
|
72
73
|
const Authorization = this.getAuthHeader(params.token);
|
|
73
|
-
return fetch(this.uploadEndpoint(params.extensionId), {
|
|
74
|
+
return fetch$1(this.uploadEndpoint(params.extensionId), {
|
|
74
75
|
method: "POST",
|
|
75
76
|
body: Bun.file(params.zipFile),
|
|
76
77
|
headers: {
|
|
@@ -85,7 +86,7 @@ var CwsApi = class {
|
|
|
85
86
|
if (params.publishType) body.publishType = params.publishType;
|
|
86
87
|
if (params.deployPercentage != null) body.deployInfos = [{ deployPercentage: params.deployPercentage }];
|
|
87
88
|
if (params.skipReview != null) body.skipReview = params.skipReview;
|
|
88
|
-
return fetch(this.publishEndpoint(params.extensionId), {
|
|
89
|
+
return fetch$1(this.publishEndpoint(params.extensionId), {
|
|
89
90
|
method: "POST",
|
|
90
91
|
headers: {
|
|
91
92
|
Authorization,
|
|
@@ -96,21 +97,21 @@ var CwsApi = class {
|
|
|
96
97
|
}
|
|
97
98
|
async fetchStatus(params) {
|
|
98
99
|
const Authorization = this.getAuthHeader(params.token);
|
|
99
|
-
return fetch(this.fetchStatusEndpoint(params.extensionId), {
|
|
100
|
+
return fetch$1(this.fetchStatusEndpoint(params.extensionId), {
|
|
100
101
|
method: "GET",
|
|
101
102
|
headers: { Authorization }
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
async cancelSubmission(params) {
|
|
105
106
|
const Authorization = this.getAuthHeader(params.token);
|
|
106
|
-
await fetch(this.cancelSubmissionEndpoint(params.extensionId), {
|
|
107
|
+
await fetch$1(this.cancelSubmissionEndpoint(params.extensionId), {
|
|
107
108
|
method: "POST",
|
|
108
109
|
headers: { Authorization }
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
async setPublishedDeployPercentage(params) {
|
|
112
113
|
const Authorization = this.getAuthHeader(params.token);
|
|
113
|
-
await fetch(this.setDeployPercentageEndpoint(params.extensionId), {
|
|
114
|
+
await fetch$1(this.setDeployPercentageEndpoint(params.extensionId), {
|
|
114
115
|
method: "POST",
|
|
115
116
|
headers: {
|
|
116
117
|
Authorization,
|
|
@@ -120,7 +121,7 @@ var CwsApi = class {
|
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
123
|
getToken() {
|
|
123
|
-
return fetch(this.tokenEndpoint(), {
|
|
124
|
+
return fetch$1(this.tokenEndpoint(), {
|
|
124
125
|
method: "POST",
|
|
125
126
|
body: JSON.stringify({
|
|
126
127
|
client_id: this.options.clientId,
|
|
@@ -255,7 +256,7 @@ var EdgeApi = class {
|
|
|
255
256
|
async uploadDraft(params) {
|
|
256
257
|
const endpoint = `https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions/draft/package`;
|
|
257
258
|
const file = fs$1.createReadStream(params.zipFile);
|
|
258
|
-
const operationId = (await fetch.raw(endpoint, {
|
|
259
|
+
const operationId = (await fetch$1.raw(endpoint, {
|
|
259
260
|
method: "POST",
|
|
260
261
|
body: file,
|
|
261
262
|
headers: {
|
|
@@ -270,14 +271,14 @@ var EdgeApi = class {
|
|
|
270
271
|
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#checking-the-status-of-a-package-upload
|
|
271
272
|
*/
|
|
272
273
|
uploadDraftOperation(params) {
|
|
273
|
-
return fetch(`https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions/draft/package/operations/${params.operationId}`, { headers: this.getAuthHeaders(params.token) });
|
|
274
|
+
return fetch$1(`https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions/draft/package/operations/${params.operationId}`, { headers: this.getAuthHeaders(params.token) });
|
|
274
275
|
}
|
|
275
276
|
/**
|
|
276
277
|
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#publishing-the-submission
|
|
277
278
|
*/
|
|
278
279
|
async publish(params) {
|
|
279
280
|
const endpoint = `https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions`;
|
|
280
|
-
const res = await fetch.raw(endpoint, {
|
|
281
|
+
const res = await fetch$1.raw(endpoint, {
|
|
281
282
|
method: "POST",
|
|
282
283
|
body: JSON.stringify({}),
|
|
283
284
|
headers: this.getAuthHeaders(params.token)
|
|
@@ -3835,7 +3836,7 @@ var AddonsApi = class {
|
|
|
3835
3836
|
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#detail
|
|
3836
3837
|
*/
|
|
3837
3838
|
details(params) {
|
|
3838
|
-
return fetch(this.addonDetailEndpoint(params.extensionId).href, { headers: { Authorization: this.getAuthHeader() } });
|
|
3839
|
+
return fetch$1(this.addonDetailEndpoint(params.extensionId).href, { headers: { Authorization: this.getAuthHeader() } });
|
|
3839
3840
|
}
|
|
3840
3841
|
/**
|
|
3841
3842
|
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#upload-create
|
|
@@ -3846,7 +3847,7 @@ var AddonsApi = class {
|
|
|
3846
3847
|
form.set("channel", params.channel);
|
|
3847
3848
|
form.set("upload", await fileFromPath(params.file));
|
|
3848
3849
|
const encoder = new FormDataEncoder(form);
|
|
3849
|
-
return await fetch(endpoint.href, {
|
|
3850
|
+
return await fetch$1(endpoint.href, {
|
|
3850
3851
|
method: "POST",
|
|
3851
3852
|
body: Readable.from(encoder),
|
|
3852
3853
|
headers: {
|
|
@@ -3859,7 +3860,7 @@ var AddonsApi = class {
|
|
|
3859
3860
|
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#upload-detail
|
|
3860
3861
|
*/
|
|
3861
3862
|
uploadDetail(params) {
|
|
3862
|
-
return fetch(this.addonsUploadDetailsEndpoint(params.uuid).href, { headers: { Authorization: this.getAuthHeader() } });
|
|
3863
|
+
return fetch$1(this.addonsUploadDetailsEndpoint(params.uuid).href, { headers: { Authorization: this.getAuthHeader() } });
|
|
3863
3864
|
}
|
|
3864
3865
|
async versionCreate(params) {
|
|
3865
3866
|
const endpoint = this.addonVersionCreateEndpoint(params.extensionId);
|
|
@@ -3868,7 +3869,7 @@ var AddonsApi = class {
|
|
|
3868
3869
|
if (params.sourceFile) form.set("source", await fileFromPath(params.sourceFile));
|
|
3869
3870
|
else form.set("source", "");
|
|
3870
3871
|
const encoder = new FormDataEncoder(form);
|
|
3871
|
-
return await fetch(endpoint.href, {
|
|
3872
|
+
return await fetch$1(endpoint.href, {
|
|
3872
3873
|
method: "POST",
|
|
3873
3874
|
body: Readable.from(encoder),
|
|
3874
3875
|
headers: {
|
|
@@ -4123,42 +4124,41 @@ async function submit(config) {
|
|
|
4123
4124
|
const envFile = ".env.submit";
|
|
4124
4125
|
async function generateRefreshTokenViaOAuth(clientId, clientSecret) {
|
|
4125
4126
|
let resolveCode;
|
|
4126
|
-
const codePromise = new Promise((resolve) =>
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
return new Response("No code found", { status: 400 });
|
|
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
4138
|
}
|
|
4139
4139
|
});
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
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
|
+
});
|
|
4150
4151
|
const code = await codePromise;
|
|
4151
|
-
|
|
4152
|
-
return (await ofetch("https://accounts.google.com/o/oauth2/token", {
|
|
4152
|
+
return (await (await fetch("https://accounts.google.com/o/oauth2/token", {
|
|
4153
4153
|
method: "POST",
|
|
4154
|
-
body: new URLSearchParams(
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
})).refresh_token;
|
|
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
4162
|
}
|
|
4163
4163
|
async function init(config) {
|
|
4164
4164
|
consola$1.info(`Initialize or update an existing \`${envFile}\` file.`);
|
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.3",
|
|
5
5
|
"packageManager": "bun@1.3.4",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -24,6 +24,7 @@
|
|
|
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",
|
|
27
28
|
"listr2": "^8.3.3",
|
|
28
29
|
"ofetch": "^1.4.1",
|
|
29
30
|
"zod": "^3.25.76 || ^4.0.0"
|