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.

feat(infra): separate DOKU payment and MCP credentials

Rahman7029cfd77476
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 5b835ed0..451ccec7 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Added**
+- `infra` separate DOKU payment and MCP credentials
- `infra` add private DOKU MCP connections
- `infra` add private Convex env presence checks
- `infra` add safe Dokploy deployment recovery
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index e8f1a48e..8a7d9d33 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -2809,3 +2809,8 @@ Screenshot evidence previously lived in unrelated scratch directories or only in
- Added `doku` as a native named integration with one deliberately bounded auth method: DOKU MCP. Payment REST HMAC credentials are not accepted by this provider until MSO has a non-mutating official verification contract for them.
- DOKU MCP setup stores Client ID/API Key only through the private setup flow, pins environment to `sandbox|production`, derives only DOKU's official MCP endpoints, and verifies credentials with a read-only JSON-RPC `initialize` request before saving.
- Portable connection mapping supports `DOKU_MCP_CLIENT_ID`, `DOKU_MCP_API_KEY`, and `DOKU_MCP_ENV`; credential values remain redacted from summaries and tool output.
+
+### 2026-09-06 — DOKU Payment + MCP credential separation
+- Expanded the native `doku` integration from MCP-only to two explicit methods: Payment REST (`Payment Client ID` + HMAC `Payment Secret Key`) and MCP (`MCP Client ID` + `MCP API Key`). The methods cannot silently substitute for each other.
+- Payment credential verification uses a signed, read-only synthetic Check Status request against the fixed official sandbox/production endpoint. Only a verified `Transaction Not Found` response is accepted; `Invalid Merchant` 404 remains fail-closed.
+- MCP credential verification remains a fixed-endpoint MCP `initialize` request. DOKU credentials stay in MSO's owner-only integration store and are never copied into project MCP JSON, Baton notes, RR, or chat.
diff --git a/lib/infra/additional-doctor.test.ts b/lib/infra/additional-doctor.test.ts
index 191eb6db..e91ddd56 100644
--- a/lib/infra/additional-doctor.test.ts
+++ b/lib/infra/additional-doctor.test.ts
@@ -16,6 +16,7 @@ describe("additional native credential providers", () => {
expect(setupFields("convex-cloud", "personal").map(f => f.key)).toEqual(["personalToken"]);
expect(setupFields("convex-cloud", "deployment").map(f => f.key)).toEqual(["deployKey", "deploymentName"]);
expect(() => setupFields("convex-cloud", "organization")).toThrow();
+ expect(setupFields("doku","payment").map(f=>f.key)).toEqual(["paymentClientId","paymentSecretKey","paymentEnvironment"]);
expect(setupFields("doku", "mcp").map(f => f.key)).toEqual(["mcpClientId", "mcpApiKey", "environment"]);
expect(() => setupFields("doku", "direct")).toThrow();
});
@@ -33,6 +34,11 @@ describe("additional native credential providers", () => {
expect(result).toContain("authenticated"); expect(result).not.toContain(KEY);
expect(mock.mock.calls[0]?.[0]).toBe(endpoint);
});
+ 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);
+ });
+ it("rejects an invalid-merchant 404 for DOKU Payment",async()=>{vi.stubGlobal("fetch",vi.fn(async()=>new Response(JSON.stringify({responseCode:"4040008",responseMessage:"Invalid Merchant"}),{status:404})));await expect(doctorAdditionalProvider("doku",{paymentClientId:"MCH-synthetic",paymentSecretKey:KEY,paymentEnvironment:"sandbox"})).rejects.toThrow("DOKU Payment HTTP 404");});
it("verifies DOKU MCP with a fixed official endpoint and never exposes credentials", async () => {
const mock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
expect(String(input)).toBe("https://api-sandbox.doku.com/doku-mcp-server/mcp");
@@ -70,6 +76,7 @@ describe("additional native credential providers", () => {
expect(JSON.stringify(summarizeInfraProvider("convex-cloud", { personalToken: KEY }))).not.toContain(KEY);
expect(JSON.stringify(summarizeInfraProvider("convex", { adminKey: KEY, apiUrl: "https://convex.example.com" }))).not.toContain(KEY);
expect(JSON.stringify(summarizeInfraProvider("supabase", { managementToken: KEY }))).not.toContain(KEY);
+ expect(JSON.stringify(summarizeInfraProvider("doku",{paymentClientId:"MCH-synthetic",paymentSecretKey:KEY,paymentEnvironment:"sandbox"}))).not.toContain(KEY);
expect(JSON.stringify(summarizeInfraProvider("doku", { mcpClientId: "BRN-synthetic", mcpApiKey: KEY, environment: "sandbox" }))).not.toContain(KEY);
});
});
diff --git a/lib/infra/additional-doctor.ts b/lib/infra/additional-doctor.ts
index 39f0bbd8..bc3a4375 100644
--- a/lib/infra/additional-doctor.ts
+++ b/lib/infra/additional-doctor.ts
@@ -1,5 +1,6 @@
import { safeProviderFetch } from "@/lib/host/ssrf";
import { obj, request, TIMEOUT_MS } from "./http";
+import { doctorDoku } from "./doku-doctor";
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1"]);
@@ -48,57 +49,6 @@ async function checked(provider: string, url: string, headers: HeadersInit, fetc
}
-function dokuMcpEndpoint(environment: string): string {
- if (environment === "sandbox") return "https://api-sandbox.doku.com/doku-mcp-server/mcp";
- if (environment === "production") return "https://mcp.doku.com/mcp";
- throw new Error("DOKU MCP invalid environment");
-}
-
-function mcpInitializeResult(body: unknown, text: string): boolean {
- const direct = obj(body);
- if (direct.jsonrpc === "2.0" && direct.id === "mso-doku-doctor" && direct.result && typeof direct.result === "object") return true;
- for (const line of text.split(/\r?\n/)) {
- if (!line.startsWith("data:")) continue;
- try {
- const event = obj(JSON.parse(line.slice(5).trim()));
- if (event.jsonrpc === "2.0" && event.id === "mso-doku-doctor" && event.result && typeof event.result === "object") return true;
- } catch {}
- }
- return false;
-}
-
-async function doctorDokuMcp(values: Record<string, string>): Promise<string | null> {
- if (!present(values.mcpClientId) || !present(values.mcpApiKey) || !present(values.environment)) return null;
- const url = dokuMcpEndpoint(values.environment);
- let response;
- try {
- response = await request(url, {
- method: "POST",
- headers: {
- "Client-Id": values.mcpClientId,
- authorization: `Basic ${Buffer.from(`${values.mcpApiKey}:`).toString("base64")}`,
- "content-type": "application/json",
- accept: "application/json, text/event-stream",
- },
- body: JSON.stringify({
- jsonrpc: "2.0",
- id: "mso-doku-doctor",
- method: "initialize",
- params: {
- protocolVersion: "2024-11-05",
- capabilities: {},
- clientInfo: { name: "mso-integration-doctor", version: "1" },
- },
- }),
- }, TIMEOUT_MS);
- } catch {
- throw new Error("DOKU MCP request failed");
- }
- if (!response.ok) throw new Error(`DOKU MCP HTTP ${response.status}`);
- if (!mcpInitializeResult(response.body, response.text)) throw new Error("DOKU MCP invalid initialize response");
- return `authenticated; ${values.environment} MCP initialize verified`;
-}
-
function countRows(body: unknown): number {
if (Array.isArray(body)) return body.length;
const value = obj(body);
@@ -151,7 +101,7 @@ export async function doctorAdditionalProvider(id: string, values: Record<string
return `authenticated; ${countRows(response.body)} accessible project(s)`;
}
case "doku":
- return doctorDokuMcp(values);
+ return doctorDoku(values);
case "convex-cloud": {
const deployKey = values.deployKey;
const deploymentName = values.deploymentName;
diff --git a/lib/infra/additional-providers.ts b/lib/infra/additional-providers.ts
index f782f28c..cbc3bffa 100644
--- a/lib/infra/additional-providers.ts
+++ b/lib/infra/additional-providers.ts
@@ -81,17 +81,14 @@ export const ADDITIONAL_PROVIDERS = {
feature: false,
fields: [{ key: "organizationId", label: "Organization ID", secret: false, required: false, description: "Optional connection-specific configuration; retained during JSON transfer." }, { key: "managementToken", label: "Management access token", secret: true, required: true, description: "A Supabase personal access token for the Management API; it is distinct from project API keys." }],
},
- doku: {
- id: "doku",
- title: "DOKU MCP",
- description: "Verify a DOKU MCP merchant connection without copying credentials into project MCP config.",
- feature: false,
- fields: [
- { key: "mcpClientId", label: "MCP Client ID", secret: true, required: true, description: "DOKU-issued Client ID for MCP access in the selected environment. Stored only in the owner-only integration store." },
- { key: "mcpApiKey", label: "MCP API Key", secret: true, required: true, description: "DOKU-issued MCP API Key. It is distinct from the REST payment HMAC Secret Key." },
- { key: "environment", label: "Environment", secret: false, required: true, description: "Exactly sandbox or production. MSO derives the official DOKU MCP endpoint from this value." },
- ],
- },
+ doku: { id:"doku", title:"DOKU", description:"Verify DOKU Payment REST or DOKU MCP merchant credentials without copying secrets into project configuration.", feature:false, fields:[
+ {key:"paymentClientId",label:"Payment Client ID",secret:true,required:false,description:"DOKU Back Office Client ID used by the signed Non-SNAP payment API."},
+ {key:"paymentSecretKey",label:"Payment Secret Key",secret:true,required:false,description:"DOKU Back Office HMAC Secret Key for signed payment API requests. This is not the MCP API Key."},
+ {key:"paymentEnvironment",label:"Payment Environment",secret:false,required:false,description:"Exactly sandbox or production for the signed payment API."},
+ {key:"mcpClientId",label:"MCP Client ID",secret:true,required:false,description:"DOKU-issued Client ID for MCP access in the selected environment."},
+ {key:"mcpApiKey",label:"MCP API Key",secret:true,required:false,description:"DOKU-issued MCP API Key. It is distinct from the REST payment HMAC Secret Key."},
+ {key:"environment",label:"MCP Environment",secret:false,required:false,description:"Exactly sandbox or production. MSO derives the official DOKU MCP endpoint from this value."},
+ ] },
} as const satisfies Record<string, AdditionalProvider>;
export type AdditionalProviderId = keyof typeof ADDITIONAL_PROVIDERS;
diff --git a/lib/infra/catalog.ts b/lib/infra/catalog.ts
index 54647b18..7b945815 100644
--- a/lib/infra/catalog.ts
+++ b/lib/infra/catalog.ts
@@ -98,9 +98,9 @@ export function normalizeInfraValues(id: InfraProviderId, raw: Record<string, un
if (url.username || url.password || url.search || url.hash || (url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)))) throw new Error("Invalid deployment URL");
}
if (id === "doku") {
- if (out.environment && !["sandbox", "production"].includes(out.environment)) throw new Error("DOKU environment must be sandbox or production");
- if (out.mcpClientId && (out.mcpClientId.length < 3 || out.mcpClientId.length > 256 || /[\s\x00-\x1f\x7f]/.test(out.mcpClientId))) throw new Error("DOKU MCP Client ID must be an opaque single-line value");
- if (out.mcpApiKey && (out.mcpApiKey.length < 8 || /[\s\x00-\x1f\x7f]/.test(out.mcpApiKey))) throw new Error("DOKU MCP API Key must be an opaque single-line value");
+ for(const key of ["environment","paymentEnvironment"])if(out[key]&&!["sandbox","production"].includes(out[key]))throw new Error("DOKU environment must be sandbox or production");
+ for(const key of ["paymentClientId","mcpClientId"])if(out[key]&&(out[key].length<3||out[key].length>256||/[\s\x00-\x1f\x7f]/.test(out[key])))throw new Error("DOKU Client ID must be an opaque single-line value");
+ for(const key of ["paymentSecretKey","mcpApiKey"])if(out[key]&&(out[key].length<8||/[\s\x00-\x1f\x7f]/.test(out[key])))throw new Error("DOKU secret/API key must be an opaque single-line value");
}
if (id === "hostinger") {
if (out.apiToken && out.apiToken.length < 24) throw new Error("Hostinger API token is too short");
diff --git a/lib/infra/connection-registry.ts b/lib/infra/connection-registry.ts
index 60ec59ce..965f7bc0 100644
--- a/lib/infra/connection-registry.ts
+++ b/lib/infra/connection-registry.ts
@@ -35,5 +35,5 @@ export function connectionSummary(user:string,c:IntegrationConnection,isDefault=
export const composioDefinition=(provider:string)=>COMPOSIO[provider];
export const nativeDefinition=(provider:string)=>NATIVE[provider];
export function legacyMethod(provider:string,values:Record<string,string>):SetupMethod {
- return provider==="composio"?(values.orgApiKey?"organization":"project"):provider==="convex-cloud"?(values.deployKey?"deployment":"personal"):provider==="doku"?"mcp":"direct";
+ return provider==="composio"?(values.orgApiKey?"organization":"project"):provider==="convex-cloud"?(values.deployKey?"deployment":"personal"):provider==="doku"?(values.paymentClientId||values.paymentSecretKey?"payment":"mcp"):"direct";
}
diff --git a/lib/infra/connection-storage.ts b/lib/infra/connection-storage.ts
index e94a6abc..854a5763 100644
--- a/lib/infra/connection-storage.ts
+++ b/lib/infra/connection-storage.ts
@@ -32,7 +32,7 @@ function projected(raw:Record<string,unknown>|undefined):IntegrationState{
for(const [provider,v] of Object.entries(providers)){
if(!isInfraProviderId(provider)||!v||typeof v!=="object"||Array.isArray(v)||Object.values(v).some(x=>typeof x!=="string"))throw new IntegrationError("legacy_migration_requires_review");
const values=v as Record<string,string>;const selected=legacyMethod(provider,values);
- const methods=provider==="composio"?[...(values.apiKey?["project"]:[]),...(values.orgApiKey?["organization"]:[])]:provider==="convex-cloud"?[...(values.personalToken?["personal"]:[]),...(values.deployKey||values.deploymentName?["deployment"]:[])]:["direct"];
+ const methods=provider==="composio"?[...(values.apiKey?["project"]:[]),...(values.orgApiKey?["organization"]:[])]:provider==="convex-cloud"?[...(values.personalToken?["personal"]:[]),...(values.deployKey||values.deploymentName?["deployment"]:[])]:provider==="doku"?[...(values.paymentClientId||values.paymentSecretKey?["payment"]:[]),...(values.mcpClientId||values.mcpApiKey?["mcp"]:[])]:["direct"];
if(!methods.length)methods.push(selected);
profile.connections[provider]={};
for(const method of methods){const def=connectionMethod(provider,"direct",method),id=methods.length===1?"default":method;
diff --git a/lib/infra/doku-doctor.ts b/lib/infra/doku-doctor.ts
new file mode 100644
index 00000000..4f84546c
--- /dev/null
+++ b/lib/infra/doku-doctor.ts
@@ -0,0 +1,127 @@
+import { createHmac, randomUUID } from "node:crypto";
+import { obj, request, TIMEOUT_MS } from "./http";
+
+const present = (value: string | undefined): value is string =>
+ typeof value === "string" && value.trim().length > 0;
+
+function paymentBase(environment: string): string {
+ if (environment === "sandbox") return "https://api-sandbox.doku.com";
+ if (environment === "production") return "https://api.doku.com";
+ throw new Error("DOKU Payment invalid environment");
+}
+function mcpEndpoint(environment: string): string {
+ if (environment === "sandbox")
+ return "https://api-sandbox.doku.com/doku-mcp-server/mcp";
+ if (environment === "production") return "https://mcp.doku.com/mcp";
+ throw new Error("DOKU MCP invalid environment");
+}
+function mcpInitializeResult(body: unknown, text: string): boolean {
+ const direct = obj(body);
+ if (
+ direct.jsonrpc === "2.0" &&
+ direct.id === "mso-doku-doctor" &&
+ direct.result &&
+ typeof direct.result === "object"
+ )
+ return true;
+ for (const line of text.split(/\r?\n/)) {
+ if (!line.startsWith("data:")) continue;
+ try {
+ const event = obj(JSON.parse(line.slice(5).trim()));
+ if (
+ event.jsonrpc === "2.0" &&
+ event.id === "mso-doku-doctor" &&
+ event.result &&
+ typeof event.result === "object"
+ )
+ return true;
+ } catch {}
+ }
+ return false;
+}
+async function payment(values: Record<string, string>): Promise<string | null> {
+ if (
+ !present(values.paymentClientId) ||
+ !present(values.paymentSecretKey) ||
+ !present(values.paymentEnvironment)
+ )
+ return null;
+ const invoice = `MSO-CRED-CHECK-${randomUUID().replaceAll("-", "").slice(0, 12)}`;
+ const target = `/orders/v1/status/${invoice}`,
+ requestId = randomUUID(),
+ timestamp = new Date().toISOString();
+ const raw = `Client-Id:${values.paymentClientId}\nRequest-Id:${requestId}\nRequest-Timestamp:${timestamp}\nRequest-Target:${target}`;
+ const signature = `HMACSHA256=${createHmac("sha256", values.paymentSecretKey).update(raw).digest("base64")}`;
+ const url = `${paymentBase(values.paymentEnvironment)}${target}`;
+ let response;
+ try {
+ response = await request(
+ url,
+ {
+ headers: {
+ "Client-Id": values.paymentClientId,
+ "Request-Id": requestId,
+ "Request-Timestamp": timestamp,
+ Signature: signature,
+ accept: "application/json",
+ },
+ },
+ TIMEOUT_MS,
+ );
+ } catch {
+ throw new Error("DOKU Payment request failed");
+ }
+ if (response.status === 404) {
+ const transactionMissing =
+ /transaction\s+not\s+found/i.test(response.text) ||
+ /\b404\d*01\b/.test(response.text);
+ if (!transactionMissing) throw new Error("DOKU Payment HTTP 404");
+ } else if (!response.ok)
+ throw new Error(`DOKU Payment HTTP ${response.status}`);
+ return `authenticated; ${values.paymentEnvironment} signed status lookup verified`;
+}
+async function mcp(values: Record<string, string>): Promise<string | null> {
+ if (
+ !present(values.mcpClientId) ||
+ !present(values.mcpApiKey) ||
+ !present(values.environment)
+ )
+ return null;
+ const url = mcpEndpoint(values.environment);
+ let response;
+ try {
+ response = await request(
+ url,
+ {
+ method: "POST",
+ headers: {
+ "Client-Id": values.mcpClientId,
+ authorization: `Basic ${Buffer.from(`${values.mcpApiKey}:`).toString("base64")}`,
+ "content-type": "application/json",
+ accept: "application/json, text/event-stream",
+ },
+ body: JSON.stringify({
+ jsonrpc: "2.0",
+ id: "mso-doku-doctor",
+ method: "initialize",
+ params: {
+ protocolVersion: "2024-11-05",
+ capabilities: {},
+ clientInfo: { name: "mso-integration-doctor", version: "1" },
+ },
+ }),
+ },
+ TIMEOUT_MS,
+ );
+ } catch {
+ throw new Error("DOKU MCP request failed");
+ }
+ if (!response.ok) throw new Error(`DOKU MCP HTTP ${response.status}`);
+ if (!mcpInitializeResult(response.body, response.text))
+ throw new Error("DOKU MCP invalid initialize response");
+ return `authenticated; ${values.environment} MCP initialize verified`;
+}
+export const doctorDoku = (values: Record<string, string>) =>
+ present(values.paymentClientId) || present(values.paymentSecretKey)
+ ? payment(values)
+ : mcp(values);
diff --git a/lib/infra/portable/mapping.ts b/lib/infra/portable/mapping.ts
index 6c97be2b..6d742d05 100644
--- a/lib/infra/portable/mapping.ts
+++ b/lib/infra/portable/mapping.ts
@@ -12,19 +12,19 @@ export const FIELD_MAP:Record<string,Record<string,string>>={
resend:{RESEND_API_KEY:'apiKey',RESEND_FROM_DOMAIN:'fromDomain'},
clerk:{CLERK_SECRET_KEY:'apiKey',NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:'publishableKey',NEXT_PUBLIC_CLERK_FRONTEND_API_URL:'frontendUrl'},
supabase:{SUPABASE_ACCESS_TOKEN:'managementToken',SUPABASE_ORG_ID:'organizationId'},
- doku:{DOKU_MCP_CLIENT_ID:'mcpClientId',DOKU_MCP_API_KEY:'mcpApiKey',DOKU_MCP_ENV:'environment'},
+ doku:{DOKU_CLIENT_ID:'paymentClientId',DOKU_SECRET_KEY:'paymentSecretKey',DOKU_ENV:'paymentEnvironment',DOKU_MCP_CLIENT_ID:'mcpClientId',DOKU_MCP_API_KEY:'mcpApiKey',DOKU_MCP_ENV:'environment'},
};
const DIRECT:Record<string,string>={github:'classic-pat',dokploy:'admin-api-key',cloudflare:'api-token',hostinger:'api-token',convex:'self-hosted-admin',vercel:'account-token',stripe:'secret-key',resend:'api-key',clerk:'instance-keys',supabase:'personal-access-token',doku:'mcp-api-key'};
export function wireMethod(provider:string,source:string,method:string){
if(source!=='direct')return source==='native-mcp'?'provider-oauth':method;
- return provider==='composio'?(method==='organization'?'organization-token':'project-api-key'):provider==='convex-cloud'?(method==='deployment'?'deployment-key':'personal-access-token'):provider==='hostinger'?(method==='mail'?'mail-api-token':'api-token'):DIRECT[provider]??method;
+ return provider==='composio'?(method==='organization'?'organization-token':'project-api-key'):provider==='convex-cloud'?(method==='deployment'?'deployment-key':'personal-access-token'):provider==='doku'?(method==='payment'?'payment-hmac':'mcp-api-key'):provider==='hostinger'?(method==='mail'?'mail-api-token':'api-token'):DIRECT[provider]??method;
}
export function nativeMethod(provider:string,source:string,method:string){
if(source==='native-mcp')return ['provider-oauth','dcr-oauth','mcp-oauth'].includes(method)?'provider-oauth':method;
if(source!=='direct')return method;
if(provider==='composio')return({'project-api-key':'project','organization-token':'organization'} as Record<string,string>)[method]??method;
if(provider==='convex-cloud')return({'deployment-key':'deployment','personal-access-token':'personal'} as Record<string,string>)[method]??method;
- if(provider==='doku')return method==='mcp-api-key'?'mcp':method;
+ if(provider==='doku')return({'mcp-api-key':'mcp','payment-hmac':'payment'} as Record<string,string>)[method]??method;
if(provider==='hostinger')return({'mail-api-token':'mail','api-token':'direct'} as Record<string,string>)[method]??method;
return method===DIRECT[provider]?'direct':method;
}
diff --git a/lib/infra/setup-guidance.ts b/lib/infra/setup-guidance.ts
index ea0e1b9d..6532adc0 100644
--- a/lib/infra/setup-guidance.ts
+++ b/lib/infra/setup-guidance.ts
@@ -2,7 +2,7 @@ import { ADDITIONAL_GUIDANCE, type AdditionalProviderId } from "./additional-pro
import { getInfraProviderDefinition } from "./catalog";
import type { InfraProviderId } from "./types";
-export type SetupMethod = "direct" | "project" | "organization" | "personal" | "deployment" | "mail" | "mcp";
+export type SetupMethod = "direct" | "project" | "organization" | "personal" | "deployment" | "mail" | "payment" | "mcp";
export function setupFields(provider: InfraProviderId, method: SetupMethod) {
if (provider === "hostinger") {
if (!["direct", "mail"].includes(method)) throw new Error("Choose Hostinger account or scoped Mail API token");
@@ -10,8 +10,8 @@ export function setupFields(provider: InfraProviderId, method: SetupMethod) {
return getInfraProviderDefinition(provider).fields.filter(f => keys.includes(f.key)).map(f => ({ ...f, required: true }));
}
if (provider === "doku") {
- if (method !== "mcp") throw new Error("DOKU currently supports only the verified MCP credential method");
- const keys = ["mcpClientId", "mcpApiKey", "environment"];
+ if (!["payment", "mcp"].includes(method)) throw new Error("Choose DOKU Payment REST or DOKU MCP credentials");
+ const keys = method === "payment" ? ["paymentClientId", "paymentSecretKey", "paymentEnvironment"] : ["mcpClientId", "mcpApiKey", "environment"];
return getInfraProviderDefinition(provider).fields.filter(f => keys.includes(f.key)).map(f => ({ ...f, required: true }));
}
if (provider === "convex-cloud") {
@@ -28,7 +28,7 @@ export function setupFields(provider: InfraProviderId, method: SetupMethod) {
}
export function setupMethod(provider: InfraProviderId, method?: string): SetupMethod {
const value = method ?? (provider === "composio" ? "project" : provider === "convex-cloud" ? "personal" : provider === "doku" ? "mcp" : "direct");
- if (!["direct", "project", "organization", "personal", "deployment", "mail", "mcp"].includes(value)) throw new Error("Unsupported authentication method");
+ if (!["direct", "project", "organization", "personal", "deployment", "mail", "payment", "mcp"].includes(value)) throw new Error("Unsupported authentication method");
setupFields(provider, value as SetupMethod);
return value as SetupMethod;
}
@@ -36,10 +36,11 @@ export function setupMethods(provider: InfraProviderId): Array<{id: SetupMethod;
if (provider === "hostinger") return [{ id: "direct", label: "Account API token" }, { id: "mail", label: "Scoped Mail API token" }];
if (provider === "composio") return [{ id: "project", label: "Project API key" }, { id: "organization", label: "Organization API key" }];
if (provider === "convex-cloud") return [{ id: "personal", label: "Personal access token" }, { id: "deployment", label: "Deployment key" }];
- if (provider === "doku") return [{ id: "mcp", label: "DOKU MCP credential" }];
+ if (provider === "doku") return [{id:"payment",label:"Payment REST · Client ID + Secret Key"},{id:"mcp",label:"MCP · Client ID + API Key"}];
return [{ id: "direct", label: "Direct credential" }];
}
export function setupGuidance(provider: InfraProviderId, method: SetupMethod) {
+ if(provider==="doku")return method==="payment"?{url:"https://dashboard.doku.com/bo/developer/api-keys",reference:"https://developers.doku.com/get-started-with-doku-api/signature-component/non-snap/signature-component-from-request-header",steps:["Open DOKU Back Office → Developer → API Keys.","Use Client ID + Secret Key for the signed Non-SNAP payment API; the API Key is not a substitute for the HMAC Secret Key.","Choose sandbox first unless this project is explicitly approved for live payments.","Enter credentials only in this private setup form. MSO verifies them with a signed read-only status lookup before saving."]}:{url:"https://developers.doku.com/accept-payments/doku-mcp-server",reference:"https://developers.doku.com/accept-payments/doku-mcp-server",steps:["Open DOKU's official MCP Server guide and choose Sandbox first unless this project is explicitly approved for production payments.","Use the DOKU MCP Client ID + MCP API Key; do not substitute the Payment REST Secret Key.","Enter them only in this private setup form; do not paste them into chat, Baton notes, RR, Git, or project MCP JSON.","MSO calls the fixed official DOKU MCP endpoint with a read-only MCP initialize request before saving the connection."]};
if (provider in ADDITIONAL_GUIDANCE) return ADDITIONAL_GUIDANCE[provider as AdditionalProviderId];
const guides = {
composio: {
diff --git a/lib/infra/store.ts b/lib/infra/store.ts
index bd93f0b4..7e2e4f56 100644
--- a/lib/infra/store.ts
+++ b/lib/infra/store.ts
@@ -36,7 +36,8 @@ export function summarizeInfraProvider(id: InfraProviderId, values: InfraProvide
const missing = def.fields.filter((field) => field.required && !values[field.key]).map((field) => field.key);
if (id === "composio" && !values.apiKey && !values.orgApiKey) missing.push("project or organization API key");
if (id === "hostinger" && !values.apiToken && !(values.mailApiToken && values.mailOrderId)) missing.push("account token or scoped Mail API token + order ID");
- if (id === "convex-cloud" && !values.personalToken && !(values.deployKey && values.deploymentName)) missing.push("personal token or deployment key and name");
+ if(id==="doku"&&!(values.paymentClientId&&values.paymentSecretKey&&values.paymentEnvironment)&&!(values.mcpClientId&&values.mcpApiKey&&values.environment))missing.push("Payment Client ID + Secret Key or MCP Client ID + API Key, plus environment");
+ if (id === "convex-cloud" && !values.personalToken && !(values.deployKey && values.deploymentName)) missing.push("personal token or deployment key and name");
const safeValues = Object.fromEntries(def.fields
.filter((field) => values[field.key])
.map((field) => [field.key, field.secret ? mask(values[field.key]) : values[field.key]]));