ymmv-cli 0.1.3 → 0.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 (2) hide show
  1. package/dist/cli.js +10 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -18,6 +18,11 @@ async function mintYmmvToken(accessToken) {
18
18
  if (res.status === 503) {
19
19
  throw new Error(body.message ?? "GitHub is unavailable \u2014 run `ymmv login` again shortly.");
20
20
  }
21
+ if (res.status === 429) {
22
+ const retry = res.headers.get("retry-after");
23
+ const msg = body.message ?? "too many login attempts \u2014 slow down and try again shortly";
24
+ throw new Error(retry ? `${msg} (retry in ${retry}s)` : msg);
25
+ }
21
26
  throw new Error(`login failed: ${res.status} ${body.error ?? ""}`.trim());
22
27
  }
23
28
  return await res.json();
@@ -104,6 +109,9 @@ function diff(mine, theirs) {
104
109
  };
105
110
  }
106
111
 
112
+ // ../shared/dist/github.js
113
+ var GITHUB_CLIENT_ID = "Ov23liMoD29eizQcN1KZ";
114
+
107
115
  // ../shared/dist/reserved.js
108
116
  var RESERVED_ROUTES = ["api", "login", "logout"];
109
117
  var CLI_VERBS = ["login", "logout", "set", "delete", "view", "help"];
@@ -169,7 +177,6 @@ async function peekBase() {
169
177
  }
170
178
 
171
179
  // src/device-flow.ts
172
- var CLIENT_ID = "Ov23liMoD29eizQcN1KZ";
173
180
  var DEVICE_CODE_URL = "https://github.com/login/device/code";
174
181
  var TOKEN_URL = "https://github.com/login/oauth/access_token";
175
182
  var realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -178,7 +185,7 @@ async function requestDeviceCode(deps = {}) {
178
185
  const res = await doFetch(DEVICE_CODE_URL, {
179
186
  method: "POST",
180
187
  headers: { accept: "application/json" },
181
- body: new URLSearchParams({ client_id: CLIENT_ID })
188
+ body: new URLSearchParams({ client_id: GITHUB_CLIENT_ID })
182
189
  });
183
190
  if (!res.ok) {
184
191
  throw new Error(`device code request failed: ${res.status} ${await res.text()}`);
@@ -197,7 +204,7 @@ async function pollForToken(dc, deps = {}) {
197
204
  method: "POST",
198
205
  headers: { accept: "application/json" },
199
206
  body: new URLSearchParams({
200
- client_id: CLIENT_ID,
207
+ client_id: GITHUB_CLIENT_ID,
201
208
  device_code: dc.device_code,
202
209
  grant_type: "urn:ietf:params:oauth:grant-type:device_code"
203
210
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ymmv-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Publish and diff terminal-native developer tool-stack profiles at ymmv.fyi.",
5
5
  "type": "module",
6
6
  "bin": {