chrome-webstore-upload-keys 1.1.2 → 1.1.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.
Files changed (3) hide show
  1. package/cli.js +7 -7
  2. package/dist/index.js +7 -7
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -6,6 +6,10 @@ import {open} from 'openurl';
6
6
  import getPort from 'get-port';
7
7
  import pDefer from 'p-defer';
8
8
 
9
+ if (typeof fetch !== 'function') {
10
+ throw new TypeError('This script requires Node.js 18.0 or newer because it relies on the global `fetch` function.');
11
+ }
12
+
9
13
  const approvalCode = pDefer();
10
14
  const port = await getPort();
11
15
  const localhost = '127.0.0.1';
@@ -55,8 +59,8 @@ async function getRefreshToken() {
55
59
  const request = await fetch('https://accounts.google.com/o/oauth2/token', {
56
60
  method: 'POST',
57
61
  body: new URLSearchParams([
58
- ['client_id', group.clientId],
59
- ['client_secret', group.clientSecret],
62
+ ['client_id', group.clientId.trim()],
63
+ ['client_secret', group.clientSecret.trim()],
60
64
  ['code', code],
61
65
  ['grant_type', 'authorization_code'],
62
66
  ['redirect_uri', serverUrl], // Unused but required
@@ -83,7 +87,7 @@ function getLoginUrl(clientId) {
83
87
  const url = new URL('https://accounts.google.com/o/oauth2/auth');
84
88
  url.searchParams.set('response_type', 'code');
85
89
  url.searchParams.set('access_type', 'offline');
86
- url.searchParams.set('client_id', clientId);
90
+ url.searchParams.set('client_id', clientId.trim());
87
91
  url.searchParams.set('scope', 'https://www.googleapis.com/auth/chromewebstore');
88
92
  url.searchParams.set('redirect_uri', serverUrl);
89
93
  return url.href;
@@ -92,10 +96,6 @@ function getLoginUrl(clientId) {
92
96
  p.intro('Follow the steps at this URL to generate the API keys, then enter them below to generate the refresh token.\n https://github.com/fregante/chrome-webstore-upload-keys');
93
97
  const group = await p.group(
94
98
  {
95
- // ExtensionId: () => p.text({
96
- // message: 'Extension ID:',
97
- // placeholder: 'e.g. bdeobgpddfaegbjfinhldnkfeieakdaf, it’s in the Chrome Web Store URL',
98
- // }),
99
99
  clientId: () => p.text({
100
100
  message: 'Client ID:',
101
101
  placeholder: 'e.g. 960453266371-2qcq5fppm3d5e.apps.googleusercontent.com',
package/dist/index.js CHANGED
@@ -252,6 +252,10 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
252
252
 
253
253
 
254
254
 
255
+ if (typeof fetch !== 'function') {
256
+ throw new TypeError('This script requires Node.js 18.0 or newer because it relies on the global `fetch` function.');
257
+ }
258
+
255
259
  const approvalCode = (0,p_defer__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)();
256
260
  const port = await (0,get_port__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)();
257
261
  const localhost = '127.0.0.1';
@@ -301,8 +305,8 @@ async function getRefreshToken() {
301
305
  const request = await fetch('https://accounts.google.com/o/oauth2/token', {
302
306
  method: 'POST',
303
307
  body: new URLSearchParams([
304
- ['client_id', group.clientId],
305
- ['client_secret', group.clientSecret],
308
+ ['client_id', group.clientId.trim()],
309
+ ['client_secret', group.clientSecret.trim()],
306
310
  ['code', code],
307
311
  ['grant_type', 'authorization_code'],
308
312
  ['redirect_uri', serverUrl], // Unused but required
@@ -329,7 +333,7 @@ function getLoginUrl(clientId) {
329
333
  const url = new URL('https://accounts.google.com/o/oauth2/auth');
330
334
  url.searchParams.set('response_type', 'code');
331
335
  url.searchParams.set('access_type', 'offline');
332
- url.searchParams.set('client_id', clientId);
336
+ url.searchParams.set('client_id', clientId.trim());
333
337
  url.searchParams.set('scope', 'https://www.googleapis.com/auth/chromewebstore');
334
338
  url.searchParams.set('redirect_uri', serverUrl);
335
339
  return url.href;
@@ -338,10 +342,6 @@ function getLoginUrl(clientId) {
338
342
  _clack_prompts__WEBPACK_IMPORTED_MODULE_2__/* .intro */ .mf('Follow the steps at this URL to generate the API keys, then enter them below to generate the refresh token.\n https://github.com/fregante/chrome-webstore-upload-keys');
339
343
  const group = await _clack_prompts__WEBPACK_IMPORTED_MODULE_2__/* .group */ .ru(
340
344
  {
341
- // ExtensionId: () => p.text({
342
- // message: 'Extension ID:',
343
- // placeholder: 'e.g. bdeobgpddfaegbjfinhldnkfeieakdaf, it’s in the Chrome Web Store URL',
344
- // }),
345
345
  clientId: () => _clack_prompts__WEBPACK_IMPORTED_MODULE_2__/* .text */ .fL({
346
346
  message: 'Client ID:',
347
347
  placeholder: 'e.g. 960453266371-2qcq5fppm3d5e.apps.googleusercontent.com',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-webstore-upload-keys",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "CLI tool to generate OAuth keys for the Chrome Web Store",
5
5
  "keywords": [
6
6
  "chrome",