@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 CHANGED
@@ -231,7 +231,7 @@ var require_package = __commonJS({
231
231
  "package.json"(exports2, module2) {
232
232
  module2.exports = {
233
233
  name: "@memoraone/mcp",
234
- version: "0.1.60",
234
+ version: "0.1.61",
235
235
  type: "module",
236
236
  main: "dist/index.cjs",
237
237
  exports: {
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
- sendUnauthorized(res, env2, parsed2.workspaceRoot);
14468
- return true;
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoraone/mcp",
3
- "version": "0.1.60",
3
+ "version": "0.1.61",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "exports": {