mrmainspring 0.1.0
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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/audit/service.d.ts +7 -0
- package/dist/audit/service.js +98 -0
- package/dist/audit/store.d.ts +7 -0
- package/dist/audit/store.js +37 -0
- package/dist/audit/supabase-store.d.ts +9 -0
- package/dist/audit/supabase-store.js +22 -0
- package/dist/audit/types.d.ts +31 -0
- package/dist/audit/types.js +1 -0
- package/dist/casper/anchorClient.d.ts +99 -0
- package/dist/casper/anchorClient.js +412 -0
- package/dist/config.d.ts +51 -0
- package/dist/config.js +215 -0
- package/dist/env-file.d.ts +1 -0
- package/dist/env-file.js +51 -0
- package/dist/grimoire/service.d.ts +13 -0
- package/dist/grimoire/service.js +199 -0
- package/dist/grimoire/store.d.ts +10 -0
- package/dist/grimoire/store.js +64 -0
- package/dist/grimoire/supabase-store.d.ts +13 -0
- package/dist/grimoire/supabase-store.js +50 -0
- package/dist/grimoire/types.d.ts +60 -0
- package/dist/grimoire/types.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +17 -0
- package/dist/mcp/auditTools.d.ts +3 -0
- package/dist/mcp/auditTools.js +13 -0
- package/dist/mcp/grimoireTools.d.ts +3 -0
- package/dist/mcp/grimoireTools.js +91 -0
- package/dist/mcp/jsonResult.d.ts +2 -0
- package/dist/mcp/jsonResult.js +10 -0
- package/dist/mcp/memoryTools.d.ts +3 -0
- package/dist/mcp/memoryTools.js +73 -0
- package/dist/mcp/paymentTools.d.ts +3 -0
- package/dist/mcp/paymentTools.js +33 -0
- package/dist/memory/canonical.d.ts +4 -0
- package/dist/memory/canonical.js +49 -0
- package/dist/memory/hash.d.ts +1 -0
- package/dist/memory/hash.js +4 -0
- package/dist/memory/service.d.ts +37 -0
- package/dist/memory/service.js +175 -0
- package/dist/memory/store.d.ts +8 -0
- package/dist/memory/store.js +49 -0
- package/dist/memory/supabase-store.d.ts +10 -0
- package/dist/memory/supabase-store.js +30 -0
- package/dist/memory/types.d.ts +56 -0
- package/dist/memory/types.js +7 -0
- package/dist/payments/service.d.ts +26 -0
- package/dist/payments/service.js +613 -0
- package/dist/payments/store.d.ts +10 -0
- package/dist/payments/store.js +64 -0
- package/dist/payments/supabase-store.d.ts +13 -0
- package/dist/payments/supabase-store.js +51 -0
- package/dist/payments/types.d.ts +101 -0
- package/dist/payments/types.js +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +68 -0
- package/dist/storage/json-file-store.d.ts +17 -0
- package/dist/storage/json-file-store.js +87 -0
- package/dist/storage/store-factory.d.ts +12 -0
- package/dist/storage/store-factory.js +26 -0
- package/dist/storage/supabase-rest.d.ts +26 -0
- package/dist/storage/supabase-rest.js +85 -0
- package/dist/x402/client.d.ts +44 -0
- package/dist/x402/client.js +95 -0
- package/dist/x402/facilitator.d.ts +84 -0
- package/dist/x402/facilitator.js +800 -0
- package/dist/x402/readiness.d.ts +55 -0
- package/dist/x402/readiness.js +433 -0
- package/dist/x402/redaction.d.ts +1 -0
- package/dist/x402/redaction.js +30 -0
- package/dist/x402/resource.d.ts +69 -0
- package/dist/x402/resource.js +325 -0
- package/dist/x402/settlement.d.ts +176 -0
- package/dist/x402/settlement.js +1210 -0
- package/dist/x402/signer.d.ts +71 -0
- package/dist/x402/signer.js +616 -0
- package/package.json +61 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type Server } from "node:http";
|
|
2
|
+
import type { CasperCommandRunner } from "../casper/anchorClient.js";
|
|
3
|
+
import type { JsonObject } from "../memory/types.js";
|
|
4
|
+
import { type X402CasperCliSettlementConfig, type X402SettlementInput } from "./settlement.js";
|
|
5
|
+
export type X402FacilitatorLogger = {
|
|
6
|
+
info?(message: string): void;
|
|
7
|
+
warn?(message: string): void;
|
|
8
|
+
error?(message: string): void;
|
|
9
|
+
};
|
|
10
|
+
export type X402FacilitatorHttpServerConfig = {
|
|
11
|
+
facilitatorUrl?: string | null;
|
|
12
|
+
settlementConfig: X402CasperCliSettlementConfig;
|
|
13
|
+
commandRunner?: CasperCommandRunner;
|
|
14
|
+
replayStore?: X402FacilitatorReplayStore;
|
|
15
|
+
now?: () => Date;
|
|
16
|
+
logger?: X402FacilitatorLogger;
|
|
17
|
+
maxBodyBytes?: number;
|
|
18
|
+
};
|
|
19
|
+
export type X402FacilitatorReplayState = "verified" | "settling" | "settled" | "failed";
|
|
20
|
+
export type X402FacilitatorReplayRecord = {
|
|
21
|
+
replayKey: string;
|
|
22
|
+
payloadHash: string;
|
|
23
|
+
state: X402FacilitatorReplayState;
|
|
24
|
+
transactionHash: string | null;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
};
|
|
27
|
+
export type X402FacilitatorReplayStore = {
|
|
28
|
+
reserveVerify(payment: ValidatedX402FacilitatorPayment): X402ReplayReservation;
|
|
29
|
+
reserveSettle(payment: ValidatedX402FacilitatorPayment): X402ReplayReservation;
|
|
30
|
+
completeSettle(payment: ValidatedX402FacilitatorPayment, state: "settled" | "failed", transactionHash: string | null): void;
|
|
31
|
+
};
|
|
32
|
+
export type X402ReplayReservation = {
|
|
33
|
+
ok: true;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
reason: "payment_payload_replayed" | "nonce_replayed" | "payment_settlement_in_progress";
|
|
37
|
+
};
|
|
38
|
+
export type X402FacilitatorRejectionReason = "request_not_object" | "payment_payload_missing" | "payment_requirements_missing" | "payment_requirements_no_matching_accept" | "selected_requirement_hash_missing" | "selected_requirement_hash_invalid" | "selected_requirement_hash_mismatch" | "accepted_requirement_hash_mismatch" | "scheme_missing" | "scheme_unsupported" | "network_missing" | "network_mismatch" | "amount_missing" | "amount_invalid" | "amount_mismatch" | "resource_missing" | "resource_mismatch" | "method_missing" | "method_invalid" | "method_mismatch" | "asset_missing" | "asset_mismatch" | "payee_missing" | "payee_mismatch" | "payer_missing" | "authorization_missing" | "payment_id_missing" | "payment_id_invalid" | "policy_hash_missing" | "policy_hash_invalid" | "public_key_missing" | "public_key_invalid" | "signature_missing" | "signature_invalid" | "authorization_hash_mismatch" | "nonce_missing" | "nonce_invalid" | "nonce_mismatch" | "valid_after_missing" | "valid_until_missing" | "validity_window_invalid" | "payment_not_yet_valid" | "payment_expired" | "timeout_missing" | "timeout_invalid" | "timeout_exceeded";
|
|
39
|
+
export type ValidatedX402FacilitatorPayment = {
|
|
40
|
+
paymentPayload: JsonObject;
|
|
41
|
+
paymentRequirements: JsonObject;
|
|
42
|
+
selectedRequirementHash: string;
|
|
43
|
+
payloadHash: string;
|
|
44
|
+
replayKey: string;
|
|
45
|
+
nonce: string;
|
|
46
|
+
paymentId: string;
|
|
47
|
+
policyHash: string;
|
|
48
|
+
payer: string;
|
|
49
|
+
publicKey: string;
|
|
50
|
+
signature: string;
|
|
51
|
+
requirement: NormalizedFacilitatorRequirement;
|
|
52
|
+
settlementInput: X402SettlementInput;
|
|
53
|
+
};
|
|
54
|
+
type NormalizedFacilitatorRequirement = {
|
|
55
|
+
scheme: "exact";
|
|
56
|
+
network: string;
|
|
57
|
+
amount: string;
|
|
58
|
+
resource: string;
|
|
59
|
+
method: string;
|
|
60
|
+
asset: string;
|
|
61
|
+
payTo: string;
|
|
62
|
+
timeoutSeconds: number;
|
|
63
|
+
};
|
|
64
|
+
type X402FacilitatorPaymentValidation = {
|
|
65
|
+
ok: true;
|
|
66
|
+
payment: ValidatedX402FacilitatorPayment;
|
|
67
|
+
} | {
|
|
68
|
+
ok: false;
|
|
69
|
+
reason: X402FacilitatorRejectionReason;
|
|
70
|
+
statusCode: number;
|
|
71
|
+
};
|
|
72
|
+
export declare class InMemoryX402FacilitatorReplayStore implements X402FacilitatorReplayStore {
|
|
73
|
+
private readonly records;
|
|
74
|
+
reserveVerify(payment: ValidatedX402FacilitatorPayment): X402ReplayReservation;
|
|
75
|
+
reserveSettle(payment: ValidatedX402FacilitatorPayment): X402ReplayReservation;
|
|
76
|
+
completeSettle(payment: ValidatedX402FacilitatorPayment, state: "settled" | "failed", transactionHash: string | null): void;
|
|
77
|
+
}
|
|
78
|
+
export declare function createX402FacilitatorHttpServer(config: X402FacilitatorHttpServerConfig): Server;
|
|
79
|
+
export declare function validateX402FacilitatorPayment(input: unknown, options?: {
|
|
80
|
+
expectedNetwork?: string | null;
|
|
81
|
+
now?: () => Date;
|
|
82
|
+
facilitatorUrl?: string | null;
|
|
83
|
+
}): X402FacilitatorPaymentValidation;
|
|
84
|
+
export {};
|