uvd-x402-sdk 2.16.1 → 2.17.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.
Files changed (76) hide show
  1. package/README.md +106 -8
  2. package/dist/adapters/index.d.mts +1 -1
  3. package/dist/adapters/index.d.ts +1 -1
  4. package/dist/adapters/index.js +103 -0
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/adapters/index.mjs +103 -0
  7. package/dist/adapters/index.mjs.map +1 -1
  8. package/dist/backend/index.d.mts +393 -3
  9. package/dist/backend/index.d.ts +393 -3
  10. package/dist/backend/index.js +448 -0
  11. package/dist/backend/index.js.map +1 -1
  12. package/dist/backend/index.mjs +445 -1
  13. package/dist/backend/index.mjs.map +1 -1
  14. package/dist/{index-BYsQM8ga.d.ts → index-BDLgm-Sg.d.mts} +4 -3
  15. package/dist/{index-B_reIs-L.d.mts → index-BE5cH7oS.d.mts} +4 -2
  16. package/dist/{index-B_reIs-L.d.ts → index-BE5cH7oS.d.ts} +4 -2
  17. package/dist/{index-1CWNFuXP.d.mts → index-DDrvK4em.d.ts} +4 -3
  18. package/dist/index.d.mts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +103 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +103 -0
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/providers/algorand/index.d.mts +1 -1
  25. package/dist/providers/algorand/index.d.ts +1 -1
  26. package/dist/providers/algorand/index.js +103 -0
  27. package/dist/providers/algorand/index.js.map +1 -1
  28. package/dist/providers/algorand/index.mjs +103 -0
  29. package/dist/providers/algorand/index.mjs.map +1 -1
  30. package/dist/providers/evm/index.d.mts +1 -1
  31. package/dist/providers/evm/index.d.ts +1 -1
  32. package/dist/providers/evm/index.js +103 -0
  33. package/dist/providers/evm/index.js.map +1 -1
  34. package/dist/providers/evm/index.mjs +103 -0
  35. package/dist/providers/evm/index.mjs.map +1 -1
  36. package/dist/providers/near/index.d.mts +1 -1
  37. package/dist/providers/near/index.d.ts +1 -1
  38. package/dist/providers/near/index.js +103 -0
  39. package/dist/providers/near/index.js.map +1 -1
  40. package/dist/providers/near/index.mjs +103 -0
  41. package/dist/providers/near/index.mjs.map +1 -1
  42. package/dist/providers/solana/index.d.mts +1 -1
  43. package/dist/providers/solana/index.d.ts +1 -1
  44. package/dist/providers/solana/index.js +103 -0
  45. package/dist/providers/solana/index.js.map +1 -1
  46. package/dist/providers/solana/index.mjs +103 -0
  47. package/dist/providers/solana/index.mjs.map +1 -1
  48. package/dist/providers/stellar/index.d.mts +1 -1
  49. package/dist/providers/stellar/index.d.ts +1 -1
  50. package/dist/providers/stellar/index.js +103 -0
  51. package/dist/providers/stellar/index.js.map +1 -1
  52. package/dist/providers/stellar/index.mjs +103 -0
  53. package/dist/providers/stellar/index.mjs.map +1 -1
  54. package/dist/providers/sui/index.d.mts +1 -1
  55. package/dist/providers/sui/index.d.ts +1 -1
  56. package/dist/providers/sui/index.js +105 -1
  57. package/dist/providers/sui/index.js.map +1 -1
  58. package/dist/providers/sui/index.mjs +105 -1
  59. package/dist/providers/sui/index.mjs.map +1 -1
  60. package/dist/react/index.d.mts +3 -3
  61. package/dist/react/index.d.ts +3 -3
  62. package/dist/react/index.js +103 -0
  63. package/dist/react/index.js.map +1 -1
  64. package/dist/react/index.mjs +103 -0
  65. package/dist/react/index.mjs.map +1 -1
  66. package/dist/utils/index.d.mts +1 -1
  67. package/dist/utils/index.d.ts +1 -1
  68. package/dist/utils/index.js +103 -0
  69. package/dist/utils/index.js.map +1 -1
  70. package/dist/utils/index.mjs +103 -0
  71. package/dist/utils/index.mjs.map +1 -1
  72. package/package.json +9 -3
  73. package/src/backend/index.ts +695 -1
  74. package/src/chains/index.ts +102 -2
  75. package/src/providers/sui/index.ts +2 -0
  76. package/src/types/index.ts +7 -2
