@relay-federation/bridge 0.3.3 → 0.3.5

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/cli.js CHANGED
@@ -428,7 +428,7 @@ async function cmdStart () {
428
428
  console.log(` Registry: ${registeredPubkeys.size} trusted pubkeys (self + seeds)`)
429
429
 
430
430
  // ── 4b. Beacon address watcher — detect on-chain registrations ──
431
- const { extractOpReturnData, decodePayload, PROTOCOL_PREFIX } = await import('../registry/lib/cbor.js')
431
+ const { extractOpReturnData, decodePayload, PROTOCOL_PREFIX } = await import('@relay-federation/registry/lib/cbor.js')
432
432
  const { Transaction: BsvTx } = await import('@bsv/sdk')
433
433
 
434
434
  // Registry bootstrapped via discoverNewPeers() after server start (no WoC dependency)
@@ -723,9 +723,9 @@ async function cmdStart () {
723
723
  // Fallback: scan chain for peers (legacy mode)
724
724
  console.log('No seed peers configured. Scanning chain for peers...')
725
725
  try {
726
- const { scanRegistry } = await import('../registry/lib/scanner.js')
727
- const { buildPeerList, excludeSelf } = await import('../registry/lib/discovery.js')
728
- const { savePeerCache, loadPeerCache } = await import('../registry/lib/peer-cache.js')
726
+ const { scanRegistry } = await import('@relay-federation/registry/lib/scanner.js')
727
+ const { buildPeerList, excludeSelf } = await import('@relay-federation/registry/lib/discovery.js')
728
+ const { savePeerCache, loadPeerCache } = await import('@relay-federation/registry/lib/peer-cache.js')
729
729
 
730
730
  const cachePath = join(dir, 'cache', 'peers.json')
731
731
  let peers = await loadPeerCache(cachePath)
@@ -1003,11 +1003,8 @@ function generateQR(text) {
1003
1003
  }
1004
1004
 
1005
1005
  // ── Configuration ──────────────────────────────────
1006
- // Seed URLs onlynames come from each bridge's /status response
1007
- const SEED_URLS = [
1008
- 'http://144.202.48.217:9333',
1009
- 'http://45.63.77.31:9333'
1010
- ];
1006
+ // Bootstrap from selfdiscover the rest of the mesh via /discover
1007
+ const SEED_URLS = [window.location.origin];
1011
1008
  let BRIDGES = SEED_URLS.map(url => ({ name: null, url }));
1012
1009
  const POLL_INTERVAL = 5000;
1013
1010
  let discoveryDone = false;
@@ -1126,12 +1123,9 @@ async function pollAll() {
1126
1123
  if (!selectedBridge && bridgeData.size > 0) {
1127
1124
  selectedBridge = bridgeData.keys().next().value;
1128
1125
  }
1129
- // Fetch price from first online bridge
1130
- const firstOnline = results.find(b => !b._error);
1131
- if (firstOnline) {
1132
- fetch(firstOnline._url + '/price', { signal: AbortSignal.timeout(5000) })
1133
- .then(r => r.ok ? r.json() : null).then(d => { if (d) latestPrice = d; }).catch(() => {});
1134
- }
1126
+ // Fetch price from self (same-origin, always works)
1127
+ fetch('/price', { signal: AbortSignal.timeout(5000) })
1128
+ .then(r => r.ok ? r.json() : null).then(d => { if (d) latestPrice = d; }).catch(() => {});
1135
1129
  renderHeader();
1136
1130
  renderBridgeRail();
1137
1131
  renderActiveTab(true);
@@ -158,7 +158,7 @@ export class PeerManager extends EventEmitter {
158
158
  // If cryptographic handshake is available, use it
159
159
  if (opts.handshake && msg.nonce && Array.isArray(msg.versions)) {
160
160
  const isSeed = opts.seedEndpoints && opts.seedEndpoints.has(msg.endpoint)
161
- const result = opts.handshake.handleHello(msg, null) // cryptographic handshake is the security layer — no whitelist gate
161
+ const result = opts.handshake.handleHello(msg, isSeed ? null : opts.registeredPubkeys)
162
162
  if (result.error) {
163
163
  ws.send(JSON.stringify({ type: 'error', error: result.error }))
164
164
  ws.close()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relay-federation/bridge",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Bridge server — WebSocket peering, header sync, tx relay, CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,8 +11,8 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@bsv/sdk": "^1.10.1",
14
- "@relay-federation/common": "^0.1.0",
15
- "@relay-federation/registry": "^0.1.0",
14
+ "@relay-federation/common": "^0.2.0",
15
+ "@relay-federation/registry": "^0.2.0",
16
16
  "level": "^10.0.0",
17
17
  "ws": "^8.19.0"
18
18
  },