uvd-x402-sdk 2.19.0 → 2.20.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/dist/backend/index.d.mts +123 -2
- package/dist/backend/index.d.ts +123 -2
- package/dist/backend/index.js +144 -0
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +144 -0
- package/dist/backend/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +247 -1
package/dist/backend/index.d.mts
CHANGED
|
@@ -1226,6 +1226,73 @@ interface ReputationResponse {
|
|
|
1226
1226
|
feedback?: FeedbackEntry[];
|
|
1227
1227
|
network: Erc8004Network;
|
|
1228
1228
|
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Key-value metadata entry for agent registration
|
|
1231
|
+
*/
|
|
1232
|
+
interface MetadataEntryParam {
|
|
1233
|
+
/** Metadata key */
|
|
1234
|
+
key: string;
|
|
1235
|
+
/** Metadata value (hex-encoded bytes or UTF-8 string) */
|
|
1236
|
+
value: string;
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Request body for POST /register
|
|
1240
|
+
*/
|
|
1241
|
+
interface RegisterAgentRequest {
|
|
1242
|
+
/** x402 protocol version */
|
|
1243
|
+
x402Version: 1 | 2;
|
|
1244
|
+
/** Network where agent will be registered */
|
|
1245
|
+
network: Erc8004Network;
|
|
1246
|
+
/** URI pointing to agent registration file (IPFS, HTTPS) */
|
|
1247
|
+
agentUri: string;
|
|
1248
|
+
/** Optional metadata key-value pairs */
|
|
1249
|
+
metadata?: MetadataEntryParam[];
|
|
1250
|
+
/** Optional recipient address - NFT is transferred to this address after minting */
|
|
1251
|
+
recipient?: string;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Response from POST /register
|
|
1255
|
+
*/
|
|
1256
|
+
interface RegisterAgentResponse {
|
|
1257
|
+
/** Whether registration succeeded */
|
|
1258
|
+
success: boolean;
|
|
1259
|
+
/** The newly assigned agent ID (ERC-721 tokenId) */
|
|
1260
|
+
agentId?: number;
|
|
1261
|
+
/** Registration transaction hash */
|
|
1262
|
+
transaction?: string;
|
|
1263
|
+
/** Transfer transaction hash (if recipient was specified) */
|
|
1264
|
+
transferTransaction?: string;
|
|
1265
|
+
/** Owner address of the agent NFT */
|
|
1266
|
+
owner?: string;
|
|
1267
|
+
/** Error message if failed */
|
|
1268
|
+
error?: string;
|
|
1269
|
+
/** Network where agent was registered */
|
|
1270
|
+
network: string;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Response from GET /identity/{network}/{agent_id}/metadata/{key}
|
|
1274
|
+
*/
|
|
1275
|
+
interface IdentityMetadataResponse {
|
|
1276
|
+
/** Agent ID */
|
|
1277
|
+
agentId: number;
|
|
1278
|
+
/** Metadata key */
|
|
1279
|
+
key: string;
|
|
1280
|
+
/** Raw hex-encoded value */
|
|
1281
|
+
valueHex: string;
|
|
1282
|
+
/** UTF-8 decoded value (if decodable) */
|
|
1283
|
+
valueUtf8?: string;
|
|
1284
|
+
/** Network */
|
|
1285
|
+
network: string;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Response from GET /identity/{network}/total-supply
|
|
1289
|
+
*/
|
|
1290
|
+
interface IdentityTotalSupplyResponse {
|
|
1291
|
+
/** Total number of registered agents */
|
|
1292
|
+
totalSupply: number;
|
|
1293
|
+
/** Network */
|
|
1294
|
+
network: string;
|
|
1295
|
+
}
|
|
1229
1296
|
/**
|
|
1230
1297
|
* Options for the ERC8004Client
|
|
1231
1298
|
*/
|
|
@@ -1239,7 +1306,9 @@ interface Erc8004ClientOptions {
|
|
|
1239
1306
|
* Client for ERC-8004 Trustless Agents API
|
|
1240
1307
|
*
|
|
1241
1308
|
* Provides methods for:
|
|
1242
|
-
* -
|
|
1309
|
+
* - Registering new agents (gasless, facilitator pays gas)
|
|
1310
|
+
* - Registering agents on behalf of users (gasless delegation)
|
|
1311
|
+
* - Querying agent identity, metadata, and total supply
|
|
1243
1312
|
* - Querying agent reputation
|
|
1244
1313
|
* - Submitting reputation feedback
|
|
1245
1314
|
* - Revoking feedback
|
|
@@ -1394,6 +1463,58 @@ declare class Erc8004Client {
|
|
|
1394
1463
|
* ```
|
|
1395
1464
|
*/
|
|
1396
1465
|
appendResponse(network: Erc8004Network, agentId: number, feedbackIndex: number, response: string, responseUri?: string): Promise<FeedbackResponse>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Register a new agent on the Identity Registry
|
|
1468
|
+
*
|
|
1469
|
+
* The facilitator pays gas fees. Optionally transfer the NFT to a
|
|
1470
|
+
* recipient address (gasless delegation).
|
|
1471
|
+
*
|
|
1472
|
+
* @param request - Registration request
|
|
1473
|
+
* @returns Registration response with agent ID and transaction hash
|
|
1474
|
+
*
|
|
1475
|
+
* @example
|
|
1476
|
+
* ```ts
|
|
1477
|
+
* // Register agent owned by facilitator
|
|
1478
|
+
* const result = await client.registerAgent({
|
|
1479
|
+
* x402Version: 1,
|
|
1480
|
+
* network: 'ethereum',
|
|
1481
|
+
* agentUri: 'ipfs://QmYourAgentFile',
|
|
1482
|
+
* });
|
|
1483
|
+
* console.log(`Agent #${result.agentId} registered`);
|
|
1484
|
+
*
|
|
1485
|
+
* // Register agent and transfer to user
|
|
1486
|
+
* const result = await client.registerAgent({
|
|
1487
|
+
* x402Version: 1,
|
|
1488
|
+
* network: 'ethereum',
|
|
1489
|
+
* agentUri: 'ipfs://QmYourAgentFile',
|
|
1490
|
+
* recipient: '0xUserAddress...',
|
|
1491
|
+
* });
|
|
1492
|
+
* console.log(`Agent #${result.agentId} transferred to user`);
|
|
1493
|
+
* ```
|
|
1494
|
+
*/
|
|
1495
|
+
registerAgent(request: RegisterAgentRequest): Promise<RegisterAgentResponse>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Get registration endpoint metadata
|
|
1498
|
+
*
|
|
1499
|
+
* @returns Endpoint information for POST /register
|
|
1500
|
+
*/
|
|
1501
|
+
getRegisterInfo(): Promise<Record<string, unknown>>;
|
|
1502
|
+
/**
|
|
1503
|
+
* Get a specific metadata entry for an agent
|
|
1504
|
+
*
|
|
1505
|
+
* @param network - Network where agent is registered
|
|
1506
|
+
* @param agentId - Agent's tokenId
|
|
1507
|
+
* @param key - Metadata key to retrieve
|
|
1508
|
+
* @returns Metadata value (hex-encoded and UTF-8 decoded if possible)
|
|
1509
|
+
*/
|
|
1510
|
+
getIdentityMetadata(network: Erc8004Network, agentId: number, key: string): Promise<IdentityMetadataResponse>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Get total number of registered agents on a network
|
|
1513
|
+
*
|
|
1514
|
+
* @param network - Network to query
|
|
1515
|
+
* @returns Total supply count
|
|
1516
|
+
*/
|
|
1517
|
+
getIdentityTotalSupply(network: Erc8004Network): Promise<IdentityTotalSupplyResponse>;
|
|
1397
1518
|
}
|
|
1398
1519
|
/**
|
|
1399
1520
|
* Build payment requirements with ERC-8004 extension
|
|
@@ -1639,4 +1760,4 @@ declare class AdvancedEscrowClient {
|
|
|
1639
1760
|
refundPostEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string, tokenCollector?: string, collectorData?: string): Promise<AdvancedTransactionResult>;
|
|
1640
1761
|
}
|
|
1641
1762
|
|
|
1642
|
-
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, 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, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|
|
1763
|
+
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, 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 IdentityMetadataResponse, type IdentityTotalSupplyResponse, type MetadataEntryParam, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -1226,6 +1226,73 @@ interface ReputationResponse {
|
|
|
1226
1226
|
feedback?: FeedbackEntry[];
|
|
1227
1227
|
network: Erc8004Network;
|
|
1228
1228
|
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Key-value metadata entry for agent registration
|
|
1231
|
+
*/
|
|
1232
|
+
interface MetadataEntryParam {
|
|
1233
|
+
/** Metadata key */
|
|
1234
|
+
key: string;
|
|
1235
|
+
/** Metadata value (hex-encoded bytes or UTF-8 string) */
|
|
1236
|
+
value: string;
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Request body for POST /register
|
|
1240
|
+
*/
|
|
1241
|
+
interface RegisterAgentRequest {
|
|
1242
|
+
/** x402 protocol version */
|
|
1243
|
+
x402Version: 1 | 2;
|
|
1244
|
+
/** Network where agent will be registered */
|
|
1245
|
+
network: Erc8004Network;
|
|
1246
|
+
/** URI pointing to agent registration file (IPFS, HTTPS) */
|
|
1247
|
+
agentUri: string;
|
|
1248
|
+
/** Optional metadata key-value pairs */
|
|
1249
|
+
metadata?: MetadataEntryParam[];
|
|
1250
|
+
/** Optional recipient address - NFT is transferred to this address after minting */
|
|
1251
|
+
recipient?: string;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Response from POST /register
|
|
1255
|
+
*/
|
|
1256
|
+
interface RegisterAgentResponse {
|
|
1257
|
+
/** Whether registration succeeded */
|
|
1258
|
+
success: boolean;
|
|
1259
|
+
/** The newly assigned agent ID (ERC-721 tokenId) */
|
|
1260
|
+
agentId?: number;
|
|
1261
|
+
/** Registration transaction hash */
|
|
1262
|
+
transaction?: string;
|
|
1263
|
+
/** Transfer transaction hash (if recipient was specified) */
|
|
1264
|
+
transferTransaction?: string;
|
|
1265
|
+
/** Owner address of the agent NFT */
|
|
1266
|
+
owner?: string;
|
|
1267
|
+
/** Error message if failed */
|
|
1268
|
+
error?: string;
|
|
1269
|
+
/** Network where agent was registered */
|
|
1270
|
+
network: string;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Response from GET /identity/{network}/{agent_id}/metadata/{key}
|
|
1274
|
+
*/
|
|
1275
|
+
interface IdentityMetadataResponse {
|
|
1276
|
+
/** Agent ID */
|
|
1277
|
+
agentId: number;
|
|
1278
|
+
/** Metadata key */
|
|
1279
|
+
key: string;
|
|
1280
|
+
/** Raw hex-encoded value */
|
|
1281
|
+
valueHex: string;
|
|
1282
|
+
/** UTF-8 decoded value (if decodable) */
|
|
1283
|
+
valueUtf8?: string;
|
|
1284
|
+
/** Network */
|
|
1285
|
+
network: string;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Response from GET /identity/{network}/total-supply
|
|
1289
|
+
*/
|
|
1290
|
+
interface IdentityTotalSupplyResponse {
|
|
1291
|
+
/** Total number of registered agents */
|
|
1292
|
+
totalSupply: number;
|
|
1293
|
+
/** Network */
|
|
1294
|
+
network: string;
|
|
1295
|
+
}
|
|
1229
1296
|
/**
|
|
1230
1297
|
* Options for the ERC8004Client
|
|
1231
1298
|
*/
|
|
@@ -1239,7 +1306,9 @@ interface Erc8004ClientOptions {
|
|
|
1239
1306
|
* Client for ERC-8004 Trustless Agents API
|
|
1240
1307
|
*
|
|
1241
1308
|
* Provides methods for:
|
|
1242
|
-
* -
|
|
1309
|
+
* - Registering new agents (gasless, facilitator pays gas)
|
|
1310
|
+
* - Registering agents on behalf of users (gasless delegation)
|
|
1311
|
+
* - Querying agent identity, metadata, and total supply
|
|
1243
1312
|
* - Querying agent reputation
|
|
1244
1313
|
* - Submitting reputation feedback
|
|
1245
1314
|
* - Revoking feedback
|
|
@@ -1394,6 +1463,58 @@ declare class Erc8004Client {
|
|
|
1394
1463
|
* ```
|
|
1395
1464
|
*/
|
|
1396
1465
|
appendResponse(network: Erc8004Network, agentId: number, feedbackIndex: number, response: string, responseUri?: string): Promise<FeedbackResponse>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Register a new agent on the Identity Registry
|
|
1468
|
+
*
|
|
1469
|
+
* The facilitator pays gas fees. Optionally transfer the NFT to a
|
|
1470
|
+
* recipient address (gasless delegation).
|
|
1471
|
+
*
|
|
1472
|
+
* @param request - Registration request
|
|
1473
|
+
* @returns Registration response with agent ID and transaction hash
|
|
1474
|
+
*
|
|
1475
|
+
* @example
|
|
1476
|
+
* ```ts
|
|
1477
|
+
* // Register agent owned by facilitator
|
|
1478
|
+
* const result = await client.registerAgent({
|
|
1479
|
+
* x402Version: 1,
|
|
1480
|
+
* network: 'ethereum',
|
|
1481
|
+
* agentUri: 'ipfs://QmYourAgentFile',
|
|
1482
|
+
* });
|
|
1483
|
+
* console.log(`Agent #${result.agentId} registered`);
|
|
1484
|
+
*
|
|
1485
|
+
* // Register agent and transfer to user
|
|
1486
|
+
* const result = await client.registerAgent({
|
|
1487
|
+
* x402Version: 1,
|
|
1488
|
+
* network: 'ethereum',
|
|
1489
|
+
* agentUri: 'ipfs://QmYourAgentFile',
|
|
1490
|
+
* recipient: '0xUserAddress...',
|
|
1491
|
+
* });
|
|
1492
|
+
* console.log(`Agent #${result.agentId} transferred to user`);
|
|
1493
|
+
* ```
|
|
1494
|
+
*/
|
|
1495
|
+
registerAgent(request: RegisterAgentRequest): Promise<RegisterAgentResponse>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Get registration endpoint metadata
|
|
1498
|
+
*
|
|
1499
|
+
* @returns Endpoint information for POST /register
|
|
1500
|
+
*/
|
|
1501
|
+
getRegisterInfo(): Promise<Record<string, unknown>>;
|
|
1502
|
+
/**
|
|
1503
|
+
* Get a specific metadata entry for an agent
|
|
1504
|
+
*
|
|
1505
|
+
* @param network - Network where agent is registered
|
|
1506
|
+
* @param agentId - Agent's tokenId
|
|
1507
|
+
* @param key - Metadata key to retrieve
|
|
1508
|
+
* @returns Metadata value (hex-encoded and UTF-8 decoded if possible)
|
|
1509
|
+
*/
|
|
1510
|
+
getIdentityMetadata(network: Erc8004Network, agentId: number, key: string): Promise<IdentityMetadataResponse>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Get total number of registered agents on a network
|
|
1513
|
+
*
|
|
1514
|
+
* @param network - Network to query
|
|
1515
|
+
* @returns Total supply count
|
|
1516
|
+
*/
|
|
1517
|
+
getIdentityTotalSupply(network: Erc8004Network): Promise<IdentityTotalSupplyResponse>;
|
|
1397
1518
|
}
|
|
1398
1519
|
/**
|
|
1399
1520
|
* Build payment requirements with ERC-8004 extension
|
|
@@ -1639,4 +1760,4 @@ declare class AdvancedEscrowClient {
|
|
|
1639
1760
|
refundPostEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string, tokenCollector?: string, collectorData?: string): Promise<AdvancedTransactionResult>;
|
|
1640
1761
|
}
|
|
1641
1762
|
|
|
1642
|
-
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, 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, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|
|
1763
|
+
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, 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 IdentityMetadataResponse, type IdentityTotalSupplyResponse, type MetadataEntryParam, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|
package/dist/backend/index.js
CHANGED
|
@@ -2287,6 +2287,150 @@ var Erc8004Client = class {
|
|
|
2287
2287
|
};
|
|
2288
2288
|
}
|
|
2289
2289
|
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Register a new agent on the Identity Registry
|
|
2292
|
+
*
|
|
2293
|
+
* The facilitator pays gas fees. Optionally transfer the NFT to a
|
|
2294
|
+
* recipient address (gasless delegation).
|
|
2295
|
+
*
|
|
2296
|
+
* @param request - Registration request
|
|
2297
|
+
* @returns Registration response with agent ID and transaction hash
|
|
2298
|
+
*
|
|
2299
|
+
* @example
|
|
2300
|
+
* ```ts
|
|
2301
|
+
* // Register agent owned by facilitator
|
|
2302
|
+
* const result = await client.registerAgent({
|
|
2303
|
+
* x402Version: 1,
|
|
2304
|
+
* network: 'ethereum',
|
|
2305
|
+
* agentUri: 'ipfs://QmYourAgentFile',
|
|
2306
|
+
* });
|
|
2307
|
+
* console.log(`Agent #${result.agentId} registered`);
|
|
2308
|
+
*
|
|
2309
|
+
* // Register agent and transfer to user
|
|
2310
|
+
* const result = await client.registerAgent({
|
|
2311
|
+
* x402Version: 1,
|
|
2312
|
+
* network: 'ethereum',
|
|
2313
|
+
* agentUri: 'ipfs://QmYourAgentFile',
|
|
2314
|
+
* recipient: '0xUserAddress...',
|
|
2315
|
+
* });
|
|
2316
|
+
* console.log(`Agent #${result.agentId} transferred to user`);
|
|
2317
|
+
* ```
|
|
2318
|
+
*/
|
|
2319
|
+
async registerAgent(request) {
|
|
2320
|
+
const url = `${this.baseUrl}/register`;
|
|
2321
|
+
const controller = new AbortController();
|
|
2322
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2323
|
+
try {
|
|
2324
|
+
const response = await fetch(url, {
|
|
2325
|
+
method: "POST",
|
|
2326
|
+
headers: {
|
|
2327
|
+
"Content-Type": "application/json",
|
|
2328
|
+
"Accept": "application/json"
|
|
2329
|
+
},
|
|
2330
|
+
body: JSON.stringify(request),
|
|
2331
|
+
signal: controller.signal
|
|
2332
|
+
});
|
|
2333
|
+
clearTimeout(timeoutId);
|
|
2334
|
+
if (!response.ok) {
|
|
2335
|
+
const errorText = await response.text();
|
|
2336
|
+
return {
|
|
2337
|
+
success: false,
|
|
2338
|
+
error: `Facilitator error: ${response.status} - ${errorText}`,
|
|
2339
|
+
network: request.network
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
return await response.json();
|
|
2343
|
+
} catch (error) {
|
|
2344
|
+
clearTimeout(timeoutId);
|
|
2345
|
+
return {
|
|
2346
|
+
success: false,
|
|
2347
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
2348
|
+
network: request.network
|
|
2349
|
+
};
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
/**
|
|
2353
|
+
* Get registration endpoint metadata
|
|
2354
|
+
*
|
|
2355
|
+
* @returns Endpoint information for POST /register
|
|
2356
|
+
*/
|
|
2357
|
+
async getRegisterInfo() {
|
|
2358
|
+
const url = `${this.baseUrl}/register`;
|
|
2359
|
+
const controller = new AbortController();
|
|
2360
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2361
|
+
try {
|
|
2362
|
+
const response = await fetch(url, {
|
|
2363
|
+
method: "GET",
|
|
2364
|
+
headers: { "Accept": "application/json" },
|
|
2365
|
+
signal: controller.signal
|
|
2366
|
+
});
|
|
2367
|
+
clearTimeout(timeoutId);
|
|
2368
|
+
if (!response.ok) {
|
|
2369
|
+
const errorText = await response.text();
|
|
2370
|
+
throw new Error(`ERC-8004 API error: ${response.status} - ${errorText}`);
|
|
2371
|
+
}
|
|
2372
|
+
return await response.json();
|
|
2373
|
+
} catch (error) {
|
|
2374
|
+
clearTimeout(timeoutId);
|
|
2375
|
+
throw error;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Get a specific metadata entry for an agent
|
|
2380
|
+
*
|
|
2381
|
+
* @param network - Network where agent is registered
|
|
2382
|
+
* @param agentId - Agent's tokenId
|
|
2383
|
+
* @param key - Metadata key to retrieve
|
|
2384
|
+
* @returns Metadata value (hex-encoded and UTF-8 decoded if possible)
|
|
2385
|
+
*/
|
|
2386
|
+
async getIdentityMetadata(network, agentId, key) {
|
|
2387
|
+
const url = `${this.baseUrl}/identity/${network}/${agentId}/metadata/${encodeURIComponent(key)}`;
|
|
2388
|
+
const controller = new AbortController();
|
|
2389
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2390
|
+
try {
|
|
2391
|
+
const response = await fetch(url, {
|
|
2392
|
+
method: "GET",
|
|
2393
|
+
headers: { "Accept": "application/json" },
|
|
2394
|
+
signal: controller.signal
|
|
2395
|
+
});
|
|
2396
|
+
clearTimeout(timeoutId);
|
|
2397
|
+
if (!response.ok) {
|
|
2398
|
+
const errorText = await response.text();
|
|
2399
|
+
throw new Error(`ERC-8004 API error: ${response.status} - ${errorText}`);
|
|
2400
|
+
}
|
|
2401
|
+
return await response.json();
|
|
2402
|
+
} catch (error) {
|
|
2403
|
+
clearTimeout(timeoutId);
|
|
2404
|
+
throw error;
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
/**
|
|
2408
|
+
* Get total number of registered agents on a network
|
|
2409
|
+
*
|
|
2410
|
+
* @param network - Network to query
|
|
2411
|
+
* @returns Total supply count
|
|
2412
|
+
*/
|
|
2413
|
+
async getIdentityTotalSupply(network) {
|
|
2414
|
+
const url = `${this.baseUrl}/identity/${network}/total-supply`;
|
|
2415
|
+
const controller = new AbortController();
|
|
2416
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2417
|
+
try {
|
|
2418
|
+
const response = await fetch(url, {
|
|
2419
|
+
method: "GET",
|
|
2420
|
+
headers: { "Accept": "application/json" },
|
|
2421
|
+
signal: controller.signal
|
|
2422
|
+
});
|
|
2423
|
+
clearTimeout(timeoutId);
|
|
2424
|
+
if (!response.ok) {
|
|
2425
|
+
const errorText = await response.text();
|
|
2426
|
+
throw new Error(`ERC-8004 API error: ${response.status} - ${errorText}`);
|
|
2427
|
+
}
|
|
2428
|
+
return await response.json();
|
|
2429
|
+
} catch (error) {
|
|
2430
|
+
clearTimeout(timeoutId);
|
|
2431
|
+
throw error;
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2290
2434
|
};
|
|
2291
2435
|
function buildErc8004PaymentRequirements(options) {
|
|
2292
2436
|
const base = buildPaymentRequirements(options);
|