@agirails/sdk 2.5.3 → 2.5.5

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.
Files changed (169) hide show
  1. package/dist/ACTPClient.d.ts +18 -0
  2. package/dist/ACTPClient.d.ts.map +1 -1
  3. package/dist/ACTPClient.js +72 -23
  4. package/dist/ACTPClient.js.map +1 -1
  5. package/dist/adapters/BasicAdapter.d.ts +15 -0
  6. package/dist/adapters/BasicAdapter.d.ts.map +1 -1
  7. package/dist/adapters/BasicAdapter.js +33 -4
  8. package/dist/adapters/BasicAdapter.js.map +1 -1
  9. package/dist/adapters/StandardAdapter.d.ts +20 -3
  10. package/dist/adapters/StandardAdapter.d.ts.map +1 -1
  11. package/dist/adapters/StandardAdapter.js +90 -12
  12. package/dist/adapters/StandardAdapter.js.map +1 -1
  13. package/dist/cli/commands/publish.js +16 -4
  14. package/dist/cli/commands/publish.js.map +1 -1
  15. package/dist/cli/commands/register.js +16 -4
  16. package/dist/cli/commands/register.js.map +1 -1
  17. package/dist/cli/commands/tx.js +31 -3
  18. package/dist/cli/commands/tx.js.map +1 -1
  19. package/dist/config/networks.d.ts +10 -2
  20. package/dist/config/networks.d.ts.map +1 -1
  21. package/dist/config/networks.js +31 -22
  22. package/dist/config/networks.js.map +1 -1
  23. package/dist/level0/request.d.ts.map +1 -1
  24. package/dist/level0/request.js +2 -1
  25. package/dist/level0/request.js.map +1 -1
  26. package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
  27. package/dist/runtime/BlockchainRuntime.js +11 -5
  28. package/dist/runtime/BlockchainRuntime.js.map +1 -1
  29. package/dist/utils/IPFSClient.d.ts +3 -1
  30. package/dist/utils/IPFSClient.d.ts.map +1 -1
  31. package/dist/utils/IPFSClient.js +27 -7
  32. package/dist/utils/IPFSClient.js.map +1 -1
  33. package/dist/wallet/AutoWalletProvider.d.ts +11 -1
  34. package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
  35. package/dist/wallet/AutoWalletProvider.js +84 -19
  36. package/dist/wallet/AutoWalletProvider.js.map +1 -1
  37. package/dist/wallet/IWalletProvider.d.ts +34 -0
  38. package/dist/wallet/IWalletProvider.d.ts.map +1 -1
  39. package/dist/wallet/SmartWalletRouter.d.ts +128 -0
  40. package/dist/wallet/SmartWalletRouter.d.ts.map +1 -0
  41. package/dist/wallet/SmartWalletRouter.js +248 -0
  42. package/dist/wallet/SmartWalletRouter.js.map +1 -0
  43. package/dist/wallet/aa/DualNonceManager.d.ts +26 -1
  44. package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
  45. package/dist/wallet/aa/DualNonceManager.js +140 -6
  46. package/dist/wallet/aa/DualNonceManager.js.map +1 -1
  47. package/package.json +3 -6
  48. package/src/ACTPClient.ts +0 -1579
  49. package/src/abi/ACTPKernel.json +0 -1356
  50. package/src/abi/AgentRegistry.json +0 -915
  51. package/src/abi/ERC20.json +0 -40
  52. package/src/abi/EscrowVault.json +0 -134
  53. package/src/abi/IdentityRegistry.json +0 -316
  54. package/src/adapters/AdapterRegistry.ts +0 -173
  55. package/src/adapters/AdapterRouter.ts +0 -416
  56. package/src/adapters/BaseAdapter.ts +0 -498
  57. package/src/adapters/BasicAdapter.ts +0 -514
  58. package/src/adapters/IAdapter.ts +0 -292
  59. package/src/adapters/StandardAdapter.ts +0 -555
  60. package/src/adapters/X402Adapter.ts +0 -731
  61. package/src/adapters/index.ts +0 -60
  62. package/src/builders/DeliveryProofBuilder.ts +0 -327
  63. package/src/builders/QuoteBuilder.ts +0 -483
  64. package/src/builders/index.ts +0 -17
  65. package/src/cli/commands/balance.ts +0 -110
  66. package/src/cli/commands/batch.ts +0 -487
  67. package/src/cli/commands/config.ts +0 -231
  68. package/src/cli/commands/deploy-check.ts +0 -364
  69. package/src/cli/commands/deploy-env.ts +0 -120
  70. package/src/cli/commands/diff.ts +0 -141
  71. package/src/cli/commands/init.ts +0 -469
  72. package/src/cli/commands/mint.ts +0 -116
  73. package/src/cli/commands/pay.ts +0 -113
  74. package/src/cli/commands/publish.ts +0 -475
  75. package/src/cli/commands/pull.ts +0 -124
  76. package/src/cli/commands/register.ts +0 -247
  77. package/src/cli/commands/simulate.ts +0 -345
  78. package/src/cli/commands/time.ts +0 -302
  79. package/src/cli/commands/tx.ts +0 -448
  80. package/src/cli/commands/watch.ts +0 -211
  81. package/src/cli/index.ts +0 -134
  82. package/src/cli/utils/client.ts +0 -252
  83. package/src/cli/utils/config.ts +0 -389
  84. package/src/cli/utils/output.ts +0 -465
  85. package/src/cli/utils/wallet.ts +0 -109
  86. package/src/config/agirailsmd.ts +0 -262
  87. package/src/config/networks.ts +0 -275
  88. package/src/config/pendingPublish.ts +0 -237
  89. package/src/config/publishPipeline.ts +0 -359
  90. package/src/config/syncOperations.ts +0 -279
  91. package/src/erc8004/ERC8004Bridge.ts +0 -462
  92. package/src/erc8004/ReputationReporter.ts +0 -468
  93. package/src/erc8004/index.ts +0 -61
  94. package/src/errors/index.ts +0 -427
  95. package/src/index.ts +0 -364
  96. package/src/level0/Provider.ts +0 -117
  97. package/src/level0/ServiceDirectory.ts +0 -131
  98. package/src/level0/index.ts +0 -10
  99. package/src/level0/provide.ts +0 -132
  100. package/src/level0/request.ts +0 -432
  101. package/src/level1/Agent.ts +0 -1426
  102. package/src/level1/index.ts +0 -10
  103. package/src/level1/pricing/PriceCalculator.ts +0 -255
  104. package/src/level1/pricing/PricingStrategy.ts +0 -198
  105. package/src/level1/types/Job.ts +0 -179
  106. package/src/level1/types/Options.ts +0 -291
  107. package/src/level1/types/index.ts +0 -8
  108. package/src/protocol/ACTPKernel.ts +0 -808
  109. package/src/protocol/AgentRegistry.ts +0 -559
  110. package/src/protocol/DIDManager.ts +0 -629
  111. package/src/protocol/DIDResolver.ts +0 -554
  112. package/src/protocol/EASHelper.ts +0 -378
  113. package/src/protocol/EscrowVault.ts +0 -255
  114. package/src/protocol/EventMonitor.ts +0 -204
  115. package/src/protocol/MessageSigner.ts +0 -510
  116. package/src/protocol/ProofGenerator.ts +0 -339
  117. package/src/protocol/QuoteBuilder.ts +0 -15
  118. package/src/registry/AgentRegistryClient.ts +0 -202
  119. package/src/runtime/BlockchainRuntime.ts +0 -1015
  120. package/src/runtime/IACTPRuntime.ts +0 -306
  121. package/src/runtime/MockRuntime.ts +0 -1298
  122. package/src/runtime/MockStateManager.ts +0 -577
  123. package/src/runtime/index.ts +0 -25
  124. package/src/runtime/types/MockState.ts +0 -237
  125. package/src/storage/ArchiveBundleBuilder.ts +0 -561
  126. package/src/storage/ArweaveClient.ts +0 -946
  127. package/src/storage/FilebaseClient.ts +0 -790
  128. package/src/storage/index.ts +0 -96
  129. package/src/storage/types.ts +0 -348
  130. package/src/types/adapter.ts +0 -310
  131. package/src/types/agent.ts +0 -79
  132. package/src/types/did.ts +0 -223
  133. package/src/types/eip712.ts +0 -175
  134. package/src/types/erc8004.ts +0 -293
  135. package/src/types/escrow.ts +0 -27
  136. package/src/types/index.ts +0 -17
  137. package/src/types/message.ts +0 -145
  138. package/src/types/state.ts +0 -87
  139. package/src/types/transaction.ts +0 -69
  140. package/src/types/x402.ts +0 -251
  141. package/src/utils/ErrorRecoveryGuide.ts +0 -676
  142. package/src/utils/Helpers.ts +0 -688
  143. package/src/utils/IPFSClient.ts +0 -368
  144. package/src/utils/Logger.ts +0 -484
  145. package/src/utils/NonceManager.ts +0 -591
  146. package/src/utils/RateLimiter.ts +0 -534
  147. package/src/utils/ReceivedNonceTracker.ts +0 -567
  148. package/src/utils/SDKLifecycle.ts +0 -416
  149. package/src/utils/SecureNonce.ts +0 -78
  150. package/src/utils/Semaphore.ts +0 -276
  151. package/src/utils/UsedAttestationTracker.ts +0 -385
  152. package/src/utils/canonicalJson.ts +0 -38
  153. package/src/utils/circuitBreaker.ts +0 -324
  154. package/src/utils/computeTypeHash.ts +0 -48
  155. package/src/utils/fsSafe.ts +0 -80
  156. package/src/utils/index.ts +0 -80
  157. package/src/utils/retry.ts +0 -364
  158. package/src/utils/security.ts +0 -418
  159. package/src/utils/validation.ts +0 -540
  160. package/src/wallet/AutoWalletProvider.ts +0 -299
  161. package/src/wallet/EOAWalletProvider.ts +0 -69
  162. package/src/wallet/IWalletProvider.ts +0 -135
  163. package/src/wallet/aa/BundlerClient.ts +0 -274
  164. package/src/wallet/aa/DualNonceManager.ts +0 -173
  165. package/src/wallet/aa/PaymasterClient.ts +0 -174
  166. package/src/wallet/aa/TransactionBatcher.ts +0 -353
  167. package/src/wallet/aa/UserOpBuilder.ts +0 -246
  168. package/src/wallet/aa/constants.ts +0 -60
  169. package/src/wallet/keystore.ts +0 -240
