@memoraone/mcp 0.1.60 → 0.1.61
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.cjs +1 -1
- package/dist/gateway.cjs +32 -3
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
package/dist/gateway.cjs
CHANGED
|
@@ -14339,6 +14339,15 @@ function sendUnauthorized(res, env2, workspaceRoot) {
|
|
|
14339
14339
|
});
|
|
14340
14340
|
res.end(body);
|
|
14341
14341
|
}
|
|
14342
|
+
function sendForbidden(res) {
|
|
14343
|
+
const body = "Forbidden";
|
|
14344
|
+
res.writeHead(403, {
|
|
14345
|
+
"content-type": "text/plain; charset=utf-8",
|
|
14346
|
+
"cache-control": "no-store",
|
|
14347
|
+
"content-length": Buffer.byteLength(body)
|
|
14348
|
+
});
|
|
14349
|
+
res.end(body);
|
|
14350
|
+
}
|
|
14342
14351
|
function sendPairingGate(res, body) {
|
|
14343
14352
|
res.writeHead(403, {
|
|
14344
14353
|
"content-type": "text/plain; charset=utf-8",
|
|
@@ -14436,6 +14445,19 @@ async function handleGatewayMcpAuthRequest(req, res, url, options = {}) {
|
|
|
14436
14445
|
sendPairingGate(res, "Setup required");
|
|
14437
14446
|
return true;
|
|
14438
14447
|
}
|
|
14448
|
+
} else {
|
|
14449
|
+
const existingCreds = await readInstallationCredentials(
|
|
14450
|
+
binding.repositoryBindingId
|
|
14451
|
+
);
|
|
14452
|
+
const existingOwnerId = existingCreds?.supabaseUserId;
|
|
14453
|
+
if (typeof existingOwnerId !== "string" || existingOwnerId.length === 0) {
|
|
14454
|
+
const repairedIdentity = await fetchAuthIdentity(apiUrl, token, {
|
|
14455
|
+
fetchImpl: options.fetchImpl
|
|
14456
|
+
});
|
|
14457
|
+
await updateInstallationCredentials(binding.repositoryBindingId, {
|
|
14458
|
+
supabaseUserId: repairedIdentity.supabase_user_id
|
|
14459
|
+
});
|
|
14460
|
+
}
|
|
14439
14461
|
}
|
|
14440
14462
|
const creds = await readInstallationCredentials(binding.repositoryBindingId);
|
|
14441
14463
|
const localOwnerId = creds?.supabaseUserId;
|
|
@@ -14460,12 +14482,19 @@ async function handleGatewayMcpAuthRequest(req, res, url, options = {}) {
|
|
|
14460
14482
|
transportOptions
|
|
14461
14483
|
);
|
|
14462
14484
|
return true;
|
|
14463
|
-
} catch {
|
|
14485
|
+
} catch (err) {
|
|
14464
14486
|
if (!canWriteGatewayResponse(res)) {
|
|
14465
14487
|
return true;
|
|
14466
14488
|
}
|
|
14467
|
-
|
|
14468
|
-
|
|
14489
|
+
if (err instanceof MemoraOneHttpError && err.status === 401) {
|
|
14490
|
+
sendUnauthorized(res, env2, parsed2.workspaceRoot);
|
|
14491
|
+
return true;
|
|
14492
|
+
}
|
|
14493
|
+
if (err instanceof MemoraOneHttpError && err.status === 403) {
|
|
14494
|
+
sendForbidden(res);
|
|
14495
|
+
return true;
|
|
14496
|
+
}
|
|
14497
|
+
throw err;
|
|
14469
14498
|
}
|
|
14470
14499
|
}
|
|
14471
14500
|
|