@elefunc/send 0.1.10 → 0.1.12
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 +1 -1
- package/src/core/protocol.ts +6 -0
- package/src/core/session.ts +5 -5
- package/src/index.ts +1 -1
- package/src/tui/app.ts +4 -4
package/package.json
CHANGED
package/src/core/protocol.ts
CHANGED
|
@@ -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" },
|
package/src/core/session.ts
CHANGED
|
@@ -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
|
|
@@ -399,7 +399,7 @@ export class SendSession {
|
|
|
399
399
|
this.localId = cleanLocalId(config.localId)
|
|
400
400
|
this.room = cleanRoom(config.room)
|
|
401
401
|
this.name = cleanName(config.name ?? fallbackName)
|
|
402
|
-
this.saveDir = resolve(config.saveDir ?? resolve(process.cwd()
|
|
402
|
+
this.saveDir = resolve(config.saveDir ?? resolve(process.cwd()))
|
|
403
403
|
this.peerSelectionMemory = config.peerSelectionMemory ?? new Map()
|
|
404
404
|
this.autoAcceptIncoming = !!config.autoAcceptIncoming
|
|
405
405
|
this.autoSaveIncoming = !!config.autoSaveIncoming
|
|
@@ -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(
|
|
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(
|
|
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
|
@@ -99,7 +99,7 @@ export const sessionConfigFrom = (options: Record<string, unknown>, defaults: {
|
|
|
99
99
|
return {
|
|
100
100
|
room,
|
|
101
101
|
...self,
|
|
102
|
-
saveDir: resolve(`${options.saveDir ?? process.env.SEND_SAVE_DIR ?? "
|
|
102
|
+
saveDir: resolve(`${options.saveDir ?? process.env.SEND_SAVE_DIR ?? "."}`),
|
|
103
103
|
autoAcceptIncoming: accept ?? defaults.autoAcceptIncoming ?? false,
|
|
104
104
|
autoSaveIncoming: save ?? defaults.autoSaveIncoming ?? false,
|
|
105
105
|
turnUrls: splitList(options.turnUrl ?? process.env.SEND_TURN_URL),
|
package/src/tui/app.ts
CHANGED
|
@@ -112,8 +112,8 @@ const METRIC_BORDER_STYLE = { fg: rgb(20, 25, 32) } as const
|
|
|
112
112
|
const PRIMARY_TEXT_STYLE = { fg: rgb(255, 255, 255) } as const
|
|
113
113
|
const HEADING_TEXT_STYLE = { fg: rgb(255, 255, 255), bold: true } as const
|
|
114
114
|
const DEFAULT_WEB_URL = "https://send.rt.ht/"
|
|
115
|
-
const DEFAULT_SAVE_DIR = resolve(process.cwd()
|
|
116
|
-
const ABOUT_ELEFUNC_URL = "https://elefunc.com"
|
|
115
|
+
const DEFAULT_SAVE_DIR = resolve(process.cwd())
|
|
116
|
+
const ABOUT_ELEFUNC_URL = "https://elefunc.com/send"
|
|
117
117
|
const ABOUT_TITLE = "About Send"
|
|
118
118
|
const ABOUT_INTRO = "Peer-to-Peer Transfers – Web & CLI"
|
|
119
119
|
const ABOUT_SUMMARY = "Join the same room, see who is there, and offer files directly to selected peers."
|
|
@@ -744,8 +744,8 @@ const renderAboutModal = (state: TuiState, actions: TuiActions) => {
|
|
|
744
744
|
actions: [
|
|
745
745
|
ui.link({
|
|
746
746
|
id: "about-elefunc-link",
|
|
747
|
-
label: "elefunc.com",
|
|
748
|
-
accessibleLabel: "Open Elefunc
|
|
747
|
+
label: "elefunc.com/send",
|
|
748
|
+
accessibleLabel: "Open Elefunc Send page",
|
|
749
749
|
url: ABOUT_ELEFUNC_URL,
|
|
750
750
|
}),
|
|
751
751
|
actionButton("close-about", "Close", actions.closeAbout, "primary"),
|