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

Rahman73d0f6d164f3
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" };