@toon-protocol/connector 3.20.0 → 3.28.6
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/README.md +6 -6
- package/dist/auth/rfc9421/content-digest.d.ts +16 -0
- package/dist/auth/rfc9421/content-digest.d.ts.map +1 -0
- package/dist/auth/rfc9421/content-digest.js +35 -0
- package/dist/auth/rfc9421/content-digest.js.map +1 -0
- package/dist/auth/rfc9421/index.d.ts +9 -0
- package/dist/auth/rfc9421/index.d.ts.map +1 -0
- package/dist/auth/rfc9421/index.js +24 -0
- package/dist/auth/rfc9421/index.js.map +1 -0
- package/dist/auth/rfc9421/sign.d.ts +20 -0
- package/dist/auth/rfc9421/sign.d.ts.map +1 -0
- package/dist/auth/rfc9421/sign.js +43 -0
- package/dist/auth/rfc9421/sign.js.map +1 -0
- package/dist/auth/rfc9421/signature-base.d.ts +21 -0
- package/dist/auth/rfc9421/signature-base.d.ts.map +1 -0
- package/dist/auth/rfc9421/signature-base.js +57 -0
- package/dist/auth/rfc9421/signature-base.js.map +1 -0
- package/dist/auth/rfc9421/verify.d.ts +19 -0
- package/dist/auth/rfc9421/verify.d.ts.map +1 -0
- package/dist/auth/rfc9421/verify.js +215 -0
- package/dist/auth/rfc9421/verify.js.map +1 -0
- package/dist/btp/btp-client-manager.d.ts +1 -1
- package/dist/btp/btp-client-manager.d.ts.map +1 -1
- package/dist/btp/btp-client.d.ts +2 -2
- package/dist/btp/btp-client.d.ts.map +1 -1
- package/dist/btp/btp-client.js.map +1 -1
- package/dist/cli/admin-client-factory.d.ts +10 -0
- package/dist/cli/admin-client-factory.d.ts.map +1 -0
- package/dist/cli/admin-client-factory.js +33 -0
- package/dist/cli/admin-client-factory.js.map +1 -0
- package/dist/cli/commands/app.d.ts +6 -0
- package/dist/cli/commands/app.d.ts.map +1 -0
- package/dist/cli/commands/app.js +132 -0
- package/dist/cli/commands/app.js.map +1 -0
- package/dist/cli/commands/route.d.ts +3 -0
- package/dist/cli/commands/route.d.ts.map +1 -0
- package/dist/cli/commands/route.js +63 -0
- package/dist/cli/commands/route.js.map +1 -0
- package/dist/cli/commands/up.d.ts +3 -0
- package/dist/cli/commands/up.d.ts.map +1 -0
- package/dist/cli/commands/up.js +27 -0
- package/dist/cli/commands/up.js.map +1 -0
- package/dist/cli/index.js +32 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/client/connector-admin-client.d.ts +17 -12
- package/dist/client/connector-admin-client.d.ts.map +1 -1
- package/dist/client/connector-admin-client.js.map +1 -1
- package/dist/config/config-loader.d.ts +0 -3
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-loader.js +41 -161
- package/dist/config/config-loader.js.map +1 -1
- package/dist/config/environment-validator.js +6 -6
- package/dist/config/environment-validator.js.map +1 -1
- package/dist/config/types.d.ts +47 -17
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +93 -1
- package/dist/config/types.js.map +1 -1
- package/dist/core/connector-node.d.ts +13 -1
- package/dist/core/connector-node.d.ts.map +1 -1
- package/dist/core/connector-node.js +279 -171
- package/dist/core/connector-node.js.map +1 -1
- package/dist/core/handlers/http-proxy-handler.d.ts +47 -0
- package/dist/core/handlers/http-proxy-handler.d.ts.map +1 -0
- package/dist/core/handlers/http-proxy-handler.js +223 -0
- package/dist/core/handlers/http-proxy-handler.js.map +1 -0
- package/dist/core/local-delivery-client.js +9 -9
- package/dist/core/local-delivery-client.js.map +1 -1
- package/dist/core/packet-handler.d.ts +7 -0
- package/dist/core/packet-handler.d.ts.map +1 -1
- package/dist/core/packet-handler.js +55 -3
- package/dist/core/packet-handler.js.map +1 -1
- package/dist/core/registry-db-schema.d.ts +2 -1
- package/dist/core/registry-db-schema.d.ts.map +1 -1
- package/dist/core/registry-db-schema.js +9 -0
- package/dist/core/registry-db-schema.js.map +1 -1
- package/dist/core/registry-store.d.ts +1 -0
- package/dist/core/registry-store.d.ts.map +1 -1
- package/dist/core/registry-store.js +6 -4
- package/dist/core/registry-store.js.map +1 -1
- package/dist/core/route-upstream-registry.d.ts +17 -0
- package/dist/core/route-upstream-registry.d.ts.map +1 -0
- package/dist/core/route-upstream-registry.js +51 -0
- package/dist/core/route-upstream-registry.js.map +1 -0
- package/dist/discovery/ilp-peer-info-event.d.ts +22 -0
- package/dist/discovery/ilp-peer-info-event.d.ts.map +1 -0
- package/dist/discovery/ilp-peer-info-event.js +21 -0
- package/dist/discovery/ilp-peer-info-event.js.map +1 -0
- package/dist/discovery/index.d.ts +8 -0
- package/dist/discovery/index.d.ts.map +1 -1
- package/dist/discovery/index.js +16 -1
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/self-announce-builder.d.ts +14 -0
- package/dist/discovery/self-announce-builder.d.ts.map +1 -0
- package/dist/discovery/self-announce-builder.js +88 -0
- package/dist/discovery/self-announce-builder.js.map +1 -0
- package/dist/discovery/self-announce-publish.d.ts +17 -0
- package/dist/discovery/self-announce-publish.d.ts.map +1 -0
- package/dist/discovery/self-announce-publish.js +35 -0
- package/dist/discovery/self-announce-publish.js.map +1 -0
- package/dist/discovery/self-announce-service.d.ts +36 -0
- package/dist/discovery/self-announce-service.d.ts.map +1 -0
- package/dist/discovery/self-announce-service.js +118 -0
- package/dist/discovery/self-announce-service.js.map +1 -0
- package/dist/http/admin-api-inventory.d.ts.map +1 -1
- package/dist/http/admin-api-inventory.js +0 -42
- package/dist/http/admin-api-inventory.js.map +1 -1
- package/dist/http/admin-api.d.ts +29 -13
- package/dist/http/admin-api.d.ts.map +1 -1
- package/dist/http/admin-api.js +141 -76
- package/dist/http/admin-api.js.map +1 -1
- package/dist/http/admin-server.d.ts +3 -4
- package/dist/http/admin-server.d.ts.map +1 -1
- package/dist/http/admin-server.js +4 -6
- package/dist/http/admin-server.js.map +1 -1
- package/dist/http/ilp-http-adapter.d.ts +10 -0
- package/dist/http/ilp-http-adapter.d.ts.map +1 -1
- package/dist/http/ilp-http-adapter.js +118 -0
- package/dist/http/ilp-http-adapter.js.map +1 -1
- package/dist/http/types.d.ts +1 -1
- package/dist/http/types.d.ts.map +1 -1
- package/dist/http/x402-greeting.d.ts +46 -0
- package/dist/http/x402-greeting.d.ts.map +1 -0
- package/dist/http/x402-greeting.js +77 -0
- package/dist/http/x402-greeting.js.map +1 -0
- package/dist/lib.d.ts +13 -2
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +41 -1
- package/dist/lib.js.map +1 -1
- package/dist/main.d.ts +3 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -1
- package/dist/main.js.map +1 -1
- package/dist/settlement/channel-manager.d.ts.map +1 -1
- package/dist/settlement/channel-manager.js +1 -1
- package/dist/settlement/channel-manager.js.map +1 -1
- package/dist/settlement/provider/solana-payment-channel-provider.d.ts.map +1 -1
- package/dist/settlement/provider/solana-payment-channel-provider.js +1 -1
- package/dist/settlement/provider/solana-payment-channel-provider.js.map +1 -1
- package/dist/settlement/solana-payment-channel-sdk.d.ts +1 -1
- package/dist/settlement/solana-payment-channel-sdk.d.ts.map +1 -1
- package/dist/settlement/solana-payment-channel-sdk.js +2 -2
- package/dist/settlement/solana-payment-channel-sdk.js.map +1 -1
- package/dist/transport/http-peer-transport.d.ts +46 -0
- package/dist/transport/http-peer-transport.d.ts.map +1 -0
- package/dist/transport/http-peer-transport.js +185 -0
- package/dist/transport/http-peer-transport.js.map +1 -0
- package/dist/transport/index.d.ts +0 -3
- package/dist/transport/index.d.ts.map +1 -1
- package/dist/transport/index.js +1 -8
- package/dist/transport/index.js.map +1 -1
- package/dist/wallet/mnemonic-keys.d.ts +15 -0
- package/dist/wallet/mnemonic-keys.d.ts.map +1 -0
- package/dist/wallet/mnemonic-keys.js +150 -0
- package/dist/wallet/mnemonic-keys.js.map +1 -0
- package/package.json +11 -8
- package/dist/transport/hs-desc-monitor.d.ts +0 -12
- package/dist/transport/hs-desc-monitor.d.ts.map +0 -1
- package/dist/transport/hs-desc-monitor.js +0 -105
- package/dist/transport/hs-desc-monitor.js.map +0 -1
- package/dist/transport/managed-anon-client.d.ts +0 -93
- package/dist/transport/managed-anon-client.d.ts.map +0 -1
- package/dist/transport/managed-anon-client.js +0 -522
- package/dist/transport/managed-anon-client.js.map +0 -1
- package/dist/transport/socks-transport-provider.d.ts +0 -29
- package/dist/transport/socks-transport-provider.d.ts.map +0 -1
- package/dist/transport/socks-transport-provider.js +0 -136
- package/dist/transport/socks-transport-provider.js.map +0 -1
- package/dist/transport/socks-url.d.ts +0 -6
- package/dist/transport/socks-url.d.ts.map +0 -1
- package/dist/transport/socks-url.js +0 -29
- package/dist/transport/socks-url.js.map +0 -1
- package/dist/transport/socks5-connect.d.ts +0 -12
- package/dist/transport/socks5-connect.d.ts.map +0 -1
- package/dist/transport/socks5-connect.js +0 -89
- package/dist/transport/socks5-connect.js.map +0 -1
package/dist/http/admin-api.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Router } from 'express';
|
|
|
2
2
|
import { Logger } from '../utils/logger';
|
|
3
3
|
import { RoutingTable } from '../routing/routing-table';
|
|
4
4
|
import { BTPClientManager } from '../btp/btp-client-manager';
|
|
5
|
+
import type { PeerEgress } from '../transport/http-peer-transport';
|
|
5
6
|
import { AdminSettlementConfig, PeerConfig as SettlementPeerConfig } from '../settlement/types';
|
|
6
7
|
import type { AdminChannelStatus } from '../settlement/types';
|
|
7
8
|
import type { ChannelManager } from '../settlement/channel-manager';
|
|
@@ -12,8 +13,7 @@ import type { ClaimReceiver } from '../settlement/claim-receiver';
|
|
|
12
13
|
import type { SentClaimsQueries } from '../settlement/sent-claims-queries';
|
|
13
14
|
import type { PacketSenderFn, IsReadyFn } from './ilp-send-handler';
|
|
14
15
|
import type { IlpMetricsRegistry } from '../observability/metrics-registry';
|
|
15
|
-
import type {
|
|
16
|
-
import type { PeerRelation } from '../config/types';
|
|
16
|
+
import type { PeerRelation, RouteTermination, TerminationChain } from '../config/types';
|
|
17
17
|
export interface AdminAPIConfig {
|
|
18
18
|
routingTable: RoutingTable;
|
|
19
19
|
btpClientManager: BTPClientManager;
|
|
@@ -33,16 +33,23 @@ export interface AdminAPIConfig {
|
|
|
33
33
|
isReady?: IsReadyFn;
|
|
34
34
|
defaultSettlementTokenId?: string;
|
|
35
35
|
metricsRegistry?: IlpMetricsRegistry;
|
|
36
|
-
managedAnonClient?: ManagedAnonClient;
|
|
37
36
|
resolveTokenMetadata?: (blockchain: 'evm' | 'solana' | 'mina', tokenAddress: string) => Promise<{
|
|
38
37
|
assetCode: string;
|
|
39
38
|
assetScale: number;
|
|
40
39
|
}>;
|
|
41
40
|
connectorFeePercentage?: number;
|
|
42
|
-
transportType?: 'direct' | 'socks5';
|
|
43
41
|
setPeerRelation?: (peerId: string, relation: PeerRelation) => void;
|
|
44
42
|
getPeerRelation?: (peerId: string) => PeerRelation | undefined;
|
|
45
43
|
registryStore?: RegistryPeerSink;
|
|
44
|
+
httpPeerEgress?: PeerEgress;
|
|
45
|
+
setPeerProtocol?: (peerId: string, protocol: 'btp' | 'ilp-http') => void;
|
|
46
|
+
routeTerminationRegistry?: RouteTerminationSink;
|
|
47
|
+
}
|
|
48
|
+
export interface RouteTerminationSink {
|
|
49
|
+
set(prefix: string, termination: RouteTermination): void;
|
|
50
|
+
delete(prefix: string): boolean;
|
|
51
|
+
lookup(prefix: string): RouteTermination | undefined;
|
|
52
|
+
prefixes(): string[];
|
|
46
53
|
}
|
|
47
54
|
export interface RegistryPeerSink {
|
|
48
55
|
savePeer(record: {
|
|
@@ -55,6 +62,13 @@ export interface RegistryPeerSink {
|
|
|
55
62
|
source: 'config' | 'runtime';
|
|
56
63
|
}): void;
|
|
57
64
|
deletePeer(id: string): void;
|
|
65
|
+
saveRoute?(record: {
|
|
66
|
+
prefix: string;
|
|
67
|
+
nextHop: string;
|
|
68
|
+
priority: number;
|
|
69
|
+
source: 'config' | 'runtime';
|
|
70
|
+
terminationJson?: string;
|
|
71
|
+
}): void;
|
|
58
72
|
}
|
|
59
73
|
export interface AddPeerRequest {
|
|
60
74
|
id: string;
|
|
@@ -65,13 +79,23 @@ export interface AddPeerRequest {
|
|
|
65
79
|
priority?: number;
|
|
66
80
|
}>;
|
|
67
81
|
settlement?: AdminSettlementConfig;
|
|
68
|
-
transport?: 'direct'
|
|
82
|
+
transport?: 'direct';
|
|
69
83
|
relation?: PeerRelation;
|
|
84
|
+
peerProtocol?: 'btp' | 'ilp-http';
|
|
85
|
+
httpUrl?: string;
|
|
86
|
+
httpPath?: string;
|
|
87
|
+
httpTimeoutMs?: number;
|
|
70
88
|
}
|
|
71
89
|
export interface AddRouteRequest {
|
|
72
90
|
prefix: string;
|
|
73
91
|
nextHop: string;
|
|
74
92
|
priority?: number;
|
|
93
|
+
upstream?: string;
|
|
94
|
+
price?: string;
|
|
95
|
+
chains?: TerminationChain[];
|
|
96
|
+
ilpAddress?: string;
|
|
97
|
+
settlementAddresses?: Partial<Record<TerminationChain, string>>;
|
|
98
|
+
asset?: Partial<Record<TerminationChain, string>>;
|
|
75
99
|
}
|
|
76
100
|
export interface BalanceResponse {
|
|
77
101
|
peerId: string;
|
|
@@ -134,14 +158,6 @@ export interface AdminMetricsJsonResponse {
|
|
|
134
158
|
peers: AdminMetricsJsonPeer[];
|
|
135
159
|
timestamp: string;
|
|
136
160
|
}
|
|
137
|
-
export interface AdminHsHostnameResponse {
|
|
138
|
-
hostname: string | null;
|
|
139
|
-
publishedAt: string | null;
|
|
140
|
-
}
|
|
141
|
-
export interface AdminAnonHostnameResponse {
|
|
142
|
-
anonHostname: string | null;
|
|
143
|
-
publishedAt: string | null;
|
|
144
|
-
}
|
|
145
161
|
export interface SettlementStateResponse {
|
|
146
162
|
peerId: string;
|
|
147
163
|
tokenId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-api.d.ts","sourceRoot":"","sources":["../../src/http/admin-api.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;A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AAC;CAChB;AAGD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAIlB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAGD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAGD,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrE,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAkBA;AAMD,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,qBAAqB,GAAG,MAAM,GAAG,IAAI,CA+BhF;AAMD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACzE,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAuDA"}
|
package/dist/http/admin-api.js
CHANGED
|
@@ -12,6 +12,7 @@ const relation_route_validator_1 = require("../routing/relation-route-validator"
|
|
|
12
12
|
const shared_1 = require("@toon-protocol/shared");
|
|
13
13
|
const types_1 = require("../settlement/types");
|
|
14
14
|
const ilp_send_handler_1 = require("./ilp-send-handler");
|
|
15
|
+
const types_2 = require("../config/types");
|
|
15
16
|
function normalizeIP(ip) {
|
|
16
17
|
if (ip.startsWith('::ffff:')) {
|
|
17
18
|
return ip.substring(7);
|
|
@@ -80,7 +81,7 @@ function createIPAllowlistMiddleware(allowedIPs, trustProxy, logger) {
|
|
|
80
81
|
async function createAdminRouter(config) {
|
|
81
82
|
const { default: express } = await (0, optional_require_1.requireOptional)('express', 'HTTP admin/health APIs');
|
|
82
83
|
const router = express.Router();
|
|
83
|
-
const { routingTable, btpClientManager, logger, apiKey, allowedIPs, trustProxy = false, nodeId, settlementPeers, channelManager, paymentChannelSDK, accountManager, settlementMonitor, claimReceiver, sentClaimsQueries, packetSender, isReady, defaultSettlementTokenId, metricsRegistry,
|
|
84
|
+
const { routingTable, btpClientManager, logger, apiKey, allowedIPs, trustProxy = false, nodeId, settlementPeers, channelManager, paymentChannelSDK, accountManager, settlementMonitor, claimReceiver, sentClaimsQueries, packetSender, isReady, defaultSettlementTokenId, metricsRegistry, resolveTokenMetadata, connectorFeePercentage, setPeerRelation, getPeerRelation, registryStore, httpPeerEgress, setPeerProtocol, routeTerminationRegistry, } = config;
|
|
84
85
|
const log = logger.child({ component: 'AdminAPI' });
|
|
85
86
|
router.use(express.json());
|
|
86
87
|
if (allowedIPs && allowedIPs.length > 0) {
|
|
@@ -177,12 +178,16 @@ async function createAdminRouter(config) {
|
|
|
177
178
|
router.post('/peers', async (req, res) => {
|
|
178
179
|
try {
|
|
179
180
|
const body = req.body;
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
const peerProtocol = body.peerProtocol ?? 'btp';
|
|
182
|
+
if (peerProtocol !== 'btp' && peerProtocol !== 'ilp-http') {
|
|
183
|
+
res.status(400).json({
|
|
184
|
+
error: 'Bad request',
|
|
185
|
+
message: `Invalid peerProtocol: must be 'btp' or 'ilp-http' (got '${peerProtocol}')`,
|
|
186
|
+
});
|
|
182
187
|
return;
|
|
183
188
|
}
|
|
184
|
-
if (!body.
|
|
185
|
-
res.status(400).json({ error: 'Bad request', message: 'Missing or invalid peer
|
|
189
|
+
if (!body.id || typeof body.id !== 'string') {
|
|
190
|
+
res.status(400).json({ error: 'Bad request', message: 'Missing or invalid peer id' });
|
|
186
191
|
return;
|
|
187
192
|
}
|
|
188
193
|
if (body.authToken === undefined ||
|
|
@@ -194,26 +199,46 @@ async function createAdminRouter(config) {
|
|
|
194
199
|
});
|
|
195
200
|
return;
|
|
196
201
|
}
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
if (peerProtocol === 'ilp-http') {
|
|
203
|
+
if (!httpPeerEgress || !setPeerProtocol) {
|
|
204
|
+
res.status(400).json({
|
|
205
|
+
error: 'Bad request',
|
|
206
|
+
message: 'ILP-over-HTTP egress is not available on this connector',
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (!body.httpUrl || typeof body.httpUrl !== 'string') {
|
|
211
|
+
res.status(400).json({
|
|
212
|
+
error: 'Bad request',
|
|
213
|
+
message: "peerProtocol 'ilp-http' requires httpUrl (http(s) endpoint)",
|
|
214
|
+
});
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (!/^https?:\/\/.+/.test(body.httpUrl)) {
|
|
218
|
+
res.status(400).json({
|
|
219
|
+
error: 'Bad request',
|
|
220
|
+
message: 'httpUrl must start with http:// or https://',
|
|
221
|
+
});
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
203
224
|
}
|
|
204
|
-
|
|
205
|
-
body.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
225
|
+
else {
|
|
226
|
+
if (!body.url || typeof body.url !== 'string') {
|
|
227
|
+
res.status(400).json({ error: 'Bad request', message: 'Missing or invalid peer url' });
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (!body.url.startsWith('ws://') && !body.url.startsWith('wss://')) {
|
|
231
|
+
res.status(400).json({
|
|
232
|
+
error: 'Bad request',
|
|
233
|
+
message: 'URL must start with ws:// or wss://',
|
|
234
|
+
});
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
212
237
|
}
|
|
213
|
-
if (body.transport
|
|
238
|
+
if (body.transport !== undefined && body.transport !== 'direct') {
|
|
214
239
|
res.status(400).json({
|
|
215
240
|
error: 'Bad request',
|
|
216
|
-
message:
|
|
241
|
+
message: `Invalid transport: must be 'direct' (got '${String(body.transport)}')`,
|
|
217
242
|
});
|
|
218
243
|
return;
|
|
219
244
|
}
|
|
@@ -227,7 +252,9 @@ async function createAdminRouter(config) {
|
|
|
227
252
|
});
|
|
228
253
|
return;
|
|
229
254
|
}
|
|
230
|
-
const existingPeers =
|
|
255
|
+
const existingPeers = peerProtocol === 'ilp-http' && httpPeerEgress
|
|
256
|
+
? httpPeerEgress.getPeerIds()
|
|
257
|
+
: btpClientManager.getPeerIds();
|
|
231
258
|
const isUpdate = existingPeers.includes(body.id);
|
|
232
259
|
if (body.routes) {
|
|
233
260
|
for (const route of body.routes) {
|
|
@@ -270,21 +297,34 @@ async function createAdminRouter(config) {
|
|
|
270
297
|
}
|
|
271
298
|
}
|
|
272
299
|
if (!isUpdate) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
300
|
+
if (peerProtocol === 'ilp-http' && httpPeerEgress) {
|
|
301
|
+
const httpPeer = {
|
|
302
|
+
id: body.id,
|
|
303
|
+
httpUrl: body.httpUrl,
|
|
304
|
+
httpPath: body.httpPath,
|
|
305
|
+
authToken: body.authToken,
|
|
306
|
+
httpTimeoutMs: body.httpTimeoutMs,
|
|
307
|
+
};
|
|
308
|
+
await httpPeerEgress.addPeer(httpPeer);
|
|
309
|
+
log.info({ event: 'admin_peer_added', peerId: body.id, peerProtocol, httpUrl: body.httpUrl }, `Added ILP-over-HTTP peer: ${body.id}`);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const peer = {
|
|
313
|
+
id: body.id,
|
|
314
|
+
url: body.url,
|
|
315
|
+
authToken: body.authToken,
|
|
316
|
+
connected: false,
|
|
317
|
+
lastSeen: new Date(),
|
|
318
|
+
transport: body.transport,
|
|
319
|
+
};
|
|
320
|
+
await btpClientManager.addPeer(peer);
|
|
321
|
+
log.info({
|
|
322
|
+
event: 'admin_peer_added',
|
|
323
|
+
peerId: body.id,
|
|
324
|
+
url: body.url,
|
|
325
|
+
transport: body.transport ?? null,
|
|
326
|
+
}, `Added peer: ${body.id}`);
|
|
327
|
+
}
|
|
288
328
|
}
|
|
289
329
|
else {
|
|
290
330
|
log.info({
|
|
@@ -304,6 +344,9 @@ async function createAdminRouter(config) {
|
|
|
304
344
|
if (setPeerRelation) {
|
|
305
345
|
setPeerRelation(body.id, body.relation ?? 'peer');
|
|
306
346
|
}
|
|
347
|
+
if (setPeerProtocol) {
|
|
348
|
+
setPeerProtocol(body.id, peerProtocol);
|
|
349
|
+
}
|
|
307
350
|
if (body.settlement && settlementPeers) {
|
|
308
351
|
const s = body.settlement;
|
|
309
352
|
const ilpAddress = effectiveRoutes && effectiveRoutes.length > 0 ? effectiveRoutes[0].prefix : '';
|
|
@@ -555,11 +598,15 @@ async function createAdminRouter(config) {
|
|
|
555
598
|
res.json({
|
|
556
599
|
nodeId,
|
|
557
600
|
routeCount: routes.length,
|
|
558
|
-
routes: routes.map((r) =>
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
601
|
+
routes: routes.map((r) => {
|
|
602
|
+
const termination = routeTerminationRegistry?.lookup(r.prefix);
|
|
603
|
+
return {
|
|
604
|
+
prefix: r.prefix,
|
|
605
|
+
nextHop: r.nextHop,
|
|
606
|
+
priority: r.priority ?? 0,
|
|
607
|
+
...(termination ? { termination } : {}),
|
|
608
|
+
};
|
|
609
|
+
}),
|
|
563
610
|
});
|
|
564
611
|
}
|
|
565
612
|
catch (error) {
|
|
@@ -597,8 +644,27 @@ async function createAdminRouter(config) {
|
|
|
597
644
|
res.status(400).json({ error: 'Bad request', message: relationValidation.error });
|
|
598
645
|
return;
|
|
599
646
|
}
|
|
647
|
+
const terminationValidation = (0, types_2.validateRouteTermination)(body, types_1.isValidNonNegativeIntegerString);
|
|
648
|
+
if (!terminationValidation.ok) {
|
|
649
|
+
res.status(400).json({ error: 'Bad request', message: terminationValidation.error });
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
600
652
|
const priority = body.priority ?? 0;
|
|
601
653
|
routingTable.addRoute(body.prefix, body.nextHop, priority);
|
|
654
|
+
const termination = (0, types_2.toRouteTermination)(body);
|
|
655
|
+
if (termination) {
|
|
656
|
+
routeTerminationRegistry?.set(body.prefix, termination);
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
routeTerminationRegistry?.delete(body.prefix);
|
|
660
|
+
}
|
|
661
|
+
registryStore?.saveRoute?.({
|
|
662
|
+
prefix: body.prefix,
|
|
663
|
+
nextHop: body.nextHop,
|
|
664
|
+
priority,
|
|
665
|
+
source: 'runtime',
|
|
666
|
+
terminationJson: termination ? JSON.stringify(termination) : undefined,
|
|
667
|
+
});
|
|
602
668
|
log.info({ event: 'admin_route_added', prefix: body.prefix, nextHop: body.nextHop, priority }, `Added route: ${body.prefix} -> ${body.nextHop}`);
|
|
603
669
|
res.status(201).json({
|
|
604
670
|
success: true,
|
|
@@ -673,8 +739,8 @@ async function createAdminRouter(config) {
|
|
|
673
739
|
if (!peer.url.startsWith('ws://') && !peer.url.startsWith('wss://')) {
|
|
674
740
|
return reject('URL must start with ws:// or wss://');
|
|
675
741
|
}
|
|
676
|
-
if (peer.transport
|
|
677
|
-
return reject(
|
|
742
|
+
if (peer.transport !== undefined && peer.transport !== 'direct') {
|
|
743
|
+
return reject(`Invalid transport: must be 'direct' (got '${String(peer.transport)}')`);
|
|
678
744
|
}
|
|
679
745
|
if (peer.relation !== undefined &&
|
|
680
746
|
peer.relation !== 'parent' &&
|
|
@@ -711,6 +777,9 @@ async function createAdminRouter(config) {
|
|
|
711
777
|
const v = (0, relation_route_validator_1.validateRelationRoute)(relation, localPrefixes, [route.prefix]);
|
|
712
778
|
if (!v.ok)
|
|
713
779
|
return reject(v.error);
|
|
780
|
+
const tv = (0, types_2.validateRouteTermination)(route, types_1.isValidNonNegativeIntegerString);
|
|
781
|
+
if (!tv.ok)
|
|
782
|
+
return reject(tv.error);
|
|
714
783
|
}
|
|
715
784
|
const desiredRoutes = new Map();
|
|
716
785
|
for (const peer of desiredPeers) {
|
|
@@ -719,7 +788,11 @@ async function createAdminRouter(config) {
|
|
|
719
788
|
}
|
|
720
789
|
}
|
|
721
790
|
for (const r of desiredTopRoutes) {
|
|
722
|
-
desiredRoutes.set(r.prefix, {
|
|
791
|
+
desiredRoutes.set(r.prefix, {
|
|
792
|
+
nextHop: r.nextHop,
|
|
793
|
+
priority: r.priority ?? 0,
|
|
794
|
+
termination: (0, types_2.toRouteTermination)(r),
|
|
795
|
+
});
|
|
723
796
|
}
|
|
724
797
|
const desiredPeerIds = new Set(desiredPeers.map((p) => p.id));
|
|
725
798
|
const currentPeerIds = btpClientManager.getPeerIds();
|
|
@@ -790,6 +863,29 @@ async function createAdminRouter(config) {
|
|
|
790
863
|
for (const [prefix, info] of desiredRoutes) {
|
|
791
864
|
routingTable.addRoute(prefix, info.nextHop, info.priority);
|
|
792
865
|
}
|
|
866
|
+
if (routeTerminationRegistry) {
|
|
867
|
+
for (const prefix of routeTerminationRegistry.prefixes()) {
|
|
868
|
+
if (!desiredRoutes.has(prefix) || !desiredRoutes.get(prefix)?.termination) {
|
|
869
|
+
routeTerminationRegistry.delete(prefix);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
for (const [prefix, info] of desiredRoutes) {
|
|
873
|
+
if (info.termination) {
|
|
874
|
+
routeTerminationRegistry.set(prefix, info.termination);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
for (const [prefix, info] of desiredRoutes) {
|
|
879
|
+
if (info.termination) {
|
|
880
|
+
registryStore?.saveRoute?.({
|
|
881
|
+
prefix,
|
|
882
|
+
nextHop: info.nextHop,
|
|
883
|
+
priority: info.priority,
|
|
884
|
+
source: 'runtime',
|
|
885
|
+
terminationJson: JSON.stringify(info.termination),
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
}
|
|
793
889
|
log.info({
|
|
794
890
|
event: 'admin_desired_state_reconciled',
|
|
795
891
|
addedPeers: addedPeers.length,
|
|
@@ -1276,37 +1372,6 @@ async function createAdminRouter(config) {
|
|
|
1276
1372
|
});
|
|
1277
1373
|
}
|
|
1278
1374
|
});
|
|
1279
|
-
router.get('/hs-hostname', (_req, res) => {
|
|
1280
|
-
if (!managedAnonClient || !managedAnonClient.isHiddenServiceConfigured()) {
|
|
1281
|
-
res.set('Cache-Control', 'no-store');
|
|
1282
|
-
res.status(503).json({ error: 'anon-disabled' });
|
|
1283
|
-
return;
|
|
1284
|
-
}
|
|
1285
|
-
const snapshot = managedAnonClient.getHostnameSnapshot();
|
|
1286
|
-
res.set('Cache-Control', 'no-store');
|
|
1287
|
-
if (snapshot.hostname === null) {
|
|
1288
|
-
res.set('Retry-After', '3');
|
|
1289
|
-
}
|
|
1290
|
-
res.json(snapshot);
|
|
1291
|
-
});
|
|
1292
|
-
router.get('/anon-hostname', (_req, res) => {
|
|
1293
|
-
if (!managedAnonClient || !managedAnonClient.isHiddenServiceConfigured()) {
|
|
1294
|
-
res.set('Cache-Control', 'no-store');
|
|
1295
|
-
res.status(503).json({ error: 'anon-disabled' });
|
|
1296
|
-
return;
|
|
1297
|
-
}
|
|
1298
|
-
const snapshot = managedAnonClient.getHostnameSnapshot();
|
|
1299
|
-
const isVerboseLevel = log.level === 'debug' || log.level === 'trace';
|
|
1300
|
-
const anonHostname = snapshot.hostname !== null && !isVerboseLevel ? '<redacted-anon>' : snapshot.hostname;
|
|
1301
|
-
res.set('Cache-Control', 'no-store');
|
|
1302
|
-
if (snapshot.hostname === null) {
|
|
1303
|
-
res.set('Retry-After', '3');
|
|
1304
|
-
}
|
|
1305
|
-
res.json({
|
|
1306
|
-
anonHostname,
|
|
1307
|
-
publishedAt: snapshot.publishedAt,
|
|
1308
|
-
});
|
|
1309
|
-
});
|
|
1310
1375
|
router.get('/earnings.json', async (_req, res) => {
|
|
1311
1376
|
try {
|
|
1312
1377
|
if (!accountManager || !claimReceiver) {
|