@@ -1,310 +0,0 @@
1
- /**
2
- * Adapter types for the ACTP SDK adapter routing system.
3
- *
4
- * This module defines types and Zod schemas for:
5
- * - AdapterMetadata: Capabilities and configuration for each adapter
6
- * - PaymentMetadata: Request-level hints for adapter selection
7
- * - UnifiedPayParams: Common payment parameters across adapters
8
- * - UnifiedPayResult: Common result type for all adapters
9
- *
10
- * @module types/adapter
11
- */
12
-
13
- import { z } from 'zod';
14
- import type { X402FeeBreakdown } from './x402';
15
-
16
- // ============================================================================
17
- // AdapterMetadata - Describes adapter capabilities
18
- // ============================================================================
19
-
20
- /**
21
- * Metadata describing an adapter's capabilities.
22
- *
23
- * CRITICAL: All adapters must respect ACTP state machine:
24
- * - No skipping IN_PROGRESS state
25
- * - DELIVERED requires proof
26
- * - releaseEscrow must be called explicitly (NO auto-settle)
27
- */
28
- export interface AdapterMetadata {
29
- /** Unique adapter identifier */
30
- id: string;
31
-
32
- /** Human-readable name */
33
- name: string;
34
-
35
- /** Whether adapter uses escrow */
36
- usesEscrow: boolean;
37
-
38
- /** Whether adapter supports dispute resolution */
39
- supportsDisputes: boolean;
40
-
41
- /** Whether adapter requires on-chain identity */
42
- requiresIdentity: boolean;
43
-
44
- /** Supported identity types (erc8004, did, ens) */
45
- supportedIdentityTypes?: string[];
46
-
47
- /**
48
- * Settlement mode:
49
- * - 'explicit': caller must call releaseEscrow (REQUIRED for ACTP compliance)
50
- * - 'timed': auto-release after dispute window (future, not Phase 1)
51
- * - 'atomic': instant settlement, no escrow (x402 protocol)
52
- */
53
- settlementMode: 'explicit' | 'timed' | 'atomic';
54
-
55
- /** Priority for auto-selection (higher = preferred) */
56
- priority: number;
57
- }
58
-
59
- /**
60
- * Zod schema for AdapterMetadata runtime validation.
61
- */
62
- export const AdapterMetadataSchema = z.object({
63
- id: z.string().min(1),
64
- name: z.string().min(1),
65
- usesEscrow: z.boolean(),
66
- supportsDisputes: z.boolean(),
67
- requiresIdentity: z.boolean(),
68
- supportedIdentityTypes: z.array(z.string()).optional(),
69
- settlementMode: z.enum(['explicit', 'timed', 'atomic']),
70
- priority: z.number().int().min(0).max(100),
71
- });
72
-
73
- // ============================================================================
74
- // PaymentMetadata - Request-level hints for adapter selection
75
- // ============================================================================
76
-
77
- /**
78
- * Identity information for adapter selection.
79
- */
80
- export interface PaymentIdentity {
81
- type: 'erc8004' | 'did' | 'ens' | 'address';
82
- value: string;
83
- }
84
-
85
- /**
86
- * Payment request metadata for adapter selection.
87
- */
88
- export interface PaymentMetadata {
89
- /** Explicitly request specific adapter */
90
- preferredAdapter?: string;
91
-
92
- /** Require escrow protection */
93
- requiresEscrow?: boolean;
94
-
95
- /** Require dispute resolution capability */
96
- requiresDispute?: boolean;
97
-
98
- /** Identity information */
99
- identity?: PaymentIdentity;
100
-
101
- /** x402 specific: payment method hint */
102
- paymentMethod?: 'x402' | 'actp' | 'auto';
103
- }
104
-
105
- /**
106
- * Zod schema for PaymentIdentity runtime validation.
107
- */
108
- export const PaymentIdentitySchema = z.object({
109
- type: z.enum(['erc8004', 'did', 'ens', 'address']),
110
- value: z.string().min(1),
111
- });
112
-
113
- /**
114
- * Zod schema for PaymentMetadata runtime validation.
115
- */
116
- export const PaymentMetadataSchema = z.object({
117
- preferredAdapter: z.string().optional(),
118
- requiresEscrow: z.boolean().optional(),
119
- requiresDispute: z.boolean().optional(),
120
- identity: PaymentIdentitySchema.optional(),
121
- paymentMethod: z.enum(['x402', 'actp', 'auto']).optional(),
122
- });
123
-
124
- // ============================================================================
125
- // UnifiedPayParams - Common payment parameters
126
- // ============================================================================
127
-
128
- /**
129
- * Unified payment parameters accepted by all adapters.
130
- */
131
- export interface UnifiedPayParams {
132
- /** Recipient - address, HTTP endpoint, or ERC-8004 agent ID */
133
- to: string;
134
-
135
- /** Amount in human-readable format */
136
- amount: string | number;
137
-
138
- /** Deadline (relative like '+24h' or unix timestamp) */
139
- deadline?: string | number;
140
-
141
- /** Dispute window in seconds (min 3600, max 30 days) */
142
- disputeWindow?: number;
143
-
144
- /** Service description */
145
- description?: string;
146
-
147
- /** Adapter selection metadata */
148
- metadata?: PaymentMetadata;
149
-
150
- /**
151
- * ERC-8004 agent ID (populated when 'to' was resolved from agentId).
152
- * Set by AdapterRouter when resolving agent ID to wallet address.
153
- * Used for reputation reporting after settlement.
154
- */
155
- erc8004AgentId?: string;
156
- }
157
-
158
- /**
159
- * Minimum dispute window in seconds (1 hour).
160
- * Ensures requesters have reasonable time to dispute.
161
- */
162
- const MIN_DISPUTE_WINDOW = 3600;
163
-
164
- /**
165
- * Maximum dispute window in seconds (30 days).
166
- * Prevents excessively long fund locks.
167
- */
168
- const MAX_DISPUTE_WINDOW = 30 * 24 * 3600;
169
-
170
- /**
171
- * Zod schema for UnifiedPayParams with strict validation.
172
- */
173
- export const UnifiedPayParamsSchema = z.object({
174
- to: z.string().min(1),
175
- amount: z.union([z.string().min(1), z.number().positive()]),
176
- deadline: z.union([z.string(), z.number()]).optional(),
177
- disputeWindow: z
178
- .number()
179
- .int()
180
- .min(MIN_DISPUTE_WINDOW)
181
- .max(MAX_DISPUTE_WINDOW)
182
- .optional(),
183
- description: z.string().optional(),
184
- metadata: PaymentMetadataSchema.optional(),
185
- erc8004AgentId: z.string().optional(),
186
- });
187
-
188
- // ============================================================================
189
- // UnifiedPayResult - Common result type
190
- // ============================================================================
191
-
192
- /**
193
- * Transaction state after payment initiation.
194
- *
195
- * Note: 'COMMITTED' means funds are locked but work hasn't started.
196
- * 'IN_PROGRESS' means provider has acknowledged and started work.
197
- */
198
- export type InitialTransactionState = 'COMMITTED' | 'IN_PROGRESS';
199
-
200
- /**
201
- * Unified payment result returned by all adapters.
202
- *
203
- * NOTE: success=true means payment INITIATED, not settled.
204
- * Caller must call releaseEscrow() after delivery verification.
205
- */
206
- export interface UnifiedPayResult {
207
- /** ACTP transaction ID */
208
- txId: string;
209
-
210
- /** Escrow ID (for release) - null for non-escrow adapters */
211
- escrowId: string | null;
212
-
213
- /** Adapter that handled the payment */
214
- adapter: string;
215
-
216
- /** Current state (COMMITTED, not SETTLED) */
217
- state: InitialTransactionState;
218
-
219
- /** Whether payment initiation succeeded */
220
- success: boolean;
221
-
222
- /** Amount locked (formatted) */
223
- amount: string;
224
-
225
- /** For x402: the HTTP response */
226
- response?: Response;
227
-
228
- /** Error message if failed */
229
- error?: string;
230
-
231
- /**
232
- * IMPORTANT: Payment is NOT complete until you call:
233
- * await client.release(result.escrowId)
234
- *
235
- * Always true for ACTP-compliant adapters.
236
- */
237
- releaseRequired: boolean;
238
-
239
- /** Provider address (normalized to lowercase) */
240
- provider: string;
241
-
242
- /** Requester address (normalized to lowercase) */
243
- requester: string;
244
-
245
- /** Deadline as ISO 8601 timestamp */
246
- deadline: string;
247
-
248
- /**
249
- * ERC-8004 agent ID (if transaction involved ERC-8004 agent).
250
- * Use with ReputationReporter.reportSettlement() after release.
251
- */
252
- erc8004AgentId?: string;
253
-
254
- /**
255
- * Fee breakdown for x402 payments routed through X402Relay.
256
- * Present only when relay is configured and payment used the relay path.
257
- */
258
- feeBreakdown?: X402FeeBreakdown;
259
- }
260
-
261
- /**
262
- * Zod schema for UnifiedPayResult validation.
263
- */
264
- export const UnifiedPayResultSchema = z.object({
265
- txId: z.string().min(1),
266
- escrowId: z.string().nullable(),
267
- adapter: z.string().min(1),
268
- state: z.enum(['COMMITTED', 'IN_PROGRESS']),
269
- success: z.boolean(),
270
- amount: z.string().min(1),
271
- response: z.any().optional(),
272
- error: z.string().optional(),
273
- releaseRequired: z.boolean(),
274
- provider: z.string().min(1),
275
- requester: z.string().min(1),
276
- deadline: z.string().min(1),
277
- erc8004AgentId: z.string().optional(),
278
- feeBreakdown: z.object({
279
- grossAmount: z.string(),
280
- providerNet: z.string(),
281
- platformFee: z.string(),
282
- feeBps: z.number(),
283
- estimated: z.literal(true),
284
- }).optional(),
285
- });
286
-
287
- // ============================================================================
288
- // Validation Helpers
289
- // ============================================================================
290
-
291
- /**
292
- * Validates UnifiedPayParams at runtime.
293
- *
294
- * @param params - Parameters to validate
295
- * @returns Validated params
296
- * @throws {z.ZodError} If validation fails
297
- */
298
- export function validatePayParams(params: unknown): UnifiedPayParams {
299
- return UnifiedPayParamsSchema.parse(params);
300
- }
301
-
302
- /**
303
- * Safe parse for UnifiedPayParams (doesn't throw).
304
- *
305
- * @param params - Parameters to validate
306
- * @returns Result with success flag and data or error
307
- */
308
- export function safeValidatePayParams(params: unknown): z.SafeParseReturnType<unknown, UnifiedPayParams> {
309
- return UnifiedPayParamsSchema.safeParse(params);
310
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * Agent Registry Types (AIP-7)
3
- *
4
- * Types for AI agent identity, registration, and reputation
5
- */
6
-
7
- /**
8
- * Service descriptor metadata for an agent
9
- */
10
- export interface ServiceDescriptor {
11
- /** keccak256(lowercase(serviceType)) */
12
- serviceTypeHash: string;
13
- /** Human-readable service type (lowercase, alphanumeric + hyphens) */
14
- serviceType: string;
15
- /** IPFS/HTTPS URL to JSON Schema for inputData */
16
- schemaURI: string;
17
- /** Minimum price in USDC base units (6 decimals) */
18
- minPrice: bigint;
19
- /** Maximum price in USDC base units */
20
- maxPrice: bigint;
21
- /** Average completion time in seconds */
22
- avgCompletionTime: number;
23
- /** IPFS CID to full service descriptor JSON */
24
- metadataCID: string;
25
- }
26
-
27
- /**
28
- * Agent profile stored on-chain
29
- */
30
- export interface AgentProfile {
31
- /** Agent's Ethereum address (controller of DID) */
32
- agentAddress: string;
33
- /** Full DID (e.g., did:ethr:8453:0x...) */
34
- did: string;
35
- /** HTTPS endpoint or IPFS gateway URL */
36
- endpoint: string;
37
- /** Supported service type hashes */
38
- serviceTypes: string[];
39
- /** USDC staked (V1: always 0, V2: slashing for disputes) */
40
- stakedAmount: bigint;
41
- /** Aggregated reputation (scale: 0-10000, 2 decimals precision) */
42
- reputationScore: number;
43
- /** Count of completed SETTLED transactions */
44
- totalTransactions: number;
45
- /** Count of transactions that went to DISPUTED state */
46
- disputedTransactions: number;
47
- /** Cumulative transaction volume (6 decimals) */
48
- totalVolumeUSDC: bigint;
49
- /** Block timestamp of registration */
50
- registeredAt: number;
51
- /** Last profile update timestamp */
52
- updatedAt: number;
53
- /** Agent is accepting new requests */
54
- isActive: boolean;
55
- }
56
-
57
- /**
58
- * Parameters for registering a new agent
59
- */
60
- export interface RegisterAgentParams {
61
- /** HTTPS endpoint or IPFS gateway URL */
62
- endpoint: string;
63
- /** List of services the agent provides */
64
- serviceDescriptors: ServiceDescriptor[];
65
- }
66
-
67
- /**
68
- * Query parameters for finding agents by service
69
- */
70
- export interface QueryAgentsParams {
71
- /** Service type hash to search for */
72
- serviceTypeHash: string;
73
- /** Minimum reputation score (0-10000) */
74
- minReputation?: number;
75
- /** Skip first N results (for pagination) */
76
- offset?: number;
77
- /** Maximum number of results to return */
78
- limit?: number;
79
- }
package/src/types/did.ts DELETED
@@ -1,223 +0,0 @@
1
- /**
2
- * DID (Decentralized Identity) Types - AIP-7 §2
3
- *
4
- * Implements W3C DID specification for Ethereum-based identities
5
- * using the did:ethr method with ERC-1056 registry
6
- */
7
-
8
- /**
9
- * DID format: did:ethr:<chainId>:<address>
10
- * Example: did:ethr:84532:0x742d35cc6634c0532925a3b844bc9e7595f0beb
11
- */
12
- export type DID = string;
13
-
14
- /**
15
- * W3C DID Document structure
16
- * @see https://www.w3.org/TR/did-core/
17
- */
18
- export interface DIDDocument {
19
- '@context': string | string[];
20
- id: DID;
21
- verificationMethod?: VerificationMethod[];
22
- authentication?: (string | VerificationMethod)[];
23
- assertionMethod?: (string | VerificationMethod)[];
24
- keyAgreement?: (string | VerificationMethod)[];
25
- capabilityInvocation?: (string | VerificationMethod)[];
26
- capabilityDelegation?: (string | VerificationMethod)[];
27
- service?: ServiceEndpoint[];
28
- }
29
-
30
- /**
31
- * Verification method for cryptographic key
32
- */
33
- export interface VerificationMethod {
34
- id: string;
35
- type: string;
36
- controller: DID;
37
- blockchainAccountId?: string; // CAIP-10 format: address@eip155:chainId
38
- publicKeyHex?: string;
39
- publicKeyBase58?: string;
40
- publicKeyMultibase?: string;
41
- ethereumAddress?: string;
42
- validTo?: number | bigint; // Unix timestamp for delegate validity (ERC-1056)
43
- }
44
-
45
- /**
46
- * Service endpoint in DID Document
47
- */
48
- export interface ServiceEndpoint {
49
- id: string;
50
- type: string;
51
- serviceEndpoint: string | string[] | Record<string, unknown>;
52
- description?: string;
53
- }
54
-
55
- /**
56
- * DID Resolution result
57
- */
58
- export interface DIDResolutionResult {
59
- didDocument: DIDDocument | null;
60
- didResolutionMetadata: DIDResolutionMetadata;
61
- didDocumentMetadata: DIDDocumentMetadata;
62
- }
63
-
64
- /**
65
- * DID Resolution metadata
66
- */
67
- export interface DIDResolutionMetadata {
68
- contentType?: string;
69
- error?: 'invalidDid' | 'notFound' | 'representationNotSupported' | 'unsupportedDidMethod' | string;
70
- message?: string;
71
- }
72
-
73
- /**
74
- * DID Document metadata
75
- */
76
- export interface DIDDocumentMetadata {
77
- created?: string;
78
- updated?: string;
79
- deactivated?: boolean;
80
- versionId?: string;
81
- nextUpdate?: string;
82
- nextVersionId?: string;
83
- }
84
-
85
- /**
86
- * Configuration for DID Resolver
87
- */
88
- export interface DIDResolverConfig {
89
- /**
90
- * Network to use (base-sepolia or base-mainnet)
91
- */
92
- network?: string;
93
-
94
- /**
95
- * Custom RPC URL (overrides network default)
96
- */
97
- rpcUrl?: string;
98
-
99
- /**
100
- * Custom Identity Registry address (overrides network default)
101
- */
102
- registryAddress?: string;
103
-
104
- /**
105
- * Chain ID (required if not using predefined network)
106
- */
107
- chainId?: number;
108
- }
109
-
110
- /**
111
- * Parsed DID components
112
- */
113
- export interface ParsedDID {
114
- method: string; // Always 'ethr' for AGIRAILS
115
- chainId: number;
116
- address: string; // Lowercase checksummed address
117
- }
118
-
119
- /**
120
- * ERC-1056 Identity Changed Event
121
- */
122
- export interface DIDOwnerChangedEvent {
123
- identity: string;
124
- owner: string;
125
- previousChange: bigint;
126
- }
127
-
128
- /**
129
- * ERC-1056 Delegate Changed Event
130
- */
131
- export interface DIDDelegateChangedEvent {
132
- identity: string;
133
- delegateType: string; // bytes32 as hex string
134
- delegate: string;
135
- validTo: bigint;
136
- previousChange: bigint;
137
- }
138
-
139
- /**
140
- * ERC-1056 Attribute Changed Event
141
- */
142
- export interface DIDAttributeChangedEvent {
143
- identity: string;
144
- name: string; // bytes32 as hex string
145
- value: Uint8Array;
146
- validTo: bigint;
147
- previousChange: bigint;
148
- }
149
-
150
- /**
151
- * Delegate types for ERC-1056
152
- */
153
- export enum DelegateType {
154
- /** Can sign on behalf of identity */
155
- SIGNING = 'veriKey',
156
-
157
- /** Can encrypt messages for identity */
158
- ENCRYPTION = 'encryptionKey',
159
-
160
- /** Can perform general actions */
161
- GENERAL = 'delegate',
162
-
163
- /** Custom delegate type */
164
- CUSTOM = 'custom'
165
- }
166
-
167
- /**
168
- * Attribute names for ERC-1056
169
- */
170
- export enum AttributeName {
171
- /** Service endpoint (e.g., AGIRAILS API endpoint) */
172
- SERVICE_ENDPOINT = 'did/svc/AGIRAILSProvider',
173
-
174
- /** Public key for verification */
175
- PUBLIC_KEY = 'did/pub/Secp256k1/veriKey',
176
-
177
- /** Encryption public key */
178
- ENCRYPTION_KEY = 'did/pub/X25519/enc',
179
-
180
- /** Custom attribute */
181
- CUSTOM = 'custom'
182
- }
183
-
184
- /**
185
- * Options for DID signature verification
186
- */
187
- export interface VerifySignatureOptions {
188
- /** Chain ID to verify against (prevents cross-chain replay) */
189
- chainId: number;
190
-
191
- /** Expected DID (optional additional check) */
192
- expectedDID?: DID;
193
-
194
- /** Timestamp for delegate validity check */
195
- timestamp?: number;
196
-
197
- /**
198
- * Use domain separation to prevent cross-protocol replay attacks
199
- * Default: true (recommended for security)
200
- * Set to false only for backwards compatibility with old signatures
201
- */
202
- useDomainSeparation?: boolean;
203
- }
204
-
205
- /**
206
- * Result of signature verification
207
- */
208
- export interface SignatureVerificationResult {
209
- /** Whether signature is valid */
210
- valid: boolean;
211
-
212
- /** Recovered signer address */
213
- signer?: string;
214
-
215
- /** Error message if verification failed */
216
- error?: string;
217
-
218
- /** Whether signer is a delegate (not the owner) */
219
- isDelegate?: boolean;
220
-
221
- /** Delegate type if signer is a delegate */
222
- delegateType?: string;
223
- }