@frihet/mcp-server 2.0.1 → 2.0.2
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/README.md +6 -6
- package/dist/canary/mcp-harness.d.ts +1 -1
- package/dist/canary/mcp-harness.js +3 -2
- package/dist/claude-profile.js +3 -1
- package/dist/client-interface.d.ts +7 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +16 -0
- package/dist/demo-client.d.ts +14 -16
- package/dist/demo-client.js +101 -30
- package/dist/demo-fixtures.d.ts +14 -4
- package/dist/demo-fixtures.js +84 -16
- package/dist/invoice-payment-link.d.ts +189 -0
- package/dist/invoice-payment-link.js +371 -0
- package/dist/mpp-sandbox.d.ts +176 -0
- package/dist/mpp-sandbox.js +612 -0
- package/dist/openai-103/openai-expansion-103.d.ts +1192 -0
- package/dist/openai-103/openai-expansion-103.js +1628 -0
- package/dist/openai-profile.d.ts +5 -1
- package/dist/openai-profile.js +14 -2
- package/dist/openai-review-contract.js +2 -1
- package/dist/server-composition.js +34 -0
- package/dist/tool-exposure.js +2 -1
- package/dist/tools/purchaseOrders.d.ts +30 -0
- package/dist/tools/purchaseOrders.js +102 -0
- package/dist/tools/register-all.js +2 -0
- package/dist/tools/shared.d.ts +42 -0
- package/dist/tools/shared.js +46 -0
- package/docs/agent-onboarding.json +2 -2
- package/package.json +9 -9
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine Payments Protocol (MPP) Sell-Side Sandbox Proof (#269 / Frihet-ERP #3127).
|
|
3
|
+
*
|
|
4
|
+
* Implements M0–M4 sandbox eligibility, HTTP 402 challenge/credential/receipt
|
|
5
|
+
* state machine (`challenged` -> `pending` -> `verified` -> `delivered` |
|
|
6
|
+
* `failed_delivery_recovery`), and MCP JSON-RPC transport binding (`-32042` /
|
|
7
|
+
* `-32043`, `_meta['org.paymentauth/credential']`, `_meta['org.paymentauth/receipt']`).
|
|
8
|
+
*
|
|
9
|
+
* Strictly gated behind `FRIHET_MPP_EXPERIMENTAL=true` and `profile_test_*`
|
|
10
|
+
* test profiles. Frozen public connector profiles (`ChatGPT`, `Claude`,
|
|
11
|
+
* `Google`, `Muse`) are strictly isolated and never modified.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MPP_PROTOCOL_VERSION: "2026-04-sandbox";
|
|
14
|
+
export declare const MPP_MCP_PAYMENT_REQUIRED_CODE: -32042;
|
|
15
|
+
export declare const MPP_MCP_VERIFICATION_FAILED_CODE: -32043;
|
|
16
|
+
export declare const MPP_META_CREDENTIAL_KEY: "org.paymentauth/credential";
|
|
17
|
+
export declare const MPP_META_RECEIPT_KEY: "org.paymentauth/receipt";
|
|
18
|
+
export declare const MPP_SPT_SUPPORTED_REGIONS: readonly ["US", "CA", "ES", "SE"];
|
|
19
|
+
export declare const MPP_SPT_MIN_AMOUNT_MINOR_USD: 50;
|
|
20
|
+
export declare const MPP_USDC_MIN_AMOUNT_MINOR: 1;
|
|
21
|
+
export type MppPaymentMethod = "stripe_spt" | "tempo_usdc";
|
|
22
|
+
export type MppSandboxState = "challenged" | "pending" | "verified" | "delivered" | "failed_delivery_recovery";
|
|
23
|
+
export type MppEligibilityReasonCode = "ELIGIBLE" | "MPP_EXPERIMENTAL_DISABLED" | "MPP_FROZEN_PROFILE_FORBIDDEN" | "MPP_TEST_PROFILE_REQUIRED" | "MPP_MUTATING_RESOURCE_UNSUPPORTED" | "MPP_SPT_UNSUPPORTED_REGION" | "MPP_SPT_CURRENCY_MISMATCH" | "MPP_SPT_BELOW_MINIMUM" | "MPP_STABLECOIN_APPROVAL_REQUIRED" | "MPP_STABLECOIN_CURRENCY_MISMATCH" | "MPP_STABLECOIN_BELOW_MINIMUM";
|
|
24
|
+
export interface MppEligibilityInput {
|
|
25
|
+
readonly env?: Record<string, string | undefined>;
|
|
26
|
+
readonly profileId: string;
|
|
27
|
+
readonly region: string;
|
|
28
|
+
readonly paymentMethod: MppPaymentMethod;
|
|
29
|
+
readonly amountMinor: number;
|
|
30
|
+
readonly currency: string;
|
|
31
|
+
readonly effect: "read" | "write" | "fiscal";
|
|
32
|
+
readonly stablecoinApprovalGranted?: boolean;
|
|
33
|
+
readonly activeConnectorModes?: {
|
|
34
|
+
readonly openaiMode?: boolean;
|
|
35
|
+
readonly claudeMode?: boolean;
|
|
36
|
+
readonly googleMode?: boolean;
|
|
37
|
+
readonly museMode?: boolean;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface MppEligibilityVerdict {
|
|
41
|
+
readonly eligible: boolean;
|
|
42
|
+
readonly reasonCode: MppEligibilityReasonCode;
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
readonly minimumAmountMinor: number;
|
|
45
|
+
readonly normalizedCurrency: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deterministic, runtime-neutral FNV-1a 64-bit hex fingerprint for sandbox
|
|
49
|
+
* payment artifacts so raw secrets, SPT tokens, or wallet signatures are never
|
|
50
|
+
* stored or echoed in receipts or logs.
|
|
51
|
+
*/
|
|
52
|
+
export declare function fingerprintMppArtifact(kind: "challenge" | "credential" | "settlement" | "receipt", rawValue: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* M0 — Evaluates whether an operation is eligible for the MPP sell-side sandbox.
|
|
55
|
+
*/
|
|
56
|
+
export declare function evaluateMppSandboxEligibility(input: MppEligibilityInput): MppEligibilityVerdict;
|
|
57
|
+
export interface MppSandboxPrincipal {
|
|
58
|
+
readonly authenticatedSubjectId?: string;
|
|
59
|
+
readonly workspaceUid?: string;
|
|
60
|
+
readonly hasReadPermission: boolean;
|
|
61
|
+
readonly bearerTokenPresent: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface MppSandboxResource {
|
|
64
|
+
readonly workspaceUid: string;
|
|
65
|
+
readonly resourceId: string;
|
|
66
|
+
readonly realm: string;
|
|
67
|
+
readonly effect: "read" | "write" | "fiscal";
|
|
68
|
+
readonly requestDigest: string;
|
|
69
|
+
readonly amountMinor: number;
|
|
70
|
+
readonly currency: string;
|
|
71
|
+
readonly paymentMethod: MppPaymentMethod;
|
|
72
|
+
readonly profileId: string;
|
|
73
|
+
readonly region: string;
|
|
74
|
+
readonly stablecoinApprovalGranted?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface MppSandboxChallenge {
|
|
77
|
+
readonly challengeId: string;
|
|
78
|
+
readonly protocolVersion: typeof MPP_PROTOCOL_VERSION;
|
|
79
|
+
readonly workspaceUid: string;
|
|
80
|
+
readonly resourceId: string;
|
|
81
|
+
readonly realm: string;
|
|
82
|
+
readonly requestDigest: string;
|
|
83
|
+
readonly paymentMethod: MppPaymentMethod;
|
|
84
|
+
readonly amountMinor: number;
|
|
85
|
+
readonly currency: string;
|
|
86
|
+
readonly issuedAt: string;
|
|
87
|
+
readonly expiresAt: string;
|
|
88
|
+
readonly challengeFingerprint: string;
|
|
89
|
+
}
|
|
90
|
+
export interface MppPaymentCredentialInput {
|
|
91
|
+
readonly challengeId: string;
|
|
92
|
+
readonly credentialId: string;
|
|
93
|
+
readonly rawCredentialToken: string;
|
|
94
|
+
readonly settlementReference: string;
|
|
95
|
+
readonly workspaceUid: string;
|
|
96
|
+
readonly resourceId: string;
|
|
97
|
+
readonly requestDigest: string;
|
|
98
|
+
readonly amountMinor: number;
|
|
99
|
+
readonly currency: string;
|
|
100
|
+
readonly paymentMethod: MppPaymentMethod;
|
|
101
|
+
readonly reportedFinality: "settled" | "pending" | "declined";
|
|
102
|
+
readonly observedAt: string;
|
|
103
|
+
}
|
|
104
|
+
export interface MppPaymentReceipt {
|
|
105
|
+
readonly receiptId: string;
|
|
106
|
+
readonly challengeId: string;
|
|
107
|
+
readonly protocolVersion: typeof MPP_PROTOCOL_VERSION;
|
|
108
|
+
readonly sandbox: true;
|
|
109
|
+
readonly paymentMethod: MppPaymentMethod;
|
|
110
|
+
readonly amountMinor: number;
|
|
111
|
+
readonly currency: string;
|
|
112
|
+
readonly resourceId: string;
|
|
113
|
+
readonly requestDigest: string;
|
|
114
|
+
readonly credentialFingerprint: string;
|
|
115
|
+
readonly settlementFingerprint: string;
|
|
116
|
+
readonly settledAt: string;
|
|
117
|
+
readonly accountingDisposition: "unmapped_sandbox";
|
|
118
|
+
}
|
|
119
|
+
export interface MppSandboxAttemptRecord {
|
|
120
|
+
readonly challenge: MppSandboxChallenge;
|
|
121
|
+
state: MppSandboxState;
|
|
122
|
+
credentialId?: string;
|
|
123
|
+
credentialFingerprint?: string;
|
|
124
|
+
settlementFingerprint?: string;
|
|
125
|
+
receipt?: MppPaymentReceipt;
|
|
126
|
+
cachedDeliveryPayload?: Record<string, unknown>;
|
|
127
|
+
recoveryDisposition: "none" | "refund_or_idempotent_retry_required";
|
|
128
|
+
lastErrorCode?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface MppHttpSandboxResponse {
|
|
131
|
+
readonly status: 200 | 401 | 402 | 403 | 502;
|
|
132
|
+
readonly headers: Record<string, string>;
|
|
133
|
+
readonly body: Record<string, unknown>;
|
|
134
|
+
readonly mcpErrorCode?: typeof MPP_MCP_PAYMENT_REQUIRED_CODE | typeof MPP_MCP_VERIFICATION_FAILED_CODE;
|
|
135
|
+
readonly mcpMeta?: Record<string, unknown>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* M1 / M2 / M3 — Stateful sell-side sandbox coordinator enforcing:
|
|
139
|
+
* 1. RBAC 401 -> 403 pre-condition before any 402 Payment Required challenge.
|
|
140
|
+
* 2. Challenge binding (`WWW-Authenticate: Payment` + `Cache-Control: no-store`).
|
|
141
|
+
* 3. Coexistence of `Authorization: Bearer` and `Payment-Authorization: Payment`.
|
|
142
|
+
* 4. Anti-substitution & anti-replay guards across workspace, resource, digest, and amount.
|
|
143
|
+
* 5. State machine: `challenged` -> `pending` -> `verified` -> `delivered` | `failed_delivery_recovery`.
|
|
144
|
+
* 6. Sanitized `Payment-Receipt` (`Cache-Control: private`) and MCP `_meta['org.paymentauth/receipt']`.
|
|
145
|
+
*/
|
|
146
|
+
export declare class MppSandboxCoordinator {
|
|
147
|
+
private readonly attemptsByChallengeId;
|
|
148
|
+
private readonly challengeIdByCredentialId;
|
|
149
|
+
private readonly env;
|
|
150
|
+
private readonly activeConnectorModes?;
|
|
151
|
+
constructor(options?: {
|
|
152
|
+
readonly env?: Record<string, string | undefined>;
|
|
153
|
+
readonly activeConnectorModes?: MppEligibilityInput["activeConnectorModes"];
|
|
154
|
+
});
|
|
155
|
+
getAttempt(challengeId: string): MppSandboxAttemptRecord | undefined;
|
|
156
|
+
handleRequest(params: {
|
|
157
|
+
readonly principal: MppSandboxPrincipal;
|
|
158
|
+
readonly targetResource: MppSandboxResource;
|
|
159
|
+
readonly credential?: MppPaymentCredentialInput;
|
|
160
|
+
readonly nowIso?: string;
|
|
161
|
+
readonly executeReadResource: () => Promise<Record<string, unknown>>;
|
|
162
|
+
}): Promise<MppHttpSandboxResponse>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* M2 — Optional experimental MCP tool registration for local/sandbox verification.
|
|
166
|
+
* Strictly no-ops unless `env.FRIHET_MPP_EXPERIMENTAL === "true"` and no frozen
|
|
167
|
+
* connector profile (`openaiMode`, `claudeMode`, `googleMode`, `museMode`) is active.
|
|
168
|
+
*/
|
|
169
|
+
export declare function attachExperimentalMppSandboxTool(server: any, options?: {
|
|
170
|
+
readonly env?: Record<string, string | undefined>;
|
|
171
|
+
readonly openaiMode?: boolean;
|
|
172
|
+
readonly claudeMode?: boolean;
|
|
173
|
+
readonly googleMode?: boolean;
|
|
174
|
+
readonly museMode?: boolean;
|
|
175
|
+
}): MppSandboxCoordinator | undefined;
|
|
176
|
+
//# sourceMappingURL=mpp-sandbox.d.ts.map
|