@agirails/sdk 3.3.0 → 3.4.1
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/api/agirailsApp.d.ts +21 -1
- package/dist/api/agirailsApp.d.ts.map +1 -1
- package/dist/api/agirailsApp.js.map +1 -1
- package/dist/builders/CounterAcceptBuilder.d.ts +96 -0
- package/dist/builders/CounterAcceptBuilder.d.ts.map +1 -0
- package/dist/builders/CounterAcceptBuilder.js +226 -0
- package/dist/builders/CounterAcceptBuilder.js.map +1 -0
- package/dist/builders/CounterOfferBuilder.d.ts +143 -0
- package/dist/builders/CounterOfferBuilder.d.ts.map +1 -0
- package/dist/builders/CounterOfferBuilder.js +329 -0
- package/dist/builders/CounterOfferBuilder.js.map +1 -0
- package/dist/builders/QuoteBuilder.d.ts.map +1 -1
- package/dist/builders/QuoteBuilder.js +8 -3
- package/dist/builders/QuoteBuilder.js.map +1 -1
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +7 -1
- package/dist/builders/index.js.map +1 -1
- package/dist/cli/agirails.js +22 -2
- package/dist/cli/agirails.js.map +1 -1
- package/dist/cli/commands/health.js +21 -5
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +25 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/publish.d.ts +34 -0
- package/dist/cli/commands/publish.d.ts.map +1 -1
- package/dist/cli/commands/publish.js +256 -80
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/repair.d.ts +23 -0
- package/dist/cli/commands/repair.d.ts.map +1 -0
- package/dist/cli/commands/repair.js +210 -0
- package/dist/cli/commands/repair.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +38 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +308 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/test.js +2 -2
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/config/agirailsmdV4.d.ts +46 -1
- package/dist/config/agirailsmdV4.d.ts.map +1 -1
- package/dist/config/agirailsmdV4.js +65 -8
- package/dist/config/agirailsmdV4.js.map +1 -1
- package/dist/config/defaults.d.ts +10 -0
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +10 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/publishPipeline.d.ts +23 -1
- package/dist/config/publishPipeline.d.ts.map +1 -1
- package/dist/config/publishPipeline.js +70 -15
- package/dist/config/publishPipeline.js.map +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/dist/level1/Agent.d.ts +27 -0
- package/dist/level1/Agent.d.ts.map +1 -1
- package/dist/level1/Agent.js +77 -6
- package/dist/level1/Agent.js.map +1 -1
- package/dist/negotiation/BuyerOrchestrator.d.ts +103 -1
- package/dist/negotiation/BuyerOrchestrator.d.ts.map +1 -1
- package/dist/negotiation/BuyerOrchestrator.js +499 -4
- package/dist/negotiation/BuyerOrchestrator.js.map +1 -1
- package/dist/negotiation/DecisionEngine.d.ts +69 -1
- package/dist/negotiation/DecisionEngine.d.ts.map +1 -1
- package/dist/negotiation/DecisionEngine.js +140 -1
- package/dist/negotiation/DecisionEngine.js.map +1 -1
- package/dist/negotiation/PolicyEngine.d.ts +32 -0
- package/dist/negotiation/PolicyEngine.d.ts.map +1 -1
- package/dist/negotiation/PolicyEngine.js.map +1 -1
- package/dist/negotiation/ProviderOrchestrator.d.ts +108 -0
- package/dist/negotiation/ProviderOrchestrator.d.ts.map +1 -0
- package/dist/negotiation/ProviderOrchestrator.js +136 -0
- package/dist/negotiation/ProviderOrchestrator.js.map +1 -0
- package/dist/negotiation/ProviderPolicy.d.ts +143 -0
- package/dist/negotiation/ProviderPolicy.d.ts.map +1 -0
- package/dist/negotiation/ProviderPolicy.js +207 -0
- package/dist/negotiation/ProviderPolicy.js.map +1 -0
- package/dist/negotiation/index.d.ts +8 -1
- package/dist/negotiation/index.d.ts.map +1 -1
- package/dist/negotiation/index.js +8 -1
- package/dist/negotiation/index.js.map +1 -1
- package/dist/negotiation/verifyQuoteOnChain.d.ts +58 -0
- package/dist/negotiation/verifyQuoteOnChain.d.ts.map +1 -0
- package/dist/negotiation/verifyQuoteOnChain.js +83 -0
- package/dist/negotiation/verifyQuoteOnChain.js.map +1 -0
- package/dist/runtime/BlockchainRuntime.d.ts +13 -0
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +23 -0
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/runtime/IACTPRuntime.d.ts +35 -0
- package/dist/runtime/IACTPRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.d.ts +11 -0
- package/dist/runtime/MockRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.js +39 -0
- package/dist/runtime/MockRuntime.js.map +1 -1
- package/dist/runtime/types/MockState.d.ts +10 -0
- package/dist/runtime/types/MockState.d.ts.map +1 -1
- package/dist/runtime/types/MockState.js.map +1 -1
- package/dist/transport/QuoteChannel.d.ts +201 -0
- package/dist/transport/QuoteChannel.d.ts.map +1 -0
- package/dist/transport/QuoteChannel.js +358 -0
- package/dist/transport/QuoteChannel.js.map +1 -0
- package/dist/types/adapter.d.ts +24 -24
- package/package.json +16 -1
|
@@ -21,10 +21,30 @@ export interface CheckSlugResult {
|
|
|
21
21
|
available: boolean;
|
|
22
22
|
/** If not available, the next available slug (e.g. "code-reviewer-2") */
|
|
23
23
|
suggestion?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Public on-chain identity of the agent that already owns this slug.
|
|
26
|
+
* Present only when `available === false` AND the slug has been
|
|
27
|
+
* published on-chain (drafts won't carry an owner block).
|
|
28
|
+
*
|
|
29
|
+
* Used by the SDK publish flow to detect "I already own this slug,
|
|
30
|
+
* recover my agent_id" instead of silently auto-renaming to slug-2.
|
|
31
|
+
*/
|
|
32
|
+
owner?: {
|
|
33
|
+
/** Owner's on-chain wallet (lowercase hex) — Smart Wallet if AA */
|
|
34
|
+
wallet: string;
|
|
35
|
+
/** AgentRegistry tokenId / on_chain_id as a string */
|
|
36
|
+
agentId: string;
|
|
37
|
+
};
|
|
24
38
|
}
|
|
25
39
|
export interface UpsertAgentParams {
|
|
26
40
|
slug: string;
|
|
27
|
-
|
|
41
|
+
/**
|
|
42
|
+
* AgentRegistry tokenId. Optional: pay-only buyer agents do not
|
|
43
|
+
* register on AgentRegistry (no NFT minted), so they have no
|
|
44
|
+
* agent_id. Omit to upsert without on-chain ownership check —
|
|
45
|
+
* the wallet signature alone proves the wallet controls the slug.
|
|
46
|
+
*/
|
|
47
|
+
agentId?: string;
|
|
28
48
|
/** On-chain wallet address (Smart Wallet if AA-enabled, EOA otherwise) */
|
|
29
49
|
wallet: string;
|
|
30
50
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agirailsApp.d.ts","sourceRoot":"","sources":["../../src/api/agirailsApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAaH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"agirailsApp.d.ts","sourceRoot":"","sources":["../../src/api/agirailsApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAaH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE;QACN,mEAAmE;QACnE,MAAM,EAAE,MAAM,CAAC;QACf,sDAAsD;Q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,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,GAAG,OAAO,CAAC,eAAe,CAAC,CAe3B;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,MAAM,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAyBzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agirailsApp.js","sourceRoot":"","sources":["../../src/api/agirailsApp.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAEH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,qBAAqB,GACzB,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"agirailsApp.js","sourceRoot":"","sources":["../../src/api/agirailsApp.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAEH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,qBAAqB,GACzB,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;AA4J7D,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;;;;GAOG;AACI,KAAK,UAAU,SAAS,CAAC,IAAY;IAC1C,MAAM,GAAG,GAAG,GAAG,qBAAqB,kCAAkC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;IAEjG,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC3B,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,EAA8B,CAAC;AA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CAAC,GAAG,CAAC,MAAM,EAAS,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/D,IAAI,MAAM,CAAC,QAAQ;QAAS,EAAE,CAAC,GAAG,CAAC,UAAU,EAAK,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEnE,MAAM,WAAW,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,GAAG,qBAAqB,mBAAmB,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAE9F,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC3B,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE;KAC1C,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,EAA6B,CAAC;AAC/C,CAAC;AAzBD,wCAyBC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CounterAcceptBuilder — AIP-2.1 provider's signed acceptance of a
|
|
3
|
+
* buyer's counter-offer.
|
|
4
|
+
*
|
|
5
|
+
* Closes the non-repudiation gap noted in AIP-2.1-DRAFT §8: the
|
|
6
|
+
* counter itself is signed by the buyer; the on-chain `acceptQuote`
|
|
7
|
+
* call by the buyer pins the price; but until now there was no
|
|
8
|
+
* signed surface for the provider to *commit* to the counter
|
|
9
|
+
* off-chain. Without this, a buyer who calls acceptQuote(counter)
|
|
10
|
+
* has no cryptographic record of provider agreement, only "they
|
|
11
|
+
* didn't reject within TTL".
|
|
12
|
+
*
|
|
13
|
+
* Mirrors CounterOfferBuilder shape — same EIP-712 domain, same
|
|
14
|
+
* canonical JSON hashing, signer-independent verification.
|
|
15
|
+
*
|
|
16
|
+
* @module builders/CounterAcceptBuilder
|
|
17
|
+
* @see Protocol/aips/AIP-2.1-DRAFT.md §8 (acceptance signal)
|
|
18
|
+
* @see src/builders/CounterOfferBuilder.ts (sibling, buyer side)
|
|
19
|
+
*/
|
|
20
|
+
import { Signer } from 'ethers';
|
|
21
|
+
import { NonceManager } from '../utils/NonceManager';
|
|
22
|
+
/**
|
|
23
|
+
* Provider-signed acceptance of a buyer's counter-offer.
|
|
24
|
+
*
|
|
25
|
+
* Carries the counter hash this is responding to (`inReplyTo`) so the
|
|
26
|
+
* buyer's verifier can cryptographically link the acceptance to the
|
|
27
|
+
* exact counter it sent. `acceptedAmount` MUST equal the counter's
|
|
28
|
+
* `counterAmount` — verifier rejects mismatches.
|
|
29
|
+
*/
|
|
30
|
+
export interface CounterAcceptMessage {
|
|
31
|
+
type: 'agirails.counteraccept.v1';
|
|
32
|
+
version: '1.0.0';
|
|
33
|
+
/** Transaction this acceptance belongs to. */
|
|
34
|
+
txId: string;
|
|
35
|
+
/** Provider DID (signer). */
|
|
36
|
+
provider: string;
|
|
37
|
+
/** Buyer DID (recipient). */
|
|
38
|
+
consumer: string;
|
|
39
|
+
/** Final agreed amount in USDC base units — equals counter.counterAmount. */
|
|
40
|
+
acceptedAmount: string;
|
|
41
|
+
/** Hash of the counter-offer this is replying to (CounterOfferBuilder.computeHash). */
|
|
42
|
+
inReplyTo: string;
|
|
43
|
+
/** Unix seconds when accepted. */
|
|
44
|
+
acceptedAt: number;
|
|
45
|
+
chainId: number;
|
|
46
|
+
nonce: number;
|
|
47
|
+
signature: string;
|
|
48
|
+
}
|
|
49
|
+
export interface CounterAcceptParams {
|
|
50
|
+
txId: string;
|
|
51
|
+
provider: string;
|
|
52
|
+
consumer: string;
|
|
53
|
+
acceptedAmount: string;
|
|
54
|
+
inReplyTo: string;
|
|
55
|
+
chainId: number;
|
|
56
|
+
kernelAddress: string;
|
|
57
|
+
}
|
|
58
|
+
export declare const AIP21CounterAcceptTypes: {
|
|
59
|
+
CounterAccept: {
|
|
60
|
+
name: string;
|
|
61
|
+
type: string;
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
export declare class CounterAcceptBuilder {
|
|
65
|
+
private readonly signer?;
|
|
66
|
+
private readonly nonceManager?;
|
|
67
|
+
/**
|
|
68
|
+
* `signer` and `nonceManager` are only required for `build()`.
|
|
69
|
+
* `verify()` and `computeHash()` work signer-independent — pass
|
|
70
|
+
* `undefined` to construct a verify-only instance (used by buyer
|
|
71
|
+
* orchestrator when validating a provider's acceptance message).
|
|
72
|
+
*/
|
|
73
|
+
constructor(signer?: Signer | undefined, nonceManager?: NonceManager | undefined);
|
|
74
|
+
build(params: CounterAcceptParams): Promise<CounterAcceptMessage>;
|
|
75
|
+
/**
|
|
76
|
+
* Verify provider acceptance:
|
|
77
|
+
* 1. Schema well-formed
|
|
78
|
+
* 2. EIP-712 signature recovers to provider DID's address
|
|
79
|
+
* 3. acceptedAmount ≥ platform minimum (defense)
|
|
80
|
+
* 4. acceptedAt within skew tolerance (one-sided future check)
|
|
81
|
+
*
|
|
82
|
+
* Caller is responsible for additionally checking
|
|
83
|
+
* `acceptedAmount === counter.counterAmount` and
|
|
84
|
+
* `inReplyTo === CounterOfferBuilder.computeHash(counter)` —
|
|
85
|
+
* those bind the acceptance to the buyer's specific counter.
|
|
86
|
+
*/
|
|
87
|
+
verify(message: CounterAcceptMessage, kernelAddress: string): Promise<boolean>;
|
|
88
|
+
computeHash(message: CounterAcceptMessage): string;
|
|
89
|
+
private signMessage;
|
|
90
|
+
private recoverSigner;
|
|
91
|
+
private toSignedShape;
|
|
92
|
+
private extractAddressFromDID;
|
|
93
|
+
private validateParams;
|
|
94
|
+
private validateMessageSchema;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=CounterAcceptBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CounterAcceptBuilder.d.ts","sourceRoot":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AAM,CAAC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAsBpF,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM;YAUpC,WAAW;IAiBzB,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,cAAc;IA8BtB,OAAO,CAAC,qBAAqB;CA6B9B"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CounterAcceptBuilder — AIP-2.1 provider's signed acceptance of a
|
|
4
|
+
* buyer's counter-offer.
|
|
5
|
+
*
|
|
6
|
+
* Closes the non-repudiation gap noted in AIP-2.1-DRAFT §8: the
|
|
7
|
+
* counter itself is signed by the buyer; the on-chain `acceptQuote`
|
|
8
|
+
* call by the buyer pins the price; but until now there was no
|
|
9
|
+
* signed surface for the provider to *commit* to the counter
|
|
10
|
+
* off-chain. Without this, a buyer who calls acceptQuote(counter)
|
|
11
|
+
* has no cryptographic record of provider agreement, only "they
|
|
12
|
+
* didn't reject within TTL".
|
|
13
|
+
*
|
|
14
|
+
* Mirrors CounterOfferBuilder shape — same EIP-712 domain, same
|
|
15
|
+
* canonical JSON hashing, signer-independent verification.
|
|
16
|
+
*
|
|
17
|
+
* @module builders/CounterAcceptBuilder
|
|
18
|
+
* @see Protocol/aips/AIP-2.1-DRAFT.md §8 (acceptance signal)
|
|
19
|
+
* @see src/builders/CounterOfferBuilder.ts (sibling, buyer side)
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.CounterAcceptBuilder = exports.AIP21CounterAcceptTypes = void 0;
|
|
23
|
+
const ethers_1 = require("ethers");
|
|
24
|
+
const canonicalJson_1 = require("../utils/canonicalJson");
|
|
25
|
+
const errors_1 = require("../errors");
|
|
26
|
+
exports.AIP21CounterAcceptTypes = {
|
|
27
|
+
CounterAccept: [
|
|
28
|
+
{ name: 'txId', type: 'bytes32' },
|
|
29
|
+
{ name: 'provider', type: 'string' },
|
|
30
|
+
{ name: 'consumer', type: 'string' },
|
|
31
|
+
{ name: 'acceptedAmount', type: 'string' },
|
|
32
|
+
{ name: 'inReplyTo', type: 'bytes32' },
|
|
33
|
+
{ name: 'acceptedAt', type: 'uint256' },
|
|
34
|
+
{ name: 'chainId', type: 'uint256' },
|
|
35
|
+
{ name: 'nonce', type: 'uint256' },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
const MESSAGE_TYPE = 'agirails.counteraccept.v1';
|
|
39
|
+
const TIMESTAMP_GRACE_SECONDS = 300;
|
|
40
|
+
const VALID_CHAIN_IDS = new Set([84532, 8453]);
|
|
41
|
+
const PLATFORM_MIN_BASE_UNITS = 50000n;
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Builder
|
|
44
|
+
// ============================================================================
|
|
45
|
+
class CounterAcceptBuilder {
|
|
46
|
+
/**
|
|
47
|
+
* `signer` and `nonceManager` are only required for `build()`.
|
|
48
|
+
* `verify()` and `computeHash()` work signer-independent — pass
|
|
49
|
+
* `undefined` to construct a verify-only instance (used by buyer
|
|
50
|
+
* orchestrator when validating a provider's acceptance message).
|
|
51
|
+
*/
|
|
52
|
+
constructor(signer, nonceManager) {
|
|
53
|
+
this.signer = signer;
|
|
54
|
+
this.nonceManager = nonceManager;
|
|
55
|
+
}
|
|
56
|
+
async build(params) {
|
|
57
|
+
if (!this.signer || !this.nonceManager) {
|
|
58
|
+
throw new Error('CounterAcceptBuilder.build requires signer + nonceManager');
|
|
59
|
+
}
|
|
60
|
+
this.validateParams(params);
|
|
61
|
+
const acceptedAt = Math.floor(Date.now() / 1000);
|
|
62
|
+
const message = {
|
|
63
|
+
type: MESSAGE_TYPE,
|
|
64
|
+
version: '1.0.0',
|
|
65
|
+
txId: params.txId,
|
|
66
|
+
provider: params.provider,
|
|
67
|
+
consumer: params.consumer,
|
|
68
|
+
acceptedAmount: params.acceptedAmount,
|
|
69
|
+
inReplyTo: params.inReplyTo,
|
|
70
|
+
acceptedAt,
|
|
71
|
+
chainId: params.chainId,
|
|
72
|
+
nonce: this.nonceManager.getNextNonce(MESSAGE_TYPE),
|
|
73
|
+
signature: '',
|
|
74
|
+
};
|
|
75
|
+
message.signature = await this.signMessage(message, params.kernelAddress);
|
|
76
|
+
this.nonceManager.recordNonce(MESSAGE_TYPE, message.nonce);
|
|
77
|
+
return message;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Verify provider acceptance:
|
|
81
|
+
* 1. Schema well-formed
|
|
82
|
+
* 2. EIP-712 signature recovers to provider DID's address
|
|
83
|
+
* 3. acceptedAmount ≥ platform minimum (defense)
|
|
84
|
+
* 4. acceptedAt within skew tolerance (one-sided future check)
|
|
85
|
+
*
|
|
86
|
+
* Caller is responsible for additionally checking
|
|
87
|
+
* `acceptedAmount === counter.counterAmount` and
|
|
88
|
+
* `inReplyTo === CounterOfferBuilder.computeHash(counter)` —
|
|
89
|
+
* those bind the acceptance to the buyer's specific counter.
|
|
90
|
+
*/
|
|
91
|
+
async verify(message, kernelAddress) {
|
|
92
|
+
this.validateMessageSchema(message);
|
|
93
|
+
const recovered = this.recoverSigner(message, kernelAddress);
|
|
94
|
+
const expected = this.extractAddressFromDID(message.provider);
|
|
95
|
+
if (recovered.toLowerCase() !== expected.toLowerCase()) {
|
|
96
|
+
throw new errors_1.SignatureVerificationError(message.provider, 'unknown');
|
|
97
|
+
}
|
|
98
|
+
const accepted = BigInt(message.acceptedAmount);
|
|
99
|
+
if (accepted < PLATFORM_MIN_BASE_UNITS) {
|
|
100
|
+
throw new Error('acceptedAmount below platform minimum ($0.05)');
|
|
101
|
+
}
|
|
102
|
+
const now = Math.floor(Date.now() / 1000);
|
|
103
|
+
if (message.acceptedAt > now + TIMESTAMP_GRACE_SECONDS) {
|
|
104
|
+
throw new Error('acceptedAt is in the future beyond skew tolerance');
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
computeHash(message) {
|
|
109
|
+
const { signature: _sig, ...withoutSig } = message;
|
|
110
|
+
void _sig;
|
|
111
|
+
return (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)((0, canonicalJson_1.canonicalJsonStringify)(withoutSig)));
|
|
112
|
+
}
|
|
113
|
+
// --------------------------------------------------------------------------
|
|
114
|
+
// Internals
|
|
115
|
+
// --------------------------------------------------------------------------
|
|
116
|
+
async signMessage(message, kernelAddress) {
|
|
117
|
+
const domain = {
|
|
118
|
+
name: 'AGIRAILS',
|
|
119
|
+
version: '1',
|
|
120
|
+
chainId: message.chainId,
|
|
121
|
+
verifyingContract: kernelAddress,
|
|
122
|
+
};
|
|
123
|
+
const signed = this.toSignedShape(message);
|
|
124
|
+
const signerWithTypedData = this.signer;
|
|
125
|
+
if (typeof signerWithTypedData.signTypedData === 'function') {
|
|
126
|
+
return signerWithTypedData.signTypedData(domain, exports.AIP21CounterAcceptTypes, signed);
|
|
127
|
+
}
|
|
128
|
+
throw new Error('Signer does not support EIP-712 typed data signing');
|
|
129
|
+
}
|
|
130
|
+
recoverSigner(message, kernelAddress) {
|
|
131
|
+
const domain = {
|
|
132
|
+
name: 'AGIRAILS',
|
|
133
|
+
version: '1',
|
|
134
|
+
chainId: message.chainId,
|
|
135
|
+
verifyingContract: kernelAddress,
|
|
136
|
+
};
|
|
137
|
+
const signed = this.toSignedShape(message);
|
|
138
|
+
try {
|
|
139
|
+
return (0, ethers_1.verifyTypedData)(domain, exports.AIP21CounterAcceptTypes, signed, message.signature);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
throw new errors_1.SignatureVerificationError(message.provider, 'unknown');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
toSignedShape(message) {
|
|
146
|
+
return {
|
|
147
|
+
txId: message.txId,
|
|
148
|
+
provider: message.provider,
|
|
149
|
+
consumer: message.consumer,
|
|
150
|
+
acceptedAmount: message.acceptedAmount,
|
|
151
|
+
inReplyTo: message.inReplyTo,
|
|
152
|
+
acceptedAt: message.acceptedAt,
|
|
153
|
+
chainId: message.chainId,
|
|
154
|
+
nonce: message.nonce,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
extractAddressFromDID(did) {
|
|
158
|
+
const parts = did.replace('did:ethr:', '').split(':');
|
|
159
|
+
const address = parts.length === 2 ? parts[1] : parts[0];
|
|
160
|
+
if (!address.startsWith('0x') || address.length !== 42) {
|
|
161
|
+
throw new Error(`Invalid DID format: ${did}`);
|
|
162
|
+
}
|
|
163
|
+
return address;
|
|
164
|
+
}
|
|
165
|
+
validateParams(params) {
|
|
166
|
+
if (!/^0x[a-fA-F0-9]{64}$/.test(params.txId)) {
|
|
167
|
+
throw new Error('txId must be valid bytes32 hex string');
|
|
168
|
+
}
|
|
169
|
+
if (!/^0x[a-fA-F0-9]{64}$/.test(params.inReplyTo)) {
|
|
170
|
+
throw new Error('inReplyTo must be valid bytes32 hex string (the counter hash)');
|
|
171
|
+
}
|
|
172
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(params.kernelAddress)) {
|
|
173
|
+
throw new Error('kernelAddress must be valid Ethereum address');
|
|
174
|
+
}
|
|
175
|
+
if (!params.provider.startsWith('did:ethr:')) {
|
|
176
|
+
throw new Error('provider must be valid did:ethr format');
|
|
177
|
+
}
|
|
178
|
+
if (!params.consumer.startsWith('did:ethr:')) {
|
|
179
|
+
throw new Error('consumer must be valid did:ethr format');
|
|
180
|
+
}
|
|
181
|
+
if (!VALID_CHAIN_IDS.has(params.chainId)) {
|
|
182
|
+
throw new Error('chainId must be 84532 (Base Sepolia) or 8453 (Base Mainnet)');
|
|
183
|
+
}
|
|
184
|
+
let accepted;
|
|
185
|
+
try {
|
|
186
|
+
accepted = BigInt(params.acceptedAmount);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
throw new Error('acceptedAmount must be a numeric string');
|
|
190
|
+
}
|
|
191
|
+
if (accepted < PLATFORM_MIN_BASE_UNITS) {
|
|
192
|
+
throw new Error('acceptedAmount below platform minimum ($0.05)');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
validateMessageSchema(message) {
|
|
196
|
+
if (message.type !== MESSAGE_TYPE) {
|
|
197
|
+
throw new Error(`Invalid message type (expected ${MESSAGE_TYPE}, got ${message.type})`);
|
|
198
|
+
}
|
|
199
|
+
if (!/^\d+\.\d+\.\d+$/.test(message.version)) {
|
|
200
|
+
throw new Error('Invalid version format');
|
|
201
|
+
}
|
|
202
|
+
if (!/^0x[a-fA-F0-9]{64}$/.test(message.txId)) {
|
|
203
|
+
throw new Error('Invalid txId format');
|
|
204
|
+
}
|
|
205
|
+
if (!/^0x[a-fA-F0-9]{64}$/.test(message.inReplyTo)) {
|
|
206
|
+
throw new Error('Invalid inReplyTo format');
|
|
207
|
+
}
|
|
208
|
+
if (!message.provider.startsWith('did:ethr:')) {
|
|
209
|
+
throw new Error('Invalid provider DID format');
|
|
210
|
+
}
|
|
211
|
+
if (!message.consumer.startsWith('did:ethr:')) {
|
|
212
|
+
throw new Error('Invalid consumer DID format');
|
|
213
|
+
}
|
|
214
|
+
if (!/^\d+$/.test(message.acceptedAmount)) {
|
|
215
|
+
throw new Error('Invalid acceptedAmount format');
|
|
216
|
+
}
|
|
217
|
+
if (!VALID_CHAIN_IDS.has(message.chainId)) {
|
|
218
|
+
throw new Error('Invalid chainId');
|
|
219
|
+
}
|
|
220
|
+
if (!/^0x[a-fA-F0-9]{130}$/.test(message.signature)) {
|
|
221
|
+
throw new Error('Invalid signature format');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.CounterAcceptBuilder = CounterAcceptBuilder;
|
|
226
|
+
//# sourceMappingURL=CounterAcceptBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CounterAcceptBuilder.js","sourceRoot":"","sources":["../../src/builders/CounterAcceptBuilder.ts"],"names":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AC,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AArMD,oDAqMC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CounterOfferBuilder — AIP-2.1 counter-offer message construction.
|
|
3
|
+
*
|
|
4
|
+
* AIP-2 covers the provider's first quote (`agirails.quote.v1`). AIP-2.1
|
|
5
|
+
* adds the buyer's reply: a signed counter-offer message that proposes a
|
|
6
|
+
* different price than what the provider quoted. The buyer can ping-pong
|
|
7
|
+
* counter-offers with the provider off-chain; the final agreed amount is
|
|
8
|
+
* pinned on-chain when the buyer eventually calls `acceptQuote(txId, amount)`
|
|
9
|
+
* followed by `linkEscrow`.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors QuoteBuilder.ts shape so the verification path is symmetric:
|
|
12
|
+
* - EIP-712 signed message (buyer signs)
|
|
13
|
+
* - Canonical JSON hash (deterministic across implementations)
|
|
14
|
+
* - Same DID extraction + signature recovery pattern
|
|
15
|
+
*
|
|
16
|
+
* @module builders/CounterOfferBuilder
|
|
17
|
+
* @see Protocol/aips/AIP-2.1-DRAFT.md §8 (security model + transport)
|
|
18
|
+
* @see src/builders/QuoteBuilder.ts (sibling, provider side)
|
|
19
|
+
*/
|
|
20
|
+
import { Signer } from 'ethers';
|
|
21
|
+
import { NonceManager } from '../utils/NonceManager';
|
|
22
|
+
/**
|
|
23
|
+
* Counter-offer message — the buyer's reply to a provider quote.
|
|
24
|
+
*
|
|
25
|
+
* Field shape mirrors QuoteMessage where it makes sense (txId, currency,
|
|
26
|
+
* decimals, chainId, nonce, signature) but flips provider/consumer
|
|
27
|
+
* semantics: the buyer/consumer is the one signing and the one proposing
|
|
28
|
+
* a (typically lower) price.
|
|
29
|
+
*
|
|
30
|
+
* `quotedAmount` from the original provider quote is preserved as
|
|
31
|
+
* `quoteAmount` for unambiguous binding — the verifier can confirm this
|
|
32
|
+
* counter is in response to the exact quote it claims to be.
|
|
33
|
+
*/
|
|
34
|
+
export interface CounterOfferMessage {
|
|
35
|
+
type: 'agirails.counteroffer.v1';
|
|
36
|
+
version: '1.0.0';
|
|
37
|
+
/** Transaction ID this counter belongs to (binds counter to txn). */
|
|
38
|
+
txId: string;
|
|
39
|
+
/** Buyer/consumer DID (signer). */
|
|
40
|
+
consumer: string;
|
|
41
|
+
/** Provider DID (recipient). */
|
|
42
|
+
provider: string;
|
|
43
|
+
/** Provider's most recent quoted amount this counter is replying to. */
|
|
44
|
+
quoteAmount: string;
|
|
45
|
+
/** Buyer's proposed counter amount in USDC base units. */
|
|
46
|
+
counterAmount: string;
|
|
47
|
+
/** Original maxPrice from the buyer's policy (anchors the negotiation band). */
|
|
48
|
+
maxPrice: string;
|
|
49
|
+
currency: 'USDC';
|
|
50
|
+
decimals: 6;
|
|
51
|
+
/** Quote hash this counter is replying to — links counter to a specific quote. */
|
|
52
|
+
inReplyTo: string;
|
|
53
|
+
/** Unix seconds, when this counter was constructed. */
|
|
54
|
+
counteredAt: number;
|
|
55
|
+
/** Unix seconds, when this counter expires. Provider must accept/reject by then. */
|
|
56
|
+
expiresAt: number;
|
|
57
|
+
/** Optional human-readable reasoning + market data. */
|
|
58
|
+
justification?: {
|
|
59
|
+
reason?: string;
|
|
60
|
+
/** Average market price observed for the same service (USD). */
|
|
61
|
+
marketRate?: number;
|
|
62
|
+
/** Free-form key/value breakdown the buyer wants to share. */
|
|
63
|
+
breakdown?: Record<string, unknown>;
|
|
64
|
+
};
|
|
65
|
+
chainId: number;
|
|
66
|
+
/** Monotonic per-consumer per-message-type. */
|
|
67
|
+
nonce: number;
|
|
68
|
+
/** EIP-712 signature by consumer over the canonical message. */
|
|
69
|
+
signature: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Parameters to build a counter-offer. `counteredAt`, `nonce`, and
|
|
73
|
+
* `signature` are filled by the builder.
|
|
74
|
+
*/
|
|
75
|
+
export interface CounterOfferParams {
|
|
76
|
+
txId: string;
|
|
77
|
+
consumer: string;
|
|
78
|
+
provider: string;
|
|
79
|
+
quoteAmount: string;
|
|
80
|
+
counterAmount: string;
|
|
81
|
+
maxPrice: string;
|
|
82
|
+
inReplyTo: string;
|
|
83
|
+
expiresAt?: number;
|
|
84
|
+
justification?: CounterOfferMessage['justification'];
|
|
85
|
+
chainId: number;
|
|
86
|
+
/** ACTPKernel address — used in EIP-712 domain. */
|
|
87
|
+
kernelAddress: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* EIP-712 type definitions for `agirails.counteroffer.v1`.
|
|
91
|
+
*
|
|
92
|
+
* The justification object is hashed (single bytes32 field) instead of
|
|
93
|
+
* inlined — same pattern as AIP-2 quotes — so callers can omit large
|
|
94
|
+
* justification blobs without changing the signed payload structure.
|
|
95
|
+
*/
|
|
96
|
+
export declare const AIP21CounterOfferTypes: {
|
|
97
|
+
CounterOffer: {
|
|
98
|
+
name: string;
|
|
99
|
+
type: string;
|
|
100
|
+
}[];
|
|
101
|
+
};
|
|
102
|
+
export declare class CounterOfferBuilder {
|
|
103
|
+
private readonly signer?;
|
|
104
|
+
private readonly nonceManager?;
|
|
105
|
+
/**
|
|
106
|
+
* `signer` and `nonceManager` are only required for `build()`.
|
|
107
|
+
* `verify()` and `computeHash()` are signer-independent — pass
|
|
108
|
+
* `undefined` to construct a verify-only instance.
|
|
109
|
+
*/
|
|
110
|
+
constructor(signer?: Signer | undefined, nonceManager?: NonceManager | undefined);
|
|
111
|
+
/**
|
|
112
|
+
* Build and sign a counter-offer message.
|
|
113
|
+
* @throws Error on validation failure (amount bands, formats, expiry).
|
|
114
|
+
*/
|
|
115
|
+
build(params: CounterOfferParams): Promise<CounterOfferMessage>;
|
|
116
|
+
/**
|
|
117
|
+
* Verify a counter-offer:
|
|
118
|
+
* 1. Schema is well-formed
|
|
119
|
+
* 2. EIP-712 signature recovers to the consumer DID's address
|
|
120
|
+
* 3. Amount band: counterAmount within [platformMin, maxPrice], not above quoteAmount
|
|
121
|
+
* 4. Not expired (with TIMESTAMP_GRACE_SECONDS slack on counteredAt)
|
|
122
|
+
*
|
|
123
|
+
* @returns true on success; throws otherwise.
|
|
124
|
+
*/
|
|
125
|
+
verify(message: CounterOfferMessage, kernelAddress: string): Promise<boolean>;
|
|
126
|
+
/**
|
|
127
|
+
* Compute the canonical hash of a counter-offer (signature stripped).
|
|
128
|
+
*
|
|
129
|
+
* This is the value that should be used for any on-chain anchoring or
|
|
130
|
+
* off-chain dedup keys. Identical counter content → identical hash on
|
|
131
|
+
* any implementation that uses fast-json-stable-stringify.
|
|
132
|
+
*/
|
|
133
|
+
computeHash(message: CounterOfferMessage): string;
|
|
134
|
+
private signMessage;
|
|
135
|
+
private recoverSigner;
|
|
136
|
+
/** Build the exact object EIP-712 sees (justificationHash field, no inline justification). */
|
|
137
|
+
private toSignedShape;
|
|
138
|
+
private computeJustificationHash;
|
|
139
|
+
private extractAddressFromDID;
|
|
140
|
+
private validateParams;
|
|
141
|
+
private validateMessageSchema;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=CounterOfferBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CounterOfferBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/CounterOfferBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAA2C,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAQrD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,0BAA0B,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,QAAQ,EAAE,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