@rookdaemon/agora 0.1.5 → 0.2.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/README.md +192 -0
- package/dist/cli.js +146 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +18 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +63 -22
- package/dist/config.js.map +1 -1
- package/dist/discovery/bootstrap.d.ts +32 -0
- package/dist/discovery/bootstrap.d.ts.map +1 -0
- package/dist/discovery/bootstrap.js +36 -0
- package/dist/discovery/bootstrap.js.map +1 -0
- package/dist/discovery/peer-discovery.d.ts +59 -0
- package/dist/discovery/peer-discovery.d.ts.map +1 -0
- package/dist/discovery/peer-discovery.js +108 -0
- package/dist/discovery/peer-discovery.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/message/envelope.d.ts +1 -1
- package/dist/message/envelope.d.ts.map +1 -1
- package/dist/message/envelope.js.map +1 -1
- package/dist/message/types/peer-discovery.d.ts +78 -0
- package/dist/message/types/peer-discovery.d.ts.map +1 -0
- package/dist/message/types/peer-discovery.js +90 -0
- package/dist/message/types/peer-discovery.js.map +1 -0
- package/dist/registry/discovery-service.d.ts +64 -0
- package/dist/registry/discovery-service.d.ts.map +1 -0
- package/dist/registry/discovery-service.js +129 -0
- package/dist/registry/discovery-service.js.map +1 -0
- package/dist/registry/messages.d.ts +55 -0
- package/dist/registry/messages.d.ts.map +1 -1
- package/dist/relay/server.d.ts +16 -0
- package/dist/relay/server.d.ts.map +1 -1
- package/dist/relay/server.js +73 -1
- package/dist/relay/server.js.map +1 -1
- package/dist/service.d.ts +82 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +132 -0
- package/dist/service.js.map +1 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +12 -0
- package/dist/utils.js.map +1 -0
- package/package.json +43 -1
package/dist/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
2
3
|
import { resolve } from 'node:path';
|
|
3
4
|
import { homedir } from 'node:os';
|
|
4
5
|
/**
|
|
@@ -11,30 +12,18 @@ export function getDefaultConfigPath() {
|
|
|
11
12
|
return resolve(homedir(), '.config', 'agora', 'config.json');
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Supports relay as string (backward compat) or object { url?, autoConnect?, name?, reconnectMaxMs? }.
|
|
16
|
-
*
|
|
17
|
-
* @param path - Config file path; defaults to getDefaultConfigPath()
|
|
18
|
-
* @returns Normalized AgoraConfig
|
|
19
|
-
* @throws Error if file doesn't exist or config is invalid
|
|
15
|
+
* Parse and normalize config from a JSON object (shared by sync and async loaders).
|
|
20
16
|
*/
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
24
|
-
throw new Error(`Config file not found at ${configPath}. Run 'npx @rookdaemon/agora init' first.`);
|
|
25
|
-
}
|
|
26
|
-
const content = readFileSync(configPath, 'utf-8');
|
|
27
|
-
let config;
|
|
28
|
-
try {
|
|
29
|
-
config = JSON.parse(content);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
throw new Error(`Invalid JSON in config file: ${configPath}`);
|
|
33
|
-
}
|
|
34
|
-
const identity = config.identity;
|
|
35
|
-
if (!identity?.publicKey || !identity?.privateKey) {
|
|
17
|
+
function parseConfig(config) {
|
|
18
|
+
const rawIdentity = config.identity;
|
|
19
|
+
if (!rawIdentity?.publicKey || !rawIdentity?.privateKey) {
|
|
36
20
|
throw new Error('Invalid config: missing identity.publicKey or identity.privateKey');
|
|
37
21
|
}
|
|
22
|
+
const identity = {
|
|
23
|
+
publicKey: rawIdentity.publicKey,
|
|
24
|
+
privateKey: rawIdentity.privateKey,
|
|
25
|
+
name: typeof rawIdentity.name === 'string' ? rawIdentity.name : undefined,
|
|
26
|
+
};
|
|
38
27
|
const peers = {};
|
|
39
28
|
if (config.peers && typeof config.peers === 'object') {
|
|
40
29
|
for (const [name, entry] of Object.entries(config.peers)) {
|
|
@@ -66,9 +55,61 @@ export function loadAgoraConfig(path) {
|
|
|
66
55
|
}
|
|
67
56
|
}
|
|
68
57
|
return {
|
|
69
|
-
identity
|
|
58
|
+
identity,
|
|
70
59
|
peers,
|
|
71
60
|
...(relay ? { relay } : {}),
|
|
72
61
|
};
|
|
73
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Load and normalize Agora configuration from a JSON file (sync).
|
|
65
|
+
* Supports relay as string (backward compat) or object { url?, autoConnect?, name?, reconnectMaxMs? }.
|
|
66
|
+
*
|
|
67
|
+
* @param path - Config file path; defaults to getDefaultConfigPath()
|
|
68
|
+
* @returns Normalized AgoraConfig
|
|
69
|
+
* @throws Error if file doesn't exist or config is invalid
|
|
70
|
+
*/
|
|
71
|
+
export function loadAgoraConfig(path) {
|
|
72
|
+
const configPath = path ?? getDefaultConfigPath();
|
|
73
|
+
if (!existsSync(configPath)) {
|
|
74
|
+
throw new Error(`Config file not found at ${configPath}. Run 'npx @rookdaemon/agora init' first.`);
|
|
75
|
+
}
|
|
76
|
+
const content = readFileSync(configPath, 'utf-8');
|
|
77
|
+
let config;
|
|
78
|
+
try {
|
|
79
|
+
config = JSON.parse(content);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
throw new Error(`Invalid JSON in config file: ${configPath}`);
|
|
83
|
+
}
|
|
84
|
+
return parseConfig(config);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Load and normalize Agora configuration from a JSON file (async).
|
|
88
|
+
*
|
|
89
|
+
* @param path - Config file path; defaults to getDefaultConfigPath()
|
|
90
|
+
* @returns Normalized AgoraConfig
|
|
91
|
+
* @throws Error if file doesn't exist or config is invalid
|
|
92
|
+
*/
|
|
93
|
+
export async function loadAgoraConfigAsync(path) {
|
|
94
|
+
const configPath = path ?? getDefaultConfigPath();
|
|
95
|
+
let content;
|
|
96
|
+
try {
|
|
97
|
+
content = await readFile(configPath, 'utf-8');
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
101
|
+
if (code === 'ENOENT') {
|
|
102
|
+
throw new Error(`Config file not found at ${configPath}. Run 'npx @rookdaemon/agora init' first.`);
|
|
103
|
+
}
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
let config;
|
|
107
|
+
try {
|
|
108
|
+
config = JSON.parse(content);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
throw new Error(`Invalid JSON in config file: ${configPath}`);
|
|
112
|
+
}
|
|
113
|
+
return parseConfig(config);
|
|
114
|
+
}
|
|
74
115
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAyClC;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;QAC7B,OAAO,OAAO,CA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C;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap configuration for peer discovery on the Agora network.
|
|
3
|
+
* Provides default bootstrap relays for initial network entry.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default bootstrap relay servers
|
|
7
|
+
* These are well-known relays that serve as initial entry points to the network
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_BOOTSTRAP_RELAYS: {
|
|
10
|
+
url: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}[];
|
|
13
|
+
/**
|
|
14
|
+
* Configuration for bootstrap connection
|
|
15
|
+
*/
|
|
16
|
+
export interface BootstrapConfig {
|
|
17
|
+
/** Bootstrap relay URL */
|
|
18
|
+
relayUrl: string;
|
|
19
|
+
/** Optional relay public key (for verification) */
|
|
20
|
+
relayPublicKey?: string;
|
|
21
|
+
/** Connection timeout in ms (default: 10000) */
|
|
22
|
+
timeout?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get default bootstrap relay configuration
|
|
26
|
+
*/
|
|
27
|
+
export declare function getDefaultBootstrapRelay(): BootstrapConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Parse bootstrap relay URL and optional public key
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseBootstrapRelay(url: string, publicKey?: string): BootstrapConfig;
|
|
32
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/discovery/bootstrap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;GAOpC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,eAAe,CAK1D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CAMpF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap configuration for peer discovery on the Agora network.
|
|
3
|
+
* Provides default bootstrap relays for initial network entry.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default bootstrap relay servers
|
|
7
|
+
* These are well-known relays that serve as initial entry points to the network
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_BOOTSTRAP_RELAYS = [
|
|
10
|
+
{
|
|
11
|
+
url: 'wss://agora-relay.lbsa71.net',
|
|
12
|
+
name: 'Primary Bootstrap Relay',
|
|
13
|
+
// Note: Public key would need to be set when the relay is actually deployed
|
|
14
|
+
// For now, this is a placeholder that would be configured when the relay is running
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Get default bootstrap relay configuration
|
|
19
|
+
*/
|
|
20
|
+
export function getDefaultBootstrapRelay() {
|
|
21
|
+
return {
|
|
22
|
+
relayUrl: DEFAULT_BOOTSTRAP_RELAYS[0].url,
|
|
23
|
+
timeout: 10000,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse bootstrap relay URL and optional public key
|
|
28
|
+
*/
|
|
29
|
+
export function parseBootstrapRelay(url, publicKey) {
|
|
30
|
+
return {
|
|
31
|
+
relayUrl: url,
|
|
32
|
+
relayPublicKey: publicKey,
|
|
33
|
+
timeout: 10000,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/discovery/bootstrap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC;QACE,GAAG,EAAE,8BAA8B;QACnC,IAAI,EAAE,yBAAyB;QAC/B,4EAA4E;QAC5E,oFAAoF;KACrF;CACF,CAAC;AAcF;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO;QACL,QAAQ,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,GAAG;QACzC,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,SAAkB;IACjE,OAAO;QACL,QAAQ,EAAE,GAAG;QACb,cAAc,EAAE,SAAS;QACzB,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import type { RelayClient } from '../relay/client.js';
|
|
3
|
+
import type { PeerListRequestPayload, PeerListResponsePayload, PeerReferralPayload } from '../message/types/peer-discovery.js';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for PeerDiscoveryService
|
|
6
|
+
*/
|
|
7
|
+
export interface PeerDiscoveryConfig {
|
|
8
|
+
/** Agent's public key */
|
|
9
|
+
publicKey: string;
|
|
10
|
+
/** Agent's private key for signing */
|
|
11
|
+
privateKey: string;
|
|
12
|
+
/** RelayClient instance for communication */
|
|
13
|
+
relayClient: RelayClient;
|
|
14
|
+
/** Public key of the relay server (for sending peer list requests) */
|
|
15
|
+
relayPublicKey?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Events emitted by PeerDiscoveryService
|
|
19
|
+
*/
|
|
20
|
+
export interface PeerDiscoveryEvents {
|
|
21
|
+
/** Emitted when peers are discovered */
|
|
22
|
+
'peers-discovered': (peers: PeerListResponsePayload['peers']) => void;
|
|
23
|
+
/** Emitted when a peer referral is received */
|
|
24
|
+
'peer-referral': (referral: PeerReferralPayload, from: string) => void;
|
|
25
|
+
/** Emitted on errors */
|
|
26
|
+
'error': (error: Error) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Service for discovering peers on the Agora network
|
|
30
|
+
*/
|
|
31
|
+
export declare class PeerDiscoveryService extends EventEmitter {
|
|
32
|
+
private config;
|
|
33
|
+
constructor(config: PeerDiscoveryConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Request peer list from relay
|
|
36
|
+
*/
|
|
37
|
+
discoverViaRelay(filters?: PeerListRequestPayload['filters']): Promise<PeerListResponsePayload | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Send peer referral to another agent
|
|
40
|
+
*/
|
|
41
|
+
referPeer(recipientPublicKey: string, referredPublicKey: string, metadata?: {
|
|
42
|
+
name?: string;
|
|
43
|
+
endpoint?: string;
|
|
44
|
+
comment?: string;
|
|
45
|
+
trustScore?: number;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
ok: boolean;
|
|
48
|
+
error?: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Handle incoming peer referral
|
|
52
|
+
*/
|
|
53
|
+
private handleReferral;
|
|
54
|
+
/**
|
|
55
|
+
* Handle incoming peer list from relay
|
|
56
|
+
*/
|
|
57
|
+
private handlePeerList;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=peer-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer-discovery.d.ts","sourceRoot":"","sources":["../../src/discovery/peer-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE/H;;G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
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { createEnvelope, verifyEnvelope } from '../message/envelope.js';
|
|
3
|
+
/**
|
|
4
|
+
* Service for discovering peers on the Agora network
|
|
5
|
+
*/
|
|
6
|
+
export class PeerDiscoveryService extends EventEmitter {
|
|
7
|
+
config;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
super();
|
|
10
|
+
this.config = config;
|
|
11
|
+
// Listen for peer list responses and referrals
|
|
12
|
+
this.config.relayClient.on('message', (envelope, from) => {
|
|
13
|
+
if (envelope.type === 'peer_list_response') {
|
|
14
|
+
this.handlePeerList(envelope);
|
|
15
|
+
}
|
|
16
|
+
else if (envelope.type === 'peer_referral') {
|
|
17
|
+
this.handleReferral(envelope, from);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Request peer list from relay
|
|
23
|
+
*/
|
|
24
|
+
async discoverViaRelay(filters) {
|
|
25
|
+
if (!this.config.relayPublicKey) {
|
|
26
|
+
throw new Error('Relay public key not configured');
|
|
27
|
+
}
|
|
28
|
+
if (!this.config.relayClient.connected()) {
|
|
29
|
+
throw new Error('Not connected to relay');
|
|
30
|
+
}
|
|
31
|
+
const payload = filters ? { filters } : {};
|
|
32
|
+
const envelope = createEnvelope('peer_list_request', this.config.publicKey, this.config.privateKey, payload);
|
|
33
|
+
// Send request to relay
|
|
34
|
+
const result = await this.config.relayClient.send(this.config.relayPublicKey, envelope);
|
|
35
|
+
if (!result.ok) {
|
|
36
|
+
throw new Error(`Failed to send peer list request: ${result.error}`);
|
|
37
|
+
}
|
|
38
|
+
// Wait for response (with timeout)
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const timeout = setTimeout(() => {
|
|
41
|
+
cleanup();
|
|
42
|
+
reject(new Error('Peer list request timed out'));
|
|
43
|
+
}, 10000); // 10 second timeout
|
|
44
|
+
const messageHandler = (responseEnvelope, from) => {
|
|
45
|
+
if (responseEnvelope.type === 'peer_list_response' &&
|
|
46
|
+
responseEnvelope.inReplyTo === envelope.id &&
|
|
47
|
+
from === this.config.relayPublicKey) {
|
|
48
|
+
cleanup();
|
|
49
|
+
resolve(responseEnvelope.payload);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const cleanup = () => {
|
|
53
|
+
clearTimeout(timeout);
|
|
54
|
+
this.config.relayClient.off('message', messageHandler);
|
|
55
|
+
};
|
|
56
|
+
this.config.relayClient.on('message', messageHandler);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Send peer referral to another agent
|
|
61
|
+
*/
|
|
62
|
+
async referPeer(recipientPublicKey, referredPublicKey, metadata) {
|
|
63
|
+
if (!this.config.relayClient.connected()) {
|
|
64
|
+
return { ok: false, error: 'Not connected to relay' };
|
|
65
|
+
}
|
|
66
|
+
const payload = {
|
|
67
|
+
publicKey: referredPublicKey,
|
|
68
|
+
endpoint: metadata?.endpoint,
|
|
69
|
+
metadata: metadata?.name ? { name: metadata.name } : undefined,
|
|
70
|
+
comment: metadata?.comment,
|
|
71
|
+
trustScore: metadata?.trustScore,
|
|
72
|
+
};
|
|
73
|
+
const envelope = createEnvelope('peer_referral', this.config.publicKey, this.config.privateKey, payload);
|
|
74
|
+
return this.config.relayClient.send(recipientPublicKey, envelope);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Handle incoming peer referral
|
|
78
|
+
*/
|
|
79
|
+
handleReferral(envelope, from) {
|
|
80
|
+
// Verify envelope
|
|
81
|
+
const verification = verifyEnvelope(envelope);
|
|
82
|
+
if (!verification.valid) {
|
|
83
|
+
this.emit('error', new Error(`Invalid peer referral: ${verification.reason}`));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Emit event for application to handle
|
|
87
|
+
this.emit('peer-referral', envelope.payload, from);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Handle incoming peer list from relay
|
|
91
|
+
*/
|
|
92
|
+
handlePeerList(envelope) {
|
|
93
|
+
// Verify envelope
|
|
94
|
+
const verification = verifyEnvelope(envelope);
|
|
95
|
+
if (!verification.valid) {
|
|
96
|
+
this.emit('error', new Error(`Invalid peer list response: ${verification.reason}`));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Verify sender is the relay
|
|
100
|
+
if (envelope.sender !== this.config.relayPublicKey) {
|
|
101
|
+
this.emit('error', new Error('Peer list response not from configured relay'));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Emit event
|
|
105
|
+
this.emit('peers-discovered', envelope.payload.peers);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=peer-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer-discovery.js","sourceRoot":"","sources":["../../src/discovery/peer-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,wBAAwB,CAAC;AA8BvF;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IAC5C,MAAM,CAAsB;IAEpC,YAAY,MAA2B;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,+CAA+C;QAC/C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,QAAkB,EAAE,IAAY,EAAE,EAAE;YACzE,IAAI,QAAQ,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;gBAC3C,IAAI,CAAC,cAAc,CAAC,QAA6C,CAAC,CAAC;YACrE,CAAC;iBAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;gBAC7C,IAAI,CAAC,cAAc,CAAC,QAAyC,EAAE,IAAI,CAAC,CAAC;YACvE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,C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WAAW,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,QAAuC,EAAE,IAAY;QAC1E,kBAAkB;QAClB,MAAM,YAAY,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,0BAA0B,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/E,OAAO;QACT,CAAC;QAED,uCAAuC;QACvC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,QAA2C;QAChE,kBAAkB;QAClB,MAAM,YAAY,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,+BAA+B,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACpF,OAAO;QACT,CAAC;QAED,6BAA6B;QAC7B,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC,CAAC;YAC9E,OAAO;QACT,CAAC;QAED,aAAa;QACb,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,17 @@ export * from './registry/capability.js';
|
|
|
4
4
|
export * from './registry/peer.js';
|
|
5
5
|
export * from './registry/peer-store.js';
|
|
6
6
|
export * from './registry/messages.js';
|
|
7
|
+
export * from './registry/discovery-service.js';
|
|
7
8
|
export * from './message/types/paper-discovery.js';
|
|
9
|
+
export * from './message/types/peer-discovery.js';
|
|
8
10
|
export * from './transport/http.js';
|
|
9
11
|
export * from './transport/peer-config.js';
|
|
10
12
|
export * from './config.js';
|
|
11
13
|
export * from './relay/server.js';
|
|
12
14
|
export * from './relay/client.js';
|
|
13
15
|
export * from './relay/types.js';
|
|
16
|
+
export * from './utils.js';
|
|
17
|
+
export * from './service.js';
|
|
18
|
+
export * from './discovery/peer-discovery.js';
|
|
19
|
+
export * from './discovery/bootstrap.js';
|
|
14
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,17 @@ export * from './registry/capability.js';
|
|
|
4
4
|
export * from './registry/peer.js';
|
|
5
5
|
export * from './registry/peer-store.js';
|
|
6
6
|
export * from './registry/messages.js';
|
|
7
|
+
export * from './registry/discovery-service.js';
|
|
7
8
|
export * from './message/types/paper-discovery.js';
|
|
9
|
+
export * from './message/types/peer-discovery.js';
|
|
8
10
|
export * from './transport/http.js';
|
|
9
11
|
export * from './transport/peer-config.js';
|
|
10
12
|
export * from './config.js';
|
|
11
13
|
export * from './relay/server.js';
|
|
12
14
|
export * from './relay/client.js';
|
|
13
15
|
export * from './relay/types.js';
|
|
16
|
+
export * from './utils.js';
|
|
17
|
+
export * from './service.js';
|
|
18
|
+
export * from './discovery/peer-discovery.js';
|
|
19
|
+
export * from './discovery/bootstrap.js';
|
|
14
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Message types on the Agora network.
|
|
3
3
|
* Every piece of data flowing between agents is wrapped in an envelope.
|
|
4
4
|
*/
|
|
5
|
-
export type MessageType = 'announce' | 'discover' | 'request' | 'response' | 'publish' | 'subscribe' | 'verify' | 'ack' | 'error' | 'paper_discovery';
|
|
5
|
+
export type MessageType = 'announce' | 'discover' | 'request' | 'response' | 'publish' | 'subscribe' | 'verify' | 'ack' | 'error' | 'paper_discovery' | 'peer_list_request' | 'peer_list_response' | 'peer_referral' | 'capability_announce' | 'capability_query' | 'capability_response';
|
|
6
6
|
/**
|
|
7
7
|
* The signed envelope that wraps every message on the network.
|
|
8
8
|
* Content-addressed: the ID is the hash of the canonical payload.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/message/envelope.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,WAAW,GACX,QAAQ,GACR,KAAK,GACL,OAAO,GACP,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/message/envelope.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,WAAW,GACX,QAAQ,GACR,KAAK,GACL,OAAO,GACP,iBAAiB,GACjB,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,qBAAqB,GACrB,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B;;;;GAIG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO;IACnC,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,OAAO,EAAE,CAAC,CAAC;IACX,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;CACnB;AAgBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAM/H;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,EACV,SAAS,CAAC,EAAE,MAAM,GACjB,QAAQ,CAAC,CAAC,CAAC,CAeb;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAmBtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/message/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/message/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AA8CtE;;GAEG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC1D,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,eAAe,CAAE,KAAiC,CAAC,CAAC,CAAC,CAA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,cAAc,CAAC,QAAkB;IAC/C,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IAEhF,6BAA6B;IAC7B,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAE5E,6BAA6B;IAC7B,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,EAAE,KAAK,UAAU,EAAE,CAAC;QACtB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IACjD,CAAC;IAED,kBAAkB;IAClB,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peer discovery message types for the Agora network.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Request peer list from relay
|
|
6
|
+
*/
|
|
7
|
+
export interface PeerListRequestPayload {
|
|
8
|
+
/** Optional filters */
|
|
9
|
+
filters?: {
|
|
10
|
+
/** Only peers seen in last N ms */
|
|
11
|
+
activeWithin?: number;
|
|
12
|
+
/** Maximum peers to return */
|
|
13
|
+
limit?: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Relay responds with connected peers
|
|
18
|
+
*/
|
|
19
|
+
export interface PeerListResponsePayload {
|
|
20
|
+
/** List of known peers */
|
|
21
|
+
peers: Array<{
|
|
22
|
+
/** Peer's Ed25519 public key */
|
|
23
|
+
publicKey: string;
|
|
24
|
+
/** Optional metadata (if peer announced) */
|
|
25
|
+
metadata?: {
|
|
26
|
+
name?: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
capabilities?: string[];
|
|
29
|
+
};
|
|
30
|
+
/** Last seen timestamp (ms) */
|
|
31
|
+
lastSeen: number;
|
|
32
|
+
}>;
|
|
33
|
+
/** Total peer count (may be > peers.length if limited) */
|
|
34
|
+
totalPeers: number;
|
|
35
|
+
/** Relay's public key (for trust verification) */
|
|
36
|
+
relayPublicKey: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Agent recommends another agent
|
|
40
|
+
*/
|
|
41
|
+
export interface PeerReferralPayload {
|
|
42
|
+
/** Referred peer's public key */
|
|
43
|
+
publicKey: string;
|
|
44
|
+
/** Optional endpoint (if known) */
|
|
45
|
+
endpoint?: string;
|
|
46
|
+
/** Optional metadata */
|
|
47
|
+
metadata?: {
|
|
48
|
+
name?: string;
|
|
49
|
+
version?: string;
|
|
50
|
+
capabilities?: string[];
|
|
51
|
+
};
|
|
52
|
+
/** Referrer's comment */
|
|
53
|
+
comment?: string;
|
|
54
|
+
/** Trust hint (RFC-001 integration) */
|
|
55
|
+
trustScore?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Validate PeerListRequestPayload
|
|
59
|
+
*/
|
|
60
|
+
export declare function validatePeerListRequest(payload: unknown): {
|
|
61
|
+
valid: boolean;
|
|
62
|
+
errors: string[];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Validate PeerListResponsePayload
|
|
66
|
+
*/
|
|
67
|
+
export declare function validatePeerListResponse(payload: unknown): {
|
|
68
|
+
valid: boolean;
|
|
69
|
+
errors: string[];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Validate PeerReferralPayload
|
|
73
|
+
*/
|
|
74
|
+
export declare function validatePeerReferral(payload: unknown): {
|
|
75
|
+
valid: boolean;
|
|
76
|
+
errors: string[];
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=peer-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer-discovery.d.ts","sourceRoot":"","sources":["../../../src/message/types/peer-discovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,uBAAuB;IACvB,OAAO,CAAC,EAAE;QACR,mCAAmC;QACnC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,8BAA8B;QAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,0BAA0B;IAC1B,KAAK,EAAE,KAAK,CAAC;QACX,gCAAgC;QAChC,SAAS,EAAE,MAAM,CAAC;QAClB,4CAA4C;QAC5C,QAAQ,CAAC,EAAE;YACT,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;SACzB,CAAC;QACF,+BAA+B;QAC/B,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,yBAAyB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAyB9F;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAqC/F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CA2B3F"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peer discovery message types for the Agora network.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Validate PeerListRequestPayload
|
|
6
|
+
*/
|
|
7
|
+
export function validatePeerListRequest(payload) {
|
|
8
|
+
const errors = [];
|
|
9
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
10
|
+
errors.push('Payload must be an object');
|
|
11
|
+
return { valid: false, errors };
|
|
12
|
+
}
|
|
13
|
+
const p = payload;
|
|
14
|
+
if (p.filters !== undefined) {
|
|
15
|
+
if (typeof p.filters !== 'object' || p.filters === null) {
|
|
16
|
+
errors.push('filters must be an object');
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const filters = p.filters;
|
|
20
|
+
if (filters.activeWithin !== undefined && typeof filters.activeWithin !== 'number') {
|
|
21
|
+
errors.push('filters.activeWithin must be a number');
|
|
22
|
+
}
|
|
23
|
+
if (filters.limit !== undefined && typeof filters.limit !== 'number') {
|
|
24
|
+
errors.push('filters.limit must be a number');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { valid: errors.length === 0, errors };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validate PeerListResponsePayload
|
|
32
|
+
*/
|
|
33
|
+
export function validatePeerListResponse(payload) {
|
|
34
|
+
const errors = [];
|
|
35
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
36
|
+
errors.push('Payload must be an object');
|
|
37
|
+
return { valid: false, errors };
|
|
38
|
+
}
|
|
39
|
+
const p = payload;
|
|
40
|
+
if (!Array.isArray(p.peers)) {
|
|
41
|
+
errors.push('peers must be an array');
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
p.peers.forEach((peer, index) => {
|
|
45
|
+
if (typeof peer !== 'object' || peer === null) {
|
|
46
|
+
errors.push(`peers[${index}] must be an object`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const peerObj = peer;
|
|
50
|
+
if (typeof peerObj.publicKey !== 'string') {
|
|
51
|
+
errors.push(`peers[${index}].publicKey must be a string`);
|
|
52
|
+
}
|
|
53
|
+
if (typeof peerObj.lastSeen !== 'number') {
|
|
54
|
+
errors.push(`peers[${index}].lastSeen must be a number`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (typeof p.totalPeers !== 'number') {
|
|
59
|
+
errors.push('totalPeers must be a number');
|
|
60
|
+
}
|
|
61
|
+
if (typeof p.relayPublicKey !== 'string') {
|
|
62
|
+
errors.push('relayPublicKey must be a string');
|
|
63
|
+
}
|
|
64
|
+
return { valid: errors.length === 0, errors };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate PeerReferralPayload
|
|
68
|
+
*/
|
|
69
|
+
export function validatePeerReferral(payload) {
|
|
70
|
+
const errors = [];
|
|
71
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
72
|
+
errors.push('Payload must be an object');
|
|
73
|
+
return { valid: false, errors };
|
|
74
|
+
}
|
|
75
|
+
const p = payload;
|
|
76
|
+
if (typeof p.publicKey !== 'string') {
|
|
77
|
+
errors.push('publicKey must be a string');
|
|
78
|
+
}
|
|
79
|
+
if (p.endpoint !== undefined && typeof p.endpoint !== 'string') {
|
|
80
|
+
errors.push('endpoint must be a string');
|
|
81
|
+
}
|
|
82
|
+
if (p.comment !== undefined && typeof p.comment !== 'string') {
|
|
83
|
+
errors.push('comment must be a string');
|
|
84
|
+
}
|
|
85
|
+
if (p.trustScore !== undefined && typeof p.trustScore !== 'number') {
|
|
86
|
+
errors.push('trustScore must be a number');
|
|
87
|
+
}
|
|
88
|
+
return { valid: errors.length === 0, errors };
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=peer-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer-discovery.js","sourceRoot":"","sources":["../../../src/message/types/peer-discovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AA0DH;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QACzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,GAAG,OAAkC,CAAC;IAE7C,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,CAAC,CAAC,OAAkC,CAAC;YACrD,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;gBACnF,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;YACv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