@elefunc/send 0.1.11 → 0.1.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elefunc/send",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Browser-compatible file transfer CLI and TUI powered by Bun, WebRTC, and Rezi.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,12 @@
1
1
  import type { RTCIceCandidateInit, RTCIceServer, RTCSessionDescriptionInit } from "werift"
2
2
 
3
3
  export const SIGNAL_WS_URL = "wss://sig.efn.kr/ws"
4
+ export const SIGNAL_PULSE_URL = "https://sig.efn.kr/pulse?app=send"
5
+ export const signalSocketUrl = (room: string) => {
6
+ const url = new URL(SIGNAL_WS_URL)
7
+ url.search = new URLSearchParams({ i: room, app: "send" }).toString()
8
+ return url.toString()
9
+ }
4
10
  export const BASE_ICE_SERVERS = [
5
11
  { urls: "stun:stun.cloudflare.com:3478" },
6
12
  { urls: "stun:stun.l.google.com:19302" },
@@ -19,7 +19,9 @@ import {
19
19
  fallbackName,
20
20
  formatEta,
21
21
  formatRate,
22
+ SIGNAL_PULSE_URL,
22
23
  signalEpoch,
24
+ signalSocketUrl,
23
25
  stamp,
24
26
  turnStateLabel,
25
27
  type CandidateSignal,
@@ -171,8 +173,6 @@ export interface SessionConfig {
171
173
  const LOG_LIMIT = 200
172
174
  const STATS_POLL_MS = 1000
173
175
  const PROFILE_URL = "https://ip.rt.ht/"
174
- const PULSE_URL = "https://sig.efn.kr/pulse"
175
-
176
176
  export interface PeerConnectivitySnapshot {
177
177
  rttMs: number
178
178
  localCandidateType: string
@@ -953,7 +953,7 @@ export class SendSession {
953
953
  if (this.stopped) return
954
954
  if (this.reconnectTimer) clearTimeout(this.reconnectTimer)
955
955
  const token = ++this.socketToken
956
- const socket = new WebSocket(`${SIGNAL_WS_URL}?i=${encodeURIComponent(this.room)}`)
956
+ const socket = new WebSocket(signalSocketUrl(this.room))
957
957
  this.socket = socket
958
958
  this.socketState = "connecting"
959
959
  this.emit({ type: "socket", socketState: this.socketState })
@@ -1012,7 +1012,7 @@ export class SendSession {
1012
1012
  this.pulse = { ...this.pulse, state: "checking", error: "" }
1013
1013
  this.notify()
1014
1014
  try {
1015
- const response = await fetch(PULSE_URL, { cache: "no-store", signal: timeoutSignal(3500, this.lifecycleAbortController?.signal) })
1015
+ const response = await fetch(SIGNAL_PULSE_URL, { cache: "no-store", signal: timeoutSignal(3500, this.lifecycleAbortController?.signal) })
1016
1016
  if (!response.ok) throw new Error(`pulse ${response.status}`)
1017
1017
  if (this.stopped) return
1018
1018
  this.pulse = { state: "open", at: Date.now(), ms: performance.now() - startedAt, error: "" }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import { resolve } from "node:path"
3
3
  import { cac, type CAC } from "cac"
4
- import { cleanRoom } from "./core/protocol"
4
+ import { cleanRoom, displayPeerName } from "./core/protocol"
5
5
  import type { SendSession, SessionConfig, SessionEvent } from "./core/session"
6
6
  import { resolvePeerTargets } from "./core/targeting"
7
7
  import { ensureSessionRuntimePatches, ensureTuiRuntimePatches } from "../runtime/install"
@@ -108,9 +108,10 @@ export const sessionConfigFrom = (options: Record<string, unknown>, defaults: {
108
108
  }
109
109
  }
110
110
 
111
- export const roomAnnouncement = (room: string, json = false) => json ? JSON.stringify({ type: "room", room }) : `room ${room}`
111
+ export const roomAnnouncement = (room: string, self: string, json = false) =>
112
+ json ? JSON.stringify({ type: "room", room, self }) : `room ${room}\nself ${self}`
112
113
 
113
- const printRoomAnnouncement = (room: string, json = false) => console.log(roomAnnouncement(room, json))
114
+ const printRoomAnnouncement = (room: string, self: string, json = false) => console.log(roomAnnouncement(room, self, json))
114
115
 
115
116
  const printEvent = (event: SessionEvent) => console.log(JSON.stringify(event))
116
117
 
@@ -191,7 +192,7 @@ const peersCommand = async (options: Record<string, unknown>) => {
191
192
  const { SendSession } = await loadSessionRuntime()
192
193
  const session = new SendSession(sessionConfigFrom(options, {}))
193
194
  handleSignals(session)
194
- printRoomAnnouncement(session.room, !!options.json)
195
+ printRoomAnnouncement(session.room, displayPeerName(session.name, session.localId), !!options.json)
195
196
  await session.connect()
196
197
  await Bun.sleep(numberOption(options.wait, 3000))
197
198
  const snapshot = session.snapshot()
@@ -218,7 +219,7 @@ const offerCommand = async (files: string[], options: Record<string, unknown>) =
218
219
  const { SendSession } = await loadSessionRuntime()
219
220
  const session = new SendSession(sessionConfigFrom(options, {}))
220
221
  handleSignals(session)
221
- printRoomAnnouncement(session.room, !!options.json)
222
+ printRoomAnnouncement(session.room, displayPeerName(session.name, session.localId), !!options.json)
222
223
  const detachReporter = attachReporter(session, !!options.json)
223
224
  await session.connect()
224
225
  const targets = await waitForTargets(session, selectors, timeoutMs)
@@ -234,7 +235,7 @@ const acceptCommand = async (options: Record<string, unknown>) => {
234
235
  const { SendSession } = await loadSessionRuntime()
235
236
  const session = new SendSession(sessionConfigFrom(options, { autoAcceptIncoming: true, autoSaveIncoming: true }))
236
237
  handleSignals(session)
237
- printRoomAnnouncement(session.room, !!options.json)
238
+ printRoomAnnouncement(session.room, displayPeerName(session.name, session.localId), !!options.json)
238
239
  const detachReporter = attachReporter(session, !!options.json)
239
240
  await session.connect()
240
241
  if (!options.json) console.log(`listening in ${session.room}`)