@@ -1,4 +1,4 @@
1
- import { m as X402Version, n as X402Header } from '../index-B_reIs-L.mjs';
1
+ import { m as X402Version, n as X402Header } from '../index-BE5cH7oS.mjs';
2
2
 
3
3
  /**
4
4
  * uvd-x402-sdk - Backend Utilities
@@ -415,7 +415,7 @@ type BazaarCategory = 'api' | 'data' | 'ai' | 'media' | 'compute' | 'storage' |
415
415
  /**
416
416
  * Network/chain filter for discovery
417
417
  */
418
- type BazaarNetwork = 'base' | 'ethereum' | 'polygon' | 'arbitrum' | 'optimism' | 'avalanche' | 'celo' | 'hyperevm' | 'unichain' | 'monad' | 'solana' | 'fogo' | 'stellar' | 'near';
418
+ type BazaarNetwork = 'base' | 'ethereum' | 'polygon' | 'arbitrum' | 'optimism' | 'avalanche' | 'celo' | 'hyperevm' | 'unichain' | 'monad' | 'scroll' | 'skale' | 'solana' | 'fogo' | 'stellar' | 'near' | 'algorand' | 'sui';
419
419
  /**
420
420
  * Token/asset filter for discovery
421
421
  */
@@ -1032,5 +1032,395 @@ declare function isEscrowExpired(escrow: EscrowPayment): boolean;
1032
1032
  * @returns Milliseconds until expiration (negative if expired)
1033
1033
  */
1034
1034
  declare function escrowTimeRemaining(escrow: EscrowPayment): number;
