@ocap/mpc-hsm 0.0.0-stage → 1.33.7
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/esm/bip39-english-wordlist.d.mts +11 -0
- package/esm/bip39-english-wordlist.mjs +31 -0
- package/esm/constants.d.mts +140 -0
- package/esm/constants.mjs +142 -0
- package/esm/dkg.d.mts +279 -0
- package/esm/dkg.mjs +903 -0
- package/esm/index.d.mts +17 -0
- package/esm/index.mjs +18 -0
- package/esm/mta.d.mts +63 -0
- package/esm/mta.mjs +275 -0
- package/esm/ocap-clear-signing.d.mts +125 -0
- package/esm/ocap-clear-signing.mjs +1170 -0
- package/esm/offline-ceremony.d.mts +127 -0
- package/esm/offline-ceremony.mjs +481 -0
- package/esm/ot.d.mts +193 -0
- package/esm/ot.mjs +726 -0
- package/esm/personal-vault.d.mts +1292 -0
- package/esm/personal-vault.mjs +3615 -0
- package/esm/personal.d.mts +10 -0
- package/esm/personal.mjs +11 -0
- package/esm/presign.d.mts +242 -0
- package/esm/presign.mjs +951 -0
- package/esm/rlp-eip1559.d.mts +75 -0
- package/esm/rlp-eip1559.mjs +293 -0
- package/esm/secp256k1-scalar.d.mts +141 -0
- package/esm/secp256k1-scalar.mjs +474 -0
- package/esm/sign.d.mts +113 -0
- package/esm/sign.mjs +225 -0
- package/esm/steel-mnemonic.d.mts +55 -0
- package/esm/steel-mnemonic.mjs +247 -0
- package/esm/tweak.d.mts +100 -0
- package/esm/tweak.mjs +168 -0
- package/esm/ves-backup.d.mts +296 -0
- package/esm/ves-backup.mjs +1025 -0
- package/esm/x402-agent-guard.d.mts +111 -0
- package/esm/x402-agent-guard.mjs +780 -0
- package/lib/bip39-english-wordlist.cjs +33 -0
- package/lib/bip39-english-wordlist.d.cts +11 -0
- package/lib/constants.cjs +264 -0
- package/lib/constants.d.cts +140 -0
- package/lib/dkg.cjs +910 -0
- package/lib/dkg.d.cts +279 -0
- package/lib/index.cjs +420 -0
- package/lib/index.d.cts +17 -0
- package/lib/mta.cjs +280 -0
- package/lib/mta.d.cts +63 -0
- package/lib/ocap-clear-signing.cjs +1176 -0
- package/lib/ocap-clear-signing.d.cts +125 -0
- package/lib/offline-ceremony.cjs +487 -0
- package/lib/offline-ceremony.d.cts +127 -0
- package/lib/ot.cjs +744 -0
- package/lib/ot.d.cts +193 -0
- package/lib/personal-vault.cjs +3725 -0
- package/lib/personal-vault.d.cts +1292 -0
- package/lib/personal.cjs +338 -0
- package/lib/personal.d.cts +10 -0
- package/lib/presign.cjs +954 -0
- package/lib/presign.d.cts +242 -0
- package/lib/rlp-eip1559.cjs +303 -0
- package/lib/rlp-eip1559.d.cts +75 -0
- package/lib/secp256k1-scalar.cjs +527 -0
- package/lib/secp256k1-scalar.d.cts +141 -0
- package/lib/sign.cjs +233 -0
- package/lib/sign.d.cts +113 -0
- package/lib/steel-mnemonic.cjs +253 -0
- package/lib/steel-mnemonic.d.cts +55 -0
- package/lib/tweak.cjs +178 -0
- package/lib/tweak.d.cts +100 -0
- package/lib/ves-backup.cjs +1053 -0
- package/lib/ves-backup.d.cts +296 -0
- package/lib/x402-agent-guard.cjs +788 -0
- package/lib/x402-agent-guard.d.cts +111 -0
- package/package.json +80 -4
- package/README.md +0 -3
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Eip1559UnsignedTxFields } from "./rlp-eip1559.mjs";
|
|
2
|
+
import { PersonalClearSigningPreview, PersonalMpcEoaSigner, PersonalPolicyProofBundle, PersonalPolicyTier, PersonalVaultPolicy, VaultEntitlementTicket, VerifiedPersonalEip1559Tx } from "./personal-vault.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/x402-agent-guard.d.ts
|
|
5
|
+
declare const MAX_X402_CHALLENGE_BYTES: 16384;
|
|
6
|
+
declare const MAX_X402_ACCEPTS_ENTRIES: 16;
|
|
7
|
+
declare const MAX_X402_RETRIES: 1;
|
|
8
|
+
declare const X402_PROTOCOL_VERSION: 1;
|
|
9
|
+
declare const X402_EXACT_EVM_TX_SCHEME: "exact-evm-tx";
|
|
10
|
+
type PolicyProofBundle = PersonalPolicyProofBundle;
|
|
11
|
+
type X402EscalationKind = 'announce-timelock' | 'role-quorum' | 'quorum-and-timelock';
|
|
12
|
+
interface X402PaymentRequirement {
|
|
13
|
+
readonly scheme: string;
|
|
14
|
+
readonly chainId: bigint;
|
|
15
|
+
readonly network: string;
|
|
16
|
+
readonly amount: bigint;
|
|
17
|
+
readonly assetKind: 'native' | 'erc20';
|
|
18
|
+
/** `'native'` or lowercase `0x...` ERC-20 contract address */
|
|
19
|
+
readonly asset: string;
|
|
20
|
+
readonly tokenChecksumAddress?: string;
|
|
21
|
+
readonly payToChecksumAddress: string;
|
|
22
|
+
readonly resource?: string;
|
|
23
|
+
readonly description?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ParsedX402PaymentChallenge {
|
|
26
|
+
readonly x402Version: 1;
|
|
27
|
+
readonly accepts: ReadonlyArray<X402PaymentRequirement>;
|
|
28
|
+
readonly source: 'header' | 'body';
|
|
29
|
+
}
|
|
30
|
+
interface X402TxExecutionParams {
|
|
31
|
+
readonly nonce: bigint;
|
|
32
|
+
readonly maxPriorityFeePerGasWei: bigint;
|
|
33
|
+
readonly maxFeePerGasWei: bigint;
|
|
34
|
+
readonly gasLimit?: bigint;
|
|
35
|
+
}
|
|
36
|
+
interface X402EscalationContext {
|
|
37
|
+
readonly challenge: ParsedX402PaymentChallenge;
|
|
38
|
+
readonly requirement: X402PaymentRequirement;
|
|
39
|
+
readonly unsignedTx: Eip1559UnsignedTxFields;
|
|
40
|
+
readonly verifiedTx: VerifiedPersonalEip1559Tx;
|
|
41
|
+
readonly preview: PersonalClearSigningPreview;
|
|
42
|
+
readonly previewHash32: Uint8Array;
|
|
43
|
+
readonly signingDigest32: Uint8Array;
|
|
44
|
+
readonly requiredTier: Exclude<PersonalPolicyTier, 'L0'>;
|
|
45
|
+
readonly escalationKind: X402EscalationKind;
|
|
46
|
+
}
|
|
47
|
+
interface X402PaymentProofPayload {
|
|
48
|
+
readonly x402Version: 1;
|
|
49
|
+
readonly scheme: typeof X402_EXACT_EVM_TX_SCHEME;
|
|
50
|
+
readonly chainId: number | string;
|
|
51
|
+
readonly signedRawTxHex: string;
|
|
52
|
+
readonly txHashHex: string;
|
|
53
|
+
readonly payer: string;
|
|
54
|
+
}
|
|
55
|
+
interface X402AgentPaymentFetchOptions {
|
|
56
|
+
readonly signer: PersonalMpcEoaSigner;
|
|
57
|
+
readonly policy: PersonalVaultPolicy;
|
|
58
|
+
readonly txParamsProvider: (ctx: {
|
|
59
|
+
readonly requirement: X402PaymentRequirement;
|
|
60
|
+
readonly payerAddress: string;
|
|
61
|
+
}) => Promise<X402TxExecutionParams> | X402TxExecutionParams;
|
|
62
|
+
readonly fetchImpl?: typeof fetch;
|
|
63
|
+
/** Optional client-side per-request ceiling (`bigint` across assets, or map keyed by `'native'` / token address). */
|
|
64
|
+
readonly maxPerRequestAmount?: bigint | Readonly<Record<string, bigint>>;
|
|
65
|
+
/** Optional client-side cumulative session ceiling (`bigint` across assets, or map keyed by `'native'` / token address). */
|
|
66
|
+
readonly maxSessionTotalAmount?: bigint | Readonly<Record<string, bigint>>;
|
|
67
|
+
/** Optional strict client-side payee allowlist (EIP-55 or lowercase `0x...`). */
|
|
68
|
+
readonly allowedPayees?: ReadonlyArray<string>;
|
|
69
|
+
/** Optional strict client-side chainId subset filter. */
|
|
70
|
+
readonly allowedChainIds?: ReadonlyArray<bigint | number | string>;
|
|
71
|
+
/** Optional hook supplying external rolling 24h velocity for `(chainId, asset)` prior to tier evaluation. */
|
|
72
|
+
readonly getRolling24hSpendAmount?: (ctx: {
|
|
73
|
+
readonly chainId: bigint;
|
|
74
|
+
readonly asset: string;
|
|
75
|
+
}) => Promise<bigint> | bigint;
|
|
76
|
+
/** Optional L1..L3 interactive escalation callback (e.g. ARC Channel / DID Wallet approval card). */
|
|
77
|
+
readonly onEscalationRequired?: (ctx: X402EscalationContext) => Promise<PolicyProofBundle | null | undefined> | PolicyProofBundle | null | undefined;
|
|
78
|
+
readonly entitlementTicket?: VaultEntitlementTicket;
|
|
79
|
+
readonly nowSec?: () => bigint;
|
|
80
|
+
}
|
|
81
|
+
type X402HeaderMap = Readonly<Record<string, string | ReadonlyArray<string> | undefined>>;
|
|
82
|
+
interface X402SyncResponseSnapshot {
|
|
83
|
+
readonly status?: number;
|
|
84
|
+
readonly headers?: Headers | X402HeaderMap;
|
|
85
|
+
readonly body?: string | Uint8Array;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parses and strictly validates an HTTP `402 Payment Required` `x402` challenge from:
|
|
89
|
+
* - a Web Fetch `Response` (`X-Payment-Required` / `Payment-Required` header or `402` JSON body),
|
|
90
|
+
* - a `Headers` instance or plain header map, or
|
|
91
|
+
* - a raw JSON / base64 / base64url header string or `Uint8Array`.
|
|
92
|
+
*
|
|
93
|
+
* Enforces `<= 16,384` bytes, prototype-pollution-free JSON parsing, strict EIP-55 checksum validation,
|
|
94
|
+
* positive `bigint` amounts, and rejects EIP-7702 (`0x04`) and `approve`/calldata tricks.
|
|
95
|
+
*/
|
|
96
|
+
declare function parseX402PaymentChallenge(response: Response): Promise<ParsedX402PaymentChallenge>;
|
|
97
|
+
declare function parseX402PaymentChallenge(headerOrSnapshot: string | Uint8Array | Headers | X402HeaderMap | X402SyncResponseSnapshot): ParsedX402PaymentChallenge;
|
|
98
|
+
declare function parseX402PaymentChallenge(responseOrHeader: Response | string | Uint8Array | Headers | X402HeaderMap | X402SyncResponseSnapshot): Promise<ParsedX402PaymentChallenge> | ParsedX402PaymentChallenge;
|
|
99
|
+
declare function encodeX402PaymentHeader(payload: X402PaymentProofPayload): string;
|
|
100
|
+
declare function decodeX402PaymentHeader(encodedHeader: string): X402PaymentProofPayload;
|
|
101
|
+
/**
|
|
102
|
+
* Wraps Web `fetch` with deterministic `x402` (`HTTP 402 Payment Required`) AI Agent Treasury governance:
|
|
103
|
+
* - Constructs ONLY canonical `native-transfer` or `erc20-transfer` Type-2 EIP-1559 transactions.
|
|
104
|
+
* - Auto-signs in `L0` within `PersonalVaultPolicy` + optional client-side ceilings, attaches base64url
|
|
105
|
+
* `X-Payment`, and retries at most once (`MAX_X402_RETRIES = 1`, failing closed on a second `402`).
|
|
106
|
+
* - Escalates `L1`..`L3` requirements through `onEscalationRequired` to collect a `PolicyProofBundle`
|
|
107
|
+
* before co-signing; fails closed with `PERSONAL_POLICY_VIOLATION` if unconfigured or denied.
|
|
108
|
+
*/
|
|
109
|
+
declare function createX402AgentPaymentFetch(options: X402AgentPaymentFetchOptions): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { MAX_X402_ACCEPTS_ENTRIES, MAX_X402_CHALLENGE_BYTES, MAX_X402_RETRIES, ParsedX402PaymentChallenge, PolicyProofBundle, X402AgentPaymentFetchOptions, X402EscalationContext, X402EscalationKind, X402HeaderMap, X402PaymentProofPayload, X402PaymentRequirement, X402SyncResponseSnapshot, X402TxExecutionParams, X402_EXACT_EVM_TX_SCHEME, X402_PROTOCOL_VERSION, createX402AgentPaymentFetch, decodeX402PaymentHeader, encodeX402PaymentHeader, parseX402PaymentChallenge };
|