jellycube 0.2.0 → 0.3.0
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/index.js +18 -8
- package/manifest.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/config.ts
|
|
4
|
-
var CLI_VERSION = "0.
|
|
4
|
+
var CLI_VERSION = "0.3.0";
|
|
5
5
|
var DEFAULT_API_ORIGIN = "https://editor.jellycube.app";
|
|
6
|
-
var CLI_CLIENT_ID = "
|
|
6
|
+
var CLI_CLIENT_ID = "hEH0yU6LUTzrXHKJ";
|
|
7
|
+
var DEV_CLI_CLIENT_ID = "J7OznJsRYDjJH3Yk";
|
|
8
|
+
function clientIdFor(config, issuer) {
|
|
9
|
+
if (config.clientId !== CLI_CLIENT_ID) return config.clientId;
|
|
10
|
+
try {
|
|
11
|
+
return new URL(issuer).hostname.endsWith(".clerk.accounts.dev") ? DEV_CLI_CLIENT_ID : CLI_CLIENT_ID;
|
|
12
|
+
} catch {
|
|
13
|
+
return CLI_CLIENT_ID;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
7
16
|
var LOOPBACK_PORT = 53682;
|
|
8
17
|
var REDIRECT_URI = `http://127.0.0.1:${LOOPBACK_PORT}/callback`;
|
|
9
18
|
var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
@@ -427,10 +436,10 @@ function credentialsFrom(token, data, previous, now) {
|
|
|
427
436
|
subject: subjectOf(token)
|
|
428
437
|
};
|
|
429
438
|
}
|
|
430
|
-
function authorizeUrl(endpoints,
|
|
439
|
+
function authorizeUrl(endpoints, clientId, pkce, redirectUri) {
|
|
431
440
|
const url = new URL(endpoints.authorizationEndpoint);
|
|
432
441
|
url.searchParams.set("response_type", "code");
|
|
433
|
-
url.searchParams.set("client_id",
|
|
442
|
+
url.searchParams.set("client_id", clientId);
|
|
434
443
|
url.searchParams.set("redirect_uri", redirectUri);
|
|
435
444
|
url.searchParams.set("scope", REQUESTED_SCOPES.join(" "));
|
|
436
445
|
url.searchParams.set("state", pkce.state);
|
|
@@ -445,8 +454,9 @@ async function login(config, store, options = {}) {
|
|
|
445
454
|
const now = options.now ?? Date.now;
|
|
446
455
|
const fetchFn = options.fetchFn ?? fetch;
|
|
447
456
|
const endpoints = options.endpoints ?? await discoverAuth(config.origin, fetchFn);
|
|
457
|
+
const clientId = clientIdFor(config, endpoints.issuer);
|
|
448
458
|
const pkce = newPkce();
|
|
449
|
-
const url = authorizeUrl(endpoints,
|
|
459
|
+
const url = authorizeUrl(endpoints, clientId, pkce, REDIRECT_URI);
|
|
450
460
|
let code;
|
|
451
461
|
try {
|
|
452
462
|
const handle = await startLoopback({
|
|
@@ -466,7 +476,7 @@ async function login(config, store, options = {}) {
|
|
|
466
476
|
say(`Port ${error.port} is busy. Using a device code instead.`);
|
|
467
477
|
code = await runDeviceFlow({
|
|
468
478
|
endpoints,
|
|
469
|
-
clientId
|
|
479
|
+
clientId,
|
|
470
480
|
scopes: REQUESTED_SCOPES,
|
|
471
481
|
fetchFn,
|
|
472
482
|
say,
|
|
@@ -478,7 +488,7 @@ async function login(config, store, options = {}) {
|
|
|
478
488
|
grant_type: "authorization_code",
|
|
479
489
|
code,
|
|
480
490
|
redirect_uri: REDIRECT_URI,
|
|
481
|
-
client_id:
|
|
491
|
+
client_id: clientId,
|
|
482
492
|
code_verifier: pkce.verifier
|
|
483
493
|
}, fetchFn);
|
|
484
494
|
const token = data["access_token"];
|
|
@@ -498,7 +508,7 @@ async function refresh(credentials, config, store, options = {}) {
|
|
|
498
508
|
const data = await tokenPost(endpoints.tokenEndpoint, {
|
|
499
509
|
grant_type: "refresh_token",
|
|
500
510
|
refresh_token: credentials.refreshToken,
|
|
501
|
-
client_id: config.
|
|
511
|
+
client_id: clientIdFor(config, endpoints.issuer)
|
|
502
512
|
}, fetchFn);
|
|
503
513
|
if (data["error"] === "invalid_grant" || data["code"] === "grant_revoked") {
|
|
504
514
|
await store.clear();
|
package/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": "0.2",
|
|
3
3
|
"name": "jellycube",
|
|
4
4
|
"display_name": "Jellycube",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"description": "Edit Jellycube sites from Claude: sign in once, then use the same tools as the cloud MCP.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "TAF Technology"
|