Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(integrations): classify resend scope-limited doctor safely

Rahman03a6cacafff8
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index bff46f8f..0cfa89a9 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -15,6 +15,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `integrations` classify resend scope-limited doctor safely
- `browser` stop Camoufox session cleanly
- `plugin` distinguish staging from ChatGPT app install
- `memory` persist workflow and organization actions
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 0061d403..80b604ec 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,3 +1,7 @@
+## 2026-09-20 — Distinguish Resend send-only scope from invalid credentials
+
+HR provider UAT exposed a verification-model bug: MSO's Resend doctor probed only `GET /domains`, so a legitimate Sending-only key could receive 401/403 and then be persisted as `invalid` even though that response only proved the key lacked Domains-read capability. The doctor now treats those Resend-specific scope denials as capability-unavailable with sending explicitly unverified, while preserving strict invalidation for providers/endpoints where 401/403 actually establishes invalid access. It does not claim a Sending-only key is valid, does not send a probe email, does not broaden permissions, and never exposes the credential. Regression coverage locks both Resend 401/403 handling and the connection-health classification.
+
## 2026-09-20 — Make the Camoufox session stop leave a clean user unit
Final production Browser QA proved viewer/auth transport clean, but stopping the Browser left
diff --git a/lib/infra/additional-doctor.test.ts b/lib/infra/additional-doctor.test.ts
index 476c1929..e99f647b 100644
--- a/lib/infra/additional-doctor.test.ts
+++ b/lib/infra/additional-doctor.test.ts
@@ -35,6 +35,14 @@ describe("additional native credential providers", () => {
expect(result).toContain("authenticated"); expect(result).not.toContain(KEY);
expect(mock.mock.calls[0]?.[0]).toBe(endpoint);
});
+ it.each([401, 403])("keeps Resend Domains %s as capability-unavailable instead of credential-invalid", async (status) => {
+ const mock = vi.fn(async () => new Response("scope denied", { status }));
+ vi.stubGlobal("fetch", mock);
+ await expect(doctorAdditionalProvider("resend", { apiKey: KEY })).rejects.toThrow(
+ "Resend Domains API access unavailable; sending capability not verified"
+ );
+ expect(mock).toHaveBeenCalledTimes(1);
+ });
it("verifies DOKU Payment with a signed read-only synthetic status lookup",async()=>{
const mock=vi.fn(async(input:RequestInfo|URL,init?:RequestInit)=>{expect(String(input)).toContain("api-sandbox.doku.com/orders/v1/status/MSO-CRED-CHECK-");const h=new Headers(init?.headers);expect(h.get("Client-Id")).toBe("MCH-synthetic");expect(h.get("Signature")).toMatch(/^HMACSHA256=/);return new Response(JSON.stringify({responseCode:"4040001",responseMessage:"Transaction Not Found"}),{status:404});});vi.stubGlobal("fetch",mock);
const result=await doctorAdditionalProvider("doku",{paymentClientId:"MCH-synthetic",paymentSecretKey:KEY,paymentEnvironment:"sandbox"});expect(result).toBe("authenticated; sandbox signed status lookup verified");expect(result).not.toContain(KEY);expect(mock).toHaveBeenCalledTimes(1);
diff --git a/lib/infra/additional-doctor.ts b/lib/infra/additional-doctor.ts
index af451125..13f1461d 100644
--- a/lib/infra/additional-doctor.ts
+++ b/lib/infra/additional-doctor.ts
@@ -102,7 +102,20 @@ export async function doctorAdditionalProvider(id: string, values: Record<string
}
case "resend": {
if (!present(values.apiKey)) return null;
- const response = await checked("Resend", "https://api.resend.com/domains", { authorization: `Bearer ${values.apiKey}`, accept: "application/json" });
+ let response;
+ try {
+ response = await request(
+ "https://api.resend.com/domains",
+ { headers: { authorization: `Bearer ${values.apiKey}`, accept: "application/json" } },
+ TIMEOUT_MS,
+ );
+ } catch {
+ throw new Error("Resend request failed");
+ }
+ if (response.status === 401 || response.status === 403) {
+ throw new Error("Resend Domains API access unavailable; sending capability not verified");
+ }
+ if (!response.ok) throw new Error(`Resend HTTP ${response.status}`);
return `authenticated; ${countRows(response.body)} accessible domain(s)`;
}
case "stripe": {
diff --git a/lib/infra/connection-health.test.ts b/lib/infra/connection-health.test.ts
index 228d1f73..a1c19bd7 100644
--- a/lib/infra/connection-health.test.ts
+++ b/lib/infra/connection-health.test.ts
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import { emptyIntegrationState } from "./identity";
import { createConnectionIn, saveConnectionValues } from "./connection-service";
import { connectionSummary } from "./connection-registry";
-import { recordConnectionCheck } from "./connection-health";
+import { checkCategory, recordConnectionCheck } from "./connection-health";
const fixture = vi.hoisted(() => ({ state: null as any }));
vi.mock("./connection-storage", () => ({
@@ -32,6 +32,15 @@ describe("revision-bound connection health", () => {
expect(connectionSummary("owner", current()).state).toBe("unavailable");
expect(JSON.stringify(current().lastCheck)).not.toContain("secret-response");
});
+ it("does not classify scope-limited Resend domain reads as an invalid credential", () => {
+ expect(
+ checkCategory({
+ id: "resend",
+ ok: false,
+ detail: "Resend Domains API access unavailable; sending capability not verified",
+ }),
+ ).toBe("unavailable");
+ });
it("rejects stale results after credential rotation or connection recreation", async () => {
const old = snapshot();
current().lastCheck = { revision: current().revision, checkedAt: 10, result: "invalid" };