1035
+ /**
1036
+ * ERC-8004 extension identifier
1037
+ */
1038
+ declare const ERC8004_EXTENSION_ID = "8004-reputation";
1039
+ /**
1040
+ * ERC-8004 contract addresses per network
1041
+ */
1042
+ declare const ERC8004_CONTRACTS: Record<string, {
1043
+ identityRegistry?: string;
1044
+ reputationRegistry?: string;
1045
+ validationRegistry?: string;
1046
+ }>;
1047
+ /**
1048
+ * Network type for ERC-8004 operations
1049
+ */
1050
+ type Erc8004Network = 'ethereum' | 'ethereum-sepolia';
1051
+ /**
1052
+ * Proof of payment returned when settling with ERC-8004 extension
1053
+ */
1054
+ interface ProofOfPayment {
1055
+ /** Transaction hash of the settled payment */
1056
+ transactionHash: string;
1057
+ /** Block number where the transaction was included */
1058
+ blockNumber: number;
1059
+ /** Network where the payment was settled */
1060
+ network: string;
1061
+ /** The payer (consumer/client) address */
1062
+ payer: string;
1063
+ /** The payee (agent/resource owner) address */
1064
+ payee: string;
1065
+ /** Amount paid in token base units */
1066
+ amount: string;
1067
+ /** Token contract address */
1068
+ token: string;
1069
+ /** Unix timestamp of the block */
1070
+ timestamp: number;
1071
+ /** Keccak256 hash of the payment data for verification */
1072
+ paymentHash: string;
1073
+ }
1074
+ /**
1075
+ * Extended settle response with ERC-8004 proof of payment
1076
+ */
1077
+ interface SettleResponseWithProof extends SettleResponse {
1078
+ /** Proof of payment for ERC-8004 reputation submission */
1079
+ proofOfPayment?: ProofOfPayment;
1080
+ }
1081
+ /**
1082
+ * Agent identity from the Identity Registry
1083
+ */
1084
+ interface AgentIdentity {
1085
+ /** The agent's ID (ERC-721 tokenId) */
1086
+ agentId: number;
1087
+ /** Owner address of the agent NFT */
1088
+ owner: string;
1089
+ /** URI pointing to agent registration file */
1090
+ agentUri: string;
1091
+ /** Payment wallet address (if set) */
1092
+ agentWallet?: string;
1093
+ /** Network where the agent is registered */
1094
+ network: Erc8004Network;
1095
+ }
1096
+ /**
1097
+ * Agent registration file structure (resolved from agentURI)
1098
+ */
1099
+ interface AgentRegistrationFile {
1100
+ /** Type identifier */
1101
+ type: string;
1102
+ /** Agent name */
1103
+ name: string;
1104
+ /** Agent description */
1105
+ description: string;
1106
+ /** Image URL */
1107
+ image?: string;
1108
+ /** List of services the agent provides */
1109
+ services: AgentService[];
1110
+ /** Whether x402 payments are supported */
1111
+ x402Support: boolean;
1112
+ /** Whether the agent is active */
1113
+ active: boolean;
1114
+ /** List of registrations across chains */
1115
+ registrations: AgentRegistration[];
1116
+ /** Supported trust models */
1117
+ supportedTrust: string[];
1118
+ }
1119
+ /**
1120
+ * Agent service entry
1121
+ */
1122
+ interface AgentService {
1123
+ name: string;
1124
+ endpoint: string;
1125
+ version?: string;
1126
+ }
1127
+ /**
1128
+ * Agent registration reference
1129
+ */
1130
+ interface AgentRegistration {
1131
+ agentId: number;
1132
+ agentRegistry: string;
1133
+ }
1134
+ /**
1135
+ * Reputation summary for an agent
1136
+ */
1137
+ interface ReputationSummary {
1138
+ /** Agent ID */
1139
+ agentId: number;
1140
+ /** Number of feedback entries */
1141
+ count: number;
1142
+ /** Aggregated value */
1143
+ summaryValue: number;
1144
+ /** Decimal places for summaryValue */
1145
+ summaryValueDecimals: number;
1146
+ /** Network */
1147
+ network: Erc8004Network;
1148
+ }
1149
+ /**
1150
+ * Individual feedback entry
1151
+ */
1152
+ interface FeedbackEntry {
1153
+ /** Client who submitted the feedback */
1154
+ client: string;
1155
+ /** Feedback index (1-indexed) */
1156
+ feedbackIndex: number;
1157
+ /** Feedback value */
1158
+ value: number;
1159
+ /** Value decimals */
1160
+ valueDecimals: number;
1161
+ /** Primary tag */
1162
+ tag1: string;
1163
+ /** Secondary tag */
1164
+ tag2: string;
1165
+ /** Whether this feedback was revoked */
1166
+ isRevoked: boolean;
1167
+ }
1168
+ /**
1169
+ * Parameters for submitting reputation feedback
1170
+ */
1171
+ interface FeedbackParams {
1172
+ /** The agent's ID (tokenId in Identity Registry) */
1173
+ agentId: number;
1174
+ /** Feedback value (e.g., 87 for 87/100) */
1175
+ value: number;
1176
+ /** Decimal places for value interpretation (0-18) */
1177
+ valueDecimals?: number;
1178
+ /** Primary categorization tag (e.g., "starred", "uptime") */
1179
+ tag1?: string;
1180
+ /** Secondary categorization tag */
1181
+ tag2?: string;
1182
+ /** Service endpoint that was used */
1183
+ endpoint?: string;
1184
+ /** URI to off-chain feedback file (IPFS, HTTPS) */
1185
+ feedbackUri?: string;
1186
+ /** Keccak256 hash of feedback content (for integrity) */
1187
+ feedbackHash?: string;
1188
+ /** Proof of payment (required for authorized feedback) */
1189
+ proof?: ProofOfPayment;
1190
+ }
1191
+ /**
1192
+ * Feedback request body for POST /feedback
1193
+ */
1194
+ interface FeedbackRequest {
1195
+ /** x402 protocol version */
1196
+ x402Version: 1 | 2;
1197
+ /** Network where feedback will be submitted */
1198
+ network: Erc8004Network;
1199
+ /** Feedback parameters */
1200
+ feedback: FeedbackParams;
1201
+ }
1202
+ /**
1203
+ * Feedback response from POST /feedback
1204
+ */
1205
+ interface FeedbackResponse {
1206
+ /** Whether the feedback was successfully submitted */
1207
+ success: boolean;
1208
+ /** Transaction hash of the feedback submission */
1209
+ transaction?: string;
1210
+ /** Feedback index assigned (1-indexed) */
1211
+ feedbackIndex?: number;
1212
+ /** Error message (if failed) */
1213
+ error?: string;
1214
+ /** Network where feedback was submitted */
1215
+ network: Erc8004Network;
1216
+ }
1217
+ /**
1218
+ * Reputation query response
1219
+ */
1220
+ interface ReputationResponse {
1221
+ agentId: number;
1222
+ summary: ReputationSummary;
1223
+ feedback?: FeedbackEntry[];
1224
+ network: Erc8004Network;
1225
+ }
1226
+ /**
1227
+ * Options for the ERC8004Client
1228
+ */
1229
+ interface Erc8004ClientOptions {
1230
+ /** Base URL of the facilitator (default: https://facilitator.ultravioletadao.xyz) */
1231
+ baseUrl?: string;
1232
+ /** Request timeout in milliseconds (default: 30000) */
1233
+ timeout?: number;
1234
+ }
1235
+ /**
1236
+ * Client for ERC-8004 Trustless Agents API
1237
+ *
1238
+ * Provides methods for:
1239
+ * - Querying agent identity
1240
+ * - Querying agent reputation
1241
+ * - Submitting reputation feedback
1242
+ * - Revoking feedback
1243
+ *
1244
+ * @example
1245
+ * ```ts
1246
+ * const client = new Erc8004Client();
1247
+ *
1248
+ * // Get agent identity
1249
+ * const identity = await client.getIdentity('ethereum', 42);
1250
+ * console.log(identity.agentUri);
1251
+ *
1252
+ * // Get agent reputation
1253
+ * const reputation = await client.getReputation('ethereum', 42);
1254
+ * console.log(`Score: ${reputation.summary.summaryValue}`);
1255
+ *
1256
+ * // Submit feedback after payment
1257
+ * const result = await client.submitFeedback({
1258
+ * x402Version: 1,
1259
+ * network: 'ethereum',
1260
+ * feedback: {
1261
+ * agentId: 42,
1262
+ * value: 95,
1263
+ * valueDecimals: 0,
1264
+ * tag1: 'quality',
1265
+ * proof: settleResponse.proofOfPayment,
1266
+ * },
1267
+ * });
1268
+ * ```
1269
+ */
1270
+ declare class Erc8004Client {
1271
+ private readonly baseUrl;
1272
+ private readonly timeout;
1273
+ constructor(options?: Erc8004ClientOptions);
1274
+ /**
1275
+ * Get agent identity from the Identity Registry
1276
+ *
1277
+ * @param network - Network where agent is registered
1278
+ * @param agentId - Agent's tokenId
1279
+ * @returns Agent identity information
1280
+ */
1281
+ getIdentity(network: Erc8004Network, agentId: number): Promise<AgentIdentity>;
1282
+ /**
1283
+ * Resolve agent registration file from agentURI
1284
+ *
1285
+ * @param agentUri - URI pointing to agent registration file
1286
+ * @returns Resolved agent registration file
1287
+ */
1288
+ resolveAgentUri(agentUri: string): Promise<AgentRegistrationFile>;
1289
+ /**
1290
+ * Get agent reputation from the Reputation Registry
1291
+ *
1292
+ * @param network - Network where agent is registered
1293
+ * @param agentId - Agent's tokenId
1294
+ * @param options - Query options (tag filters, include individual feedback)
1295
+ * @returns Reputation summary and optionally individual feedback entries
1296
+ */
1297
+ getReputation(network: Erc8004Network, agentId: number, options?: {
1298
+ tag1?: string;
1299
+ tag2?: string;
1300
+ includeFeedback?: boolean;
1301
+ }): Promise<ReputationResponse>;
1302
+ /**
1303
+ * Submit reputation feedback for an agent
1304
+ *
1305
+ * Requires proof of payment for authorized feedback submission.
1306
+ *
1307
+ * @param request - Feedback request with agent ID, value, and proof
1308
+ * @returns Feedback response with transaction hash
1309
+ *
1310
+ * @example
1311
+ * ```ts
1312
+ * // After settling a payment with ERC-8004 extension
1313
+ * const settleResult = await facilitator.settle(payment, {
1314
+ * ...requirements,
1315
+ * extra: { '8004-reputation': { includeProof: true } },
1316
+ * });
1317
+ *
1318
+ * // Submit feedback with proof of payment
1319
+ * const feedback = await erc8004.submitFeedback({
1320
+ * x402Version: 1,
1321
+ * network: 'ethereum',
1322
+ * feedback: {
1323
+ * agentId: 42,
1324
+ * value: 95, // 95/100
1325
+ * valueDecimals: 0,
1326
+ * tag1: 'quality',
1327
+ * tag2: 'response-time',
1328
+ * proof: settleResult.proofOfPayment,
1329
+ * },
1330
+ * });
1331
+ * ```
1332
+ */
1333
+ submitFeedback(request: FeedbackRequest): Promise<FeedbackResponse>;
1334
+ /**
1335
+ * Revoke previously submitted feedback
1336
+ *
1337
+ * Only the original submitter can revoke their feedback.
1338
+ *
1339
+ * @param network - Network where feedback was submitted
1340
+ * @param agentId - Agent ID
1341
+ * @param feedbackIndex - Index of feedback to revoke
1342
+ * @returns Revocation result
1343
+ */
1344
+ revokeFeedback(network: Erc8004Network, agentId: number, feedbackIndex: number): Promise<FeedbackResponse>;
1345
+ /**
1346
+ * Get ERC-8004 contract addresses for a network
1347
+ *
1348
+ * @param network - Network to get contracts for
1349
+ * @returns Contract addresses or undefined if not deployed
1350
+ */
1351
+ getContracts(network: Erc8004Network): typeof ERC8004_CONTRACTS[Erc8004Network] | undefined;
1352
+ /**
1353
+ * Check if ERC-8004 is available on a network
1354
+ *
1355
+ * @param network - Network to check
1356
+ * @returns True if ERC-8004 contracts are deployed
1357
+ */
1358
+ isAvailable(network: string): network is Erc8004Network;
1359
+ /**
1360
+ * Get feedback endpoint metadata
1361
+ *
1362
+ * @returns Endpoint information for /feedback
1363
+ */
1364
+ getFeedbackMetadata(): Promise<{
1365
+ endpoint: string;
1366
+ supportedNetworks: Erc8004Network[];
1367
+ version: string;
1368
+ }>;
1369
+ /**
1370
+ * Append a response to existing feedback
1371
+ *
1372
+ * Allows agents to respond to feedback they received.
1373
+ * Only the agent (identity owner) can append responses.
1374
+ *
1375
+ * @param network - Network where feedback was submitted
1376
+ * @param agentId - Agent ID
1377
+ * @param feedbackIndex - Index of feedback to respond to
1378
+ * @param response - Response content
1379
+ * @param responseUri - Optional URI to off-chain response file
1380
+ * @returns Response result
1381
+ *
1382
+ * @example
1383
+ * ```ts
1384
+ * // Agent responds to feedback
1385
+ * const result = await erc8004.appendResponse(
1386
+ * 'ethereum',
1387
+ * 42,
1388
+ * 1,
1389
+ * 'Thank you for your feedback! We have addressed the issue.',
1390
+ * );
1391
+ * ```
1392
+ */
1393
+ appendResponse(network: Erc8004Network, agentId: number, feedbackIndex: number, response: string, responseUri?: string): Promise<FeedbackResponse>;
1394
+ }
1395
+ /**
1396
+ * Build payment requirements with ERC-8004 extension
1397
+ *
1398
+ * Adds the 8004-reputation extension to include proof of payment
1399
+ * in settlement responses for reputation submission.
1400
+ *
1401
+ * @param options - Base payment requirements options
1402
+ * @returns Payment requirements with ERC-8004 extension
1403
+ *
1404
+ * @example
1405
+ * ```ts
1406
+ * const requirements = buildErc8004PaymentRequirements({
1407
+ * amount: '1.00',
1408
+ * recipient: '0x...',
1409
+ * resource: 'https://api.example.com/service',
1410
+ * chainName: 'ethereum',
1411
+ * });
1412
+ *
1413
+ * // Settlement will include proofOfPayment
1414
+ * const result = await facilitator.settle(payment, requirements);
1415
+ * console.log(result.proofOfPayment);
1416
+ * ```
1417
+ */
1418
+ declare function buildErc8004PaymentRequirements(options: PaymentRequirementsOptions): PaymentRequirements & {
1419
+ extra: {
1420
+ '8004-reputation': {
1421
+ includeProof: boolean;
1422
+ };
1423
+ };
1424
+ };
1035
1425
 
1036
- export { type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, type Dispute, type DisputeOutcome, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type PaymentRequirements, type PaymentRequirementsOptions, type RefundRequest, type RefundStatus, type RequestRefundOptions, type SettleRequest, type SettleResponse, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
1426
+ export { type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };