@agirails/sdk 2.0.4 → 2.2.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/README.md +536 -87
- package/dist/adapters/BasicAdapter.d.ts.map +1 -1
- package/dist/adapters/BasicAdapter.js +8 -0
- package/dist/adapters/BasicAdapter.js.map +1 -1
- package/dist/adapters/StandardAdapter.d.ts +10 -5
- package/dist/adapters/StandardAdapter.d.ts.map +1 -1
- package/dist/adapters/StandardAdapter.js +19 -6
- package/dist/adapters/StandardAdapter.js.map +1 -1
- package/dist/config/networks.d.ts +9 -0
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +25 -10
- package/dist/config/networks.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/dist/level0/provide.d.ts.map +1 -1
- package/dist/level0/provide.js +2 -1
- package/dist/level0/provide.js.map +1 -1
- package/dist/level1/Agent.d.ts.map +1 -1
- package/dist/level1/Agent.js +11 -3
- package/dist/level1/Agent.js.map +1 -1
- package/dist/protocol/ACTPKernel.d.ts.map +1 -1
- package/dist/protocol/ACTPKernel.js +7 -5
- package/dist/protocol/ACTPKernel.js.map +1 -1
- package/dist/protocol/DIDResolver.js +1 -1
- package/dist/protocol/DIDResolver.js.map +1 -1
- package/dist/protocol/EASHelper.d.ts.map +1 -1
- package/dist/protocol/EASHelper.js +2 -3
- package/dist/protocol/EASHelper.js.map +1 -1
- package/dist/protocol/MessageSigner.d.ts.map +1 -1
- package/dist/protocol/MessageSigner.js +8 -8
- package/dist/protocol/MessageSigner.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts +7 -0
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +38 -22
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/runtime/IACTPRuntime.d.ts +15 -0
- package/dist/runtime/IACTPRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.d.ts +7 -0
- package/dist/runtime/MockRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.js +15 -4
- package/dist/runtime/MockRuntime.js.map +1 -1
- package/dist/runtime/types/MockState.d.ts +5 -2
- package/dist/runtime/types/MockState.d.ts.map +1 -1
- package/dist/runtime/types/MockState.js.map +1 -1
- package/dist/storage/ArchiveBundleBuilder.d.ts +150 -0
- package/dist/storage/ArchiveBundleBuilder.d.ts.map +1 -0
- package/dist/storage/ArchiveBundleBuilder.js +468 -0
- package/dist/storage/ArchiveBundleBuilder.js.map +1 -0
- package/dist/storage/ArweaveClient.d.ts +271 -0
- package/dist/storage/ArweaveClient.d.ts.map +1 -0
- package/dist/storage/ArweaveClient.js +761 -0
- package/dist/storage/ArweaveClient.js.map +1 -0
- package/dist/storage/FilebaseClient.d.ts +193 -0
- package/dist/storage/FilebaseClient.d.ts.map +1 -0
- package/dist/storage/FilebaseClient.js +643 -0
- package/dist/storage/FilebaseClient.js.map +1 -0
- package/dist/storage/index.d.ts +47 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +64 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/types.d.ts +291 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +18 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/types/state.d.ts +5 -4
- package/dist/types/state.d.ts.map +1 -1
- package/dist/types/state.js +10 -9
- package/dist/types/state.js.map +1 -1
- package/dist/utils/IPFSClient.d.ts.map +1 -1
- package/dist/utils/IPFSClient.js +5 -2
- package/dist/utils/IPFSClient.js.map +1 -1
- package/dist/utils/NonceManager.d.ts.map +1 -1
- package/dist/utils/NonceManager.js +3 -2
- package/dist/utils/NonceManager.js.map +1 -1
- package/dist/utils/UsedAttestationTracker.d.ts.map +1 -1
- package/dist/utils/UsedAttestationTracker.js +3 -3
- package/dist/utils/UsedAttestationTracker.js.map +1 -1
- package/dist/utils/circuitBreaker.d.ts +136 -0
- package/dist/utils/circuitBreaker.d.ts.map +1 -0
- package/dist/utils/circuitBreaker.js +253 -0
- package/dist/utils/circuitBreaker.js.map +1 -0
- package/dist/utils/retry.d.ts +120 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +260 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/validation.d.ts +100 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +248 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +14 -2
- package/src/adapters/BasicAdapter.ts +11 -0
- package/src/adapters/StandardAdapter.ts +26 -6
- package/src/config/networks.ts +34 -10
- package/src/index.ts +54 -0
- package/src/level0/provide.ts +2 -1
- package/src/level1/Agent.ts +13 -3
- package/src/protocol/ACTPKernel.ts +7 -5
- package/src/protocol/DIDResolver.ts +1 -1
- package/src/protocol/EASHelper.ts +2 -5
- package/src/protocol/MessageSigner.ts +8 -14
- package/src/runtime/BlockchainRuntime.ts +39 -45
- package/src/runtime/IACTPRuntime.ts +16 -0
- package/src/runtime/MockRuntime.ts +16 -4
- package/src/runtime/types/MockState.ts +5 -2
- package/src/storage/ArchiveBundleBuilder.ts +563 -0
- package/src/storage/ArweaveClient.ts +945 -0
- package/src/storage/FilebaseClient.ts +790 -0
- package/src/storage/index.ts +96 -0
- package/src/storage/types.ts +348 -0
- package/src/types/state.ts +10 -9
- package/src/utils/IPFSClient.ts +5 -4
- package/src/utils/NonceManager.ts +3 -2
- package/src/utils/UsedAttestationTracker.ts +3 -5
- package/src/utils/circuitBreaker.ts +324 -0
- package/src/utils/fsSafe.ts +5 -0
- package/src/utils/retry.ts +365 -0
- package/src/utils/validation.ts +295 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA+C;AAC/C,
|
|
1
|
+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AAQ,EAAE,CAAC;QACrC,OAAO,GAAG,KAAK,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,qBAAqB;IACrB,MAAM,iBAAiB,GAAG;QACxB,qBAAqB;QACrB,oBAAoB;QACpB,qBAAqB;QACrB,mBAAmB;QACnB,6BAA6B;QAC7B,qBAAqB;QACrB,gBAAgB;QAChB,4BAA4B;QAC5B,6BAA6B;QAC7B,8CAA8C;QAC9C,6BAA6B;QAC7B,oBAAoB;QACpB,kBAAkB;QAClB,sBAAsB;QACtB,wBAAwB;QACxB,0CAA0C;KAC3C,CAAC;IAEF,IAAI,SAAS,GAAG,OAAO,CAAC;IACxB,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAtCD,oDAsCC;AAED;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,KAAc,EACd,SAAiB;IAEjB,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAErD,yEAAyE;IACzE,OAAO;QACL,OAAO,EAAE,qBAAqB,SAAS,KAAK,gBAAgB,EAAE;QAC9D,IAAI,EAAG,KAAa,EAAE,IAAI,IAAI,eAAe;QAC7C,SAAS;KACV,CAAC;AACJ,CAAC;AAZD,0CAYC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agirails/sdk",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "AGIRAILS SDK for the ACTP (Agent Commerce Transaction Protocol) - Unified mock + blockchain support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./storage": {
|
|
13
|
+
"types": "./dist/storage/index.d.ts",
|
|
14
|
+
"default": "./dist/storage/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
7
17
|
"bin": {
|
|
8
18
|
"actp": "./bin/actp"
|
|
9
19
|
},
|
|
@@ -31,7 +41,9 @@
|
|
|
31
41
|
"test:cancel": "ts-node test-scripts/03-cancel.ts",
|
|
32
42
|
"test:happy-path-eas": "ts-node test-scripts/04-happy-path-eas.ts",
|
|
33
43
|
"test:status": "ts-node test-scripts/status.ts",
|
|
34
|
-
"test:all": "npm run test:setup && npm run test:happy-path && npm run test:dispute && npm run test:cancel"
|
|
44
|
+
"test:all": "npm run test:setup && npm run test:happy-path && npm run test:dispute && npm run test:cancel",
|
|
45
|
+
"eas:register": "ts-node scripts/register-eas-schema.ts",
|
|
46
|
+
"eas:register:mainnet": "ts-node scripts/register-eas-schema.ts base-mainnet"
|
|
35
47
|
},
|
|
36
48
|
"keywords": [
|
|
37
49
|
"agirails",
|
|
@@ -155,6 +155,17 @@ export class BasicAdapter extends BaseAdapter {
|
|
|
155
155
|
throw new ValidationError('Deadline must be in the future');
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
// SECURITY: Enforce transaction amount limit on unaudited mainnet contracts
|
|
159
|
+
const maxAmount = this.runtime.maxTransactionAmount;
|
|
160
|
+
const amountInUsdc = Number(amount) / 1_000_000; // Convert from wei to USDC
|
|
161
|
+
if (maxAmount !== undefined && amountInUsdc > maxAmount) {
|
|
162
|
+
throw new ValidationError(
|
|
163
|
+
`Transaction amount $${amountInUsdc.toFixed(2)} exceeds maximum allowed $${maxAmount}. ` +
|
|
164
|
+
`This limit exists because contracts have not been formally audited. ` +
|
|
165
|
+
`For larger amounts, please contact support@agirails.io.`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
158
169
|
// Create transaction
|
|
159
170
|
const txId = await this.runtime.createTransaction({
|
|
160
171
|
provider,
|
|
@@ -125,6 +125,17 @@ export class StandardAdapter extends BaseAdapter {
|
|
|
125
125
|
throw new ValidationError('Deadline must be in the future');
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// SECURITY: Enforce transaction amount limit on unaudited mainnet contracts
|
|
129
|
+
const maxAmount = this.runtime.maxTransactionAmount;
|
|
130
|
+
const amountInUsdc = Number(amount) / 1_000_000; // Convert from wei to USDC
|
|
131
|
+
if (maxAmount !== undefined && amountInUsdc > maxAmount) {
|
|
132
|
+
throw new ValidationError(
|
|
133
|
+
`Transaction amount $${amountInUsdc.toFixed(2)} exceeds maximum allowed $${maxAmount}. ` +
|
|
134
|
+
`This limit exists because contracts have not been formally audited. ` +
|
|
135
|
+
`For larger amounts, please contact support@agirails.io.`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
128
139
|
return this.runtime.createTransaction({
|
|
129
140
|
provider,
|
|
130
141
|
requester,
|
|
@@ -169,23 +180,32 @@ export class StandardAdapter extends BaseAdapter {
|
|
|
169
180
|
* Valid transitions:
|
|
170
181
|
* - INITIATED → QUOTED, COMMITTED, CANCELLED
|
|
171
182
|
* - QUOTED → COMMITTED, CANCELLED
|
|
172
|
-
* - COMMITTED → IN_PROGRESS,
|
|
183
|
+
* - COMMITTED → IN_PROGRESS, CANCELLED
|
|
173
184
|
* - IN_PROGRESS → DELIVERED, CANCELLED
|
|
174
185
|
* - DELIVERED → SETTLED, DISPUTED
|
|
175
|
-
* - DISPUTED → SETTLED
|
|
186
|
+
* - DISPUTED → SETTLED, CANCELLED (admin/pauser)
|
|
176
187
|
*
|
|
177
188
|
* @param txId - Transaction ID
|
|
178
189
|
* @param newState - Target state
|
|
190
|
+
* @param proof - Optional proof data (required for DELIVERED transition with dispute window)
|
|
179
191
|
* @throws {Error} If transition is invalid
|
|
180
192
|
*
|
|
181
193
|
* @example
|
|
182
194
|
* ```typescript
|
|
183
|
-
* // Provider
|
|
184
|
-
* await adapter.transitionState(txId, '
|
|
195
|
+
* // Provider starts work
|
|
196
|
+
* await adapter.transitionState(txId, 'IN_PROGRESS');
|
|
197
|
+
*
|
|
198
|
+
* // Provider marks work as delivered (with dispute window proof)
|
|
199
|
+
* const disputeWindowProof = ethers.AbiCoder.defaultAbiCoder().encode(['uint256'], [7200]);
|
|
200
|
+
* await adapter.transitionState(txId, 'DELIVERED', disputeWindowProof);
|
|
185
201
|
* ```
|
|
186
202
|
*/
|
|
187
|
-
async transitionState(
|
|
188
|
-
|
|
203
|
+
async transitionState(
|
|
204
|
+
txId: string,
|
|
205
|
+
newState: TransactionState,
|
|
206
|
+
proof?: string
|
|
207
|
+
): Promise<void> {
|
|
208
|
+
return this.runtime.transitionState(txId, newState, proof);
|
|
189
209
|
}
|
|
190
210
|
|
|
191
211
|
/**
|
package/src/config/networks.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface NetworkConfig {
|
|
|
30
30
|
eas: string; // EAS contract address
|
|
31
31
|
easSchemaRegistry: string; // EAS SchemaRegistry contract
|
|
32
32
|
agentRegistry?: string; // AIP-7 Agent Registry (optional until deployed)
|
|
33
|
+
identityRegistry?: string; // AIP-7 ERC-1056 DID Registry (optional until deployed)
|
|
34
|
+
archiveTreasury?: string; // AIP-7 Archive Treasury for Arweave funding (optional until deployed)
|
|
33
35
|
};
|
|
34
36
|
eas: {
|
|
35
37
|
deliverySchemaUID: string; // AIP-4 delivery proof schema
|
|
@@ -38,6 +40,13 @@ export interface NetworkConfig {
|
|
|
38
40
|
maxFeePerGas: bigint;
|
|
39
41
|
maxPriorityFeePerGas: bigint;
|
|
40
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Maximum transaction amount in USDC (human-readable, e.g., 100 = $100)
|
|
45
|
+
*
|
|
46
|
+
* SECURITY: Limits exposure on unaudited mainnet contracts.
|
|
47
|
+
* Set to undefined for no limit (testnet only).
|
|
48
|
+
*/
|
|
49
|
+
maxTransactionAmount?: number;
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
/**
|
|
@@ -49,7 +58,7 @@ export const BASE_SEPOLIA: NetworkConfig = {
|
|
|
49
58
|
rpcUrl: BASE_SEPOLIA_RPC_URL,
|
|
50
59
|
blockExplorer: 'https://sepolia.basescan.org',
|
|
51
60
|
contracts: {
|
|
52
|
-
// Redeployed 2025-12-10
|
|
61
|
+
// Redeployed 2025-12-10
|
|
53
62
|
actpKernel: '0xD199070F8e9FB9a127F6Fe730Bc13300B4b3d962',
|
|
54
63
|
escrowVault: '0x948b9Ea081C4Cec1E112Af2e539224c531d4d585',
|
|
55
64
|
usdc: '0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb', // MockUSDC
|
|
@@ -57,7 +66,11 @@ export const BASE_SEPOLIA: NetworkConfig = {
|
|
|
57
66
|
eas: '0x4200000000000000000000000000000000000021',
|
|
58
67
|
easSchemaRegistry: '0x4200000000000000000000000000000000000020',
|
|
59
68
|
// AIP-7 Agent Registry (deployed 2025-12-11)
|
|
60
|
-
agentRegistry: '0xFed6914Aa70c0a53E9c7Cc4d2Ae159e4748fb09D'
|
|
69
|
+
agentRegistry: '0xFed6914Aa70c0a53E9c7Cc4d2Ae159e4748fb09D',
|
|
70
|
+
// AIP-7 Identity Registry - ERC-1056 DID Registry (deployed 2026-01-09)
|
|
71
|
+
identityRegistry: '0xF64F748C7802a68Cb936a9213881fE74e83FDA97',
|
|
72
|
+
// AIP-7 Archive Treasury - Arweave funding (deployed 2026-01-09)
|
|
73
|
+
archiveTreasury: '0xeB75DE7cF5ce77ab15BB0fFa3a2A79e6aaa554B0'
|
|
61
74
|
},
|
|
62
75
|
eas: {
|
|
63
76
|
// Deployed 2025-11-23 - AIP-4 delivery proof schema
|
|
@@ -82,22 +95,31 @@ export const BASE_MAINNET: NetworkConfig = {
|
|
|
82
95
|
rpcUrl: BASE_MAINNET_RPC_URL,
|
|
83
96
|
blockExplorer: 'https://basescan.org',
|
|
84
97
|
contracts: {
|
|
85
|
-
//
|
|
86
|
-
actpKernel: '
|
|
87
|
-
escrowVault: '
|
|
98
|
+
// Deployed 2026-02-03
|
|
99
|
+
actpKernel: '0xeaE4D6925510284dbC45C8C64bb8104a079D4c60',
|
|
100
|
+
escrowVault: '0xb7bCadF7F26f0761995d95105DFb2346F81AF02D',
|
|
88
101
|
usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // Official USDC on Base
|
|
89
102
|
// EAS contracts (Base native deployment)
|
|
90
103
|
eas: '0x4200000000000000000000000000000000000021',
|
|
91
|
-
easSchemaRegistry: '0x4200000000000000000000000000000000000020'
|
|
104
|
+
easSchemaRegistry: '0x4200000000000000000000000000000000000020',
|
|
105
|
+
// AIP-7 contracts
|
|
106
|
+
agentRegistry: '0xbf9Aa0FC291A06A4dFA943c3E0Ad41E7aE20DF02',
|
|
107
|
+
archiveTreasury: '0x64B8f93fef2D2E749F5E88586753343F73246012'
|
|
92
108
|
},
|
|
93
109
|
eas: {
|
|
94
|
-
//
|
|
95
|
-
deliverySchemaUID: '
|
|
110
|
+
// Registered 2026-02-03
|
|
111
|
+
deliverySchemaUID: '0x166501e7476e2fcf9214c4c5144533c2957d56fe59d639effc1719a0658d9c9a'
|
|
96
112
|
},
|
|
97
113
|
gasSettings: {
|
|
98
114
|
maxFeePerGas: ethers.parseUnits('0.5', 'gwei'),
|
|
99
115
|
maxPriorityFeePerGas: ethers.parseUnits('0.1', 'gwei')
|
|
100
|
-
}
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* SECURITY: $1,000 max transaction limit until contracts are audited.
|
|
119
|
+
* This limits exposure in case of undiscovered vulnerabilities.
|
|
120
|
+
* Will be removed/increased after formal security audit.
|
|
121
|
+
*/
|
|
122
|
+
maxTransactionAmount: 1000
|
|
101
123
|
};
|
|
102
124
|
|
|
103
125
|
/**
|
|
@@ -134,7 +156,9 @@ export function getNetwork(network: string): NetworkConfig {
|
|
|
134
156
|
usdc: config.contracts.usdc,
|
|
135
157
|
eas: config.contracts.eas,
|
|
136
158
|
easSchemaRegistry: config.contracts.easSchemaRegistry,
|
|
137
|
-
agentRegistry: config.contracts.agentRegistry
|
|
159
|
+
agentRegistry: config.contracts.agentRegistry,
|
|
160
|
+
identityRegistry: config.contracts.identityRegistry,
|
|
161
|
+
archiveTreasury: config.contracts.archiveTreasury
|
|
138
162
|
},
|
|
139
163
|
eas: {
|
|
140
164
|
deliverySchemaUID: config.eas.deliverySchemaUID
|
package/src/index.ts
CHANGED
|
@@ -217,6 +217,46 @@ export type {
|
|
|
217
217
|
PriceCalculation,
|
|
218
218
|
} from './level1';
|
|
219
219
|
|
|
220
|
+
// =============================================================================
|
|
221
|
+
// Storage Layer (AIP-7 §4) - Hybrid IPFS + Arweave
|
|
222
|
+
// =============================================================================
|
|
223
|
+
|
|
224
|
+
// Storage clients
|
|
225
|
+
export { FilebaseClient } from './storage/FilebaseClient';
|
|
226
|
+
export { ArweaveClient } from './storage/ArweaveClient';
|
|
227
|
+
|
|
228
|
+
// Archive bundle builder
|
|
229
|
+
export {
|
|
230
|
+
ArchiveBundleBuilder,
|
|
231
|
+
computeContentHash,
|
|
232
|
+
validateArchiveBundle,
|
|
233
|
+
} from './storage/ArchiveBundleBuilder';
|
|
234
|
+
|
|
235
|
+
// Storage types
|
|
236
|
+
export type {
|
|
237
|
+
FilebaseConfig,
|
|
238
|
+
ArweaveConfig,
|
|
239
|
+
IrysCurrency,
|
|
240
|
+
IrysNetwork,
|
|
241
|
+
ArchiveBundle,
|
|
242
|
+
ArchiveChainId,
|
|
243
|
+
ArchiveFinalState,
|
|
244
|
+
ArchiveParticipants,
|
|
245
|
+
ArchiveReferences,
|
|
246
|
+
ArchiveHashes,
|
|
247
|
+
ArchiveSignatures,
|
|
248
|
+
ArchiveAttestation,
|
|
249
|
+
ArchiveSettlement,
|
|
250
|
+
EscrowRelease,
|
|
251
|
+
ArchiveTags,
|
|
252
|
+
IPFSUploadResult,
|
|
253
|
+
ArweaveUploadResult,
|
|
254
|
+
DownloadResult,
|
|
255
|
+
} from './storage/types';
|
|
256
|
+
|
|
257
|
+
// Storage constants
|
|
258
|
+
export { ARCHIVE_BUNDLE_TYPE } from './storage/types';
|
|
259
|
+
|
|
220
260
|
// =============================================================================
|
|
221
261
|
// Enhanced Error Exports
|
|
222
262
|
// =============================================================================
|
|
@@ -241,4 +281,18 @@ export {
|
|
|
241
281
|
DisputeRaisedError,
|
|
242
282
|
ServiceConfigError,
|
|
243
283
|
AgentLifecycleError,
|
|
284
|
+
// Storage errors (AIP-7)
|
|
285
|
+
StorageError,
|
|
286
|
+
StorageAuthenticationError,
|
|
287
|
+
StorageRateLimitError,
|
|
288
|
+
UploadTimeoutError,
|
|
289
|
+
DownloadTimeoutError,
|
|
290
|
+
ContentNotFoundError,
|
|
291
|
+
FileSizeLimitExceededError,
|
|
292
|
+
InvalidCIDError,
|
|
293
|
+
ArweaveUploadError,
|
|
294
|
+
ArweaveDownloadError,
|
|
295
|
+
ArweaveTimeoutError,
|
|
296
|
+
InvalidArweaveTxIdError,
|
|
297
|
+
InsufficientBalanceError as StorageInsufficientBalanceError,
|
|
244
298
|
} from './errors';
|
package/src/level0/provide.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { JobHandler } from '../level1/types/Job';
|
|
|
12
12
|
import { ProvideOptions } from '../level1/types/Options';
|
|
13
13
|
import { Provider } from './Provider';
|
|
14
14
|
import { serviceDirectory } from './ServiceDirectory';
|
|
15
|
+
import { sdkLogger } from '../utils/Logger';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Provide a service
|
|
@@ -83,7 +84,7 @@ export function provide(
|
|
|
83
84
|
// Register in service directory after agent has started and has an address
|
|
84
85
|
serviceDirectory.register(service, agent.address);
|
|
85
86
|
}).catch((error) => {
|
|
86
|
-
|
|
87
|
+
sdkLogger.error(`Failed to start provider for ${service}`, { error: error instanceof Error ? error.message : String(error) });
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
// Return Provider interface (adapter over Agent)
|
package/src/level1/Agent.ts
CHANGED
|
@@ -1232,7 +1232,7 @@ export class Agent extends EventEmitter {
|
|
|
1232
1232
|
result, // Include original result for convenience
|
|
1233
1233
|
});
|
|
1234
1234
|
|
|
1235
|
-
// Transition transaction
|
|
1235
|
+
// Transition transaction through IN_PROGRESS → DELIVERED states
|
|
1236
1236
|
if (this._client) {
|
|
1237
1237
|
// Store delivery proof by directly accessing MockRuntime's state
|
|
1238
1238
|
// This is a workaround - in production, we'd use a proper method
|
|
@@ -1246,8 +1246,18 @@ export class Agent extends EventEmitter {
|
|
|
1246
1246
|
});
|
|
1247
1247
|
}
|
|
1248
1248
|
|
|
1249
|
-
//
|
|
1250
|
-
|
|
1249
|
+
// AUDIT FIX (2026-02): Must transition through IN_PROGRESS before DELIVERED
|
|
1250
|
+
// Contract rejects COMMITTED → DELIVERED direct transition
|
|
1251
|
+
await this._client.runtime.transitionState(job.id, 'IN_PROGRESS');
|
|
1252
|
+
|
|
1253
|
+
// Encode dispute window proof for DELIVERED transition
|
|
1254
|
+
// Use transaction's disputeWindow from metadata, fallback to 2 days (172800s) per Options.ts default
|
|
1255
|
+
const disputeWindowSeconds = job.metadata?.disputeWindow || 172800;
|
|
1256
|
+
const abiCoder = ethers.AbiCoder.defaultAbiCoder();
|
|
1257
|
+
const disputeWindowProof = abiCoder.encode(['uint256'], [disputeWindowSeconds]);
|
|
1258
|
+
|
|
1259
|
+
// Transition to DELIVERED with dispute window proof
|
|
1260
|
+
await this._client.runtime.transitionState(job.id, 'DELIVERED', disputeWindowProof);
|
|
1251
1261
|
}
|
|
1252
1262
|
|
|
1253
1263
|
// SECURITY FIX (C-2): Remove from active jobs on SUCCESS
|
|
@@ -681,16 +681,18 @@ export class ACTPKernel {
|
|
|
681
681
|
validateAddress(mediator, 'mediator');
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
// Encode resolution proof (128 bytes:
|
|
685
|
-
//
|
|
684
|
+
// Encode resolution proof (128 bytes: 2x uint256 + address + uint256)
|
|
685
|
+
// AUDIT FIX (2026-02): Contract expects: (uint256, uint256, address, uint256)
|
|
686
|
+
// = [requesterAmount, providerAmount, mediator, mediatorAmount]
|
|
687
|
+
// See ACTPKernel.sol _decodeResolutionProof() line 654-655
|
|
686
688
|
const abiCoder = AbiCoder.defaultAbiCoder();
|
|
687
689
|
const proofData = abiCoder.encode(
|
|
688
|
-
['uint256', 'uint256', '
|
|
690
|
+
['uint256', 'uint256', 'address', 'uint256'],
|
|
689
691
|
[
|
|
690
692
|
requesterAmount,
|
|
691
693
|
providerAmount,
|
|
692
|
-
|
|
693
|
-
|
|
694
|
+
mediator || ethers.getAddress('0x0000000000000000000000000000000000000000'),
|
|
695
|
+
mediatorAmount
|
|
694
696
|
]
|
|
695
697
|
);
|
|
696
698
|
|
|
@@ -115,7 +115,7 @@ export class DIDResolver {
|
|
|
115
115
|
network: config.network,
|
|
116
116
|
chainId: config.chainId || networkConfig.chainId,
|
|
117
117
|
rpcUrl: config.rpcUrl || networkConfig.rpcUrl,
|
|
118
|
-
registryAddress: config.registryAddress || networkConfig.contracts.
|
|
118
|
+
registryAddress: config.registryAddress || networkConfig.contracts.identityRegistry || ''
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
IUsedAttestationTracker,
|
|
7
7
|
InMemoryUsedAttestationTracker
|
|
8
8
|
} from '../utils/UsedAttestationTracker';
|
|
9
|
+
import { sdkLogger } from '../utils/Logger';
|
|
9
10
|
|
|
10
11
|
export interface EASConfig {
|
|
11
12
|
contractAddress: string;
|
|
@@ -65,11 +66,7 @@ export class EASHelper {
|
|
|
65
66
|
//
|
|
66
67
|
// Without persistence, attestation replay protection is lost on process restart,
|
|
67
68
|
// allowing potential double-spend attacks.
|
|
68
|
-
|
|
69
|
-
'[SECURITY WARNING] EASHelper: Using in-memory attestation tracker. ' +
|
|
70
|
-
'Replay protection will be lost on process restart. ' +
|
|
71
|
-
'For production, provide FileBasedUsedAttestationTracker for persistence.'
|
|
72
|
-
);
|
|
69
|
+
sdkLogger.warn('Using in-memory attestation tracker - replay protection lost on restart (use FileBasedUsedAttestationTracker for production)');
|
|
73
70
|
}
|
|
74
71
|
this.attestationTracker = attestationTracker || new InMemoryUsedAttestationTracker();
|
|
75
72
|
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
deliveryProofDataFromProof
|
|
11
11
|
} from '../types/eip712';
|
|
12
12
|
import { IReceivedNonceTracker } from '../utils/ReceivedNonceTracker';
|
|
13
|
+
import { sdkLogger } from '../utils/Logger';
|
|
13
14
|
|
|
14
15
|
// Legacy generic ACTP message types moved to types/eip712.ts
|
|
15
16
|
|
|
@@ -175,22 +176,14 @@ export class MessageSigner {
|
|
|
175
176
|
const nonceValue = BigInt(nonce);
|
|
176
177
|
if (nonceValue < 0xFFFFFFFFn) {
|
|
177
178
|
// Nonce is suspiciously small (< 4 billion = likely sequential)
|
|
178
|
-
|
|
179
|
-
`[SECURITY WARNING] Nonce ${nonce} appears to be sequential (value < 2^32). ` +
|
|
180
|
-
`This makes replay attacks easier. ` +
|
|
181
|
-
`Use SecureNonce.generateSecureNonce() for cryptographically secure random nonces.`
|
|
182
|
-
);
|
|
179
|
+
sdkLogger.warn('Nonce appears sequential - use SecureNonce.generateSecureNonce()', { nonce });
|
|
183
180
|
}
|
|
184
181
|
|
|
185
182
|
// Check if nonce has all same digits (e.g., 0x111...111 or 0x000...000)
|
|
186
183
|
const hexDigits = nonce.slice(2); // Remove '0x'
|
|
187
184
|
const firstDigit = hexDigits[0];
|
|
188
185
|
if (hexDigits.split('').every(d => d === firstDigit)) {
|
|
189
|
-
|
|
190
|
-
`[SECURITY WARNING] Nonce ${nonce} has low entropy (all digits are '${firstDigit}'). ` +
|
|
191
|
-
`This is NOT cryptographically secure. ` +
|
|
192
|
-
`Use SecureNonce.generateSecureNonce() instead.`
|
|
193
|
-
);
|
|
186
|
+
sdkLogger.warn('Nonce has low entropy - use SecureNonce.generateSecureNonce()', { nonce, repeatedDigit: firstDigit });
|
|
194
187
|
}
|
|
195
188
|
|
|
196
189
|
// Generic ACTPMessage with payload encoding (backward compatible)
|
|
@@ -463,10 +456,11 @@ export class MessageSigner {
|
|
|
463
456
|
// This prevents cross-chain replay attacks where a message signed for one chain
|
|
464
457
|
// is replayed on another. For now, we just extract the address but log a warning.
|
|
465
458
|
if (this.domain && this.domain.chainId !== chainId) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
459
|
+
sdkLogger.warn('DID chainId mismatch - potential cross-chain replay attempt', {
|
|
460
|
+
didChainId: chainId,
|
|
461
|
+
domainChainId: this.domain.chainId,
|
|
462
|
+
did,
|
|
463
|
+
});
|
|
470
464
|
}
|
|
471
465
|
|
|
472
466
|
return address;
|
|
@@ -28,6 +28,7 @@ import { ValidationError } from '../errors';
|
|
|
28
28
|
import { ServiceHash, DisputeWindow } from '../utils/Helpers';
|
|
29
29
|
import { IUsedAttestationTracker, createUsedAttestationTracker } from '../utils/UsedAttestationTracker';
|
|
30
30
|
import { IReceivedNonceTracker, createReceivedNonceTracker } from '../utils/ReceivedNonceTracker';
|
|
31
|
+
import { sdkLogger } from '../utils/Logger';
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Configuration for BlockchainRuntime
|
|
@@ -217,20 +218,17 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
217
218
|
);
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
`BlockchainRuntime: Connected to ${this.networkConfig.name} (chainId: ${connectedChainId})`
|
|
222
|
-
);
|
|
221
|
+
sdkLogger.info(`Connected to ${this.networkConfig.name}`, { chainId: connectedChainId });
|
|
223
222
|
} catch (error) {
|
|
224
223
|
if (error instanceof Error && error.message.includes('Network mismatch')) {
|
|
225
224
|
throw error; // Re-throw our validation error
|
|
226
225
|
}
|
|
227
226
|
// For other errors (e.g., network issues), log warning but continue
|
|
228
227
|
// This allows initialization to proceed even if network check fails temporarily
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
);
|
|
228
|
+
sdkLogger.warn('Could not verify network chainId, proceeding with expected value', {
|
|
229
|
+
error: error instanceof Error ? error.message : String(error),
|
|
230
|
+
expectedChainId: this.networkConfig.chainId,
|
|
231
|
+
});
|
|
234
232
|
}
|
|
235
233
|
|
|
236
234
|
// SECURITY FIX (H-4): Use factory pattern to guarantee domain initialization
|
|
@@ -254,10 +252,7 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
254
252
|
this.attestationTracker
|
|
255
253
|
);
|
|
256
254
|
} else if (this.requireAttestation) {
|
|
257
|
-
|
|
258
|
-
'[SECURITY WARNING] BlockchainRuntime: requireAttestation is true but no EAS config provided. ' +
|
|
259
|
-
'Attestation verification will fail. Please provide easConfig in BlockchainRuntimeConfig.'
|
|
260
|
-
);
|
|
255
|
+
sdkLogger.warn('requireAttestation is true but no EAS config provided - attestation verification will fail');
|
|
261
256
|
}
|
|
262
257
|
}
|
|
263
258
|
|
|
@@ -319,11 +314,12 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
319
314
|
this.reconnectAttempts = attempt + 1;
|
|
320
315
|
const delay = this.baseReconnectDelay * Math.pow(2, attempt);
|
|
321
316
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
317
|
+
sdkLogger.warn('Provider connection lost, attempting reconnection', {
|
|
318
|
+
attempt: attempt + 1,
|
|
319
|
+
maxAttempts: this.maxReconnectAttempts,
|
|
320
|
+
delayMs: delay,
|
|
321
|
+
error: error instanceof Error ? error.message : String(error),
|
|
322
|
+
});
|
|
327
323
|
|
|
328
324
|
// Wait before next attempt
|
|
329
325
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
@@ -543,7 +539,11 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
543
539
|
escrowId: tx.escrowId,
|
|
544
540
|
createdAt: Number(tx.createdAt),
|
|
545
541
|
updatedAt: Number(tx.updatedAt),
|
|
546
|
-
|
|
542
|
+
// LIMITATION (V2): completedAt requires event indexing to fetch DELIVERED event timestamp.
|
|
543
|
+
// Currently 0, which means SDK-side dispute window check in releaseEscrow() is bypassed.
|
|
544
|
+
// On-chain contract still enforces dispute window correctly via _validateSettlementConditions().
|
|
545
|
+
// V2 will implement EventMonitor to track this properly.
|
|
546
|
+
completedAt: 0,
|
|
547
547
|
serviceDescription: '', // V2: Decode from on-chain serviceHash
|
|
548
548
|
deliveryProof: '', // V2: Fetch from EAS attestation
|
|
549
549
|
events: [], // V2: Populate via EventMonitor.getTransactionEvents()
|
|
@@ -562,9 +562,7 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
562
562
|
async getAllTransactions(): Promise<MockTransaction[]> {
|
|
563
563
|
// V2: Implement event-based transaction indexing via EventMonitor
|
|
564
564
|
// For now, return empty array as this requires off-chain indexer
|
|
565
|
-
|
|
566
|
-
'getAllTransactions() not fully implemented for BlockchainRuntime. Use EventMonitor for event-based queries.'
|
|
567
|
-
);
|
|
565
|
+
sdkLogger.warn('getAllTransactions() not implemented - use EventMonitor for event-based queries');
|
|
568
566
|
return [];
|
|
569
567
|
}
|
|
570
568
|
|
|
@@ -604,10 +602,7 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
604
602
|
if (legacyMatch) {
|
|
605
603
|
// Legacy SDK format - extract txId
|
|
606
604
|
txId = legacyMatch[1];
|
|
607
|
-
|
|
608
|
-
`BlockchainRuntime.releaseEscrow: Using legacy escrowId format. ` +
|
|
609
|
-
`Please update to use txId directly as escrowId.`
|
|
610
|
-
);
|
|
605
|
+
sdkLogger.warn('Using legacy escrowId format - please update to use txId directly as escrowId');
|
|
611
606
|
} else {
|
|
612
607
|
// Standard: escrowId = txId
|
|
613
608
|
txId = escrowId;
|
|
@@ -658,9 +653,7 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
658
653
|
// Verify attestation is valid for this transaction
|
|
659
654
|
try {
|
|
660
655
|
await this.easHelper.verifyAndRecordForRelease(txId, attestationUID);
|
|
661
|
-
|
|
662
|
-
`BlockchainRuntime.releaseEscrow: Attestation ${attestationUID} verified for transaction ${txId}.`
|
|
663
|
-
);
|
|
656
|
+
sdkLogger.info('Attestation verified for release', { txId, attestationUID });
|
|
664
657
|
} catch (error) {
|
|
665
658
|
throw new Error(
|
|
666
659
|
`Cannot release escrow: attestation verification failed for transaction ${txId}. ` +
|
|
@@ -671,21 +664,16 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
671
664
|
// Even if not required, verify attestation if provided (best effort)
|
|
672
665
|
try {
|
|
673
666
|
await this.easHelper.verifyAndRecordForRelease(txId, attestationUID);
|
|
674
|
-
|
|
675
|
-
`BlockchainRuntime.releaseEscrow: Attestation ${attestationUID} verified (optional) for transaction ${txId}.`
|
|
676
|
-
);
|
|
667
|
+
sdkLogger.info('Attestation verified (optional)', { txId, attestationUID });
|
|
677
668
|
} catch (error) {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
);
|
|
669
|
+
sdkLogger.warn('Attestation verification failed but not required, proceeding', {
|
|
670
|
+
txId,
|
|
671
|
+
error: error instanceof Error ? error.message : String(error),
|
|
672
|
+
});
|
|
682
673
|
}
|
|
683
674
|
} else {
|
|
684
675
|
// No attestation verification
|
|
685
|
-
|
|
686
|
-
`BlockchainRuntime.releaseEscrow: Settling transaction ${txId}. ` +
|
|
687
|
-
`Note: Set requireAttestation=true and provide easConfig for additional security.`
|
|
688
|
-
);
|
|
676
|
+
sdkLogger.info('Settling transaction without attestation verification', { txId });
|
|
689
677
|
}
|
|
690
678
|
|
|
691
679
|
// SECURITY FIX (SETTLEMENT-FLOW): Use transitionState(SETTLED) instead of releaseEscrow()
|
|
@@ -731,7 +719,7 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
731
719
|
return '0';
|
|
732
720
|
} catch (error) {
|
|
733
721
|
// If query fails, return 0
|
|
734
|
-
|
|
722
|
+
sdkLogger.warn('getEscrowBalance query failed', { error: error instanceof Error ? error.message : String(error) });
|
|
735
723
|
return '0';
|
|
736
724
|
}
|
|
737
725
|
}
|
|
@@ -773,6 +761,16 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
773
761
|
return this.networkConfig;
|
|
774
762
|
}
|
|
775
763
|
|
|
764
|
+
/**
|
|
765
|
+
* Maximum transaction amount in USDC (human-readable).
|
|
766
|
+
*
|
|
767
|
+
* SECURITY: Limits exposure on unaudited mainnet contracts.
|
|
768
|
+
* Returns undefined if no limit (testnet).
|
|
769
|
+
*/
|
|
770
|
+
get maxTransactionAmount(): number | undefined {
|
|
771
|
+
return this.networkConfig.maxTransactionAmount;
|
|
772
|
+
}
|
|
773
|
+
|
|
776
774
|
/**
|
|
777
775
|
* Get ACTPKernel instance (for advanced usage)
|
|
778
776
|
*/
|
|
@@ -869,11 +867,7 @@ export class BlockchainRuntime implements IACTPRuntime {
|
|
|
869
867
|
|
|
870
868
|
// SECURITY FIX (CRITICAL): If it's a raw string (legacy format), hash it
|
|
871
869
|
// This ensures on-chain compatibility with the contract's bytes32 expectation
|
|
872
|
-
|
|
873
|
-
'BlockchainRuntime: serviceDescription is not a valid bytes32 hash. ' +
|
|
874
|
-
'Hashing it now. For best practice, use ServiceHash.hash() before calling createTransaction.'
|
|
875
|
-
);
|
|
876
|
-
|
|
870
|
+
sdkLogger.warn('serviceDescription is not a valid bytes32 hash - hashing now (use ServiceHash.hash() for best practice)');
|
|
877
871
|
return keccak256(toUtf8Bytes(serviceDescription));
|
|
878
872
|
}
|
|
879
873
|
|
|
@@ -199,6 +199,22 @@ export interface IACTPRuntime {
|
|
|
199
199
|
/** Get current timestamp in seconds */
|
|
200
200
|
now(): number;
|
|
201
201
|
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Maximum transaction amount in USDC (human-readable, e.g., 100 = $100).
|
|
205
|
+
*
|
|
206
|
+
* SECURITY: Limits exposure on unaudited contracts.
|
|
207
|
+
* Returns undefined if no limit is enforced (testnet/mock mode).
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const limit = runtime.maxTransactionAmount;
|
|
212
|
+
* if (limit && amount > limit) {
|
|
213
|
+
* throw new Error(`Amount exceeds limit of $${limit}`);
|
|
214
|
+
* }
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
maxTransactionAmount?: number;
|
|
202
218
|
}
|
|
203
219
|
|
|
204
220
|
/**
|