@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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiveBundleBuilder - Builder for Archive Bundles (AIP-7 §4.4)
|
|
3
|
+
*
|
|
4
|
+
* Provides a fluent builder pattern for constructing archive bundles
|
|
5
|
+
* that will be stored permanently on Arweave.
|
|
6
|
+
*
|
|
7
|
+
* Archive bundles contain minimal metadata with cryptographic hashes
|
|
8
|
+
* and references. Full content remains on IPFS.
|
|
9
|
+
*
|
|
10
|
+
* @module storage/ArchiveBundleBuilder
|
|
11
|
+
*/
|
|
12
|
+
import { ArchiveBundle, ArchiveChainId, ArchiveParticipants, ArchiveReferences, ArchiveHashes, ArchiveSignatures, ArchiveAttestation, ArchiveSettlement } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* ArchiveBundleBuilder - Fluent builder for archive bundles
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const bundle = new ArchiveBundleBuilder()
|
|
19
|
+
* .setTransactionId('0x1234...')
|
|
20
|
+
* .setChainId(8453)
|
|
21
|
+
* .setParticipants({
|
|
22
|
+
* requester: '0xRequester...',
|
|
23
|
+
* provider: '0xProvider...'
|
|
24
|
+
* })
|
|
25
|
+
* .setReferences({
|
|
26
|
+
* requestCID: 'bafybei...',
|
|
27
|
+
* deliveryCID: 'bafybei...'
|
|
28
|
+
* })
|
|
29
|
+
* .setHashes({
|
|
30
|
+
* requestHash: '0xabc...',
|
|
31
|
+
* deliveryHash: '0xdef...',
|
|
32
|
+
* serviceHash: '0x123...'
|
|
33
|
+
* })
|
|
34
|
+
* .setSignatures({
|
|
35
|
+
* providerDeliverySignature: '0xsig...'
|
|
36
|
+
* })
|
|
37
|
+
* .setAttestation({ easUID: '0xeas...' })
|
|
38
|
+
* .setSettlement({
|
|
39
|
+
* settledAt: Date.now() / 1000,
|
|
40
|
+
* finalState: 'SETTLED',
|
|
41
|
+
* escrowReleased: { to: '0xProvider...', amount: '100000000' },
|
|
42
|
+
* platformFee: '1000000',
|
|
43
|
+
* wasDisputed: false
|
|
44
|
+
* })
|
|
45
|
+
* .build();
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class ArchiveBundleBuilder {
|
|
49
|
+
private protocolVersion;
|
|
50
|
+
private archiveSchemaVersion;
|
|
51
|
+
private txId?;
|
|
52
|
+
private chainId?;
|
|
53
|
+
private archivedAt?;
|
|
54
|
+
private participants?;
|
|
55
|
+
private references?;
|
|
56
|
+
private hashes?;
|
|
57
|
+
private signatures?;
|
|
58
|
+
private attestation?;
|
|
59
|
+
private settlement?;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new ArchiveBundleBuilder
|
|
62
|
+
*/
|
|
63
|
+
constructor();
|
|
64
|
+
/**
|
|
65
|
+
* Set protocol version
|
|
66
|
+
* @default '1.0.0'
|
|
67
|
+
*/
|
|
68
|
+
setProtocolVersion(version: string): this;
|
|
69
|
+
/**
|
|
70
|
+
* Set archive schema version
|
|
71
|
+
* @default '1.0.0'
|
|
72
|
+
*/
|
|
73
|
+
setArchiveSchemaVersion(version: string): this;
|
|
74
|
+
/**
|
|
75
|
+
* Set ACTP transaction ID (bytes32)
|
|
76
|
+
*/
|
|
77
|
+
setTransactionId(txId: string): this;
|
|
78
|
+
/**
|
|
79
|
+
* Set blockchain chain ID
|
|
80
|
+
* @param chainId - 8453 (Base Mainnet) or 84532 (Base Sepolia)
|
|
81
|
+
*/
|
|
82
|
+
setChainId(chainId: ArchiveChainId): this;
|
|
83
|
+
/**
|
|
84
|
+
* Set archive timestamp
|
|
85
|
+
* @param timestamp - Unix timestamp in seconds (defaults to now)
|
|
86
|
+
*/
|
|
87
|
+
setArchivedAt(timestamp?: number): this;
|
|
88
|
+
/**
|
|
89
|
+
* Set transaction participants
|
|
90
|
+
*/
|
|
91
|
+
setParticipants(participants: ArchiveParticipants): this;
|
|
92
|
+
/**
|
|
93
|
+
* Set IPFS CID references
|
|
94
|
+
*/
|
|
95
|
+
setReferences(references: ArchiveReferences): this;
|
|
96
|
+
/**
|
|
97
|
+
* Set cryptographic hashes
|
|
98
|
+
*/
|
|
99
|
+
setHashes(hashes: ArchiveHashes): this;
|
|
100
|
+
/**
|
|
101
|
+
* Compute and set hashes from raw data
|
|
102
|
+
*
|
|
103
|
+
* @param request - Request metadata JSON
|
|
104
|
+
* @param delivery - Delivery proof JSON
|
|
105
|
+
* @param serviceHash - Service hash from transaction (already computed)
|
|
106
|
+
*/
|
|
107
|
+
setHashesFromData(request: unknown, delivery: unknown, serviceHash: string): this;
|
|
108
|
+
/**
|
|
109
|
+
* Set cryptographic signatures
|
|
110
|
+
*/
|
|
111
|
+
setSignatures(signatures: ArchiveSignatures): this;
|
|
112
|
+
/**
|
|
113
|
+
* Set EAS attestation reference
|
|
114
|
+
*/
|
|
115
|
+
setAttestation(attestation: ArchiveAttestation): this;
|
|
116
|
+
/**
|
|
117
|
+
* Set settlement information
|
|
118
|
+
*/
|
|
119
|
+
setSettlement(settlement: ArchiveSettlement): this;
|
|
120
|
+
/**
|
|
121
|
+
* Build the archive bundle
|
|
122
|
+
*
|
|
123
|
+
* @returns Complete archive bundle ready for Arweave upload
|
|
124
|
+
* @throws {ValidationError} If required fields are missing
|
|
125
|
+
*/
|
|
126
|
+
build(): ArchiveBundle;
|
|
127
|
+
/**
|
|
128
|
+
* Create builder from existing bundle (for modifications)
|
|
129
|
+
*/
|
|
130
|
+
static fromBundle(bundle: ArchiveBundle): ArchiveBundleBuilder;
|
|
131
|
+
/**
|
|
132
|
+
* Sort object keys recursively for canonical JSON
|
|
133
|
+
*/
|
|
134
|
+
private sortObjectKeys;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Compute keccak256 hash of canonical JSON
|
|
138
|
+
*
|
|
139
|
+
* @param data - Data to hash
|
|
140
|
+
* @returns keccak256 hash (0x-prefixed)
|
|
141
|
+
*/
|
|
142
|
+
export declare function computeContentHash(data: unknown): string;
|
|
143
|
+
/**
|
|
144
|
+
* Validate archive bundle structure
|
|
145
|
+
*
|
|
146
|
+
* @param bundle - Bundle to validate
|
|
147
|
+
* @throws {ValidationError} If bundle is invalid
|
|
148
|
+
*/
|
|
149
|
+
export declare function validateArchiveBundle(bundle: unknown): bundle is ArchiveBundle;
|
|
150
|
+
//# sourceMappingURL=ArchiveBundleBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArchiveBundleBuilder.d.ts","sourceRoot":"","sources":["../../src/storage/ArchiveBundleBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EACL,aAAa,EACb,cAAc,EAEd,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,SAAS,CAAC;AA4BjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,oBAAoB,CAA0C;IACtE,OAAO,CAAC,IAAI,CAAC,CAAS;IACtB,OAAO,CAAC,OAAO,CAAC,CAAiB;IACjC,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAsB;IAC3C,OAAO,CAAC,UAAU,CAAC,CAAoB;IACvC,OAAO,CAAC,MAAM,CAAC,CAAgB;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAoB;IACvC,OAAO,CAAC,WAAW,CAAC,CAAqB;IACzC,OAAO,CAAC,UAAU,CAAC,CAAoB;IAEvC;;OAEG;;IAOH;;;OAGG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQzC;;;OAGG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAY9C;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQpC;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAQzC;;;OAGG;IACH,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAavC;;OAEG;IACH,eAAe,CAAC,YAAY,EAAE,mBAAmB,GAAG,IAAI;IAmBxD;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAuBlD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAmBtC;;;;;;OAMG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAsBjF;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IA4BlD;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI;IAgBrD;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IA4ClD;;;;;OAKG;IACH,KAAK,IAAI,aAAa;IAqDtB;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,oBAAoB;IAyB9D;;OAEG;IACH,OAAO,CAAC,cAAc;CAkBvB;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAIxD;AAwBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,aAAa,CAiC9E"}
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ArchiveBundleBuilder - Builder for Archive Bundles (AIP-7 §4.4)
|
|
4
|
+
*
|
|
5
|
+
* Provides a fluent builder pattern for constructing archive bundles
|
|
6
|
+
* that will be stored permanently on Arweave.
|
|
7
|
+
*
|
|
8
|
+
* Archive bundles contain minimal metadata with cryptographic hashes
|
|
9
|
+
* and references. Full content remains on IPFS.
|
|
10
|
+
*
|
|
11
|
+
* @module storage/ArchiveBundleBuilder
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.validateArchiveBundle = exports.computeContentHash = exports.ArchiveBundleBuilder = void 0;
|
|
15
|
+
const ethers_1 = require("ethers");
|
|
16
|
+
const errors_1 = require("../errors");
|
|
17
|
+
const types_1 = require("./types");
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Constants
|
|
20
|
+
// ============================================================================
|
|
21
|
+
const DEFAULT_PROTOCOL_VERSION = '1.0.0';
|
|
22
|
+
const DEFAULT_ARCHIVE_SCHEMA_VERSION = '1.0.0';
|
|
23
|
+
// Address validation pattern
|
|
24
|
+
const ADDRESS_PATTERN = /^0x[a-fA-F0-9]{40}$/;
|
|
25
|
+
// Transaction ID validation pattern
|
|
26
|
+
const TX_ID_PATTERN = /^0x[a-fA-F0-9]{64}$/;
|
|
27
|
+
// Hash validation pattern
|
|
28
|
+
const HASH_PATTERN = /^0x[a-fA-F0-9]{64}$/;
|
|
29
|
+
// Signature validation pattern (65 bytes = 130 hex chars)
|
|
30
|
+
const SIGNATURE_PATTERN = /^0x[a-fA-F0-9]{130}$/;
|
|
31
|
+
// CID validation pattern (CIDv0 or CIDv1)
|
|
32
|
+
const CID_PATTERN = /^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{58,})$/;
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// ArchiveBundleBuilder Class
|
|
35
|
+
// ============================================================================
|
|
36
|
+
/**
|
|
37
|
+
* ArchiveBundleBuilder - Fluent builder for archive bundles
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const bundle = new ArchiveBundleBuilder()
|
|
42
|
+
* .setTransactionId('0x1234...')
|
|
43
|
+
* .setChainId(8453)
|
|
44
|
+
* .setParticipants({
|
|
45
|
+
* requester: '0xRequester...',
|
|
46
|
+
* provider: '0xProvider...'
|
|
47
|
+
* })
|
|
48
|
+
* .setReferences({
|
|
49
|
+
* requestCID: 'bafybei...',
|
|
50
|
+
* deliveryCID: 'bafybei...'
|
|
51
|
+
* })
|
|
52
|
+
* .setHashes({
|
|
53
|
+
* requestHash: '0xabc...',
|
|
54
|
+
* deliveryHash: '0xdef...',
|
|
55
|
+
* serviceHash: '0x123...'
|
|
56
|
+
* })
|
|
57
|
+
* .setSignatures({
|
|
58
|
+
* providerDeliverySignature: '0xsig...'
|
|
59
|
+
* })
|
|
60
|
+
* .setAttestation({ easUID: '0xeas...' })
|
|
61
|
+
* .setSettlement({
|
|
62
|
+
* settledAt: Date.now() / 1000,
|
|
63
|
+
* finalState: 'SETTLED',
|
|
64
|
+
* escrowReleased: { to: '0xProvider...', amount: '100000000' },
|
|
65
|
+
* platformFee: '1000000',
|
|
66
|
+
* wasDisputed: false
|
|
67
|
+
* })
|
|
68
|
+
* .build();
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
class ArchiveBundleBuilder {
|
|
72
|
+
/**
|
|
73
|
+
* Create a new ArchiveBundleBuilder
|
|
74
|
+
*/
|
|
75
|
+
constructor() {
|
|
76
|
+
this.protocolVersion = DEFAULT_PROTOCOL_VERSION;
|
|
77
|
+
this.archiveSchemaVersion = DEFAULT_ARCHIVE_SCHEMA_VERSION;
|
|
78
|
+
}
|
|
79
|
+
// ==========================================================================
|
|
80
|
+
// Version Setters
|
|
81
|
+
// ==========================================================================
|
|
82
|
+
/**
|
|
83
|
+
* Set protocol version
|
|
84
|
+
* @default '1.0.0'
|
|
85
|
+
*/
|
|
86
|
+
setProtocolVersion(version) {
|
|
87
|
+
if (!/^\d+\.\d+\.\d+$/.test(version)) {
|
|
88
|
+
throw new errors_1.ValidationError('protocolVersion', 'Must be semver format (e.g., 1.0.0)');
|
|
89
|
+
}
|
|
90
|
+
this.protocolVersion = version;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Set archive schema version
|
|
95
|
+
* @default '1.0.0'
|
|
96
|
+
*/
|
|
97
|
+
setArchiveSchemaVersion(version) {
|
|
98
|
+
if (!/^\d+\.\d+\.\d+$/.test(version)) {
|
|
99
|
+
throw new errors_1.ValidationError('archiveSchemaVersion', 'Must be semver format (e.g., 1.0.0)');
|
|
100
|
+
}
|
|
101
|
+
this.archiveSchemaVersion = version;
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
// ==========================================================================
|
|
105
|
+
// Transaction Identity Setters
|
|
106
|
+
// ==========================================================================
|
|
107
|
+
/**
|
|
108
|
+
* Set ACTP transaction ID (bytes32)
|
|
109
|
+
*/
|
|
110
|
+
setTransactionId(txId) {
|
|
111
|
+
if (!TX_ID_PATTERN.test(txId)) {
|
|
112
|
+
throw new errors_1.ValidationError('txId', 'Must be bytes32 hex string (0x + 64 hex chars)');
|
|
113
|
+
}
|
|
114
|
+
this.txId = txId.toLowerCase();
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set blockchain chain ID
|
|
119
|
+
* @param chainId - 8453 (Base Mainnet) or 84532 (Base Sepolia)
|
|
120
|
+
*/
|
|
121
|
+
setChainId(chainId) {
|
|
122
|
+
if (chainId !== 8453 && chainId !== 84532) {
|
|
123
|
+
throw new errors_1.ValidationError('chainId', 'Must be 8453 (Base Mainnet) or 84532 (Base Sepolia)');
|
|
124
|
+
}
|
|
125
|
+
this.chainId = chainId;
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Set archive timestamp
|
|
130
|
+
* @param timestamp - Unix timestamp in seconds (defaults to now)
|
|
131
|
+
*/
|
|
132
|
+
setArchivedAt(timestamp) {
|
|
133
|
+
const ts = timestamp ?? Math.floor(Date.now() / 1000);
|
|
134
|
+
if (ts <= 0) {
|
|
135
|
+
throw new errors_1.ValidationError('archivedAt', 'Must be positive Unix timestamp');
|
|
136
|
+
}
|
|
137
|
+
this.archivedAt = ts;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
// ==========================================================================
|
|
141
|
+
// Participant Setters
|
|
142
|
+
// ==========================================================================
|
|
143
|
+
/**
|
|
144
|
+
* Set transaction participants
|
|
145
|
+
*/
|
|
146
|
+
setParticipants(participants) {
|
|
147
|
+
if (!ADDRESS_PATTERN.test(participants.requester)) {
|
|
148
|
+
throw new errors_1.ValidationError('participants.requester', 'Invalid Ethereum address');
|
|
149
|
+
}
|
|
150
|
+
if (!ADDRESS_PATTERN.test(participants.provider)) {
|
|
151
|
+
throw new errors_1.ValidationError('participants.provider', 'Invalid Ethereum address');
|
|
152
|
+
}
|
|
153
|
+
this.participants = {
|
|
154
|
+
requester: participants.requester.toLowerCase(),
|
|
155
|
+
provider: participants.provider.toLowerCase()
|
|
156
|
+
};
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
// ==========================================================================
|
|
160
|
+
// Reference Setters
|
|
161
|
+
// ==========================================================================
|
|
162
|
+
/**
|
|
163
|
+
* Set IPFS CID references
|
|
164
|
+
*/
|
|
165
|
+
setReferences(references) {
|
|
166
|
+
if (!CID_PATTERN.test(references.requestCID)) {
|
|
167
|
+
throw new errors_1.ValidationError('references.requestCID', 'Invalid IPFS CID format');
|
|
168
|
+
}
|
|
169
|
+
if (!CID_PATTERN.test(references.deliveryCID)) {
|
|
170
|
+
throw new errors_1.ValidationError('references.deliveryCID', 'Invalid IPFS CID format');
|
|
171
|
+
}
|
|
172
|
+
if (references.resultCID && !CID_PATTERN.test(references.resultCID)) {
|
|
173
|
+
throw new errors_1.ValidationError('references.resultCID', 'Invalid IPFS CID format');
|
|
174
|
+
}
|
|
175
|
+
this.references = {
|
|
176
|
+
requestCID: references.requestCID,
|
|
177
|
+
deliveryCID: references.deliveryCID,
|
|
178
|
+
...(references.resultCID && { resultCID: references.resultCID })
|
|
179
|
+
};
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
// ==========================================================================
|
|
183
|
+
// Hash Setters
|
|
184
|
+
// ==========================================================================
|
|
185
|
+
/**
|
|
186
|
+
* Set cryptographic hashes
|
|
187
|
+
*/
|
|
188
|
+
setHashes(hashes) {
|
|
189
|
+
if (!HASH_PATTERN.test(hashes.requestHash)) {
|
|
190
|
+
throw new errors_1.ValidationError('hashes.requestHash', 'Invalid hash format (bytes32)');
|
|
191
|
+
}
|
|
192
|
+
if (!HASH_PATTERN.test(hashes.deliveryHash)) {
|
|
193
|
+
throw new errors_1.ValidationError('hashes.deliveryHash', 'Invalid hash format (bytes32)');
|
|
194
|
+
}
|
|
195
|
+
if (!HASH_PATTERN.test(hashes.serviceHash)) {
|
|
196
|
+
throw new errors_1.ValidationError('hashes.serviceHash', 'Invalid hash format (bytes32)');
|
|
197
|
+
}
|
|
198
|
+
this.hashes = {
|
|
199
|
+
requestHash: hashes.requestHash.toLowerCase(),
|
|
200
|
+
deliveryHash: hashes.deliveryHash.toLowerCase(),
|
|
201
|
+
serviceHash: hashes.serviceHash.toLowerCase()
|
|
202
|
+
};
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Compute and set hashes from raw data
|
|
207
|
+
*
|
|
208
|
+
* @param request - Request metadata JSON
|
|
209
|
+
* @param delivery - Delivery proof JSON
|
|
210
|
+
* @param serviceHash - Service hash from transaction (already computed)
|
|
211
|
+
*/
|
|
212
|
+
setHashesFromData(request, delivery, serviceHash) {
|
|
213
|
+
if (!HASH_PATTERN.test(serviceHash)) {
|
|
214
|
+
throw new errors_1.ValidationError('serviceHash', 'Invalid hash format (bytes32)');
|
|
215
|
+
}
|
|
216
|
+
// Compute canonical hashes (sorted keys JSON)
|
|
217
|
+
const requestJson = JSON.stringify(this.sortObjectKeys(request));
|
|
218
|
+
const deliveryJson = JSON.stringify(this.sortObjectKeys(delivery));
|
|
219
|
+
this.hashes = {
|
|
220
|
+
requestHash: (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)(requestJson)),
|
|
221
|
+
deliveryHash: (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)(deliveryJson)),
|
|
222
|
+
serviceHash: serviceHash.toLowerCase()
|
|
223
|
+
};
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
// ==========================================================================
|
|
227
|
+
// Signature Setters
|
|
228
|
+
// ==========================================================================
|
|
229
|
+
/**
|
|
230
|
+
* Set cryptographic signatures
|
|
231
|
+
*/
|
|
232
|
+
setSignatures(signatures) {
|
|
233
|
+
if (!SIGNATURE_PATTERN.test(signatures.providerDeliverySignature)) {
|
|
234
|
+
throw new errors_1.ValidationError('signatures.providerDeliverySignature', 'Invalid signature format (65 bytes = 0x + 130 hex chars)');
|
|
235
|
+
}
|
|
236
|
+
if (signatures.requesterSettlementSignature &&
|
|
237
|
+
!SIGNATURE_PATTERN.test(signatures.requesterSettlementSignature)) {
|
|
238
|
+
throw new errors_1.ValidationError('signatures.requesterSettlementSignature', 'Invalid signature format');
|
|
239
|
+
}
|
|
240
|
+
this.signatures = {
|
|
241
|
+
providerDeliverySignature: signatures.providerDeliverySignature,
|
|
242
|
+
...(signatures.requesterSettlementSignature && {
|
|
243
|
+
requesterSettlementSignature: signatures.requesterSettlementSignature
|
|
244
|
+
})
|
|
245
|
+
};
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
248
|
+
// ==========================================================================
|
|
249
|
+
// Attestation Setters
|
|
250
|
+
// ==========================================================================
|
|
251
|
+
/**
|
|
252
|
+
* Set EAS attestation reference
|
|
253
|
+
*/
|
|
254
|
+
setAttestation(attestation) {
|
|
255
|
+
if (!HASH_PATTERN.test(attestation.easUID)) {
|
|
256
|
+
throw new errors_1.ValidationError('attestation.easUID', 'Invalid EAS UID format (bytes32)');
|
|
257
|
+
}
|
|
258
|
+
this.attestation = {
|
|
259
|
+
easUID: attestation.easUID.toLowerCase(),
|
|
260
|
+
...(attestation.schemaUID && { schemaUID: attestation.schemaUID.toLowerCase() })
|
|
261
|
+
};
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
// ==========================================================================
|
|
265
|
+
// Settlement Setters
|
|
266
|
+
// ==========================================================================
|
|
267
|
+
/**
|
|
268
|
+
* Set settlement information
|
|
269
|
+
*/
|
|
270
|
+
setSettlement(settlement) {
|
|
271
|
+
// Validate settledAt
|
|
272
|
+
if (settlement.settledAt <= 0) {
|
|
273
|
+
throw new errors_1.ValidationError('settlement.settledAt', 'Must be positive Unix timestamp');
|
|
274
|
+
}
|
|
275
|
+
// Validate finalState
|
|
276
|
+
if (settlement.finalState !== 'SETTLED' && settlement.finalState !== 'CANCELLED') {
|
|
277
|
+
throw new errors_1.ValidationError('settlement.finalState', 'Must be SETTLED or CANCELLED');
|
|
278
|
+
}
|
|
279
|
+
// Validate escrowReleased
|
|
280
|
+
if (!ADDRESS_PATTERN.test(settlement.escrowReleased.to)) {
|
|
281
|
+
throw new errors_1.ValidationError('settlement.escrowReleased.to', 'Invalid Ethereum address');
|
|
282
|
+
}
|
|
283
|
+
if (!/^\d+$/.test(settlement.escrowReleased.amount)) {
|
|
284
|
+
throw new errors_1.ValidationError('settlement.escrowReleased.amount', 'Must be numeric string (USDC base units)');
|
|
285
|
+
}
|
|
286
|
+
// Validate platformFee
|
|
287
|
+
if (!/^\d+$/.test(settlement.platformFee)) {
|
|
288
|
+
throw new errors_1.ValidationError('settlement.platformFee', 'Must be numeric string');
|
|
289
|
+
}
|
|
290
|
+
this.settlement = {
|
|
291
|
+
settledAt: settlement.settledAt,
|
|
292
|
+
finalState: settlement.finalState,
|
|
293
|
+
escrowReleased: {
|
|
294
|
+
to: settlement.escrowReleased.to.toLowerCase(),
|
|
295
|
+
amount: settlement.escrowReleased.amount
|
|
296
|
+
},
|
|
297
|
+
platformFee: settlement.platformFee,
|
|
298
|
+
wasDisputed: Boolean(settlement.wasDisputed)
|
|
299
|
+
};
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
// ==========================================================================
|
|
303
|
+
// Build Method
|
|
304
|
+
// ==========================================================================
|
|
305
|
+
/**
|
|
306
|
+
* Build the archive bundle
|
|
307
|
+
*
|
|
308
|
+
* @returns Complete archive bundle ready for Arweave upload
|
|
309
|
+
* @throws {ValidationError} If required fields are missing
|
|
310
|
+
*/
|
|
311
|
+
build() {
|
|
312
|
+
// Validate all required fields
|
|
313
|
+
if (!this.txId) {
|
|
314
|
+
throw new errors_1.ValidationError('build', 'Transaction ID is required');
|
|
315
|
+
}
|
|
316
|
+
if (this.chainId === undefined) {
|
|
317
|
+
throw new errors_1.ValidationError('build', 'Chain ID is required');
|
|
318
|
+
}
|
|
319
|
+
if (!this.participants) {
|
|
320
|
+
throw new errors_1.ValidationError('build', 'Participants are required');
|
|
321
|
+
}
|
|
322
|
+
if (!this.references) {
|
|
323
|
+
throw new errors_1.ValidationError('build', 'References are required');
|
|
324
|
+
}
|
|
325
|
+
if (!this.hashes) {
|
|
326
|
+
throw new errors_1.ValidationError('build', 'Hashes are required');
|
|
327
|
+
}
|
|
328
|
+
if (!this.signatures) {
|
|
329
|
+
throw new errors_1.ValidationError('build', 'Signatures are required');
|
|
330
|
+
}
|
|
331
|
+
if (!this.settlement) {
|
|
332
|
+
throw new errors_1.ValidationError('build', 'Settlement info is required');
|
|
333
|
+
}
|
|
334
|
+
// Set archivedAt if not set
|
|
335
|
+
const archivedAt = this.archivedAt ?? Math.floor(Date.now() / 1000);
|
|
336
|
+
const bundle = {
|
|
337
|
+
protocolVersion: this.protocolVersion,
|
|
338
|
+
archiveSchemaVersion: this.archiveSchemaVersion,
|
|
339
|
+
type: types_1.ARCHIVE_BUNDLE_TYPE,
|
|
340
|
+
txId: this.txId,
|
|
341
|
+
chainId: this.chainId,
|
|
342
|
+
archivedAt,
|
|
343
|
+
participants: this.participants,
|
|
344
|
+
references: this.references,
|
|
345
|
+
hashes: this.hashes,
|
|
346
|
+
signatures: this.signatures,
|
|
347
|
+
settlement: this.settlement
|
|
348
|
+
};
|
|
349
|
+
// Add attestation if present (optional for CANCELLED transactions)
|
|
350
|
+
if (this.attestation) {
|
|
351
|
+
bundle.attestation = this.attestation;
|
|
352
|
+
}
|
|
353
|
+
return bundle;
|
|
354
|
+
}
|
|
355
|
+
// ==========================================================================
|
|
356
|
+
// Static Factory Methods
|
|
357
|
+
// ==========================================================================
|
|
358
|
+
/**
|
|
359
|
+
* Create builder from existing bundle (for modifications)
|
|
360
|
+
*/
|
|
361
|
+
static fromBundle(bundle) {
|
|
362
|
+
const builder = new ArchiveBundleBuilder();
|
|
363
|
+
builder.protocolVersion = bundle.protocolVersion;
|
|
364
|
+
builder.archiveSchemaVersion = bundle.archiveSchemaVersion;
|
|
365
|
+
builder.txId = bundle.txId;
|
|
366
|
+
builder.chainId = bundle.chainId;
|
|
367
|
+
builder.archivedAt = bundle.archivedAt;
|
|
368
|
+
builder.participants = { ...bundle.participants };
|
|
369
|
+
builder.references = { ...bundle.references };
|
|
370
|
+
builder.hashes = { ...bundle.hashes };
|
|
371
|
+
builder.signatures = { ...bundle.signatures };
|
|
372
|
+
builder.settlement = { ...bundle.settlement };
|
|
373
|
+
if (bundle.attestation) {
|
|
374
|
+
builder.attestation = { ...bundle.attestation };
|
|
375
|
+
}
|
|
376
|
+
return builder;
|
|
377
|
+
}
|
|
378
|
+
// ==========================================================================
|
|
379
|
+
// Private Helpers
|
|
380
|
+
// ==========================================================================
|
|
381
|
+
/**
|
|
382
|
+
* Sort object keys recursively for canonical JSON
|
|
383
|
+
*/
|
|
384
|
+
sortObjectKeys(obj) {
|
|
385
|
+
if (obj === null || typeof obj !== 'object') {
|
|
386
|
+
return obj;
|
|
387
|
+
}
|
|
388
|
+
if (Array.isArray(obj)) {
|
|
389
|
+
return obj.map(item => this.sortObjectKeys(item));
|
|
390
|
+
}
|
|
391
|
+
const sorted = {};
|
|
392
|
+
const keys = Object.keys(obj).sort();
|
|
393
|
+
for (const key of keys) {
|
|
394
|
+
sorted[key] = this.sortObjectKeys(obj[key]);
|
|
395
|
+
}
|
|
396
|
+
return sorted;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
exports.ArchiveBundleBuilder = ArchiveBundleBuilder;
|
|
400
|
+
// ============================================================================
|
|
401
|
+
// Utility Functions
|
|
402
|
+
// ============================================================================
|
|
403
|
+
/**
|
|
404
|
+
* Compute keccak256 hash of canonical JSON
|
|
405
|
+
*
|
|
406
|
+
* @param data - Data to hash
|
|
407
|
+
* @returns keccak256 hash (0x-prefixed)
|
|
408
|
+
*/
|
|
409
|
+
function computeContentHash(data) {
|
|
410
|
+
const sorted = sortObjectKeysRecursive(data);
|
|
411
|
+
const json = JSON.stringify(sorted);
|
|
412
|
+
return (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)(json));
|
|
413
|
+
}
|
|
414
|
+
exports.computeContentHash = computeContentHash;
|
|
415
|
+
/**
|
|
416
|
+
* Sort object keys recursively
|
|
417
|
+
*/
|
|
418
|
+
function sortObjectKeysRecursive(obj) {
|
|
419
|
+
if (obj === null || typeof obj !== 'object') {
|
|
420
|
+
return obj;
|
|
421
|
+
}
|
|
422
|
+
if (Array.isArray(obj)) {
|
|
423
|
+
return obj.map(item => sortObjectKeysRecursive(item));
|
|
424
|
+
}
|
|
425
|
+
const sorted = {};
|
|
426
|
+
const keys = Object.keys(obj).sort();
|
|
427
|
+
for (const key of keys) {
|
|
428
|
+
sorted[key] = sortObjectKeysRecursive(obj[key]);
|
|
429
|
+
}
|
|
430
|
+
return sorted;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Validate archive bundle structure
|
|
434
|
+
*
|
|
435
|
+
* @param bundle - Bundle to validate
|
|
436
|
+
* @throws {ValidationError} If bundle is invalid
|
|
437
|
+
*/
|
|
438
|
+
function validateArchiveBundle(bundle) {
|
|
439
|
+
if (!bundle || typeof bundle !== 'object') {
|
|
440
|
+
throw new errors_1.ValidationError('bundle', 'Archive bundle must be an object');
|
|
441
|
+
}
|
|
442
|
+
const b = bundle;
|
|
443
|
+
// Type check
|
|
444
|
+
if (b.type !== types_1.ARCHIVE_BUNDLE_TYPE) {
|
|
445
|
+
throw new errors_1.ValidationError('bundle.type', `Expected ${types_1.ARCHIVE_BUNDLE_TYPE}`);
|
|
446
|
+
}
|
|
447
|
+
// Required fields
|
|
448
|
+
const required = [
|
|
449
|
+
'protocolVersion',
|
|
450
|
+
'archiveSchemaVersion',
|
|
451
|
+
'txId',
|
|
452
|
+
'chainId',
|
|
453
|
+
'archivedAt',
|
|
454
|
+
'participants',
|
|
455
|
+
'references',
|
|
456
|
+
'hashes',
|
|
457
|
+
'signatures',
|
|
458
|
+
'settlement'
|
|
459
|
+
];
|
|
460
|
+
for (const field of required) {
|
|
461
|
+
if (!(field in b)) {
|
|
462
|
+
throw new errors_1.ValidationError(`bundle.${field}`, 'Required field missing');
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
exports.validateArchiveBundle = validateArchiveBundle;
|
|
468
|
+
//# sourceMappingURL=ArchiveBundleBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArchiveBundleBuilder.js","sourceRoot":"","sources":["../../src/storage/ArchiveBundleBuilder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,mCAAgD;AAChD,sCAA4C;AAC5C,mCAYiB;AAEjB,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,wBAAwB,GAAG,OAAO,CAAC;AACzC,MAAM,8BAA8B,GAAG,OAAO,CAAC;AAE/C,6BAA6B;AAC7B,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAE9C,oCAAoC;AACpC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAE5C,0BAA0B;AAC1B,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,0CAA0C;AAC1C,MAAM,WAAW,GAAG,+CAA+C,CAAC;AAEpE,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,oBAAoB;IAa/B;;OAEG;IACH;QAfQ,oBAAe,GAAW,wBAAwB,CAAC;QACnD,yBAAoB,GAAW,8B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