@equicord/publish-browser-extension 4.0.2 → 4.0.4

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 CHANGED
@@ -1,10 +1,10 @@
1
- import { d as chromeStatus, n as submit, t as init, u as chromeSetDeployPercentage } from "./init-DY8IxpMl.js";
1
+ import { d as chromeStatus, n as submit, t as init, u as chromeSetDeployPercentage } from "./init-D2uZ1oqE.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.2";
7
+ var version = "4.0.4";
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-DY8IxpMl.js";
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-D2uZ1oqE.js";
2
2
 
3
3
  export { AddonsApi, ChromeWebStore, ChromeWebStoreOptions, CwsApi, EdgeAddonStore, EdgeAddonStoreOptions, EdgeApi, FirefoxAddonStore, FirefoxAddonStoreOptions, InlineConfig, chromeSetDeployPercentage, chromeStatus, init, submit };
@@ -4121,45 +4121,6 @@ async function submit(config) {
4121
4121
  //#endregion
4122
4122
  //#region src/init.ts
4123
4123
  const envFile = ".env.submit";
4124
- async function generateRefreshTokenViaOAuth(clientId, clientSecret) {
4125
- let resolveCode;
4126
- const codePromise = new Promise((resolve) => {
4127
- resolveCode = resolve;
4128
- });
4129
- const server = Bun.serve({
4130
- port: 0,
4131
- fetch(req) {
4132
- const code$1 = new URL(req.url).searchParams.get("code");
4133
- if (code$1) {
4134
- resolveCode(code$1);
4135
- return new Response("Success! You can close this tab. <script>window.close()<\/script>", { headers: { "Content-Type": "text/html" } });
4136
- }
4137
- return new Response("No code found", { status: 400 });
4138
- }
4139
- });
4140
- const serverUrl = `http://127.0.0.1:${server.port}`;
4141
- const authUrl = new URL("https://accounts.google.com/o/oauth2/auth");
4142
- authUrl.searchParams.set("response_type", "code");
4143
- authUrl.searchParams.set("access_type", "offline");
4144
- authUrl.searchParams.set("client_id", clientId);
4145
- authUrl.searchParams.set("scope", "https://www.googleapis.com/auth/chromewebstore");
4146
- authUrl.searchParams.set("redirect_uri", serverUrl);
4147
- consola$1.info("Open this URL in your browser to authorize:");
4148
- consola$1.log(authUrl.href);
4149
- consola$1.info("Waiting for authorization...");
4150
- const code = await codePromise;
4151
- server.stop();
4152
- return (await ofetch("https://accounts.google.com/o/oauth2/token", {
4153
- method: "POST",
4154
- body: new URLSearchParams([
4155
- ["client_id", clientId],
4156
- ["client_secret", clientSecret],
4157
- ["code", code],
4158
- ["grant_type", "authorization_code"],
4159
- ["redirect_uri", serverUrl]
4160
- ])
4161
- })).refresh_token;
4162
- }
4163
4124
  async function init(config) {
4164
4125
  consola$1.info(`Initialize or update an existing \`${envFile}\` file.`);
4165
4126
  const previousConfig = resolveConfig(config);
@@ -4223,7 +4184,22 @@ async function initChrome(previousOptions) {
4223
4184
  const clientSecret = await prompt("Enter your client secret:", { type: "text" }, previousOptions?.clientSecret);
4224
4185
  entries.push(["CHROME_CLIENT_SECRET", clientSecret]);
4225
4186
  if (await prompt("Generate new refresh token?", { type: "confirm" })) {
4226
- const refreshToken = await generateRefreshTokenViaOAuth(clientId, clientSecret);
4187
+ 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`;
4188
+ consola$1.log(authCodeUrl);
4189
+ const authCode = await consola$1.prompt("Open the above URL, login, and enter the auth code:", {
4190
+ type: "text",
4191
+ required: true
4192
+ });
4193
+ const data = new URLSearchParams();
4194
+ data.set("client_id", clientId);
4195
+ data.set("client_secret", clientSecret);
4196
+ data.set("code", authCode);
4197
+ data.set("grant_type", "authorization_code");
4198
+ data.set("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
4199
+ const refreshToken = (await ofetch(`https://accounts.google.com/o/oauth2/token`, {
4200
+ method: "POST",
4201
+ body: data
4202
+ })).refresh_token;
4227
4203
  consola$1.info(`Refresh token: \`${refreshToken}\``);
4228
4204
  entries.push(["CHROME_REFRESH_TOKEN", refreshToken]);
4229
4205
  }
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.2",
4
+ "version": "4.0.4",
5
5
  "packageManager": "bun@1.3.4",
6
6
  "type": "module",
7
7
  "scripts": {