@antseed/node 0.2.82 → 0.2.84
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/package.json +2 -2
- package/dist/discovery/default-metadata-resolver.d.ts +0 -16
- package/dist/discovery/default-metadata-resolver.d.ts.map +0 -1
- package/dist/discovery/default-metadata-resolver.js +0 -16
- package/dist/discovery/default-metadata-resolver.js.map +0 -1
- package/dist/discovery/peer-selector.d.ts +0 -33
- package/dist/discovery/peer-selector.d.ts.map +0 -1
- package/dist/discovery/peer-selector.js +0 -80
- package/dist/discovery/peer-selector.js.map +0 -1
- package/dist/discovery/profile-manager.d.ts +0 -50
- package/dist/discovery/profile-manager.d.ts.map +0 -1
- package/dist/discovery/profile-manager.js +0 -105
- package/dist/discovery/profile-manager.js.map +0 -1
- package/dist/discovery/profile-search.d.ts +0 -27
- package/dist/discovery/profile-search.d.ts.map +0 -1
- package/dist/discovery/profile-search.js +0 -75
- package/dist/discovery/profile-search.js.map +0 -1
- package/dist/discovery/reputation-verifier.d.ts +0 -5
- package/dist/discovery/reputation-verifier.d.ts.map +0 -1
- package/dist/discovery/reputation-verifier.js +0 -5
- package/dist/discovery/reputation-verifier.js.map +0 -1
- package/dist/discovery/stats-verifier.d.ts +0 -27
- package/dist/discovery/stats-verifier.d.ts.map +0 -1
- package/dist/discovery/stats-verifier.js +0 -38
- package/dist/discovery/stats-verifier.js.map +0 -1
- package/dist/p2p/handshake.d.ts +0 -47
- package/dist/p2p/handshake.d.ts.map +0 -1
- package/dist/p2p/handshake.js +0 -107
- package/dist/p2p/handshake.js.map +0 -1
- package/dist/p2p/reconnect.d.ts +0 -48
- package/dist/p2p/reconnect.d.ts.map +0 -1
- package/dist/p2p/reconnect.js +0 -89
- package/dist/p2p/reconnect.js.map +0 -1
- package/dist/payments/disputes.d.ts +0 -18
- package/dist/payments/disputes.d.ts.map +0 -1
- package/dist/payments/disputes.js +0 -47
- package/dist/payments/disputes.js.map +0 -1
- package/dist/payments/evm/escrow-client.d.ts +0 -82
- package/dist/payments/evm/escrow-client.d.ts.map +0 -1
- package/dist/payments/evm/escrow-client.js +0 -277
- package/dist/payments/evm/escrow-client.js.map +0 -1
- package/dist/payments/evm/keypair.d.ts +0 -10
- package/dist/payments/evm/keypair.d.ts.map +0 -1
- package/dist/payments/evm/keypair.js +0 -13
- package/dist/payments/evm/keypair.js.map +0 -1
- package/dist/payments/evm/sessions-client.d.ts +0 -30
- package/dist/payments/evm/sessions-client.d.ts.map +0 -1
- package/dist/payments/evm/sessions-client.js +0 -61
- package/dist/payments/evm/sessions-client.js.map +0 -1
- package/dist/payments/evm/wallet.d.ts +0 -5
- package/dist/payments/evm/wallet.d.ts.map +0 -1
- package/dist/payments/evm/wallet.js +0 -31
- package/dist/payments/evm/wallet.js.map +0 -1
- package/dist/payments/session-store.d.ts +0 -68
- package/dist/payments/session-store.d.ts.map +0 -1
- package/dist/payments/session-store.js +0 -272
- package/dist/payments/session-store.js.map +0 -1
- package/dist/payments/settlement.d.ts +0 -6
- package/dist/payments/settlement.d.ts.map +0 -1
- package/dist/payments/settlement.js +0 -25
- package/dist/payments/settlement.js.map +0 -1
- package/dist/proxy/model-api-adapter.d.ts +0 -30
- package/dist/proxy/model-api-adapter.d.ts.map +0 -1
- package/dist/proxy/model-api-adapter.js +0 -891
- package/dist/proxy/model-api-adapter.js.map +0 -1
- package/dist/reputation/trust-engine.d.ts +0 -36
- package/dist/reputation/trust-engine.d.ts.map +0 -1
- package/dist/reputation/trust-engine.js +0 -95
- package/dist/reputation/trust-engine.js.map +0 -1
- package/dist/reputation/trust-score.d.ts +0 -43
- package/dist/reputation/trust-score.d.ts.map +0 -1
- package/dist/reputation/trust-score.js +0 -34
- package/dist/reputation/trust-score.js.map +0 -1
- package/dist/types/model-api.d.ts +0 -4
- package/dist/types/model-api.d.ts.map +0 -1
- package/dist/types/model-api.js +0 -11
- package/dist/types/model-api.js.map +0 -1
- package/dist/types/peer-profile.d.ts +0 -24
- package/dist/types/peer-profile.d.ts.map +0 -1
- package/dist/types/peer-profile.js +0 -2
- package/dist/types/peer-profile.js.map +0 -1
- package/dist/types/staking.d.ts +0 -16
- package/dist/types/staking.d.ts.map +0 -1
- package/dist/types/staking.js +0 -6
- package/dist/types/staking.js.map +0 -1
package/dist/p2p/handshake.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { toPeerId } from "../types/peer.js";
|
|
2
|
-
import { MessageType } from "../types/protocol.js";
|
|
3
|
-
import { ConnectionState } from "../types/connection.js";
|
|
4
|
-
import { signData, verifySignature, bytesToHex } from "./identity.js";
|
|
5
|
-
/** Nonce size in bytes. */
|
|
6
|
-
const NONCE_SIZE = 32;
|
|
7
|
-
/** Handshake timeout in milliseconds. */
|
|
8
|
-
const HANDSHAKE_TIMEOUT_MS = 10_000;
|
|
9
|
-
/** Generate a random nonce for the handshake challenge. */
|
|
10
|
-
function generateNonce() {
|
|
11
|
-
const nonce = new Uint8Array(NONCE_SIZE);
|
|
12
|
-
crypto.getRandomValues(nonce);
|
|
13
|
-
return nonce;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Build the HandshakeInit payload:
|
|
17
|
-
* [32 bytes pubkey] [32 bytes nonce] [64 bytes signature(nonce)]
|
|
18
|
-
*/
|
|
19
|
-
export async function buildHandshakeInit(publicKey, privateKey) {
|
|
20
|
-
const nonce = generateNonce();
|
|
21
|
-
const signature = await signData(privateKey, nonce);
|
|
22
|
-
const payload = new Uint8Array(32 + 32 + 64);
|
|
23
|
-
payload.set(publicKey, 0);
|
|
24
|
-
payload.set(nonce, 32);
|
|
25
|
-
payload.set(signature, 64);
|
|
26
|
-
return { payload, nonce };
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Verify a received HandshakeInit payload.
|
|
30
|
-
* Returns the remote peer's public key and nonce if valid.
|
|
31
|
-
*/
|
|
32
|
-
export async function verifyHandshakeInit(payload) {
|
|
33
|
-
if (payload.length !== 128) {
|
|
34
|
-
return { remotePubKey: new Uint8Array(32), nonce: new Uint8Array(32), valid: false };
|
|
35
|
-
}
|
|
36
|
-
const remotePubKey = payload.slice(0, 32);
|
|
37
|
-
const nonce = payload.slice(32, 64);
|
|
38
|
-
const signature = payload.slice(64, 128);
|
|
39
|
-
const valid = await verifySignature(remotePubKey, signature, nonce);
|
|
40
|
-
return { remotePubKey, nonce, valid };
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Build a HandshakeAck payload:
|
|
44
|
-
* [32 bytes pubkey] [32 bytes echo-nonce] [64 bytes signature(echo-nonce)]
|
|
45
|
-
*/
|
|
46
|
-
export async function buildHandshakeAck(publicKey, privateKey, remoteNonce) {
|
|
47
|
-
const signature = await signData(privateKey, remoteNonce);
|
|
48
|
-
const payload = new Uint8Array(32 + 32 + 64);
|
|
49
|
-
payload.set(publicKey, 0);
|
|
50
|
-
payload.set(remoteNonce, 32);
|
|
51
|
-
payload.set(signature, 64);
|
|
52
|
-
return payload;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Verify a received HandshakeAck payload against the nonce we originally sent.
|
|
56
|
-
*/
|
|
57
|
-
export async function verifyHandshakeAck(payload, originalNonce) {
|
|
58
|
-
if (payload.length !== 128) {
|
|
59
|
-
return { remotePubKey: new Uint8Array(32), valid: false };
|
|
60
|
-
}
|
|
61
|
-
const remotePubKey = payload.slice(0, 32);
|
|
62
|
-
const echoNonce = payload.slice(32, 64);
|
|
63
|
-
const signature = payload.slice(64, 128);
|
|
64
|
-
// Verify that the echoed nonce matches what we sent
|
|
65
|
-
const nonceMatches = originalNonce.every((b, i) => b === echoNonce[i]);
|
|
66
|
-
if (!nonceMatches) {
|
|
67
|
-
return { remotePubKey, valid: false };
|
|
68
|
-
}
|
|
69
|
-
const valid = await verifySignature(remotePubKey, signature, echoNonce);
|
|
70
|
-
return { remotePubKey, valid };
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Perform the full handshake as the initiator.
|
|
74
|
-
* Sends HandshakeInit, waits for HandshakeAck, verifies.
|
|
75
|
-
*/
|
|
76
|
-
export async function performHandshake(conn, localPublicKey, localPrivateKey, sendFn, waitForMessage) {
|
|
77
|
-
const { payload, nonce } = await buildHandshakeInit(localPublicKey, localPrivateKey);
|
|
78
|
-
sendFn(MessageType.HandshakeInit, payload);
|
|
79
|
-
const ackPayload = await waitForMessage(MessageType.HandshakeAck, HANDSHAKE_TIMEOUT_MS);
|
|
80
|
-
const { remotePubKey, valid } = await verifyHandshakeAck(ackPayload, nonce);
|
|
81
|
-
const remotePeerId = toPeerId(bytesToHex(remotePubKey));
|
|
82
|
-
if (valid) {
|
|
83
|
-
conn.setState(ConnectionState.Authenticated);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
conn.setState(ConnectionState.Failed);
|
|
87
|
-
}
|
|
88
|
-
return { remotePeerId, verified: valid };
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Respond to a handshake as the responder.
|
|
92
|
-
* Waits for HandshakeInit, verifies, sends HandshakeAck.
|
|
93
|
-
*/
|
|
94
|
-
export async function respondToHandshake(conn, localPublicKey, localPrivateKey, sendFn, waitForMessage) {
|
|
95
|
-
const initPayload = await waitForMessage(MessageType.HandshakeInit, HANDSHAKE_TIMEOUT_MS);
|
|
96
|
-
const { remotePubKey, nonce, valid } = await verifyHandshakeInit(initPayload);
|
|
97
|
-
if (!valid) {
|
|
98
|
-
conn.setState(ConnectionState.Failed);
|
|
99
|
-
return { remotePeerId: toPeerId(bytesToHex(remotePubKey)), verified: false };
|
|
100
|
-
}
|
|
101
|
-
const ackPayload = await buildHandshakeAck(localPublicKey, localPrivateKey, nonce);
|
|
102
|
-
sendFn(MessageType.HandshakeAck, ackPayload);
|
|
103
|
-
const remotePeerId = toPeerId(bytesToHex(remotePubKey));
|
|
104
|
-
conn.setState(ConnectionState.Authenticated);
|
|
105
|
-
return { remotePeerId, verified: true };
|
|
106
|
-
}
|
|
107
|
-
//# sourceMapp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
1
|
-
/** Configuration for the reconnection strategy. */
|
|
2
|
-
export interface ReconnectConfig {
|
|
3
|
-
/** Base delay in milliseconds before the first reconnect attempt. */
|
|
4
|
-
baseDelayMs?: number;
|
|
5
|
-
/** Maximum delay in milliseconds between reconnect attempts. */
|
|
6
|
-
maxDelayMs?: number;
|
|
7
|
-
/** Maximum number of reconnect attempts before giving up. */
|
|
8
|
-
maxAttempts?: number;
|
|
9
|
-
/** Jitter factor (0-1) to randomize the delay. */
|
|
10
|
-
jitterFactor?: number;
|
|
11
|
-
}
|
|
12
|
-
export interface ReconnectCallbacks {
|
|
13
|
-
/** Called when a reconnect attempt should be made. */
|
|
14
|
-
onReconnect: (attempt: number) => Promise<boolean>;
|
|
15
|
-
/** Called when all attempts are exhausted. */
|
|
16
|
-
onGiveUp: (totalAttempts: number) => void;
|
|
17
|
-
/** Called when reconnection succeeds. */
|
|
18
|
-
onSuccess: (attempt: number) => void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Manages reconnection with exponential backoff and jitter.
|
|
22
|
-
*
|
|
23
|
-
* Delay formula: min(baseDelay * 2^attempt + jitter, maxDelay)
|
|
24
|
-
*/
|
|
25
|
-
export declare class ReconnectManager {
|
|
26
|
-
private _baseDelay;
|
|
27
|
-
private _maxDelay;
|
|
28
|
-
private _maxAttempts;
|
|
29
|
-
private _jitterFactor;
|
|
30
|
-
private _attempt;
|
|
31
|
-
private _callbacks;
|
|
32
|
-
private _timeoutHandle;
|
|
33
|
-
private _active;
|
|
34
|
-
constructor(callbacks: ReconnectCallbacks, config?: ReconnectConfig);
|
|
35
|
-
get attempt(): number;
|
|
36
|
-
get isActive(): boolean;
|
|
37
|
-
/** Calculate delay for the current attempt with exponential backoff + jitter. */
|
|
38
|
-
calculateDelay(attempt: number): number;
|
|
39
|
-
/** Start the reconnection process. */
|
|
40
|
-
start(): void;
|
|
41
|
-
/** Stop the reconnection process. */
|
|
42
|
-
stop(): void;
|
|
43
|
-
/** Reset the attempt counter (e.g., after a successful connection). */
|
|
44
|
-
reset(): void;
|
|
45
|
-
/** Schedule the next reconnect attempt. */
|
|
46
|
-
private _scheduleAttempt;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=reconnect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reconnect.d.ts","sourceRoot":"","sources":["../../src/p2p/reconnect.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAOD,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,8CAA8C;IAC9C,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,yCAAyC;IACzC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,OAAO,CAAS;gBAEZ,SAAS,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,eAAe;IAQnE,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,iFAAiF;IACjF,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAMvC,sCAAsC;IACtC,KAAK,IAAI,IAAI;IAOb,qCAAqC;IACrC,IAAI,IAAI,IAAI;IAQZ,uEAAuE;IACvE,KAAK,IAAI,IAAI;IAKb,2CAA2C;IAC3C,OAAO,CAAC,gBAAgB;CA4BzB"}
|
package/dist/p2p/reconnect.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
const DEFAULT_BASE_DELAY_MS = 1_000;
|
|
2
|
-
const DEFAULT_MAX_DELAY_MS = 30_000;
|
|
3
|
-
const DEFAULT_MAX_ATTEMPTS = 5;
|
|
4
|
-
const DEFAULT_JITTER_FACTOR = 0.3;
|
|
5
|
-
/**
|
|
6
|
-
* Manages reconnection with exponential backoff and jitter.
|
|
7
|
-
*
|
|
8
|
-
* Delay formula: min(baseDelay * 2^attempt + jitter, maxDelay)
|
|
9
|
-
*/
|
|
10
|
-
export class ReconnectManager {
|
|
11
|
-
_baseDelay;
|
|
12
|
-
_maxDelay;
|
|
13
|
-
_maxAttempts;
|
|
14
|
-
_jitterFactor;
|
|
15
|
-
_attempt = 0;
|
|
16
|
-
_callbacks;
|
|
17
|
-
_timeoutHandle = null;
|
|
18
|
-
_active = false;
|
|
19
|
-
constructor(callbacks, config) {
|
|
20
|
-
this._callbacks = callbacks;
|
|
21
|
-
this._baseDelay = config?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
|
|
22
|
-
this._maxDelay = config?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
|
|
23
|
-
this._maxAttempts = config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
|
24
|
-
this._jitterFactor = config?.jitterFactor ?? DEFAULT_JITTER_FACTOR;
|
|
25
|
-
}
|
|
26
|
-
get attempt() {
|
|
27
|
-
return this._attempt;
|
|
28
|
-
}
|
|
29
|
-
get isActive() {
|
|
30
|
-
return this._active;
|
|
31
|
-
}
|
|
32
|
-
/** Calculate delay for the current attempt with exponential backoff + jitter. */
|
|
33
|
-
calculateDelay(attempt) {
|
|
34
|
-
const exponentialDelay = this._baseDelay * Math.pow(2, attempt);
|
|
35
|
-
const jitter = exponentialDelay * this._jitterFactor * Math.random();
|
|
36
|
-
return Math.min(exponentialDelay + jitter, this._maxDelay);
|
|
37
|
-
}
|
|
38
|
-
/** Start the reconnection process. */
|
|
39
|
-
start() {
|
|
40
|
-
if (this._active)
|
|
41
|
-
return;
|
|
42
|
-
this._active = true;
|
|
43
|
-
this._attempt = 0;
|
|
44
|
-
this._scheduleAttempt();
|
|
45
|
-
}
|
|
46
|
-
/** Stop the reconnection process. */
|
|
47
|
-
stop() {
|
|
48
|
-
this._active = false;
|
|
49
|
-
if (this._timeoutHandle) {
|
|
50
|
-
clearTimeout(this._timeoutHandle);
|
|
51
|
-
this._timeoutHandle = null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** Reset the attempt counter (e.g., after a successful connection). */
|
|
55
|
-
reset() {
|
|
56
|
-
this._attempt = 0;
|
|
57
|
-
this.stop();
|
|
58
|
-
}
|
|
59
|
-
/** Schedule the next reconnect attempt. */
|
|
60
|
-
_scheduleAttempt() {
|
|
61
|
-
if (!this._active)
|
|
62
|
-
return;
|
|
63
|
-
if (this._attempt >= this._maxAttempts) {
|
|
64
|
-
this._active = false;
|
|
65
|
-
this._callbacks.onGiveUp(this._attempt);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const delay = this.calculateDelay(this._attempt);
|
|
69
|
-
this._timeoutHandle = setTimeout(async () => {
|
|
70
|
-
if (!this._active)
|
|
71
|
-
return;
|
|
72
|
-
this._attempt++;
|
|
73
|
-
try {
|
|
74
|
-
const success = await this._callbacks.onReconnect(this._attempt);
|
|
75
|
-
if (success) {
|
|
76
|
-
this._active = false;
|
|
77
|
-
this._callbacks.onSuccess(this._attempt);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
this._scheduleAttempt();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
this._scheduleAttempt();
|
|
85
|
-
}
|
|
86
|
-
}, delay);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=reconnect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reconnect.js","sourceRoot":"","sources":["../../src/p2p/reconnect.ts"],"names":[],"mappings":"AAYA,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAWlC;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IACnB,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,YAAY,CAAS;IACrB,aAAa,CAAS;IACtB,QAAQ,GAAG,CAAC,CAAC;IACb,UAAU,CAAqB;IAC/B,cAAc,GAAyC,IAAI,CAAC;IAC5D,OAAO,GAAG,KAAK,CAAC;IAExB,YAAY,SAA6B,EAAE,MAAwB;QACjE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,MAAM,EAAE,WAAW,IAAI,qBAAqB,CAAC;QAC/D,IAAI,CAAC,SAAS,GAAG,MAAM,EAAE,UAAU,IAAI,oBAAoB,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,WAAW,IAAI,oBAAoB,CAAC;QAChE,IAAI,CAAC,aAAa,GAAG,MAAM,EAAE,YAAY,IAAI,qBAAqB,CAAC;IACrE,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,iFAAiF;IACjF,cAAc,CAAC,OAAe;QAC5B,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,C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O;gBAAE,OAAO;YAE1B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACjE,IAAI,OAAO,EAAE,CAAC;oBACZ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;oBACrB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC3C,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,CAAC;QACH,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { PeerId } from '../types/peer.js';
|
|
2
|
-
import type { UsageReceipt } from '../types/metering.js';
|
|
3
|
-
import type { PaymentDispute } from './types.js';
|
|
4
|
-
export declare const DISPUTE_TIMEOUT_MS: number;
|
|
5
|
-
export declare function createDispute(channel: {
|
|
6
|
-
channelId: string;
|
|
7
|
-
sessionId: string;
|
|
8
|
-
}, initiatorPeerId: PeerId, reason: string, buyerReceipts: UsageReceipt[], sellerReceipts: UsageReceipt[]): PaymentDispute;
|
|
9
|
-
export declare function detectDiscrepancy(buyerReceipts: UsageReceipt[], sellerReceipts: UsageReceipt[], thresholdPercent: number): {
|
|
10
|
-
discrepancyDetected: boolean;
|
|
11
|
-
buyerTotal: number;
|
|
12
|
-
sellerTotal: number;
|
|
13
|
-
diffPercent: number;
|
|
14
|
-
};
|
|
15
|
-
export declare function resolveDispute(dispute: PaymentDispute, resolution: string): PaymentDispute;
|
|
16
|
-
export declare function isDisputeExpired(dispute: PaymentDispute): boolean;
|
|
17
|
-
export declare function calculateDisputedAmount(buyerReceipts: UsageReceipt[], sellerReceipts: UsageReceipt[]): number;
|
|
18
|
-
//# sourceMappingURL=disputes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"disputes.d.ts","sourceRoot":"","sources":["../../src/payments/disputes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,kBAAkB,QAAsB,CAAC;AAEtD,wBAAgB,aAAa,CAC3B,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EACjD,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,EAC7B,cAAc,EAAE,YAAY,EAAE,GAC7B,cAAc,CAchB;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,YAAY,EAAE,EAC7B,cAAc,EAAE,YAAY,EAAE,EAC9B,gBAAgB,EAAE,MAAM,GACvB;IAAE,mBAAmB,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAahG;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,GACjB,cAAc,CAOhB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAEjE;AAED,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,YAAY,EAAE,EAC7B,cAAc,EAAE,YAAY,EAAE,GAC7B,MAAM,CAIR"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
export const DISPUTE_TIMEOUT_MS = 72 * 60 * 60 * 1000;
|
|
3
|
-
export function createDispute(channel, initiatorPeerId, reason, buyerReceipts, sellerReceipts) {
|
|
4
|
-
return {
|
|
5
|
-
disputeId: randomUUID(),
|
|
6
|
-
channelId: channel.channelId,
|
|
7
|
-
sessionId: channel.sessionId,
|
|
8
|
-
initiatorPeerId,
|
|
9
|
-
reason,
|
|
10
|
-
status: 'open',
|
|
11
|
-
buyerReceipts,
|
|
12
|
-
sellerReceipts,
|
|
13
|
-
createdAt: Date.now(),
|
|
14
|
-
resolvedAt: null,
|
|
15
|
-
resolution: null,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function detectDiscrepancy(buyerReceipts, sellerReceipts, thresholdPercent) {
|
|
19
|
-
const buyerTotal = buyerReceipts.reduce((sum, r) => sum + r.tokens.totalTokens, 0);
|
|
20
|
-
const sellerTotal = sellerReceipts.reduce((sum, r) => sum + r.tokens.totalTokens, 0);
|
|
21
|
-
const max = Math.max(buyerTotal, sellerTotal);
|
|
22
|
-
const diffPercent = max === 0 ? 0 : (Math.abs(buyerTotal - sellerTotal) / max) * 100;
|
|
23
|
-
const discrepancyDetected = diffPercent > thresholdPercent;
|
|
24
|
-
return {
|
|
25
|
-
discrepancyDetected,
|
|
26
|
-
buyerTotal,
|
|
27
|
-
sellerTotal,
|
|
28
|
-
diffPercent,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export function resolveDispute(dispute, resolution) {
|
|
32
|
-
return {
|
|
33
|
-
...dispute,
|
|
34
|
-
status: 'resolved',
|
|
35
|
-
resolvedAt: Date.now(),
|
|
36
|
-
resolution,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export function isDisputeExpired(dispute) {
|
|
40
|
-
return Date.now() - dispute.createdAt > DISPUTE_TIMEOUT_MS;
|
|
41
|
-
}
|
|
42
|
-
export function calculateDisputedAmount(buyerReceipts, sellerReceipts) {
|
|
43
|
-
const buyerTotalUsd = buyerReceipts.reduce((sum, r) => sum + r.costCents, 0) / 100;
|
|
44
|
-
const sellerTotalUsd = sellerReceipts.reduce((sum, r) => sum + r.costCents, 0) / 100;
|
|
45
|
-
return Math.abs(buyerTotalUsd - sellerTotalUsd);
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=disputes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"disputes.js","sourceRoot":"","sources":["../../src/payments/disputes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtD,MAAM,UAAU,aAAa,CAC3B,OAAiD,EACjD,eAAuB,EACvB,MAAc,EACd,aAA6B,EAC7B,cAA8B;IAE9B,OAAO;QACL,SAAS,EAAE,UAAU,EAAE;QACvB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,eAAe;QACf,MAAM;QACN,MAAM,EAAE,MAAM;QACd,aAAa;QACb,cAAc;QACd,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;KACjB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,aAA6B,EAC7B,cAA8B,EAC9B,gBAAwB;IAExB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACnF,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACrF,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACrF,MAAM,mBAAmB,GAAG,WAAW,GAAG,gBAAgB,CAAC;IAE3D,OAAO;QACL,mBAAmB;QACnB,UAAU;QACV,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,OAAuB,EACvB,UAAkB;IAElB,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;QACtB,UAAU;KACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAuB;IACtD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,SAAS,GAAG,kBAAkB,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,aAA6B,EAC7B,cAA8B;IAE9B,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;IACnF,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;IACrF,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,cAAc,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { type AbstractSigner } from 'ethers';
|
|
2
|
-
import { BaseEvmClient } from './base-evm-client.js';
|
|
3
|
-
export interface BaseEscrowConfig {
|
|
4
|
-
/** Base JSON-RPC endpoint (e.g. http://127.0.0.1:8545 for anvil) */
|
|
5
|
-
rpcUrl: string;
|
|
6
|
-
/** Deployed AntseedEscrow contract address */
|
|
7
|
-
contractAddress: string;
|
|
8
|
-
/** USDC token contract address */
|
|
9
|
-
usdcAddress: string;
|
|
10
|
-
/** Confirmation commitment level (not used on EVM, reserved for future) */
|
|
11
|
-
commitment?: 'latest' | 'finalized';
|
|
12
|
-
}
|
|
13
|
-
export interface SessionInfo {
|
|
14
|
-
buyer: string;
|
|
15
|
-
seller: string;
|
|
16
|
-
maxAmount: bigint;
|
|
17
|
-
nonce: bigint;
|
|
18
|
-
deadline: bigint;
|
|
19
|
-
previousConsumption: bigint;
|
|
20
|
-
previousSessionId: string;
|
|
21
|
-
reservedAt: bigint;
|
|
22
|
-
settledAmount: bigint;
|
|
23
|
-
settledTokenCount: bigint;
|
|
24
|
-
tokenRate: bigint;
|
|
25
|
-
status: number;
|
|
26
|
-
isFirstSign: boolean;
|
|
27
|
-
isProvenSign: boolean;
|
|
28
|
-
isQualifiedProvenSign: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface BuyerBalanceInfo {
|
|
31
|
-
available: bigint;
|
|
32
|
-
reserved: bigint;
|
|
33
|
-
pendingWithdrawal: bigint;
|
|
34
|
-
lastActivityAt: bigint;
|
|
35
|
-
}
|
|
36
|
-
export interface SellerAccountInfo {
|
|
37
|
-
stake: bigint;
|
|
38
|
-
earnings: bigint;
|
|
39
|
-
stakedAt: bigint;
|
|
40
|
-
tokenRate: bigint;
|
|
41
|
-
}
|
|
42
|
-
export declare class BaseEscrowClient extends BaseEvmClient {
|
|
43
|
-
private readonly _usdcAddress;
|
|
44
|
-
constructor(config: BaseEscrowConfig);
|
|
45
|
-
get usdcAddress(): string;
|
|
46
|
-
private _prepareEscrowWrite;
|
|
47
|
-
deposit(signer: AbstractSigner, amount: bigint): Promise<string>;
|
|
48
|
-
depositFor(signer: AbstractSigner, buyer: string, amount: bigint): Promise<string>;
|
|
49
|
-
requestWithdrawal(signer: AbstractSigner, amount: bigint): Promise<string>;
|
|
50
|
-
executeWithdrawal(signer: AbstractSigner): Promise<string>;
|
|
51
|
-
cancelWithdrawal(signer: AbstractSigner): Promise<string>;
|
|
52
|
-
stake(signer: AbstractSigner, amount: bigint): Promise<string>;
|
|
53
|
-
unstake(signer: AbstractSigner): Promise<string>;
|
|
54
|
-
setTokenRate(signer: AbstractSigner, rate: bigint): Promise<string>;
|
|
55
|
-
claimEarnings(signer: AbstractSigner): Promise<string>;
|
|
56
|
-
reserve(signer: AbstractSigner, buyer: string, sessionId: string, maxAmount: bigint, nonce: bigint, deadline: bigint, previousConsumption: bigint, previousSessionId: string, buyerSig: string): Promise<string>;
|
|
57
|
-
settle(signer: AbstractSigner, sessionId: string, tokenCount: bigint): Promise<string>;
|
|
58
|
-
settleTimeout(signer: AbstractSigner, sessionId: string): Promise<string>;
|
|
59
|
-
getBuyerBalance(buyerAddr: string): Promise<BuyerBalanceInfo>;
|
|
60
|
-
getBuyerCreditLimit(buyerAddr: string): Promise<bigint>;
|
|
61
|
-
getSellerAccount(sellerAddr: string): Promise<SellerAccountInfo>;
|
|
62
|
-
getSession(sessionId: string): Promise<SessionInfo>;
|
|
63
|
-
domainSeparator(): Promise<string>;
|
|
64
|
-
getFirstSignCap(): Promise<bigint>;
|
|
65
|
-
getLatestSessionId(buyerAddr: string, sellerAddr: string): Promise<string>;
|
|
66
|
-
getFirstSessionTimestamp(buyerAddr: string, sellerAddr: string): Promise<bigint>;
|
|
67
|
-
getProvenSignCooldown(): Promise<bigint>;
|
|
68
|
-
/**
|
|
69
|
-
* Fetch all data the buyer needs to display a payment approval card.
|
|
70
|
-
* Batches multiple view calls in parallel.
|
|
71
|
-
*/
|
|
72
|
-
getBuyerApprovalContext(buyerAddr: string, sellerAddr: string): Promise<{
|
|
73
|
-
buyerBalance: BuyerBalanceInfo;
|
|
74
|
-
firstSignCap: bigint;
|
|
75
|
-
latestSessionId: string;
|
|
76
|
-
firstSessionTimestamp: bigint;
|
|
77
|
-
isFirstSign: boolean;
|
|
78
|
-
cooldownRemainingSecs: number;
|
|
79
|
-
}>;
|
|
80
|
-
getUSDCBalance(ownerAddr: string): Promise<bigint>;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=escrow-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escrow-client.d.ts","sourceRoot":"","sources":["../../../src/payments/evm/escrow-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;CACrC;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAi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