@antseed/node 0.2.167 → 0.2.169
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metering/seller-session-tracker.d.ts +3 -4
- package/dist/metering/seller-session-tracker.d.ts.map +1 -1
- package/dist/metering/seller-session-tracker.js +7 -3
- package/dist/metering/seller-session-tracker.js.map +1 -1
- package/dist/model-metadata.d.ts +7 -0
- package/dist/model-metadata.d.ts.map +1 -1
- package/dist/model-metadata.js +11 -0
- package/dist/model-metadata.js.map +1 -1
- package/dist/node.d.ts +11 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +31 -2
- package/dist/node.js.map +1 -1
- package/dist/p2p/connection-manager.d.ts +16 -0
- package/dist/p2p/connection-manager.d.ts.map +1 -1
- package/dist/p2p/connection-manager.js +35 -1
- package/dist/p2p/connection-manager.js.map +1 -1
- package/dist/p2p/inbound-idle-tracker.d.ts +39 -0
- package/dist/p2p/inbound-idle-tracker.d.ts.map +1 -0
- package/dist/p2p/inbound-idle-tracker.js +65 -0
- package/dist/p2p/inbound-idle-tracker.js.map +1 -0
- package/dist/payments/seller-free-usage-manager.d.ts +2 -0
- package/dist/payments/seller-free-usage-manager.d.ts.map +1 -1
- package/dist/payments/seller-free-usage-manager.js +4 -0
- package/dist/payments/seller-free-usage-manager.js.map +1 -1
- package/dist/reputation/trust-score.d.ts +49 -33
- package/dist/reputation/trust-score.d.ts.map +1 -1
- package/dist/reputation/trust-score.js +55 -41
- package/dist/reputation/trust-score.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,71 +1,79 @@
|
|
|
1
1
|
import type { PeerInfo } from '../types/peer.js';
|
|
2
2
|
/**
|
|
3
|
-
* Buyer-side trust score, 0-100
|
|
3
|
+
* Buyer-side trust score, 0-100. It estimates what a buyer's spend with a seller
|
|
4
|
+
* earns (stake behind the seller, scaled by the points policies) and whether the
|
|
5
|
+
* seller carries real volume, plus credit for a proven identity and a free model:
|
|
4
6
|
*
|
|
5
|
-
*
|
|
7
|
+
* sum = min(100, power + usage + identity + freeModels)
|
|
8
|
+
* trust = washFlagged ? 0 : min(100, sum * verification multiplier)
|
|
6
9
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - usage (20): the seller pool's share of all pools' recognized-usage points
|
|
10
|
+
* - power (70): the pool's share of all pools' lock-weighted staking power in
|
|
11
|
+
* the current epoch (`AntseedSellerPools`): what a buyer's spend
|
|
12
|
+
* with this seller earns this week.
|
|
13
|
+
* - usage (30): the seller pool's share of all pools' recognized-usage points
|
|
12
14
|
* in the last complete weekly epoch (`AntseedUsageAccounting`).
|
|
13
15
|
* Points only accrue for sellers with a pool and already pass
|
|
14
16
|
* the on-chain points policies.
|
|
15
|
-
* -
|
|
16
|
-
* the current epoch (`AntseedSellerPools`): what a buyer's spend
|
|
17
|
-
* with this seller earns this week.
|
|
18
|
-
* - identity (20): public history of a verified identity (GitHub portfolio or
|
|
17
|
+
* - identity (+20): public history of a verified identity (GitHub portfolio or
|
|
19
18
|
* domain registration age, see `identity-history.ts`).
|
|
20
|
-
* - freeModels (+5):
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* - freeModels (+5): when the seller offers at least one model at $0 input and
|
|
20
|
+
* output (and cached input, when it prices one).
|
|
21
|
+
* - verification: the seller's points multiplier from the verification policy,
|
|
22
|
+
* both its bonus and its penalty: what the same spend earns.
|
|
23
23
|
* - wash: a seller flagged by `AntseedWashTradingRegistry` scores 0.
|
|
24
24
|
*
|
|
25
25
|
* Shares are unitless and self-normalizing, mapped through `shareCurve`, a log
|
|
26
|
-
* curve with a 1000x range
|
|
27
|
-
*
|
|
26
|
+
* curve with a 1000x range that gives full marks at `TRUST_FULL_SHARE_BPS`
|
|
27
|
+
* (50% -> 1, 5% -> 0.67, 0.5% -> 0.35). Settled service history is reported for
|
|
28
|
+
* display and does not change the number.
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* Failure streaks, cooldowns, price limits and allow/block lists stay separate
|
|
31
|
+
* router rules.
|
|
31
32
|
*/
|
|
32
|
-
/**
|
|
33
|
+
/** Most a verified identity adds on top of the weights; the total caps at 100. */
|
|
34
|
+
export declare const TRUST_IDENTITY_BONUS = 20;
|
|
35
|
+
/** Maximum contribution of each part. `usage` and `power`, the two network shares, sum to 100. */
|
|
33
36
|
export declare const TRUST_WEIGHTS: {
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
|
|
37
|
+
readonly usage: 30;
|
|
38
|
+
readonly power: 70;
|
|
39
|
+
/** @deprecated Service history no longer feeds the score. */
|
|
40
|
+
readonly history: 0;
|
|
41
|
+
/** @deprecated Use `TRUST_IDENTITY_BONUS`. */
|
|
37
42
|
readonly identity: 20;
|
|
38
43
|
};
|
|
39
44
|
/** Bonus for offering a free model, added on top of the weights; the total caps at 100. */
|
|
40
45
|
export declare const TRUST_FREE_MODELS_BONUS = 5;
|
|
41
|
-
/**
|
|
46
|
+
/** The network share that earns full marks in `shareCurve`, in basis points. */
|
|
47
|
+
export declare const TRUST_FULL_SHARE_BPS = 5000;
|
|
48
|
+
/** @deprecated Service history no longer feeds the trust score. */
|
|
42
49
|
export declare const TRUST_HISTORY_CHANNEL_TARGET = 100;
|
|
43
|
-
/**
|
|
50
|
+
/** @deprecated Service history no longer feeds the trust score. */
|
|
44
51
|
export declare const TRUST_HISTORY_VOLUME_USDC_MICROS_TARGET = 100000000;
|
|
45
52
|
/** Dynamic range of the share curve: a share of 1/SHARE_CURVE_RANGE maps to ~0. */
|
|
46
53
|
export declare const SHARE_CURVE_RANGE = 1000;
|
|
47
54
|
export interface TrustBreakdown {
|
|
48
55
|
/** Final trust score, 0-100. */
|
|
49
56
|
score: number;
|
|
50
|
-
/** Settled service history,
|
|
57
|
+
/** Settled service history, for display only; `null` when channel stats are unavailable. */
|
|
51
58
|
history: {
|
|
59
|
+
/** @deprecated Always 0: service history no longer feeds the score. */
|
|
52
60
|
score: number;
|
|
53
61
|
channelCount: number;
|
|
54
62
|
totalVolumeUsdcMicros: number;
|
|
55
63
|
} | null;
|
|
56
|
-
/** Last epoch's usage-points share, weighted 0-
|
|
64
|
+
/** Last epoch's usage-points share, weighted 0-30; `null` when usage accounting data is unavailable. */
|
|
57
65
|
usage: {
|
|
58
66
|
score: number;
|
|
59
67
|
shareBps: number;
|
|
60
68
|
epoch: number;
|
|
61
69
|
} | null;
|
|
62
|
-
/** Current epoch's staking-power share, weighted 0-
|
|
70
|
+
/** Current epoch's staking-power share, weighted 0-70; `null` when pool data is unavailable. */
|
|
63
71
|
power: {
|
|
64
72
|
score: number;
|
|
65
73
|
shareBps: number;
|
|
66
74
|
epoch: number;
|
|
67
75
|
} | null;
|
|
68
|
-
/** Verified-identity
|
|
76
|
+
/** Verified-identity bonus, 0-20; `null` when no verified identity has usable history. */
|
|
69
77
|
identity: {
|
|
70
78
|
score: number;
|
|
71
79
|
kind: 'github' | 'domain';
|
|
@@ -79,22 +87,30 @@ export interface TrustBreakdown {
|
|
|
79
87
|
/** Wash-trading registry verdict; `null` when the registry is unavailable. */
|
|
80
88
|
washFlagged: boolean | null;
|
|
81
89
|
/**
|
|
82
|
-
* Model-verification
|
|
83
|
-
*
|
|
84
|
-
* `null` when
|
|
90
|
+
* Model-verification effect: the seller's points multiplier from the verification policy and
|
|
91
|
+
* the points it added (positive) or took off (negative).
|
|
92
|
+
* `null` when it changes nothing or there is no fresh verification read.
|
|
85
93
|
*/
|
|
86
94
|
verification?: {
|
|
87
95
|
multiplierBps: number;
|
|
88
96
|
sameCount: number;
|
|
89
97
|
diffCount: number;
|
|
98
|
+
change: number;
|
|
99
|
+
/** @deprecated Use `change`. The points taken off, 0 for a bonus. */
|
|
90
100
|
penalty: number;
|
|
91
101
|
} | null;
|
|
92
102
|
}
|
|
93
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* `log10(1 + (SHARE_CURVE_RANGE - 1) · min(1, share / full)) / log10(SHARE_CURVE_RANGE)` in 0-1, share in
|
|
105
|
+
* basis points and `full` being `TRUST_FULL_SHARE_BPS`.
|
|
106
|
+
*/
|
|
94
107
|
export declare function shareCurve(shareBps: number): number;
|
|
95
108
|
/** The first announced model priced at $0, or `null` when the seller offers none. */
|
|
96
109
|
export declare function firstFreeService(peer: PeerInfo): string | null;
|
|
97
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Bounded logarithmic progress toward a non-zero target.
|
|
112
|
+
* @deprecated Service history no longer feeds the trust score.
|
|
113
|
+
*/
|
|
98
114
|
export declare function historyCurve(value: number, target: number): number;
|
|
99
115
|
/**
|
|
100
116
|
* Compute the trust breakdown, or `null` when nothing about the peer is known
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trust-score.d.ts","sourceRoot":"","sources":["../../src/reputation/trust-score.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD
|
|
1
|
+
{"version":3,"file":"trust-score.d.ts","sourceRoot":"","sources":["../../src/reputation/trust-score.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,kGAAkG;AAClG,eAAO,MAAM,aAAa;;;IAGxB,6DAA6D;;IAE7D,8CAA8C;;CAEtC,CAAC;AAEX,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAE1C,mEAAmE;AACnE,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAEhD,mEAAmE;AACnE,eAAO,MAAM,uCAAuC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,MAAM,CAInD;AAQD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAS9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,SAAa,GAAG,cAAc,GAAG,IAAI,CA0C3F;AAcD,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,SAAa,GAAG,MAAM,GAAG,IAAI,CAE5E"}
|
|
@@ -2,53 +2,68 @@ import { VERIFICATION_POINTS_BPS } from './verification-points.js';
|
|
|
2
2
|
import { VERIFICATION_STATUS_STALE_MAX_MS } from './model-reputation.js';
|
|
3
3
|
import { IDENTITY_GITHUB_MAX_POINTS as IDENTITY_MAX_POINTS, scoreIdentityHistory } from './identity-history.js';
|
|
4
4
|
/**
|
|
5
|
-
* Buyer-side trust score, 0-100
|
|
5
|
+
* Buyer-side trust score, 0-100. It estimates what a buyer's spend with a seller
|
|
6
|
+
* earns (stake behind the seller, scaled by the points policies) and whether the
|
|
7
|
+
* seller carries real volume, plus credit for a proven identity and a free model:
|
|
6
8
|
*
|
|
7
|
-
*
|
|
9
|
+
* sum = min(100, power + usage + identity + freeModels)
|
|
10
|
+
* trust = washFlagged ? 0 : min(100, sum * verification multiplier)
|
|
8
11
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - usage (20): the seller pool's share of all pools' recognized-usage points
|
|
12
|
+
* - power (70): the pool's share of all pools' lock-weighted staking power in
|
|
13
|
+
* the current epoch (`AntseedSellerPools`): what a buyer's spend
|
|
14
|
+
* with this seller earns this week.
|
|
15
|
+
* - usage (30): the seller pool's share of all pools' recognized-usage points
|
|
14
16
|
* in the last complete weekly epoch (`AntseedUsageAccounting`).
|
|
15
17
|
* Points only accrue for sellers with a pool and already pass
|
|
16
18
|
* the on-chain points policies.
|
|
17
|
-
* -
|
|
18
|
-
* the current epoch (`AntseedSellerPools`): what a buyer's spend
|
|
19
|
-
* with this seller earns this week.
|
|
20
|
-
* - identity (20): public history of a verified identity (GitHub portfolio or
|
|
19
|
+
* - identity (+20): public history of a verified identity (GitHub portfolio or
|
|
21
20
|
* domain registration age, see `identity-history.ts`).
|
|
22
|
-
* - freeModels (+5):
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* - freeModels (+5): when the seller offers at least one model at $0 input and
|
|
22
|
+
* output (and cached input, when it prices one).
|
|
23
|
+
* - verification: the seller's points multiplier from the verification policy,
|
|
24
|
+
* both its bonus and its penalty: what the same spend earns.
|
|
25
25
|
* - wash: a seller flagged by `AntseedWashTradingRegistry` scores 0.
|
|
26
26
|
*
|
|
27
27
|
* Shares are unitless and self-normalizing, mapped through `shareCurve`, a log
|
|
28
|
-
* curve with a 1000x range
|
|
29
|
-
*
|
|
28
|
+
* curve with a 1000x range that gives full marks at `TRUST_FULL_SHARE_BPS`
|
|
29
|
+
* (50% -> 1, 5% -> 0.67, 0.5% -> 0.35). Settled service history is reported for
|
|
30
|
+
* display and does not change the number.
|
|
30
31
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
32
|
+
* Failure streaks, cooldowns, price limits and allow/block lists stay separate
|
|
33
|
+
* router rules.
|
|
33
34
|
*/
|
|
34
|
-
/**
|
|
35
|
-
export const
|
|
35
|
+
/** Most a verified identity adds on top of the weights; the total caps at 100. */
|
|
36
|
+
export const TRUST_IDENTITY_BONUS = 20;
|
|
37
|
+
/** Maximum contribution of each part. `usage` and `power`, the two network shares, sum to 100. */
|
|
38
|
+
export const TRUST_WEIGHTS = {
|
|
39
|
+
usage: 30,
|
|
40
|
+
power: 70,
|
|
41
|
+
/** @deprecated Service history no longer feeds the score. */
|
|
42
|
+
history: 0,
|
|
43
|
+
/** @deprecated Use `TRUST_IDENTITY_BONUS`. */
|
|
44
|
+
identity: TRUST_IDENTITY_BONUS,
|
|
45
|
+
};
|
|
36
46
|
/** Bonus for offering a free model, added on top of the weights; the total caps at 100. */
|
|
37
47
|
export const TRUST_FREE_MODELS_BONUS = 5;
|
|
38
|
-
/**
|
|
48
|
+
/** The network share that earns full marks in `shareCurve`, in basis points. */
|
|
49
|
+
export const TRUST_FULL_SHARE_BPS = 5_000;
|
|
50
|
+
/** @deprecated Service history no longer feeds the trust score. */
|
|
39
51
|
export const TRUST_HISTORY_CHANNEL_TARGET = 100;
|
|
40
|
-
/**
|
|
52
|
+
/** @deprecated Service history no longer feeds the trust score. */
|
|
41
53
|
export const TRUST_HISTORY_VOLUME_USDC_MICROS_TARGET = 100_000_000;
|
|
42
54
|
/** Dynamic range of the share curve: a share of 1/SHARE_CURVE_RANGE maps to ~0. */
|
|
43
55
|
export const SHARE_CURVE_RANGE = 1_000;
|
|
44
56
|
function finite(value) {
|
|
45
57
|
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null;
|
|
46
58
|
}
|
|
47
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* `log10(1 + (SHARE_CURVE_RANGE - 1) · min(1, share / full)) / log10(SHARE_CURVE_RANGE)` in 0-1, share in
|
|
61
|
+
* basis points and `full` being `TRUST_FULL_SHARE_BPS`.
|
|
62
|
+
*/
|
|
48
63
|
export function shareCurve(shareBps) {
|
|
49
64
|
if (!Number.isFinite(shareBps) || shareBps <= 0)
|
|
50
65
|
return 0;
|
|
51
|
-
const share = Math.min(1, shareBps /
|
|
66
|
+
const share = Math.min(1, shareBps / TRUST_FULL_SHARE_BPS);
|
|
52
67
|
return Math.log10(1 + (SHARE_CURVE_RANGE - 1) * share) / Math.log10(SHARE_CURVE_RANGE);
|
|
53
68
|
}
|
|
54
69
|
function isFreePrice(price) {
|
|
@@ -69,7 +84,10 @@ export function firstFreeService(peer) {
|
|
|
69
84
|
}
|
|
70
85
|
return null;
|
|
71
86
|
}
|
|
72
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Bounded logarithmic progress toward a non-zero target.
|
|
89
|
+
* @deprecated Service history no longer feeds the trust score.
|
|
90
|
+
*/
|
|
73
91
|
export function historyCurve(value, target) {
|
|
74
92
|
if (!Number.isFinite(value) || value <= 0 || !Number.isFinite(target) || target <= 0)
|
|
75
93
|
return 0;
|
|
@@ -84,12 +102,7 @@ export function computeTrustScore(peer, nowMs = Date.now()) {
|
|
|
84
102
|
const channelCount = finite(peer.onChainChannelCount);
|
|
85
103
|
const totalVolumeUsdcMicros = finite(peer.onChainTotalVolumeUsdcMicros);
|
|
86
104
|
const history = channelCount !== null && totalVolumeUsdcMicros !== null
|
|
87
|
-
? {
|
|
88
|
-
score: TRUST_WEIGHTS.history * (historyCurve(channelCount, TRUST_HISTORY_CHANNEL_TARGET)
|
|
89
|
-
+ historyCurve(totalVolumeUsdcMicros / 1_000_000, TRUST_HISTORY_VOLUME_USDC_MICROS_TARGET / 1_000_000)) / 2,
|
|
90
|
-
channelCount,
|
|
91
|
-
totalVolumeUsdcMicros,
|
|
92
|
-
}
|
|
105
|
+
? { score: 0, channelCount, totalVolumeUsdcMicros }
|
|
93
106
|
: null;
|
|
94
107
|
const epoch = finite(peer.onChainUsageEpoch);
|
|
95
108
|
const usageShare = finite(peer.onChainUsageShareBps);
|
|
@@ -102,32 +115,33 @@ export function computeTrustScore(peer, nowMs = Date.now()) {
|
|
|
102
115
|
: null;
|
|
103
116
|
const identityHistory = scoreIdentityHistory(peer, nowMs);
|
|
104
117
|
const identity = identityHistory
|
|
105
|
-
? { score:
|
|
118
|
+
? { score: TRUST_IDENTITY_BONUS * identityHistory.points / IDENTITY_MAX_POINTS, kind: identityHistory.kind, claim: identityHistory.claim }
|
|
106
119
|
: null;
|
|
107
120
|
const freeService = firstFreeService(peer);
|
|
108
121
|
const freeModels = freeService !== null ? { score: TRUST_FREE_MODELS_BONUS, service: freeService } : null;
|
|
109
122
|
const washFlagged = typeof peer.onChainWashFlagged === 'boolean' ? peer.onChainWashFlagged : null;
|
|
110
123
|
if (history === null && usage === null && power === null && identity === null && washFlagged === null)
|
|
111
124
|
return null;
|
|
112
|
-
const
|
|
113
|
-
const multiplierBps =
|
|
114
|
-
const score = multiplierBps === null ?
|
|
115
|
-
const verification = multiplierBps === null ? null : {
|
|
125
|
+
const sum = washFlagged ? 0 : Math.min(100, (usage?.score ?? 0) + (power?.score ?? 0) + (identity?.score ?? 0) + (freeModels?.score ?? 0));
|
|
126
|
+
const multiplierBps = verificationMultiplierBps(peer, nowMs);
|
|
127
|
+
const score = multiplierBps === null ? sum : Math.min(100, sum * multiplierBps / VERIFICATION_POINTS_BPS);
|
|
128
|
+
const verification = multiplierBps === null || score === sum ? null : {
|
|
116
129
|
multiplierBps,
|
|
117
130
|
sameCount: peer.onChainVerificationStatus.sameCount,
|
|
118
131
|
diffCount: peer.onChainVerificationStatus.diffCount,
|
|
119
|
-
|
|
132
|
+
change: score - sum,
|
|
133
|
+
penalty: Math.max(0, sum - score),
|
|
120
134
|
};
|
|
121
135
|
return { score, history, usage, power, identity, freeModels, washFlagged, verification };
|
|
122
136
|
}
|
|
123
137
|
/**
|
|
124
|
-
* The seller's verification points multiplier
|
|
125
|
-
*
|
|
138
|
+
* The seller's verification points multiplier from a read at most VERIFICATION_STATUS_STALE_MAX_MS
|
|
139
|
+
* old; null otherwise, so stale reads fail open.
|
|
126
140
|
*/
|
|
127
|
-
function
|
|
141
|
+
function verificationMultiplierBps(peer, nowMs) {
|
|
128
142
|
const multiplier = peer.onChainVerificationStatus?.pointsMultiplierBps;
|
|
129
143
|
const fetchedAt = peer.onChainVerificationFetchedAt;
|
|
130
|
-
if (typeof multiplier !== 'number' || !Number.isFinite(multiplier)
|
|
144
|
+
if (typeof multiplier !== 'number' || !Number.isFinite(multiplier))
|
|
131
145
|
return null;
|
|
132
146
|
if (typeof fetchedAt !== 'number' || nowMs - fetchedAt >= VERIFICATION_STATUS_STALE_MAX_MS)
|
|
133
147
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trust-score.js","sourceRoot":"","sources":["../../src/reputation/trust-score.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,0BAA0B,IAAI,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEhH
|
|
1
|
+
{"version":3,"file":"trust-score.js","sourceRoot":"","sources":["../../src/reputation/trust-score.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,0BAA0B,IAAI,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEhH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,kGAAkG;AAClG,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;IACT,6DAA6D;IAC7D,OAAO,EAAE,CAAC;IACV,8CAA8C;IAC9C,QAAQ,EAAE,oBAAoB;CACtB,CAAC;AAEX,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,gFAAgF;AAChF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,mEAAmE;AACnE,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD,mEAAmE;AACnE,MAAM,CAAC,MAAM,uCAAuC,GAAG,WAAW,CAAC;AAEnE,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAA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,EAAE,mBAAmB,CAAC;IACvE,MAAM,SAAS,GAAG,IAAI,CAAC,4BAA4B,CAAC;IACpD,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IAChF,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,KAAK,GAAG,SAAS,IAAI,gCAAgC;QAAE,OAAO,IAAI,CAAC;IACxG,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACjC,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,UAAU,CAAC,IAAc,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE;IAC3D,OAAO,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antseed/node",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.169",
|
|
4
4
|
"description": "Antseed Network protocol SDK — P2P inference marketplace",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"node-datachannel": "^0.7.0",
|
|
83
83
|
"tokenx": "^1.3.0",
|
|
84
84
|
"@antseed/api-adapter": "0.1.57",
|
|
85
|
-
"@antseed/
|
|
86
|
-
"@antseed/
|
|
85
|
+
"@antseed/buyer-core": "0.1.38",
|
|
86
|
+
"@antseed/protocol": "0.1.15"
|
|
87
87
|
},
|
|
88
88
|
"optionalDependencies": {
|
|
89
89
|
"keytar": "^7.9.0"
|