fix: harden WebRTC transfers for v0.0.1
Require mutual fingerprint confirmation before sharing metadata or files. Validate incoming messages, bound buffering, and confirm receipt before reporting success. Add direct-to-disk saving and explicit TURN opt-in. Fix reset and retry handling, clean up cancelled connections, and preserve completed Firefox downloads when the sender disconnects. Update dependencies, clarify security assumptions, and add protocol and cross-browser regression tests. Set version 0.0.1 and document the release in CHANGELOG.md, linked from the README. BREAKING CHANGE: both peers must use signaling and transfer protocol v2; older connection codes are no longer accepted.
This commit is contained in:
1 parent
d198332c92
commit
752d0cf3af
16 files changed
+1351
-602
No files matched your search
@@ -0,0 +1,39 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.1] - 2026-10-09
|
||||
|
||||
### Added
|
||||
|
||||
- Mandatory full SHA-256 fingerprint confirmation by both peers before sharing
|
||||
file metadata or contents.
|
||||
- Receiver acceptance and direct-to-disk saving in supported browsers.
|
||||
- Optional TURN relaying, requiring explicit opt-in from both peers. Consent
|
||||
clears after a connection completes, fails, or is reset or cancelled.
|
||||
- Protocol regression tests and Chromium, Brave, and Firefox integration checks.
|
||||
|
||||
### Changed
|
||||
|
||||
- Enforced message validation, exact file sizes, and bounded buffering.
|
||||
- Limited memory downloads to 64 MiB and direct-to-disk transfers to 64 GiB.
|
||||
- Report transfer completion only after receiver acknowledgment.
|
||||
- Updated dependencies, including the fix for the `source-map-js` advisory.
|
||||
- Clarified encryption, hosting trust, connection-code privacy, and deployment
|
||||
requirements.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Reset failing to restore the ready state.
|
||||
- Invalid answers unnecessarily destroying valid connection offers.
|
||||
- Connections and unfinished disk writes surviving cancellation or tab changes.
|
||||
- Completed Firefox downloads disappearing when Brave disconnected.
|
||||
- Excess data, duplicate metadata, and malformed messages corrupting transfers
|
||||
or causing unbounded memory growth.
|
||||
- ICE gathering silently returning incomplete connection information, and
|
||||
stalled transfers waiting indefinitely.
|
||||
|
||||
### Compatibility
|
||||
|
||||
- Introduced signaling and transfer protocol v2. Both peers must use the updated
|
||||
app; connection codes from earlier versions are no longer accepted.
|
||||
- Files larger than 64 MiB require a receiving browser with direct-to-disk
|
||||
saving support.
|
||||
@@ -1,57 +1,148 @@
|
||||
# HellCon
|
||||
|
||||
Peer-to-peer file sharing between two browsers. No server, no account, no
|
||||
upload. The page you host is only a delivery mechanism for the JavaScript —
|
||||
the files themselves travel directly from one browser to the other over
|
||||
WebRTC, end-to-end encrypted (DTLS-SRTP) by the browsers themselves.
|
||||
Current version: **0.0.1**. See the [changelog](CHANGELOG.md) for release notes
|
||||
and compatibility changes.
|
||||
|
||||
Built with Vite + Vue 3, toolchain is `bun`.
|
||||
Browser-to-browser file sharing with Vue 3 and WebRTC. No accounts, signaling
|
||||
backend, or server-side file storage. You exchange connection codes manually.
|
||||
Direct connections are the default. TURN relaying is optional and requires
|
||||
explicit opt-in by both people; no relay is configured automatically.
|
||||
|
||||
## How it works
|
||||
|
||||
1. **Sender** picks a file, chooses a STUN provider, and clicks
|
||||
*Create code*. Their browser generates a WebRTC offer and the app presents
|
||||
it as one copyable string.
|
||||
2. The sender pastes that code to the receiver through **any channel they
|
||||
already trust** — a chat app, email, a piece of paper read over the phone.
|
||||
3. **Receiver** pastes the code; their browser answers and the app shows the
|
||||
answer string. They send it back the same way.
|
||||
4. The sender pastes the answer. Both browsers exchange the SDP fingerprints
|
||||
as a two-line security check — if both sides see the same codes, no one
|
||||
can have interposed on the exchange.
|
||||
5. The connection opens and the file is transferred in chunks with
|
||||
backpressure, reassembled on the receiver side and handed to the user as
|
||||
a download.
|
||||
1. The sender picks one file and configures STUN (Google by default, Cloudflare,
|
||||
a custom provider, or None). They create a code and send it privately to the
|
||||
intended receiver through an authenticated channel.
|
||||
2. The receiver pastes the code, creates an answer, and sends it back. The sender
|
||||
pastes the answer. Gathering waits for completion, up to 30 seconds; a timeout
|
||||
fails rather than quietly exporting incomplete connection information.
|
||||
3. **Both people compare both full SHA-256 certificate fingerprints** over a
|
||||
channel whose authenticity and integrity they trust, such as in person.
|
||||
Your fingerprint must equal their “Their fingerprint”, and vice versa.
|
||||
Compare every byte. Cancel on any mismatch. Both people must explicitly
|
||||
confirm before the app sends the filename, size, MIME metadata, or contents.
|
||||
4. The receiver sees the filename and size and explicitly accepts the file.
|
||||
Supported browsers can stream directly to a chosen disk destination, up to
|
||||
64 GiB. Other browsers can receive files up to 64 MiB in memory and then offer
|
||||
a download. Larger files require direct-to-disk support. Even capped memory
|
||||
downloads may be too large on a memory-constrained device.
|
||||
5. The sender waits for a receipt acknowledgment. For disk transfers, the receiver
|
||||
sends this only after its writable stream closes successfully; for memory
|
||||
transfers, after constructing the complete download. This does not prove a
|
||||
human saved the memory download, nor that a malicious receiver told the truth.
|
||||
|
||||
**STUN**: if both peers are on the same network nothing external is needed
|
||||
(pick "None"). For peers on different networks the browsers need one
|
||||
stateless UDP lookup against a public STUN server (Google or Cloudflare, or
|
||||
your own) to discover their public IP. That's the only third-party contact,
|
||||
and it never sees connection or file data. Remove the `iceServers` entry in
|
||||
`src/lib/webrtc.js` if you want to talk to nobody but your peers.
|
||||
Cancel, reset, changing the selected file, or switching Send/Receive closes the
|
||||
connection and aborts unfinished disk writes. Keep the tab open until receipt is
|
||||
confirmed. A completed memory download is discarded when you reset or switch.
|
||||
Pending verification/acceptance expires after five minutes; stalled transfers
|
||||
expire after one minute. The two peers must use this protocol version (v2);
|
||||
legacy connection codes are rejected.
|
||||
|
||||
**MITM model**: the file data is end-to-end encrypted by the browsers and
|
||||
cannot be MITM'd by a passive attacker. The only theoretical attack is
|
||||
interposing on the *code exchange* itself; the built-in fingerprint
|
||||
comparison ("Security check" after signaling) closes it — compare the codes
|
||||
over a channel you trust.
|
||||
If an answer is rejected as invalid, correct the pasted answer and click Connect
|
||||
again; the sender keeps its existing offer while it is still awaiting an answer.
|
||||
After a connection actually closes or fails, use Reset and exchange a **new offer
|
||||
and new answer**. Old codes refer to the closed connection and cannot reopen it.
|
||||
Reset returns the page to its initial ready state. For a local test, open two
|
||||
separate browser tabs or windows; switching Send/Receive inside one page cancels
|
||||
that page's previous connection. Use the specific error shown in red to diagnose
|
||||
failures; if a configured STUN server is unreachable, try None for a local test.
|
||||
|
||||
## Commands
|
||||
## Network privacy and optional TURN
|
||||
|
||||
STUN discovers externally reachable addresses. Its operator can see your public
|
||||
IP address and request metadata, but STUN does not relay file contents. Lookups,
|
||||
retries and connectivity checks may involve multiple packets. Choosing None
|
||||
avoids contacting a configured STUN provider; direct connectivity depends on
|
||||
addresses, routing, browser policy and firewalls, not simply whether peers share
|
||||
one network. A VPN is not automatically a guarantee against address disclosure.
|
||||
|
||||
Connection codes are **Base64-encoded, not encrypted**. They contain SDP,
|
||||
including candidate addresses, temporary ICE credentials and certificate
|
||||
fingerprints. Peers and anyone who sees these codes (including the messaging
|
||||
service used to exchange them) may learn connection details. Local addresses may
|
||||
be obscured by the browser, but this app does not provide anonymity. Treat codes
|
||||
as private session information; do not publish them.
|
||||
|
||||
Restrictive NATs or firewalls can prevent direct connections. There is no silent
|
||||
TURN retry. To permit a relay, both people must explicitly check **Allow a TURN
|
||||
relay**, supply their authorized TURN URL, username and password, and generate
|
||||
new codes. Otherwise TURN URLs are rejected in the STUN field and codes with
|
||||
relay candidates are rejected. Enabling TURN allows the browser to contact that
|
||||
relay during gathering and select a relay route when needed. This does not force
|
||||
relay-only routing or hide your IP from the peer. A remote peer can independently
|
||||
proxy their own traffic; the opt-in controls this app's configuration and the
|
||||
relay candidates it accepts, not arbitrary software run by the other person.
|
||||
|
||||
TURN credentials stay in the current component's memory; the app does not persist
|
||||
them or include them in codes. The relay receives its authentication exchange and
|
||||
can observe addresses, timing and traffic volume, and may charge for bandwidth.
|
||||
Resetting, cancelling, completing or failing a connection clears TURN consent;
|
||||
check the option again before creating another relayed connection.
|
||||
File traffic remains DTLS encrypted through the relay. The web host, DNS resolver,
|
||||
and code-exchange service are also relevant third parties.
|
||||
|
||||
## Security model and limits
|
||||
|
||||
Data channels use **SCTP over DTLS**, which provides transport confidentiality and
|
||||
integrity. This is not DTLS-SRTP (the media transport). DTLS authenticates the
|
||||
certificate in the connection description; an independently authenticated full
|
||||
fingerprint comparison binds that certificate to the intended peer. Comparing
|
||||
fingerprints through a channel an attacker can rewrite provides no such assurance.
|
||||
|
||||
You must trust your browser, device, and **the JavaScript you load**. A compromised
|
||||
host or build can steal plaintext or falsify the verification display. Serve the
|
||||
production build over HTTPS, or run a verified build you control on localhost.
|
||||
HTTPS protects delivery against network tampering, not against a malicious host.
|
||||
The app does not upload files to its web host in this implementation; that is a
|
||||
property of this code, not a guarantee against a host serving different code.
|
||||
|
||||
The protocol accepts one ordered, reliable data channel, bounded metadata and
|
||||
messages, an exact declared byte count, and a single file. It rejects unexpected
|
||||
states, excess data and duplicate metadata. An acknowledged 1 MiB send window
|
||||
and a bounded receive queue limit buffering during disk writes. Files are treated
|
||||
as opaque downloads; metadata is not rendered as HTML. Encryption does not make
|
||||
a file safe to open. These limits reduce denial-of-service exposure but do not
|
||||
eliminate browser, device, network, or malicious-peer risks.
|
||||
|
||||
For deployment, serve `dist/` as static files over HTTPS. Do not expose the Vite
|
||||
dev or preview server as the production service. Configure hosting headers such
|
||||
as `Content-Security-Policy` (including `frame-ancestors 'none'`),
|
||||
`X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer`. A baseline
|
||||
CSP for this build is `default-src 'self'; script-src 'self'; style-src 'self'
|
||||
'unsafe-inline'; img-src 'self'; connect-src 'self'; object-src 'none'; base-uri
|
||||
'none'; frame-ancestors 'none'`. Inline styles are currently used for progress and
|
||||
Vue visibility. Test headers on the actual host; CSP is defense in depth and is
|
||||
not a substitute for trusting the host or a portable WebRTC egress filter.
|
||||
`robots.txt` and indexing metadata are crawler requests, not access control.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
bun install
|
||||
bun run dev # dev server
|
||||
bun run build # static build -> dist/ (3 static files + favicon + robots.txt)
|
||||
bun run preview # serve the production build
|
||||
bun install --frozen-lockfile
|
||||
bun run dev
|
||||
bun run test
|
||||
bun run build
|
||||
bun run test:browser # local Chromium integration checks against dist/
|
||||
bun run test:cross-browser # Brave sender → Firefox receiver
|
||||
bun run preview # local build inspection only
|
||||
bun audit
|
||||
```
|
||||
|
||||
## Honest disclaimer
|
||||
The lockfile pins dependencies. Review dependency updates and advisories before
|
||||
publishing a build. Protocol regression tests cover verification gating, malformed
|
||||
messages, size limits, cancellation, receipt acknowledgment, and relay opt-in.
|
||||
The browser check requires Chromium at `/usr/bin/chromium` (override with
|
||||
`CHROMIUM_PATH`); it uses an isolated temporary profile and a loopback server.
|
||||
The cross-browser check uses Brave and Firefox at `/usr/bin/brave` and
|
||||
`/usr/bin/firefox` (override with `BRAVE_PATH` and `FIREFOX_PATH`). It checks
|
||||
that the received file remains downloadable after the sender disconnects.
|
||||
Pass `--reverse` to test Firefox → Brave, or `--default-network` to use Google
|
||||
STUN instead of the local test's default None. These checks use temporary
|
||||
browser profiles and do not modify your normal browser settings.
|
||||
|
||||
This is **vibe-coded throw-away software**. It was generated for fun, it
|
||||
worked on the machines it was tried on, and it is roughly audited rather
|
||||
than battle-tested. It may break on your browser, your NAT, or your use
|
||||
case. If it works for you, great. If not, fixing it is now your hobby.
|
||||
This is experimental software, not independently audited or battle-tested.
|
||||
Browser compatibility, network connectivity and storage availability vary.
|
||||
|
||||
## License
|
||||
|
||||
MIT — do whatever you want with this. No warranty, see `LICENSE`.
|
||||
MIT — see `LICENSE`.
|
||||
@@ -5,11 +5,11 @@
|
||||
"": {
|
||||
"name": "hellcon",
|
||||
"dependencies": {
|
||||
"vue": "^3.5.0",
|
||||
"vue": "^3.5.43",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^6.0.0",
|
||||
"vite": "^7.0.0",
|
||||
"@vitejs/plugin-vue": "^6.0.9",
|
||||
"vite": "^7.3.7",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
"@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.29.7", "", {}, "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg=="],
|
||||
|
||||
"@babel/parser": ["@babel/parser@7.29.8", "", { "dependencies": { "@babel/types": "^7.29.8" }, "bin": "./bin/babel-parser.js" }, "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA=="],
|
||||
"@babel/parser": ["@babel/parser@7.29.9", "", { "dependencies": { "@babel/types": "^7.29.8" }, "bin": "./bin/babel-parser.js" }, "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA=="],
|
||||
|
||||
"@babel/types": ["@babel/types@7.29.8", "", { "dependencies": { "@babel/helper-string-parser": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7" } }, "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg=="],
|
||||
|
||||
@@ -80,77 +80,77 @@
|
||||
|
||||
"@rolldown/pluginutils": ["@rolldown/pluginutils@1.0.1", "", {}, "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw=="],
|
||||
|
||||
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.63.1", "", { "os": "android", "cpu": "arm" }, "sha512-UZ8sUxPTiHWYX9QNdJedb1kDZSpS1t/VPWBWGSgqHNi9w3Cu6IXvu2mzbhiTiPvtrqgTQJ+zqiAq2iPIPilpaQ=="],
|
||||
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.64.3", "", { "os": "android", "cpu": "arm" }, "sha512-a31GFbL70GlGUGhn8goVjRLtdDG1urLCJFWLZ7JcxdHK9pPvCohLFtYLgJDdNbtrNZSrJl1u9bK05ISsSC2EpA=="],
|
||||
|
||||
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.63.1", "", { "os": "android", "cpu": "arm64" }, "sha512-cQ4nFQABN5cDvDpbvJ7bMStCpnaVxynZrRMfUJYgxcIk9Sh54FIO1vtfkg0B69REjER77ioZ/ov+eAApx/KmLQ=="],
|
||||
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.64.3", "", { "os": "android", "cpu": "arm64" }, "sha512-IRv757RLiPGlNxAX5JXU0eiUlUPvKiwFRbkqLd+gywptLK4uSEg1qkl6en6r0cXMazSnWUWOBABv+QfuLV3n5Q=="],
|
||||
|
||||
"@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.63.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-FQNqd1lRy/0QhDk3xeRIkSBiCpXCiDnZO3YLVdcDKN1UBiKToNftCzcXYNLshmPDUMlu2TdeS8tGcsU6f3YF1Q=="],
|
||||
"@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.64.3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-UkzI35Fnz6+MJNATdnjnZ3TpdG/rXab8h7oDOD9R0zDVIFmuuYrvgUj8V8mh+A//+LR4TlEQo4ZW4RhyRtWv3A=="],
|
||||
|
||||
"@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.63.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-pvD16V939D3CloK0+qikpGaxiPrDUXTe7Y5cWOMkMSy7m1cawa8EGy/kXYi/G/cKAC4HDAbSnzCIk1WmsoOKXg=="],
|
||||
"@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.64.3", "", { "os": "darwin", "cpu": "x64" }, "sha512-C3AyMtAnKQ/jSkZ0chIoWbPXRbFz8JnPLhl1ULecEhcaOGkT19xt7KmO8BulQxt9S/XideHRXvsVQUbGj4JCOg=="],
|
||||
|
||||
"@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.63.1", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-pcFGeL2345VwdTnJhA6zLbew+YgWB0qBG2+dMtXjCicf6+rm6kO6cOoh5VnTe0ZMrMRgRyuHmCJxZWrIdzYuOw=="],
|
||||
"@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.64.3", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-M8yAdBMyHh14JLeXDNGvEkljzuHdcoLBQ399O4Fp4nvX51lueuEY/5U2G9Ci0D6/bQlBp/3JLiBQH55STwwbwg=="],
|
||||
|
||||
"@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.63.1", "", { "os": "freebsd", "cpu": "x64" }, "sha512-mRJlqSRulVzcKq/LKA6ICSIc3K/l4fzlVn/gePn2nXIHy8seRi5z/eeRE0d/XMBxcMldiXtQTSpRj0tkkC3g8Q=="],
|
||||
"@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.64.3", "", { "os": "freebsd", "cpu": "x64" }, "sha512-WQjuOKGh2FN98ZK6i0uM6M6YqnPEds85p3oRkrxiEeTQo/p7RpuU8c9MwQ88LfgwVAzohumlzbQQSikz4Zw9rw=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.63.1", "", { "os": "linux", "cpu": "arm" }, "sha512-YDUNvVM85TI3g/1OpnqKP1h4NeW/j64DfWMf+G3M809xNk1bJSnpFp4sh83NpmVE5DXnkh8ULor4LTVZKoYLHw=="],
|
||||
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.64.3", "", { "os": "linux", "cpu": "arm" }, "sha512-5tDLZG5s9WyVKoEHgwos6FpKrgpotl61EYeHSLSVkQzMzTsaClwEr8mok9rm3y734zjiGInG4dfw/56ebWVvEQ=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.63.1", "", { "os": "linux", "cpu": "arm" }, "sha512-7Mcn71p9ZuQFAj+h+dhQXy/yeLePRS2yKRnmW1DijA9thKO5qap0GNOIQK4yQ6iP3SU0Mrb/yWo8h8vgRba8lw=="],
|
||||
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.64.3", "", { "os": "linux", "cpu": "arm" }, "sha512-Mh5KbLeplM2HX6lQI18jsxSsqvPW8d+Hyk8HtY6Zl93woMitRSCZ92rBEzq6v8bfZGlpyMgj4P/sKW4KCjhH3A=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.63.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-4YiLQTX6U4CSl0L9cluep9A9W6UmTfqBDc2/CH6wlu54pl4E7Jn3cOD8oxzvBDEGk/JMKgJ47C8g+radF7mwvg=="],
|
||||
"@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.64.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-QZrrwHnznTv6y4iiHtCqDN+ZsF4qNFQObMOLgPrbxhh9O5o4rgoUe5OnkqG/ceCObMrAjhQt+eQ6HSDzBFgVMw=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.63.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-2ra8F7w8OquwZN9z2/fKFnli69wa8PLwaVzRMIPGb13ByMJwC28Fbp8YcVGoUhlYMTt7j5j9bNgpysrN2UM+vw=="],
|
||||
"@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.64.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-4vLehpXSwlkltnvk5ETB+Hz+d3xayZS3NamZ5Vq4bSo+IUoIALovEJF1YgWPMjHwN7R5o/R4BpP9h3q8EK1xAA=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.63.1", "", { "os": "linux", "cpu": "none" }, "sha512-Sy20ncyhjmBP0Ml+UvQbimjlk6VFgjW5uNP+qqwHB00mTE8Bl2C1TuHTlRwK2YoXeZbee5lP2XevBWVkAQAtSQ=="],
|
||||
"@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.64.3", "", { "os": "linux", "cpu": "none" }, "sha512-SEN7TTTOdXJKZmsWKOnQeVfgy3Dje/08ISXWwFhTggQ3SxjuIaChvmOB5ZDZqJNlBjaXrV6nAHraqEAvdLGqcw=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.63.1", "", { "os": "linux", "cpu": "none" }, "sha512-noITLp8oNjYliPnGWmLyelIHwULGqbHloQHGw1rtxbWhTuWooRpnZarZQJ1y9EUC4szuCusCc+HEpUtxpIwYvA=="],
|
||||
"@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.64.3", "", { "os": "linux", "cpu": "none" }, "sha512-1LDsQMRMCEdGF9Dih5qyh6fF1LK3NnA+pAtE2+9AgZwUdXyd19TOBVC9crSB63iZBHR4vOG7h8gN/LcUH3J7xw=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.63.1", "", { "os": "linux", "cpu": "ppc64" }, "sha512-hlxxXd+F1mWiAcaFR7Sv9ZQT6m6UfI8+Vy/kFJzztq2pDMU/0wZ9sish0iszNZvsQDo8Gc0i5yuFEOz5dDf6fA=="],
|
||||
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.64.3", "", { "os": "linux", "cpu": "ppc64" }, "sha512-v3D2tAfRriqGOi+5Ac5CiYbBo2NXtLVxJlludTvUZRj502lVMFeVIuvvWbz4qCrotn3e3Uvpvh7FcMpG2QxxXQ=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.63.1", "", { "os": "linux", "cpu": "ppc64" }, "sha512-EF7OpqQTQ/BvGqLzUi4rEHuagCV9MugAUXSHemwPW5vxZ75RR+jxO/2j95Ph2dalMpFHSVECjRoioHZgA9zOYA=="],
|
||||
"@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.64.3", "", { "os": "linux", "cpu": "ppc64" }, "sha512-db5q6dP189V2+JkMpsXBl8ym6bC0x8ydZ47fUJZ9YdM6T2OF5uqNzX9HaAZHRP/lqjA9bJeNwi0qw1/2/37dUA=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.63.1", "", { "os": "linux", "cpu": "none" }, "sha512-wQO3JesW9PRkwlabQ27y7sPfVOOTLRG73I4F2UYHG5PXun3J9U3y+b7ezVKSYbsvSKGQ1k1cq8Qlun4C9kLt3w=="],
|
||||
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.64.3", "", { "os": "linux", "cpu": "none" }, "sha512-nArAVDmrL5ix9UoipcKEsYJw4kMUQCIPYRWuYF2POOC7jd9rmN95d/48ewsYFC/OdtwEx6VYYWYxrp8FbMOU2Q=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.63.1", "", { "os": "linux", "cpu": "none" }, "sha512-ouAGwhO6wHRXdnOVCOsB0tRFkA7nhNB2Nwax6oECXN0YiN8EYUTBAOudADOB1PI+yDL61TeNx/u7MVCzksNbkQ=="],
|
||||
"@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.64.3", "", { "os": "linux", "cpu": "none" }, "sha512-2dc7LElu7EVSvpQT8epNnBLa02wlqilNYqHN0FA/RaKqCr9U9ZFYQ0Eh4sfgSzLneLDuJsJRjcezR/l2UyYGXA=="],
|
||||
|
||||
"@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.63.1", "", { "os": "linux", "cpu": "s390x" }, "sha512-q2R38Sn+1J8RxhfJ+T54wSWmyKXWec+9jgDfqO2AtArEqHO5R2aeayp5H5OYLr5UYDVGsVaZPEFUooMhYCdz5A=="],
|
||||
"@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.64.3", "", { "os": "linux", "cpu": "s390x" }, "sha512-9PYq2IEzSwXcvQLERcT9LKXRzw8J05GFTbJHA2anJR2WmlRjA1esgXVYhanp+bmjKsDVoZeU2L7Z2pRClLcZTw=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.63.1", "", { "os": "linux", "cpu": "x64" }, "sha512-gfI5T24WLLuFfSKw7Go/zDXjAAV0fny0swTaDv+WjK7vqcw4cRhFfdsyKL1n+ukI+ooBxn3bVQnyrn06WpI50w=="],
|
||||
"@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.64.3", "", { "os": "linux", "cpu": "x64" }, "sha512-vMh+mt0cw1BHldd8cqaU6A5s1W4EUKl6+8MRsv86mj954L4xyruKD7qPXMUI2icImadAZARK10h0onaGTLmCVg=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.63.1", "", { "os": "linux", "cpu": "x64" }, "sha512-4h6XqthmB4Hspji84wvgk+ElodTsGj+dbZqHJHHtKxj4mYq0ANSEEPX9ys3moJueqsRjwpaJYH7874Itwnj2ow=="],
|
||||
"@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.64.3", "", { "os": "linux", "cpu": "x64" }, "sha512-PpiKU+sWbqDGc0U0su8oXiyeyqm0UQjmaaPKHktX+DaLe6YKJwW2YVD0f2AXHdVvblZbRqpwRVClWP2F5HCqrQ=="],
|
||||
|
||||
"@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.63.1", "", { "os": "openbsd", "cpu": "x64" }, "sha512-dlfCOa87o1VAYegLQ9EKilx2JCeRofiyPGhTCmqnuXZ6bMPiycO1rq1+sKoulAp7pGLIsTIw+1x5R+zgh5LhhA=="],
|
||||
"@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.64.3", "", { "os": "openbsd", "cpu": "x64" }, "sha512-/3enY/AmaIt8IS0fWjX4ztYVPBqkj49cQTy/hCryhBFaEzDfJwwEolq9sxvyWAM2qmsmVuPdeRg5JXSrmeqvJg=="],
|
||||
|
||||
"@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.63.1", "", { "os": "none", "cpu": "arm64" }, "sha512-cjkLbOlfcm3QGhMM1J5zaZjsw1GggbN6rw9UTSSRrPrR1KkcXnN7Uq9rPw34xImQ9VOY9GN+6u2Zj80B9ptkcw=="],
|
||||
"@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.64.3", "", { "os": "none", "cpu": "arm64" }, "sha512-zsEP/QDuet52hhwvi5T1VPg0/Tkms0m3zkVv7CPsznvhdO4pL4oJTMz26EJsiCe18OeLKPgpTu3XVO3C1eq3ew=="],
|
||||
|
||||
"@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.63.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-Li1KdUnWGE4N3e1F/B4RTB1ms+nG4WBgjByO46pkeBVX/2UBsY53xf5vK9WygVmnH3RwncIST7lkSdLSY6P9lg=="],
|
||||
"@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.64.3", "", { "os": "win32", "cpu": "arm64" }, "sha512-4ESknW4Db+kqvazVOfsReYJaHxcIsOqcgwjKV2J1tG5Bn4RVf5ocTQKSGuq2HWBJcOLuyim8IWX8DuH6nKmELA=="],
|
||||
|
||||
"@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.63.1", "", { "os": "win32", "cpu": "ia32" }, "sha512-t4ZYOSoLTgwhuFMrmTMLx/+i1DQVK7HYqMc6kY46EApwi8X0nIVphzdNoThU3xt6n+N5urG1/gxBdCaKDLavfg=="],
|
||||
"@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.64.3", "", { "os": "win32", "cpu": "ia32" }, "sha512-3B8VCQyIyv7FQxYYhb3HpR3bIpronR20txjMSffSoz/sm/DDs3/49CFpEueOsvq9qW9sWoI/6pi6mtciD9NXFg=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.63.1", "", { "os": "win32", "cpu": "x64" }, "sha512-RgroPfMmKlD1RzSDxvwgcPiy2HNQKoYV7OmwIXDsk73uKW5t6B/V8KIy27SMv/FNXFo/oSBtWc9J0X7t91ezZg=="],
|
||||
"@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.64.3", "", { "os": "win32", "cpu": "x64" }, "sha512-YOoDkKh2oQxOxRB5D9AR8sj3qpMShpmyTkjojiBjMGigz3caV7UvCnXWWUQC0TBmrZ5zuHe2pWl8S+cMfvXzRg=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.63.1", "", { "os": "win32", "cpu": "x64" }, "sha512-at8QVep6S3h5Y6gSbdGU06bRY5WJkf6WUduM9YtvYMbYhB1MOFfUgc6kehitQXzOtMSaT70q7f9ydPhpqu821w=="],
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.64.3", "", { "os": "win32", "cpu": "x64" }, "sha512-qTv4bG+eKJKifzxNJevMUh8L6CjJrz9/Kn1IbP2F5bo0tBzNIR7HMg4vni6XmDzcKUl00lHHY+J5ZgjbGiujOQ=="],
|
||||
|
||||
"@types/estree": ["@types/estree@1.0.9", "", {}, "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg=="],
|
||||
|
||||
"@vitejs/plugin-vue": ["@vitejs/plugin-vue@6.0.8", "", { "dependencies": { "@rolldown/pluginutils": "^1.0.1" }, "peerDependencies": { "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0", "vue": "^3.2.25" } }, "sha512-0ZjgOg7oO6farnNGup7yvoM/YXZV84OZxHAwtflItNa/6zzQyVb5LNxyea3FEKEX2XlagIKzrlH7wwxkKgtiew=="],
|
||||
"@vitejs/plugin-vue": ["@vitejs/plugin-vue@6.0.9", "", { "dependencies": { "@rolldown/pluginutils": "^1.0.1" }, "peerDependencies": { "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0", "vue": "^3.2.25" } }, "sha512-rD/MORlhaZMlXWW0rEn4FB4wMinWC0z/D7Ye160S5+Rs1mC8ZDAdcDp4SjKfUhG5t8q1ktcPVw4xuTkPRlzrSA=="],
|
||||
|
||||
"@vue/compiler-core": ["@vue/compiler-core@3.5.42", "", { "dependencies": { "@babel/parser": "^7.29.8", "@vue/shared": "3.5.42", "entities": "^7.0.1", "estree-walker": "^2.0.2", "source-map-js": "^1.2.1" } }, "sha512-2Ye1ilMtKXxl8qZUrQ5j0CdgenFp/HFQmta6rfRyfEsTG69L6Wk+tWuNoHYHMx9E8tF2Slvdg1FuwDvAXdy1LQ=="],
|
||||
"@vue/compiler-core": ["@vue/compiler-core@3.5.43", "", { "dependencies": { "@babel/parser": "^7.29.8", "@vue/shared": "3.5.43", "entities": "^7.0.1", "estree-walker": "^2.0.2", "source-map-js": "^1.2.1" } }, "sha512-zdiLhnbe1QQqgDT8xZMpNmyqZ3qlI+/Q/FHQco57Kwl/b05HhCzN6eVGN9QU9rbga4CrS0H5SYY8VGHZCt/1Hg=="],
|
||||
|
||||
"@vue/compiler-dom": ["@vue/compiler-dom@3.5.42", "", { "dependencies": { "@vue/compiler-core": "3.5.42", "@vue/shared": "3.5.42" } }, "sha512-qbhQZEFmycr+ni/qyuccS4sucNN7VAbDfbkvNxWOX2VfgFm90MNs3/UhRNKoPMEIVn0F8gdlYjLPvqxHwHeQOA=="],
|
||||
"@vue/compiler-dom": ["@vue/compiler-dom@3.5.43", "", { "dependencies": { "@vue/compiler-core": "3.5.43", "@vue/shared": "3.5.43" } }, "sha512-PEZoAk3NQmsn/ejMzSOCyTYqwGqczrWm70PuhBKjjv1+TCoQAaO/zOqNwjV+honlNstT5ILxtc+8r8UUfj+iEQ=="],
|
||||
|
||||
"@vue/compiler-sfc": ["@vue/compiler-sfc@3.5.42", "", { "dependencies": { "@babel/parser": "^7.29.8", "@vue/compiler-core": "3.5.42", "@vue/compiler-dom": "3.5.42", "@vue/compiler-ssr": "3.5.42", "@vue/shared": "3.5.42", "estree-walker": "^2.0.2", "magic-string": "^0.30.21", "postcss": "^8.5.19", "source-map-js": "^1.2.1" } }, "sha512-fkCAFB4okcAANGMThboWnScp/gzWjU0ZSkVnjTIiplmMDq2uq0tIB3j+xVu4rhv5rvOgBySCysudmbMd6xRRqw=="],
|
||||
"@vue/compiler-sfc": ["@vue/compiler-sfc@3.5.43", "", { "dependencies": { "@babel/parser": "^7.29.8", "@vue/compiler-core": "3.5.43", "@vue/compiler-dom": "3.5.43", "@vue/compiler-ssr": "3.5.43", "@vue/shared": "3.5.43", "estree-walker": "^2.0.2", "magic-string": "^0.30.21", "postcss": "^8.5.28", "source-map-js": "^1.2.1" } }, "sha512-FCbrG3XNCRl+js3huuKx4IVHBLTvMkJhVepjbxSPu1gn4yWLaYtGNQdjJGZaMytXB6qb76qQDDmDSLy/vkmleQ=="],
|
||||
|
||||
"@vue/compiler-ssr": ["@vue/compiler-ssr@3.5.42", "", { "dependencies": { "@vue/compiler-dom": "3.5.42", "@vue/shared": "3.5.42" } }, "sha512-xmLk3wLkbizPAiLyomjgFFosf2ys9b5Ghb+oh/k2tnvipNz8OFrQOiTcWCzyK7MpBp9KkyGtfvgfLUivbmuGYA=="],
|
||||
"@vue/compiler-ssr": ["@vue/compiler-ssr@3.5.43", "", { "dependencies": { "@vue/compiler-dom": "3.5.43", "@vue/shared": "3.5.43" } }, "sha512-GF62orf7KiJX9RqrHNGrYBudsQGD0OhJ5nDs90O8UiDuS40+YMYomiXu6w6EuvtXuRDc3MSNis3EaaSKAVSWpg=="],
|
||||
|
||||
"@vue/reactivity": ["@vue/reactivity@3.5.42", "", { "dependencies": { "@vue/shared": "3.5.42" } }, "sha512-TzNNfKpb7hDxbQltwAut8VDQA5YP+BuRlxntHUuRjyKwlMvmAPbs3unhCvieijifY6vFfVBwsS7wG/C7uq+bEQ=="],
|
||||
"@vue/reactivity": ["@vue/reactivity@3.5.43", "", { "dependencies": { "@vue/shared": "3.5.43" } }, "sha512-G/c9GyOZNI2jVaaS6OX1EF1SSFSv7H0ERqNTl4+DTFMlZmB5eVAB53aLQNam/7NL2NPtaDD7RdVrzf8uJzMuOA=="],
|
||||
|
||||
"@vue/runtime-core": ["@vue/runtime-core@3.5.42", "", { "dependencies": { "@vue/reactivity": "3.5.42", "@vue/shared": "3.5.42" } }, "sha512-9uACtuHs7vJGkm5Bp3xu4xRDLFTIYy5DgxpToVjqGIAhAEKwQfsaLvKINhM6nFVp6bZPRFGdDqd1g52MqKsotA=="],
|
||||
"@vue/runtime-core": ["@vue/runtime-core@3.5.43", "", { "dependencies": { "@vue/reactivity": "3.5.43", "@vue/shared": "3.5.43" } }, "sha512-hU6U6VnVhBGQDpvlnnDlIB8ZGJBiOcgk2lh/0InltHiz3D8oSkluvuvY+do1G2H3+udeKFsmaBlgVYP7gXQzEw=="],
|
||||
|
||||
"@vue/runtime-dom": ["@vue/runtime-dom@3.5.42", "", { "dependencies": { "@vue/reactivity": "3.5.42", "@vue/runtime-core": "3.5.42", "@vue/shared": "3.5.42", "csstype": "^3.2.3" } }, "sha512-rsCmhiWLaRxGltLwhlCWyYkFn7WAbKRh0q17eZ1A6Dq6eqc2ACQ61IIryxz0LrsvCzHSilLA9JHovVwM8CNE2g=="],
|
||||
"@vue/runtime-dom": ["@vue/runtime-dom@3.5.43", "", { "dependencies": { "@vue/reactivity": "3.5.43", "@vue/runtime-core": "3.5.43", "@vue/shared": "3.5.43", "csstype": "^3.2.3" } }, "sha512-Bb2Jc0YjjJdMt1SJmb9b2L/IWd3I8lIT9x9eS/xvvP9CiVgna0ffua74xKRmt4/uSJ+0r4iN8ex1jrqkhQGWQw=="],
|
||||
|
||||
"@vue/server-renderer": ["@vue/server-renderer@3.5.42", "", { "dependencies": { "@vue/compiler-ssr": "3.5.42", "@vue/runtime-dom": "3.5.42", "@vue/shared": "3.5.42" } }, "sha512-2++5dUyYS4gvo7xQXSECUDhB7TS0aOl5SeVfC5qSq1Jgfhjvegw1zqhwTIR3imZ+QYPJQw9gfcFvXGAjGZ7ajQ=="],
|
||||
"@vue/server-renderer": ["@vue/server-renderer@3.5.43", "", { "dependencies": { "@vue/compiler-ssr": "3.5.43", "@vue/runtime-dom": "3.5.43", "@vue/shared": "3.5.43" } }, "sha512-l2Ygjv9NehV94PSBxNWsAHC0j/eIIKbn92mBuWXAPGLnn6HfJ6MH5ubsd+Nk0YoZ5FRuxWI1P2VSoh+dbPQhCQ=="],
|
||||
|
||||
"@vue/shared": ["@vue/shared@3.5.42", "", {}, "sha512-2rPxex1jQf4jvl9MOHl6YaXCPcrNqz/FstMOEh3QWY+/OME9nQTvl9WYeCwhW7AFjaR0SnngZGlp/wkR6rkI6g=="],
|
||||
"@vue/shared": ["@vue/shared@3.5.43", "", {}, "sha512-uksS7YGMR5NZyr4JNq0Rp+QyLns0ueaz20KwzIPW9R0LH1Vnt4E+XUM29PNseEbf1www2gOuhuDi5AKOIXag9Q=="],
|
||||
|
||||
"csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
|
||||
|
||||
@@ -166,22 +166,22 @@
|
||||
|
||||
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
|
||||
|
||||
"nanoid": ["nanoid@3.3.18", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w=="],
|
||||
"nanoid": ["nanoid@3.3.20", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ=="],
|
||||
|
||||
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
||||
|
||||
"picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="],
|
||||
|
||||
"postcss": ["postcss@8.5.28", "", { "dependencies": { "nanoid": "^3.3.18", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A=="],
|
||||
"postcss": ["postcss@8.5.29", "", { "dependencies": { "nanoid": "^3.3.19", "picocolors": "^1.1.1", "source-map-js": "^1.2.2" } }, "sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ=="],
|
||||
|
||||
"rollup": ["rollup@4.63.1", "", { "dependencies": { "@types/estree": "1.0.9" }, "optionalDependencies": { "@napi-rs/lzma-linux-x64-gnu": "1.5.1", "@rollup/rollup-android-arm-eabi": "4.63.1", "@rollup/rollup-android-arm64": "4.63.1", "@rollup/rollup-darwin-arm64": "4.63.1", "@rollup/rollup-darwin-x64": "4.63.1", "@rollup/rollup-freebsd-arm64": "4.63.1", "@rollup/rollup-freebsd-x64": "4.63.1", "@rollup/rollup-linux-arm-gnueabihf": "4.63.1", "@rollup/rollup-linux-arm-musleabihf": "4.63.1", "@rollup/rollup-linux-arm64-gnu": "4.63.1", "@rollup/rollup-linux-arm64-musl": "4.63.1", "@rollup/rollup-linux-loong64-gnu": "4.63.1", "@rollup/rollup-linux-loong64-musl": "4.63.1", "@rollup/rollup-linux-ppc64-gnu": "4.63.1", "@rollup/rollup-linux-ppc64-musl": "4.63.1", "@rollup/rollup-linux-riscv64-gnu": "4.63.1", "@rollup/rollup-linux-riscv64-musl": "4.63.1", "@rollup/rollup-linux-s390x-gnu": "4.63.1", "@rollup/rollup-linux-x64-gnu": "4.63.1", "@rollup/rollup-linux-x64-musl": "4.63.1", "@rollup/rollup-openbsd-x64": "4.63.1", "@rollup/rollup-openharmony-arm64": "4.63.1", "@rollup/rollup-win32-arm64-msvc": "4.63.1", "@rollup/rollup-win32-ia32-msvc": "4.63.1", "@rollup/rollup-win32-x64-gnu": "4.63.1", "@rollup/rollup-win32-x64-msvc": "4.63.1", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-3Df9jsstwhccuEfmAMi9l8XUh/GOkVObmFTU7CCVBysEbcOZLl84jCtaAZMcPiMz2EGKsATzQcU+Xr3n/wU6cg=="],
|
||||
"rollup": ["rollup@4.64.3", "", { "dependencies": { "@types/estree": "1.0.9" }, "optionalDependencies": { "@napi-rs/lzma-linux-x64-gnu": "1.5.1", "@rollup/rollup-android-arm-eabi": "4.64.3", "@rollup/rollup-android-arm64": "4.64.3", "@rollup/rollup-darwin-arm64": "4.64.3", "@rollup/rollup-darwin-x64": "4.64.3", "@rollup/rollup-freebsd-arm64": "4.64.3", "@rollup/rollup-freebsd-x64": "4.64.3", "@rollup/rollup-linux-arm-gnueabihf": "4.64.3", "@rollup/rollup-linux-arm-musleabihf": "4.64.3", "@rollup/rollup-linux-arm64-gnu": "4.64.3", "@rollup/rollup-linux-arm64-musl": "4.64.3", "@rollup/rollup-linux-loong64-gnu": "4.64.3", "@rollup/rollup-linux-loong64-musl": "4.64.3", "@rollup/rollup-linux-ppc64-gnu": "4.64.3", "@rollup/rollup-linux-ppc64-musl": "4.64.3", "@rollup/rollup-linux-riscv64-gnu": "4.64.3", "@rollup/rollup-linux-riscv64-musl": "4.64.3", "@rollup/rollup-linux-s390x-gnu": "4.64.3", "@rollup/rollup-linux-x64-gnu": "4.64.3", "@rollup/rollup-linux-x64-musl": "4.64.3", "@rollup/rollup-openbsd-x64": "4.64.3", "@rollup/rollup-openharmony-arm64": "4.64.3", "@rollup/rollup-win32-arm64-msvc": "4.64.3", "@rollup/rollup-win32-ia32-msvc": "4.64.3", "@rollup/rollup-win32-x64-gnu": "4.64.3", "@rollup/rollup-win32-x64-msvc": "4.64.3", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-iIMWbptLYsZdGTJMH8ngApXdsCatE6bCMv2eqGIfGE1++kwh7TCWBdWKK0FKC0yx++196vGK5VdagzRXSLMa8A=="],
|
||||
|
||||
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
|
||||
"source-map-js": ["source-map-js@1.2.2", "", {}, "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw=="],
|
||||
|
||||
"tinyglobby": ["tinyglobby@0.2.17", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],
|
||||
|
||||
"vite": ["vite@7.3.6", "", { "dependencies": { "esbuild": "^0.27.0 || ^0.28.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg=="],
|
||||
"vite": ["vite@7.3.7", "", { "dependencies": { "esbuild": "^0.27.0 || ^0.28.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-AHEzTORMbi7/7aXp7w7KZ5+DCUdSeLsJz0grY8xHpc9DHdYb0vQu6DqJfm2tOw3gDExNgPgnJTXxM6syYFHaCA=="],
|
||||
|
||||
"vue": ["vue@3.5.42", "", { "dependencies": { "@vue/compiler-dom": "3.5.42", "@vue/compiler-sfc": "3.5.42", "@vue/runtime-dom": "3.5.42", "@vue/server-renderer": "3.5.42", "@vue/shared": "3.5.42" }, "peerDependencies": { "typescript": "*" }, "optionalPeers": ["typescript"] }, "sha512-4RyHQTbQvOPs3MfvUO1Sg0YRrKNnA0mAVtvpd12Tg1fKDN7OHBUl1IqSn8zGJjK9nI3NkNp8cgTpVrSZC5TTcA=="],
|
||||
"vue": ["vue@3.5.43", "", { "dependencies": { "@vue/compiler-dom": "3.5.43", "@vue/compiler-sfc": "3.5.43", "@vue/runtime-dom": "3.5.43", "@vue/server-renderer": "3.5.43", "@vue/shared": "3.5.43" }, "peerDependencies": { "typescript": "*" }, "optionalPeers": ["typescript"] }, "sha512-o5qZoksdnjIKvW1srZ3ab7pcDNYAerBjRe54D0LBLfRdCYFrSgBHVXokMas35czQc0//lmx4/tuY4ZNQ+Rf2Ng=="],
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -1,19 +1,22 @@
|
||||
{
|
||||
"name": "hellcon",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "0.0.1",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"test": "node --test",
|
||||
"test:browser": "node scripts/browser-check.mjs",
|
||||
"test:cross-browser": "node scripts/cross-browser-check.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.5.0"
|
||||
"vue": "^3.5.43"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^6.0.0",
|
||||
"vite": "^7.0.0"
|
||||
"@vitejs/plugin-vue": "^6.0.9",
|
||||
"vite": "^7.3.7"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
// Dependency-free Chromium integration check. Run after `bun run build`.
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { createServer } from 'node:http';
|
||||
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { dirname, extname, join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const provider = process.argv.includes('--default-network') ? 'google' : 'none';
|
||||
const profile = await mkdtemp(join(tmpdir(), 'hellcon-browser-'));
|
||||
const server = createServer(async (req, res) => {
|
||||
try {
|
||||
const pathname = new URL(req.url, 'http://localhost').pathname;
|
||||
const base = pathname.startsWith('/src/lib/') ? root : join(root, 'dist');
|
||||
const path = resolve(base, '.' + (pathname === '/' ? '/index.html' : pathname));
|
||||
if (!path.startsWith(base + '/')) throw new Error('Invalid path');
|
||||
const types = { '.js': 'text/javascript', '.css': 'text/css', '.html': 'text/html', '.png': 'image/png' };
|
||||
res.setHeader('Content-Type', types[extname(path)] || 'application/octet-stream');
|
||||
res.end(await readFile(path));
|
||||
} catch { res.statusCode = 404; res.end(); }
|
||||
});
|
||||
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
|
||||
const origin = `http://127.0.0.1:${server.address().port}`;
|
||||
const browser = spawn(process.env.CHROMIUM_PATH || '/usr/bin/chromium', [
|
||||
'--headless', '--no-sandbox', '--disable-gpu', '--disable-background-networking',
|
||||
'--no-first-run', '--no-default-browser-check', `--user-data-dir=${profile}`, '--remote-debugging-pipe', 'about:blank',
|
||||
], { stdio: ['ignore', 'ignore', 'pipe', 'pipe', 'pipe'] });
|
||||
let stderr = '', nextId = 0, buffer = '';
|
||||
const pending = new Map();
|
||||
const browserErrors = [];
|
||||
browser.stderr.on('data', data => { stderr += data; });
|
||||
browser.stdio[3].on('error', () => {}); browser.stdio[4].on('error', () => {});
|
||||
browser.stdio[4].on('data', data => {
|
||||
buffer += data;
|
||||
let end;
|
||||
while ((end = buffer.indexOf('\0')) !== -1) {
|
||||
const message = JSON.parse(buffer.slice(0, end)); buffer = buffer.slice(end + 1);
|
||||
if (message.id) { pending.get(message.id)?.(message); pending.delete(message.id); }
|
||||
if (message.method === 'Runtime.exceptionThrown') browserErrors.push(message.params.exceptionDetails);
|
||||
}
|
||||
});
|
||||
function call(method, params = {}, sessionId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = ++nextId;
|
||||
const timer = setTimeout(() => { pending.delete(id); reject(new Error(`Timed out: ${method}\n${stderr.slice(-1500)}`)); }, 45000);
|
||||
pending.set(id, message => { clearTimeout(timer); message.error ? reject(new Error(JSON.stringify(message.error))) : resolve(message.result); });
|
||||
browser.stdio[3].write(JSON.stringify({ id, method, params, ...(sessionId ? { sessionId } : {}) }) + '\0');
|
||||
});
|
||||
}
|
||||
async function evaluate(session, expression) {
|
||||
const result = await call('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }, session);
|
||||
if (result.exceptionDetails) throw new Error(JSON.stringify(result.exceptionDetails));
|
||||
return result.result.value;
|
||||
}
|
||||
async function wait(session, expression) {
|
||||
return evaluate(session, `(async () => { for (let n = 0; n < 1800; n++) { if (${expression}) return true; await new Promise(r => setTimeout(r, 20)); } throw new Error('UI condition timed out: ' + ${JSON.stringify(expression)} + '\\n' + document.body.innerText); })()`);
|
||||
}
|
||||
async function page() {
|
||||
const { targetId } = await call('Target.createTarget', { url: 'about:blank' });
|
||||
const { sessionId } = await call('Target.attachToTarget', { targetId, flatten: true });
|
||||
await call('Runtime.enable', {}, sessionId);
|
||||
await call('Page.enable', {}, sessionId);
|
||||
await call('Page.navigate', { url: origin }, sessionId);
|
||||
for (let n = 0; n < 100; n++) {
|
||||
try { if (await evaluate(sessionId, `location.origin === ${JSON.stringify(origin)} && document.readyState === 'complete'`)) break; }
|
||||
catch (err) { if (!err.message.includes('context')) throw err; }
|
||||
await new Promise(resolve => setTimeout(resolve, 20));
|
||||
}
|
||||
await wait(sessionId, "!!document.querySelector('#stun-provider')");
|
||||
return sessionId;
|
||||
}
|
||||
const click = (session, label) => evaluate(session, `(() => { const b = [...document.querySelectorAll('button')].find(b => b.textContent.trim() === ${JSON.stringify(label)}); if (!b || b.disabled) throw new Error('Unavailable button: ' + ${JSON.stringify(label)}); b.click(); })()`);
|
||||
const input = (session, selector, value) => evaluate(session, `(() => { const el = document.querySelector(${JSON.stringify(selector)}); el.value = ${JSON.stringify(value)}; el.dispatchEvent(new Event(el.tagName === 'SELECT' ? 'change' : 'input', { bubbles: true })); })()`);
|
||||
async function connect(sender, receiver, size) {
|
||||
await evaluate(sender, `(() => { const input = document.querySelector('#file-input'); const files = new DataTransfer(); files.items.add(new File([new Uint8Array(${size}).fill(123)], 'browser-test.bin')); input.files = files.files; input.dispatchEvent(new Event('change', { bubbles: true })); })()`);
|
||||
await input(sender, '#stun-provider', provider);
|
||||
await input(receiver, '#stun-provider', provider);
|
||||
await click(sender, 'Create code'); await wait(sender, "!!document.querySelector('#output-code')");
|
||||
const offer = await evaluate(sender, "document.querySelector('#output-code').value");
|
||||
await input(receiver, '#offer-input', 'invalid-code!');
|
||||
await click(receiver, 'Accept & create answer');
|
||||
await wait(receiver, "!!document.querySelector('[role=alert]')");
|
||||
assert.equal(await evaluate(receiver, "document.querySelector('#offer-input').disabled"), false);
|
||||
await input(receiver, '#offer-input', offer); await click(receiver, 'Accept & create answer');
|
||||
await wait(receiver, "!!document.querySelector('#output-code')");
|
||||
const answer = await evaluate(receiver, "document.querySelector('#output-code').value");
|
||||
await input(sender, '#answer-input', 'invalid-answer!'); await click(sender, 'Connect');
|
||||
await wait(sender, "!!document.querySelector('[role=alert]')");
|
||||
assert.equal(await evaluate(sender, "document.querySelector('#output-code')?.value"), offer);
|
||||
assert.equal(await evaluate(sender, "document.querySelector('#answer-input').disabled"), false);
|
||||
await input(sender, '#answer-input', answer); await click(sender, 'Connect');
|
||||
await wait(sender, "!!document.querySelector('.fingerprint')");
|
||||
const sf = await evaluate(sender, "[...document.querySelectorAll('.fp-row code')].map(e => e.textContent)");
|
||||
const rf = await evaluate(receiver, "[...document.querySelectorAll('.fp-row code')].map(e => e.textContent)");
|
||||
assert.equal(sf[0], rf[1]); assert.equal(sf[1], rf[0]); assert.equal(sf[0].split(' ').length, 32);
|
||||
assert.equal(await evaluate(receiver, "!!document.querySelector('.incoming')"), false);
|
||||
await click(sender, 'Both fingerprints match — confirm');
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
assert.equal(await evaluate(receiver, "!!document.querySelector('.incoming')"), false);
|
||||
await click(receiver, 'Both fingerprints match — confirm');
|
||||
await wait(receiver, "!!document.querySelector('.incoming')");
|
||||
}
|
||||
try {
|
||||
const sender = await page(), receiver = await page();
|
||||
await click(receiver, 'Receive');
|
||||
assert.equal(await evaluate(sender, "document.querySelector('.checkbox input').checked"), false);
|
||||
await connect(sender, receiver, 2 * 1024 * 1024 + 7);
|
||||
await click(receiver, 'Receive in memory (up to 64 MiB)');
|
||||
await wait(sender, "document.querySelector('[role=status]').textContent.includes('confirmed the complete file')");
|
||||
const data = await evaluate(receiver, `(async () => { const response = await fetch(document.querySelector('a.download').href); const bytes = new Uint8Array(await response.arrayBuffer()); return { length: bytes.length, valid: bytes.every(b => b === 123) }; })()`);
|
||||
assert.deepEqual(data, { length: 2 * 1024 * 1024 + 7, valid: true });
|
||||
console.log('PASS: real two-page WebRTC flow; full fingerprints; no metadata before both confirmations; exact file and receipt.');
|
||||
console.log('PASS: invalid offers can be replaced; invalid answers can be corrected without losing the live offer.');
|
||||
await click(sender, 'Reset'); await click(receiver, 'Reset');
|
||||
assert.equal(await evaluate(sender, "document.querySelector('[role=status]').textContent"), 'Choose a file to start.');
|
||||
assert.equal(await evaluate(receiver, "document.querySelector('[role=status]').textContent"), 'Paste the sender’s connection code to start.');
|
||||
console.log('PASS: Reset restores the ready state on both sides.');
|
||||
await evaluate(receiver, `window.__aborted = false; window.showSaveFilePicker = async () => ({ createWritable: async () => ({ write() { return new Promise(resolve => { window.__releaseWrite = resolve; }); }, async close() {}, async abort() { window.__aborted = true; window.__releaseWrite?.(); } }) });`);
|
||||
await connect(sender, receiver, 2 * 1024 * 1024);
|
||||
await click(receiver, 'Choose destination & receive to disk');
|
||||
await wait(receiver, '!!window.__releaseWrite');
|
||||
await click(sender, 'Receive');
|
||||
await wait(receiver, 'window.__aborted === true');
|
||||
assert.equal(await evaluate(receiver, "!!document.querySelector('a.download')"), false);
|
||||
console.log('PASS: switching away from Send closes the connection and aborts the receiver’s pending disk write.');
|
||||
await click(sender, 'Send'); await click(receiver, 'Reset');
|
||||
await connect(sender, receiver, 2048);
|
||||
await click(receiver, 'Receive in memory (up to 64 MiB)');
|
||||
await wait(sender, "document.querySelector('[role=status]').textContent.includes('confirmed the complete file')");
|
||||
console.log('PASS: fresh code exchange after a failed transfer succeeds without reloading either page.');
|
||||
assert.deepEqual(browserErrors, []);
|
||||
} finally {
|
||||
browser.kill();
|
||||
await new Promise(resolve => { if (browser.exitCode !== null) resolve(); else browser.once('exit', resolve); });
|
||||
await new Promise(resolve => server.close(resolve));
|
||||
await rm(profile, { recursive: true, force: true, maxRetries: 3 });
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
// Exercises the built Vue app in separate Brave and Firefox processes.
|
||||
import { createServer } from 'node:http';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { readFile, mkdtemp, rm } from 'node:fs/promises';
|
||||
import { dirname, extname, join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { tmpdir } from 'node:os';
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const state = {};
|
||||
const profiles = [];
|
||||
const children = [];
|
||||
const provider = process.argv.includes('--default-network') ? 'google' : 'none';
|
||||
const reversed = process.argv.includes('--reverse');
|
||||
const driver = `
|
||||
const role = new URL(location.href).searchParams.get('role');
|
||||
const pause = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
const post = async (key, value) => fetch('/.test/' + key, {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(value)});
|
||||
const get = async key => (await fetch('/.test/' + key)).json();
|
||||
const wait = async fn => { const deadline=Date.now()+36000; while(Date.now()<deadline){ const value = await fn(); if(value) return value; const error=document.querySelector('[role=alert]'); if(error) throw new Error(error.textContent); await pause(20); } throw new Error('Timed out: '+document.querySelector('[role=status]')?.textContent); };
|
||||
const click = text => { const button=[...document.querySelectorAll('button')].find(b=>b.textContent.trim()===text); if(!button || button.disabled)throw new Error('Unavailable: '+text); button.click(); };
|
||||
const input = (selector,value) => { const el=document.querySelector(selector); el.value=value; el.dispatchEvent(new Event(el.tagName==='SELECT'?'change':'input',{bubbles:true})); };
|
||||
const stage = async text => post(role+'Stage', text);
|
||||
const peers=[]; const NativePC=window.RTCPeerConnection;
|
||||
window.RTCPeerConnection = class extends NativePC { constructor(...args){super(...args);peers.push(this);} };
|
||||
setInterval(()=>post(role+'Diagnostic',{status:document.querySelector('[role=status]')?.textContent,error:document.querySelector('[role=alert]')?.textContent,download:!!document.querySelector('a.download')}),2000);
|
||||
try {
|
||||
await wait(()=>document.querySelector('#stun-provider'));
|
||||
if(role==='receiver'){click('Receive');await pause(20);}
|
||||
if(role==='sender'){
|
||||
const files=new DataTransfer();files.items.add(new File([new Uint8Array(2*1024*1024+7).fill(123)],'cross-browser.bin'));
|
||||
const el=document.querySelector('#file-input');el.files=files.files;el.dispatchEvent(new Event('change',{bubbles:true}));await pause(20);
|
||||
}
|
||||
input('#stun-provider',${JSON.stringify(provider)});await pause(20);
|
||||
if(role==='sender'){
|
||||
await stage('creating offer'); click('Create code');await wait(()=>document.querySelector('#output-code'));
|
||||
await post('offer',document.querySelector('#output-code').value);
|
||||
await stage('waiting for answer'); const answer=await wait(()=>get('answer'));input('#answer-input',answer);await pause(20);click('Connect');
|
||||
}else{
|
||||
await stage('waiting for offer'); const offer=await wait(()=>get('offer'));input('#offer-input',offer);await pause(20);
|
||||
await stage('creating answer');click('Accept & create answer');await wait(()=>document.querySelector('#output-code'));
|
||||
await post('answer',document.querySelector('#output-code').value);
|
||||
}
|
||||
await stage('comparing fingerprints');await wait(()=>document.querySelector('.fingerprint'));
|
||||
const fps=[...document.querySelectorAll('.fp-row code')].map(el=>el.textContent);
|
||||
await post(role+'Fingerprints',fps);
|
||||
const other=await wait(()=>get((role==='sender'?'receiver':'sender')+'Fingerprints'));
|
||||
if(fps[0]!==other[1]||fps[1]!==other[0])throw new Error('Fingerprints do not match');
|
||||
click('Both fingerprints match — confirm');
|
||||
if(role==='receiver'){
|
||||
await stage('waiting for metadata');await wait(()=>document.querySelector('.incoming'));click('Receive in memory (up to 64 MiB)');
|
||||
await stage('receiving');await wait(()=>document.querySelector('a.download'));
|
||||
await wait(()=>get('senderResult'));
|
||||
await pause(250);
|
||||
if(!document.querySelector('a.download'))throw new Error('Download was revoked after sender shutdown');
|
||||
await stage('checking downloaded bytes');
|
||||
const bytes=new Uint8Array(await (await fetch(document.querySelector('a.download').href)).arrayBuffer());
|
||||
if(bytes.length!==2*1024*1024+7||!bytes.every(b=>b===123))throw new Error('File content mismatch');
|
||||
}else{
|
||||
await stage('waiting for receipt');await wait(()=>document.querySelector('[role=status]').textContent.includes('confirmed the complete file'));
|
||||
}
|
||||
await post(role+'Result',{ok:true});
|
||||
}catch(error){
|
||||
await post(role+'Result',{ok:false,error:error.message,peers:peers.map(pc=>({connection:pc.connectionState,gathering:pc.iceGatheringState,ice:pc.iceConnectionState,localFingerprints:pc.localDescription?.sdp.match(/^a=fingerprint:.*$/gm),remoteFingerprints:pc.remoteDescription?.sdp.match(/^a=fingerprint:.*$/gm)}))});
|
||||
}
|
||||
`;
|
||||
let finish;
|
||||
const result = new Promise(resolve => { finish = resolve; });
|
||||
const server = createServer(async (req,res) => {
|
||||
try {
|
||||
const pathname=new URL(req.url,'http://localhost').pathname;
|
||||
if(pathname==='/.test/driver.js'){res.setHeader('Content-Type','text/javascript');res.end(driver);return;}
|
||||
if(pathname.startsWith('/.test/')){
|
||||
const key=pathname.slice('/.test/'.length);
|
||||
if(req.method==='POST'){
|
||||
let body='';for await(const part of req){body+=part;if(body.length>262144)throw new Error('Too big');}
|
||||
const previous=state[key];
|
||||
state[key]=JSON.parse(body);
|
||||
if(key.endsWith('Stage'))console.log(key+': '+state[key]);
|
||||
if(key.endsWith('Diagnostic')&&JSON.stringify(previous)!==JSON.stringify(state[key]))console.log(key+': '+JSON.stringify(state[key]));
|
||||
if(key.endsWith('Result')){
|
||||
console.log(key+': '+JSON.stringify(state[key]));
|
||||
if(!state[key].ok||(state.senderResult&&state.receiverResult))finish();
|
||||
}
|
||||
}
|
||||
res.setHeader('Content-Type','application/json');res.end(JSON.stringify(state[key]??null));return;
|
||||
}
|
||||
const base=join(root,'dist');const path=resolve(base,'.'+(pathname==='/'?'/index.html':pathname));
|
||||
if(!path.startsWith(base+'/'))throw new Error('Invalid path');
|
||||
let body=await readFile(path);
|
||||
if(pathname==='/')body=body.toString().replace('</body>','<script type="module" src="/.test/driver.js"></script></body>');
|
||||
res.setHeader('Content-Type',({'.html':'text/html','.js':'text/javascript','.css':'text/css','.png':'image/png'})[extname(path)]||'application/octet-stream');res.end(body);
|
||||
}catch{res.statusCode=404;res.end();}
|
||||
});
|
||||
await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));
|
||||
const origin='http://127.0.0.1:'+server.address().port;
|
||||
let timer;
|
||||
try{
|
||||
for(const name of ['brave','firefox']){
|
||||
const profile=await mkdtemp(join(tmpdir(),'hellcon-'+name+'-'));profiles.push(profile);
|
||||
const role=(name==='brave')!==reversed?'sender':'receiver';
|
||||
const args=name==='brave'?['--headless','--no-sandbox','--disable-gpu','--no-first-run','--no-default-browser-check','--user-data-dir='+profile,origin+'/?role='+role]:['--headless','--no-remote','--profile',profile,origin+'/?role='+role];
|
||||
const child=spawn(process.env[name==='brave'?'BRAVE_PATH':'FIREFOX_PATH']||'/usr/bin/'+name,args,{stdio:['ignore','ignore','pipe']});children.push(child);
|
||||
let errors='';child.stderr.on('data',chunk=>{errors+=chunk;});
|
||||
child.on('error',err=>{console.error(name,err.message);finish();});
|
||||
child.on('exit',code=>{if(code){console.error(name+' exited: '+errors.slice(-1500));finish();}});
|
||||
}
|
||||
timer=setTimeout(()=>{console.error('Cross-browser check timed out.', JSON.stringify({sender:state.senderDiagnostic,receiver:state.receiverDiagnostic}));finish();},provider==='none'?15000:90000);
|
||||
await result;
|
||||
if(!state.senderResult?.ok||!state.receiverResult?.ok)process.exitCode=1;
|
||||
else console.log('PASS: '+(reversed?'Firefox → Brave':'Brave → Firefox')+' full UI transfer, fingerprint verification and exact file contents.');
|
||||
}finally{
|
||||
clearTimeout(timer);
|
||||
for(const child of children)child.kill();
|
||||
await Promise.all(children.map(child=>new Promise(resolve=>{if(child.exitCode!==null||child.signalCode!==null)resolve();else child.once('exit',resolve);})));
|
||||
server.closeAllConnections();await new Promise(resolve=>server.close(resolve));
|
||||
for(const profile of profiles)await rm(profile,{recursive:true,force:true,maxRetries:5,retryDelay:200});
|
||||
}
|
||||
+8
-6
@@ -9,8 +9,8 @@ const mode = ref('send');
|
||||
<template>
|
||||
<h1>HellCon</h1>
|
||||
<p class="subtitle">
|
||||
Peer-to-peer file sharing. No server, no account — files go straight from
|
||||
browser to browser over WebRTC.
|
||||
Browser-to-browser file sharing. No account or file-hosting backend.
|
||||
Direct WebRTC connections, with an optional relay you explicitly enable.
|
||||
</p>
|
||||
|
||||
<div class="tabs" style="width: 100%; max-width: 680px">
|
||||
@@ -23,10 +23,12 @@ const mode = ref('send');
|
||||
|
||||
<footer>
|
||||
<p>
|
||||
All transfers are end-to-end encrypted (WebRTC/DTLS) and never pass
|
||||
through this server — it only delivers this page. Verify the security
|
||||
check codes with your peer to exclude interception. You are responsible
|
||||
for what you send, and for whom you send it to.
|
||||
Files travel over encrypted WebRTC data channels (SCTP over DTLS).
|
||||
Verify both full fingerprints before sharing. This requires trusted
|
||||
browsers, a trusted copy of this app, and an authenticated comparison
|
||||
channel. The website host supplies JavaScript that can read your selected
|
||||
file; HTTPS protects delivery but cannot protect you from a malicious host.
|
||||
A TURN relay is used only after opt-in and carries encrypted traffic.
|
||||
</p>
|
||||
</footer>
|
||||
</template>
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup>
|
||||
import { STUN_PROVIDERS } from '../lib/webrtc.js';
|
||||
const settings = defineModel({ required: true });
|
||||
defineProps({ disabled: Boolean });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<fieldset :disabled="disabled" class="network-settings">
|
||||
<legend>Connection settings</legend>
|
||||
<label for="stun-provider">STUN provider</label>
|
||||
<select id="stun-provider" v-model="settings.stunChoice" class="stun-select">
|
||||
<option v-for="provider in STUN_PROVIDERS" :key="provider.id" :value="provider.id">{{ provider.label }}</option>
|
||||
<option value="custom">Custom…</option>
|
||||
</select>
|
||||
<input v-if="settings.stunChoice === 'custom'" v-model="settings.customStun" class="stun-input" aria-label="Custom STUN address" placeholder="stun:your.domain:3478" />
|
||||
<p class="status">STUN helps discover a reachable address. Its operator sees your public IP and request timing, but does not carry your file. Direct connections may fail on restrictive networks.</p>
|
||||
<label class="checkbox"><input type="checkbox" v-model="settings.allowTurn" /> Allow a TURN relay for this connection (opt-in)</label>
|
||||
<template v-if="settings.allowTurn">
|
||||
<p class="status">Both people must opt in. Your browser may contact this relay and route encrypted file traffic through it. The operator sees addresses, timing and traffic volume, and may charge for bandwidth. Use credentials you are authorized to use; they remain in this tab.</p>
|
||||
<input v-model="settings.turnUrl" class="stun-input" aria-label="TURN address" placeholder="turns:relay.example:5349?transport=tcp" autocomplete="off" />
|
||||
<input v-model="settings.username" class="stun-input" aria-label="TURN username" placeholder="TURN username" autocomplete="off" />
|
||||
<input v-model="settings.credential" class="stun-input" type="password" aria-label="TURN password" placeholder="TURN password" autocomplete="off" />
|
||||
</template>
|
||||
</fieldset>
|
||||
</template>
|
||||
@@ -1,190 +1,4 @@
|
||||
<script setup>
|
||||
import { ref, computed, onBeforeUnmount } from 'vue';
|
||||
import {
|
||||
createPeerConnection,
|
||||
createAnswerCode,
|
||||
getFingerprints,
|
||||
STUN_PROVIDERS,
|
||||
} from '../lib/webrtc';
|
||||
|
||||
const STATUS = {
|
||||
idle: 'Paste the sender\'s connection code to start.',
|
||||
'creating-answer': 'Gathering connection info…',
|
||||
'answer-ready': 'Send the code below back to the sender.',
|
||||
connecting: 'Waiting for the P2P connection…',
|
||||
receiving: 'Receiving…',
|
||||
done: 'File received!',
|
||||
closed: 'Connection closed.',
|
||||
};
|
||||
|
||||
const step = ref('idle');
|
||||
const offerInput = ref('');
|
||||
const answerCode = ref('');
|
||||
const progress = ref(0);
|
||||
const error = ref('');
|
||||
const copied = ref(false);
|
||||
const fps = ref(null);
|
||||
const stunChoice = ref('google');
|
||||
const customStun = ref('');
|
||||
|
||||
const fileName = ref('');
|
||||
const fileSize = ref(0);
|
||||
const downloadUrl = ref('');
|
||||
|
||||
let pc = null;
|
||||
|
||||
const statusText = computed(() => STATUS[step.value] ?? '');
|
||||
const resolvedStun = computed(() => {
|
||||
if (stunChoice.value === 'custom') {
|
||||
const raw = customStun.value.trim();
|
||||
return raw ? raw : null;
|
||||
}
|
||||
return STUN_PROVIDERS.find((p) => p.id === stunChoice.value)?.url ?? null;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
pc?.close();
|
||||
if (downloadUrl.value) URL.revokeObjectURL(downloadUrl.value);
|
||||
});
|
||||
|
||||
async function acceptOffer() {
|
||||
error.value = '';
|
||||
if (downloadUrl.value) {
|
||||
URL.revokeObjectURL(downloadUrl.value);
|
||||
downloadUrl.value = '';
|
||||
}
|
||||
progress.value = 0;
|
||||
fps.value = null;
|
||||
|
||||
pc?.close();
|
||||
pc = createPeerConnection(resolvedStun.value);
|
||||
pc.ondatachannel = (e) => setupReceiver(e.channel);
|
||||
pc.onconnectionstatechange = () => {
|
||||
if (['disconnected', 'failed', 'closed'].includes(pc.connectionState)) {
|
||||
if (step.value !== 'done') step.value = 'closed';
|
||||
}
|
||||
};
|
||||
|
||||
step.value = 'creating-answer';
|
||||
try {
|
||||
answerCode.value = await createAnswerCode(pc, offerInput.value);
|
||||
fps.value = getFingerprints(pc);
|
||||
step.value = 'answer-ready';
|
||||
} catch {
|
||||
step.value = 'idle';
|
||||
error.value = 'Invalid offer code — paste the full code from the sender.';
|
||||
}
|
||||
}
|
||||
|
||||
function setupReceiver(dc) {
|
||||
dc.binaryType = 'arraybuffer';
|
||||
let meta = null;
|
||||
let chunks = [];
|
||||
let received = 0;
|
||||
|
||||
dc.onopen = () => {
|
||||
if (step.value === 'answer-ready') step.value = 'connecting';
|
||||
};
|
||||
|
||||
dc.onmessage = (e) => {
|
||||
if (typeof e.data === 'string') {
|
||||
// Metadata frame
|
||||
meta = JSON.parse(e.data);
|
||||
fileName.value = meta.name;
|
||||
fileSize.value = meta.size;
|
||||
received = 0;
|
||||
if (meta.size === 0) finish(meta, []);
|
||||
else step.value = 'receiving';
|
||||
return;
|
||||
}
|
||||
chunks.push(e.data);
|
||||
received += e.data.byteLength;
|
||||
if (meta) {
|
||||
progress.value = Math.min(100, Math.floor((received / meta.size) * 100));
|
||||
if (received >= meta.size) finish(meta, chunks);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function finish(meta, chunks) {
|
||||
if (downloadUrl.value) URL.revokeObjectURL(downloadUrl.value);
|
||||
const blob = new Blob(chunks, { type: meta.type || 'application/octet-stream' });
|
||||
downloadUrl.value = URL.createObjectURL(blob);
|
||||
progress.value = 100;
|
||||
step.value = 'done';
|
||||
}
|
||||
|
||||
async function copy(text) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
copied.value = true;
|
||||
setTimeout(() => (copied.value = false), 1500);
|
||||
}
|
||||
import TransferPanel from './TransferPanel.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="panel">
|
||||
<label class="step">1 — Choose a STUN provider</label>
|
||||
<select v-model="stunChoice" class="stun-select">
|
||||
<option v-for="p in STUN_PROVIDERS" :key="p.id" :value="p.id">
|
||||
{{ p.label }}
|
||||
</option>
|
||||
<option value="custom">Custom…</option>
|
||||
</select>
|
||||
<input
|
||||
v-if="stunChoice === 'custom'"
|
||||
v-model="customStun"
|
||||
class="stun-input"
|
||||
type="text"
|
||||
placeholder="stun:your.domain:3478"
|
||||
/>
|
||||
<p class="status stun-hint">
|
||||
STUN is only needed for peers on different networks — a stateless UDP
|
||||
lookup of your public IP; it never sees the connection or the file.
|
||||
Same-network or VPN peers work with "None".
|
||||
</p>
|
||||
|
||||
<label class="step">2 — Paste the sender's connection code</label>
|
||||
<textarea
|
||||
v-model="offerInput"
|
||||
placeholder="Paste the code from the sender…"
|
||||
/>
|
||||
<button class="primary" :disabled="!offerInput.trim()" @click="acceptOffer">
|
||||
Accept & create answer
|
||||
</button>
|
||||
|
||||
<template v-if="answerCode">
|
||||
<label class="step">3 — Send this answer code back to the sender</label>
|
||||
<textarea :value="answerCode" readonly @focus="$event.target.select()" />
|
||||
<button @click="copy(answerCode)">{{ copied ? 'Copied!' : 'Copy code' }}</button>
|
||||
</template>
|
||||
|
||||
<div class="progress" v-if="step === 'receiving' || step === 'done'">
|
||||
<div :style="{ width: progress + '%' }"></div>
|
||||
</div>
|
||||
|
||||
<div v-if="fps" class="fingerprint">
|
||||
<label class="step">Security check</label>
|
||||
<div class="fp-row">
|
||||
<span>Your code</span>
|
||||
<code>{{ fps.local }}</code>
|
||||
</div>
|
||||
<div class="fp-row">
|
||||
<span>Their code</span>
|
||||
<code>{{ fps.remote }}</code>
|
||||
</div>
|
||||
<p class="status">
|
||||
To rule out an intercepted exchange, compare with your peer over a
|
||||
channel you trust: your "Your code" must equal their "Their code",
|
||||
and vice versa.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p class="status">{{ statusText }}</p>
|
||||
<p class="error" v-if="error">{{ error }}</p>
|
||||
|
||||
<div v-if="downloadUrl" class="file-chip">
|
||||
<span>{{ fileName }}</span>
|
||||
<a class="download" :href="downloadUrl" :download="fileName">Save file</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template><TransferPanel /></template>
|
||||
@@ -1,248 +1,4 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import {
|
||||
createPeerConnection,
|
||||
createOfferCode,
|
||||
acceptAnswerCode,
|
||||
getFingerprints,
|
||||
STUN_PROVIDERS,
|
||||
CHUNK_SIZE,
|
||||
MAX_BUFFERED,
|
||||
waitForBufferDrain,
|
||||
} from '../lib/webrtc';
|
||||
|
||||
const STATUS = {
|
||||
idle: 'Pick a file to start.',
|
||||
'creating-offer': 'Gathering connection info…',
|
||||
'offer-ready': 'Send the code below to the receiver (any chat works).',
|
||||
connecting: 'Answer accepted — waiting for the P2P connection…',
|
||||
sending: 'Transferring…',
|
||||
done: 'Transfer complete!',
|
||||
closed: 'Connection closed.',
|
||||
};
|
||||
|
||||
const file = ref(null);
|
||||
const step = ref('idle');
|
||||
const offerCode = ref('');
|
||||
const answerInput = ref('');
|
||||
const progress = ref(0);
|
||||
const error = ref('');
|
||||
const copied = ref(false);
|
||||
const dragover = ref(false);
|
||||
const fps = ref(null);
|
||||
const stunChoice = ref('google');
|
||||
const customStun = ref('');
|
||||
|
||||
let pc = null;
|
||||
let dc = null;
|
||||
|
||||
const statusText = computed(() => STATUS[step.value] ?? '');
|
||||
const resolvedStun = computed(() => {
|
||||
if (stunChoice.value === 'custom') {
|
||||
const raw = customStun.value.trim();
|
||||
return raw ? raw : null;
|
||||
}
|
||||
return STUN_PROVIDERS.find((p) => p.id === stunChoice.value)?.url ?? null;
|
||||
});
|
||||
|
||||
function reset() {
|
||||
pc?.close();
|
||||
pc = null;
|
||||
dc = null;
|
||||
offerCode.value = '';
|
||||
answerInput.value = '';
|
||||
progress.value = 0;
|
||||
error.value = '';
|
||||
copied.value = false;
|
||||
fps.value = null;
|
||||
step.value = 'idle';
|
||||
}
|
||||
|
||||
function pickFiles(e) {
|
||||
const f = e.target?.files?.[0] ?? e.dataTransfer?.files?.[0];
|
||||
if (f) {
|
||||
reset();
|
||||
file.value = f;
|
||||
}
|
||||
}
|
||||
|
||||
async function makeOffer() {
|
||||
if (!file.value) return;
|
||||
error.value = '';
|
||||
step.value = 'creating-offer';
|
||||
|
||||
pc = createPeerConnection(resolvedStun.value);
|
||||
pc.onconnectionstatechange = () => {
|
||||
if (pc && ['disconnected', 'failed', 'closed'].includes(pc.connectionState)) {
|
||||
step.value = 'closed';
|
||||
}
|
||||
};
|
||||
dc = pc.createDataChannel('file');
|
||||
dc.binaryType = 'arraybuffer';
|
||||
dc.onopen = () => sendFile();
|
||||
dc.onclose = () => {
|
||||
if (step.value === 'sending' && progress.value < 100) step.value = 'closed';
|
||||
};
|
||||
|
||||
try {
|
||||
offerCode.value = await createOfferCode(pc);
|
||||
step.value = 'offer-ready';
|
||||
} catch (err) {
|
||||
error.value = String(err);
|
||||
step.value = 'idle';
|
||||
}
|
||||
}
|
||||
|
||||
async function useAnswer() {
|
||||
if (!pc) return;
|
||||
error.value = '';
|
||||
try {
|
||||
await acceptAnswerCode(pc, answerInput.value);
|
||||
fps.value = getFingerprints(pc);
|
||||
step.value = 'connecting';
|
||||
} catch {
|
||||
error.value = 'Invalid answer code — paste the full code from the receiver.';
|
||||
}
|
||||
}
|
||||
|
||||
async function sendFile() {
|
||||
const f = file.value;
|
||||
if (!dc || !f) return;
|
||||
step.value = 'sending';
|
||||
progress.value = 0;
|
||||
|
||||
// First frame: metadata as JSON. Everything after is raw bytes.
|
||||
dc.send(JSON.stringify({ name: f.name, size: f.size, type: f.type }));
|
||||
|
||||
let sent = 0;
|
||||
try {
|
||||
for (let offset = 0; offset < f.size; offset += CHUNK_SIZE) {
|
||||
if (dc.readyState !== 'open') break;
|
||||
if (dc.bufferedAmount > MAX_BUFFERED) await waitForBufferDrain(dc);
|
||||
const buf = await f.slice(offset, offset + CHUNK_SIZE).arrayBuffer();
|
||||
dc.send(buf);
|
||||
sent += buf.byteLength;
|
||||
progress.value = Math.floor((sent / Math.max(f.size, 1)) * 100);
|
||||
}
|
||||
if (dc.readyState === 'open') {
|
||||
progress.value = 100;
|
||||
step.value = 'done';
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = String(err);
|
||||
step.value = 'closed';
|
||||
}
|
||||
}
|
||||
|
||||
async function copy(text) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
copied.value = true;
|
||||
setTimeout(() => (copied.value = false), 1500);
|
||||
}
|
||||
|
||||
function formatBytes(n) {
|
||||
if (n < 1024) return n + ' B';
|
||||
const u = ['KiB', 'MiB', 'GiB'];
|
||||
let v = n;
|
||||
let i = -1;
|
||||
do {
|
||||
v /= 1024;
|
||||
i++;
|
||||
} while (v >= 1024 && i < u.length - 1);
|
||||
return v.toFixed(1) + ' ' + u[i];
|
||||
}
|
||||
import TransferPanel from './TransferPanel.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="panel">
|
||||
<label class="step">1 — Choose a file</label>
|
||||
|
||||
<div
|
||||
class="dropzone"
|
||||
:class="{ dragover }"
|
||||
@dragover.prevent="dragover = true"
|
||||
@dragleave="dragover = false"
|
||||
@drop.prevent="dragover = false; pickFiles($event)"
|
||||
@click="$refs.input.click()"
|
||||
>
|
||||
<span v-if="!file">Drop a file here or click to browse</span>
|
||||
<div v-else class="file-chip" @click.stop>
|
||||
<span>{{ file.name }}</span>
|
||||
<span class="status">{{ formatBytes(file.size) }}</span>
|
||||
</div>
|
||||
<input
|
||||
ref="input"
|
||||
type="file"
|
||||
style="display: none"
|
||||
@change="pickFiles"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template v-if="file">
|
||||
<label class="step">2 — Choose a STUN provider</label>
|
||||
<select v-model="stunChoice" class="stun-select">
|
||||
<option v-for="p in STUN_PROVIDERS" :key="p.id" :value="p.id">
|
||||
{{ p.label }}
|
||||
</option>
|
||||
<option value="custom">Custom…</option>
|
||||
</select>
|
||||
<input
|
||||
v-if="stunChoice === 'custom'"
|
||||
v-model="customStun"
|
||||
class="stun-input"
|
||||
type="text"
|
||||
placeholder="stun:your.domain:3478"
|
||||
/>
|
||||
<p class="status stun-hint">
|
||||
STUN is only needed for peers on different networks — a stateless UDP
|
||||
lookup of your public IP; it never sees the connection or the file.
|
||||
Same-network or VPN peers work with "None".
|
||||
</p>
|
||||
|
||||
<label class="step">3 — Create your connection code</label>
|
||||
<button class="primary" :disabled="step !== 'idle'" @click="makeOffer">
|
||||
Create code
|
||||
</button>
|
||||
|
||||
<template v-if="offerCode">
|
||||
<textarea :value="offerCode" readonly @focus="$event.target.select()" />
|
||||
<button @click="copy(offerCode)">{{ copied ? 'Copied!' : 'Copy code' }}</button>
|
||||
</template>
|
||||
|
||||
<template v-if="offerCode">
|
||||
<label class="step">4 — Paste the receiver's answer code</label>
|
||||
<textarea
|
||||
v-model="answerInput"
|
||||
placeholder="Paste the code the receiver sends back…"
|
||||
/>
|
||||
<button class="primary" :disabled="!answerInput.trim()" @click="useAnswer">
|
||||
Connect
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<div class="progress" v-if="step === 'sending' || step === 'done'">
|
||||
<div :style="{ width: progress + '%' }"></div>
|
||||
</div>
|
||||
|
||||
<div v-if="fps" class="fingerprint">
|
||||
<label class="step">Security check</label>
|
||||
<div class="fp-row">
|
||||
<span>Your code</span>
|
||||
<code>{{ fps.local }}</code>
|
||||
</div>
|
||||
<div class="fp-row">
|
||||
<span>Their code</span>
|
||||
<code>{{ fps.remote }}</code>
|
||||
</div>
|
||||
<p class="status">
|
||||
To rule out an intercepted exchange, compare with your peer over a
|
||||
channel you trust: your "Your code" must equal their "Their code",
|
||||
and vice versa.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p class="status">{{ statusText }}</p>
|
||||
<p class="error" v-if="error">{{ error }}</p>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template><TransferPanel sending /></template>
|
||||
@@ -0,0 +1,259 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||
import NetworkSettings from './NetworkSettings.vue';
|
||||
import { acceptAnswerCode, createAnswerCode, createOfferCode, createPeerConnection, getFingerprints, MAX_SIGNAL_LENGTH, STUN_PROVIDERS } from '../lib/webrtc.js';
|
||||
import { FILE_LIMIT, MEMORY_LIMIT, Transfer, validateMetadata } from '../lib/transfer.js';
|
||||
|
||||
const props = defineProps({ sending: Boolean });
|
||||
const file = ref(null);
|
||||
const inputCode = ref('');
|
||||
const outputCode = ref('');
|
||||
const step = ref('idle');
|
||||
const error = ref('');
|
||||
const copied = ref(false);
|
||||
const fps = ref(null);
|
||||
const verified = ref(false);
|
||||
const progress = ref(0);
|
||||
const incoming = ref(null);
|
||||
const downloadUrl = ref('');
|
||||
const choosing = ref(false);
|
||||
const dragover = ref(false);
|
||||
const settings = ref({ stunChoice: 'google', customStun: '', allowTurn: false, turnUrl: '', username: '', credential: '' });
|
||||
const canSaveToDisk = typeof window.showSaveFilePicker === 'function';
|
||||
let active = null;
|
||||
let copyTimer;
|
||||
const busy = computed(() => !['idle', 'closed', 'done'].includes(step.value));
|
||||
const status = computed(() => ({
|
||||
idle: props.sending ? 'Choose a file to start.' : 'Paste the sender’s connection code to start.',
|
||||
gathering: 'Gathering connection info (up to 30 seconds)…',
|
||||
'offer-ready': 'Send your code through an authenticated channel, then paste the answer.',
|
||||
'answer-ready': 'Send your answer back, then compare both full fingerprints.',
|
||||
verification: verified.value ? 'Waiting for the connection and your peer’s verification…' : 'Compare both full fingerprints before confirming.',
|
||||
'waiting-accept': 'Waiting for the receiver to accept the file…',
|
||||
'choose-storage': 'Choose how to receive this file.',
|
||||
sending: 'Sending…', receiving: 'Receiving…', saving: 'Saving file…',
|
||||
'awaiting-receipt': 'Waiting for the receiver to confirm the complete file…',
|
||||
done: props.sending ? 'The receiver confirmed the complete file.' : (downloadUrl.value ? 'File received. Save it below.' : 'File saved to disk.'),
|
||||
closed: props.sending
|
||||
? 'Create a new code, then ask the receiver for a new answer. Previous codes cannot reopen a closed connection.'
|
||||
: 'Ask the sender for a new code and paste it above. Previous codes cannot reopen a closed connection.',
|
||||
}[step.value] || ''));
|
||||
|
||||
function revokeDownload() {
|
||||
if (downloadUrl.value) URL.revokeObjectURL(downloadUrl.value);
|
||||
downloadUrl.value = '';
|
||||
}
|
||||
function dispose() {
|
||||
const old = active;
|
||||
active = null;
|
||||
if (!old) return;
|
||||
clearTimeout(old.timer);
|
||||
old.controller.abort();
|
||||
old.transfer?.close();
|
||||
old.pc.ondatachannel = old.pc.onconnectionstatechange = null;
|
||||
old.pc.close();
|
||||
}
|
||||
function reset(keepNetwork = false) {
|
||||
dispose(); revokeDownload(); clearTimeout(copyTimer);
|
||||
if (!keepNetwork) settings.value.allowTurn = false;
|
||||
inputCode.value = outputCode.value = error.value = '';
|
||||
fps.value = incoming.value = null;
|
||||
verified.value = copied.value = choosing.value = false;
|
||||
progress.value = 0; step.value = 'idle';
|
||||
}
|
||||
function fail(session, err) {
|
||||
if (active !== session) return;
|
||||
dispose(); revokeDownload();
|
||||
fps.value = incoming.value = null;
|
||||
outputCode.value = ''; verified.value = false;
|
||||
settings.value.allowTurn = false;
|
||||
error.value = err.message || 'Connection failed.'; step.value = 'closed';
|
||||
}
|
||||
function pickFiles(event) {
|
||||
const selected = event.target?.files?.[0] ?? event.dataTransfer?.files?.[0];
|
||||
if (!selected) return;
|
||||
reset();
|
||||
if (selected.size > FILE_LIMIT) { file.value = null; error.value = 'The maximum file size is 64 GiB.'; return; }
|
||||
file.value = selected;
|
||||
}
|
||||
function attach(session, channel) {
|
||||
if (active !== session) { channel.close(); return; }
|
||||
if (session.transfer || channel.label !== 'hellcon-v2' || !channel.ordered || channel.maxRetransmits !== null || channel.maxPacketLifeTime !== null) {
|
||||
channel.close(); fail(session, new Error('Unexpected data channel.')); return;
|
||||
}
|
||||
session.transfer = new Transfer(channel, {
|
||||
file: props.sending ? session.file : null,
|
||||
onState: state => { if (active === session) step.value = state; },
|
||||
onMeta: meta => { if (active === session) incoming.value = meta; },
|
||||
onProgress: (bytes, size) => { if (active === session) progress.value = Math.min(99, Math.floor(bytes / Math.max(size, 1) * 100)); },
|
||||
onComplete: ({ blob }) => {
|
||||
if (active !== session) return;
|
||||
progress.value = 100;
|
||||
settings.value.allowTurn = false;
|
||||
if (blob) downloadUrl.value = URL.createObjectURL(blob);
|
||||
// The receiver leaves the channel open until its completion ACK reaches the sender.
|
||||
if (props.sending) dispose();
|
||||
else {
|
||||
clearTimeout(session.timer);
|
||||
session.timer = setTimeout(() => { if (active === session) dispose(); }, 10000);
|
||||
}
|
||||
},
|
||||
onError: err => fail(session, err),
|
||||
});
|
||||
if (verified.value) session.transfer.verify();
|
||||
}
|
||||
function start() {
|
||||
const chosen = settings.value;
|
||||
const options = {
|
||||
...chosen,
|
||||
stunUrl: chosen.stunChoice === 'custom' ? chosen.customStun.trim() || null : STUN_PROVIDERS.find(p => p.id === chosen.stunChoice)?.url ?? null,
|
||||
turnUrl: chosen.turnUrl.trim(),
|
||||
};
|
||||
const pc = createPeerConnection(options);
|
||||
const session = { pc, options, file: file.value, controller: new AbortController(), transfer: null };
|
||||
active = session;
|
||||
session.timer = setTimeout(() => fail(session, new Error('Connection timed out. Start again with new codes.')), 5 * 60 * 1000);
|
||||
pc.ondatachannel = event => attach(session, event.channel);
|
||||
pc.onconnectionstatechange = () => {
|
||||
if (active !== session) return;
|
||||
if (['failed', 'closed'].includes(pc.connectionState)) {
|
||||
if (step.value === 'done') dispose();
|
||||
else fail(session, new Error('Connection failed. Direct connections may be blocked; TURN is available only if both people opt in.'));
|
||||
}
|
||||
};
|
||||
return session;
|
||||
}
|
||||
async function createCode() {
|
||||
const pasted = inputCode.value;
|
||||
reset(true); inputCode.value = props.sending ? '' : pasted; step.value = 'gathering';
|
||||
let session;
|
||||
try {
|
||||
if (props.sending) {
|
||||
if (!file.value) throw new Error('Choose a file first.');
|
||||
validateMetadata({ name: file.value.name, size: file.value.size, mime: file.value.type || '' });
|
||||
}
|
||||
session = start();
|
||||
const options = { ...session.options, signal: session.controller.signal };
|
||||
if (props.sending) attach(session, session.pc.createDataChannel('hellcon-v2'));
|
||||
const code = props.sending ? await createOfferCode(session.pc, options) : await createAnswerCode(session.pc, pasted, options);
|
||||
if (active !== session) return;
|
||||
outputCode.value = code;
|
||||
if (!props.sending) fps.value = getFingerprints(session.pc, options);
|
||||
step.value = props.sending ? 'offer-ready' : 'answer-ready';
|
||||
} catch (err) {
|
||||
if (session) fail(session, err);
|
||||
else { settings.value.allowTurn = false; error.value = err.message; step.value = 'closed'; }
|
||||
}
|
||||
}
|
||||
async function useAnswer() {
|
||||
const session = active;
|
||||
if (!session || step.value !== 'offer-ready') return;
|
||||
error.value = '';
|
||||
step.value = 'verification';
|
||||
try {
|
||||
await acceptAnswerCode(session.pc, inputCode.value, session.options);
|
||||
if (active !== session) return;
|
||||
fps.value = getFingerprints(session.pc, session.options);
|
||||
} catch (err) {
|
||||
if (active !== session) return;
|
||||
// A rejected answer does not consume a valid local offer. Let the user
|
||||
// correct a paste error instead of silently invalidating both peers' codes.
|
||||
if (session.pc.signalingState === 'have-local-offer') {
|
||||
error.value = `${err.message || 'Invalid answer.'} Correct the answer and connect again; your offer is still valid.`;
|
||||
step.value = 'offer-ready';
|
||||
} else fail(session, err);
|
||||
}
|
||||
}
|
||||
function verify() {
|
||||
if (!active || !fps.value || verified.value) return;
|
||||
verified.value = true; step.value = 'verification';
|
||||
// Gathering/handshake timeout ends; Transfer manages verification and transfer deadlines.
|
||||
const session = active;
|
||||
clearTimeout(session.timer);
|
||||
session.timer = setTimeout(() => { if (active === session && !session.transfer) fail(session, new Error('Connection timed out.')); }, 60000);
|
||||
session.transfer?.verify();
|
||||
}
|
||||
async function acceptFile(toDisk) {
|
||||
const session = active;
|
||||
if (!session?.transfer || choosing.value || step.value !== 'choose-storage') return;
|
||||
choosing.value = true; error.value = '';
|
||||
let writable;
|
||||
try {
|
||||
if (toDisk) {
|
||||
const handle = await window.showSaveFilePicker({ suggestedName: incoming.value.name });
|
||||
if (active !== session) return;
|
||||
writable = await handle.createWritable();
|
||||
if (active !== session) { await writable.abort(); return; }
|
||||
}
|
||||
session.transfer.accept(writable);
|
||||
} catch (err) {
|
||||
if (writable) await writable.abort().catch(() => {});
|
||||
if (active === session && err.name !== 'AbortError') error.value = err.message || 'Could not open the destination file.';
|
||||
} finally { if (active === session) choosing.value = false; }
|
||||
}
|
||||
async function copy() {
|
||||
const session = active;
|
||||
try {
|
||||
await navigator.clipboard.writeText(outputCode.value);
|
||||
if (active !== session) return;
|
||||
copied.value = true; clearTimeout(copyTimer);
|
||||
copyTimer = setTimeout(() => { copied.value = false; }, 1500);
|
||||
} catch { if (active === session) error.value = 'Clipboard unavailable. Select and copy the code manually.'; }
|
||||
}
|
||||
function formatBytes(bytes) {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
const index = Math.min(3, Math.floor(Math.log(bytes) / Math.log(1024)));
|
||||
return `${(bytes / 1024 ** index).toFixed(1)} ${['B', 'KiB', 'MiB', 'GiB'][index]}`;
|
||||
}
|
||||
onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="panel">
|
||||
<template v-if="sending">
|
||||
<label class="step" for="file-input">Choose one file (up to 64 GiB)</label>
|
||||
<div class="dropzone" :class="{ dragover }" @dragover.prevent="dragover = true" @dragleave="dragover = false" @drop.prevent="dragover = false; pickFiles($event)">
|
||||
<p>Drop a file here or choose one below. Choosing a new file cancels the current connection.</p>
|
||||
<input id="file-input" type="file" @change="pickFiles" />
|
||||
</div>
|
||||
<p v-if="file" class="file-chip"><span>{{ file.name }}</span><span>{{ formatBytes(file.size) }}</span></p>
|
||||
</template>
|
||||
<NetworkSettings v-model="settings" :disabled="busy" />
|
||||
<p class="status">Connection codes are not encrypted: they can reveal your IP address and connection details to anyone who sees them. Exchange them privately with your intended peer.</p>
|
||||
<template v-if="!sending">
|
||||
<label class="step" for="offer-input">Paste the sender’s connection code</label>
|
||||
<textarea id="offer-input" v-model="inputCode" :maxlength="MAX_SIGNAL_LENGTH" :disabled="busy" />
|
||||
</template>
|
||||
<button class="primary" :disabled="busy || (sending ? !file : !inputCode.trim())" @click="createCode">{{ sending ? 'Create code' : 'Accept & create answer' }}</button>
|
||||
<template v-if="outputCode">
|
||||
<label class="step" for="output-code">{{ sending ? 'Send this code to the receiver' : 'Send this answer to the sender' }}</label>
|
||||
<textarea id="output-code" :value="outputCode" readonly @focus="$event.target.select()" />
|
||||
<button @click="copy">{{ copied ? 'Copied!' : 'Copy code' }}</button>
|
||||
</template>
|
||||
<template v-if="sending && outputCode">
|
||||
<label class="step" for="answer-input">Paste the receiver’s answer</label>
|
||||
<textarea id="answer-input" v-model="inputCode" :maxlength="MAX_SIGNAL_LENGTH" :disabled="step !== 'offer-ready'" />
|
||||
<button class="primary" :disabled="step !== 'offer-ready' || !inputCode.trim()" @click="useAnswer">Connect</button>
|
||||
</template>
|
||||
<div v-if="fps" class="fingerprint">
|
||||
<label class="step">Verify both full SHA-256 fingerprints</label>
|
||||
<div class="fp-row"><span>Your fingerprint</span><code>{{ fps.local }}</code></div>
|
||||
<div class="fp-row"><span>Their fingerprint</span><code>{{ fps.remote }}</code></div>
|
||||
<p class="status">Compare every byte over an authenticated channel an attacker cannot alter (for example, an in-person comparison). Your fingerprint must match their “Their fingerprint”, and vice versa. If either differs, cancel. Both people must confirm before the filename or contents are sent.</p>
|
||||
<button class="primary" :disabled="verified || step === 'done'" @click="verify">{{ verified ? 'Fingerprints confirmed' : 'Both fingerprints match — confirm' }}</button>
|
||||
</div>
|
||||
<div v-if="incoming && step === 'choose-storage'" class="incoming">
|
||||
<p>{{ incoming.name }} — {{ formatBytes(incoming.size) }}</p>
|
||||
<p class="status">Only accept files you expect. Encryption does not make their contents safe to open.</p>
|
||||
<button v-if="canSaveToDisk" class="primary" :disabled="choosing" @click="acceptFile(true)">Choose destination & receive to disk</button>
|
||||
<button :disabled="choosing || incoming.size > MEMORY_LIMIT" @click="acceptFile(false)">Receive in memory (up to 64 MiB)</button>
|
||||
<p v-if="incoming.size > MEMORY_LIMIT && !canSaveToDisk" class="error">This browser cannot save directly to disk. Use a browser with file-system saving support or send a smaller file.</p>
|
||||
</div>
|
||||
<div v-if="progress > 0 || step === 'done'" class="progress" role="progressbar" :aria-valuenow="progress" aria-valuemin="0" aria-valuemax="100" aria-label="Transfer progress"><div :style="{ width: progress + '%' }"></div></div>
|
||||
<p class="status" role="status">{{ status }}</p>
|
||||
<p v-if="error" class="error" role="alert">{{ error }}</p>
|
||||
<div v-if="downloadUrl" class="file-chip"><span>{{ incoming.name }}</span><a class="download" :href="downloadUrl" :download="incoming.name">Save file</a></div>
|
||||
<button v-if="step !== 'idle'" @click="reset()">{{ busy ? 'Cancel connection' : 'Reset' }}</button>
|
||||
<p class="status">Switching tabs cancels an active transfer. Keep this tab open until receipt is confirmed.</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,168 @@
|
||||
import { CHUNK_SIZE, MAX_BUFFERED, waitForBufferDrain } from './webrtc.js';
|
||||
|
||||
export const MEMORY_LIMIT = 64 * 1024 * 1024;
|
||||
export const FILE_LIMIT = 64 * 1024 * 1024 * 1024;
|
||||
const CONTROL_LIMIT = 2048;
|
||||
const WINDOW = MAX_BUFFERED;
|
||||
|
||||
export function validateMetadata(meta) {
|
||||
if (!meta || typeof meta.name !== 'string' || !meta.name.length || meta.name.length > 255 ||
|
||||
/[\x00-\x1f\x7f/\\\u202a-\u202e\u2066-\u2069]/.test(meta.name) ||
|
||||
!Number.isSafeInteger(meta.size) || meta.size < 0 || meta.size > FILE_LIMIT ||
|
||||
typeof meta.mime !== 'string' || meta.mime.length > 128 || /[^\x20-\x7e]/.test(meta.mime)) {
|
||||
throw new Error('Invalid file metadata or file exceeds the 64 GiB limit.');
|
||||
}
|
||||
return { name: meta.name, size: meta.size, mime: meta.mime };
|
||||
}
|
||||
|
||||
// One ordered, reliable channel; bounded receive queue and acknowledged send window.
|
||||
export class Transfer {
|
||||
constructor(dc, { file = null, onState = () => {}, onMeta = () => {}, onProgress = () => {}, onComplete = () => {}, onError = () => {}, timeout = 60000 } = {}) {
|
||||
Object.assign(this, { dc, file, onState, onMeta, onProgress, onComplete, onError, timeout });
|
||||
this.state = 'verification';
|
||||
this.verified = false;
|
||||
this.peerReady = false;
|
||||
this.readySent = false;
|
||||
this.closed = false;
|
||||
this.received = this.sent = this.acked = this.queued = this.messages = 0;
|
||||
this.chunks = [];
|
||||
this.queue = Promise.resolve();
|
||||
this.controller = new AbortController();
|
||||
dc.binaryType = 'arraybuffer';
|
||||
dc.onopen = () => this.guard(() => this.ready());
|
||||
dc.onmessage = e => this.enqueue(e.data);
|
||||
const transportEnded = message => {
|
||||
// Firefox can report an SCTP error when the sender closes its peer
|
||||
// connection after receiving our completion ACK. The saved file remains
|
||||
// valid; a transport shutdown must not revoke a completed download.
|
||||
if (this.state === 'done') this.close();
|
||||
else this.fail(new Error(message));
|
||||
};
|
||||
dc.onclose = () => transportEnded('Connection closed before receipt was confirmed.');
|
||||
dc.onerror = () => transportEnded('Data channel failed.');
|
||||
this.touch(5 * 60 * 1000);
|
||||
}
|
||||
setState(state) { this.state = state; this.onState(state); }
|
||||
touch(ms = this.timeout) {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = setTimeout(() => this.fail(new Error('Transfer timed out. Start a new connection.')), ms);
|
||||
}
|
||||
guard(fn) { try { fn(); } catch (err) { this.fail(err); } }
|
||||
control(type, data = {}) {
|
||||
if (this.closed || this.dc.readyState !== 'open') throw new Error('Connection is not open.');
|
||||
const text = JSON.stringify({ v: 2, type, ...data });
|
||||
if (text.length > CONTROL_LIMIT) throw new Error('Control message is too large.');
|
||||
this.dc.send(text);
|
||||
}
|
||||
verify() {
|
||||
if (this.closed || this.verified) return;
|
||||
this.verified = true;
|
||||
this.guard(() => this.ready());
|
||||
}
|
||||
ready() {
|
||||
if (!this.verified || this.dc.readyState !== 'open' || this.closed) return;
|
||||
if (!this.readySent) { this.control('ready'); this.readySent = true; }
|
||||
if (this.file && this.peerReady && this.state === 'verification') {
|
||||
this.meta = validateMetadata({ name: this.file.name, size: this.file.size, mime: this.file.type || '' });
|
||||
this.setState('waiting-accept');
|
||||
this.control('meta', this.meta);
|
||||
this.touch(5 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
enqueue(data) {
|
||||
if (this.closed) return;
|
||||
const binary = data instanceof ArrayBuffer;
|
||||
const size = binary ? data.byteLength : typeof data === 'string' ? data.length : Infinity;
|
||||
if (size > (binary ? CHUNK_SIZE : CONTROL_LIMIT) || this.queued + size > WINDOW * 2 || this.messages >= 128) {
|
||||
this.fail(new Error('Peer exceeded message or buffering limits.')); return;
|
||||
}
|
||||
this.queued += size; this.messages++;
|
||||
this.queue = this.queue.then(async () => {
|
||||
if (!this.closed) await this.message(data);
|
||||
}).catch(err => this.fail(err)).finally(() => { this.queued -= size; this.messages--; });
|
||||
}
|
||||
async message(data) {
|
||||
if (data instanceof ArrayBuffer) {
|
||||
if (this.file || this.state !== 'receiving' || !data.byteLength || this.received + data.byteLength > this.meta.size) throw new Error('Unexpected or excess file data.');
|
||||
// Bound per-chunk overhead as well as payload bytes: millions of tiny
|
||||
// ArrayBuffers would otherwise defeat the in-memory size limit.
|
||||
if (data.byteLength !== Math.min(CHUNK_SIZE, this.meta.size - this.received)) throw new Error('Invalid file chunk size.');
|
||||
if (this.writable) await this.writable.write(data);
|
||||
else this.chunks.push(data);
|
||||
if (this.closed) return;
|
||||
this.received += data.byteLength;
|
||||
this.control('ack', { bytes: this.received });
|
||||
this.onProgress(this.received, this.meta.size);
|
||||
this.touch();
|
||||
return;
|
||||
}
|
||||
const msg = JSON.parse(data);
|
||||
if (!msg || msg.v !== 2 || typeof msg.type !== 'string') throw new Error('Unsupported transfer protocol.');
|
||||
if (msg.type === 'ready' && !this.peerReady && this.state === 'verification') {
|
||||
this.peerReady = true; this.ready(); return;
|
||||
}
|
||||
if (!this.verified || !this.peerReady || !this.readySent) throw new Error('File data arrived before verification.');
|
||||
if (msg.type === 'meta' && !this.file && this.state === 'verification') {
|
||||
this.meta = validateMetadata(msg);
|
||||
this.setState('choose-storage'); this.onMeta(this.meta); this.touch(5 * 60 * 1000); return;
|
||||
}
|
||||
if (msg.type === 'accept' && this.file && this.state === 'waiting-accept') {
|
||||
this.setState('sending'); this.touch();
|
||||
void this.sendFile().catch(err => this.fail(err)); return;
|
||||
}
|
||||
if (msg.type === 'ack' && this.file && ['sending', 'awaiting-receipt'].includes(this.state)) {
|
||||
if (!Number.isSafeInteger(msg.bytes) || msg.bytes <= this.acked || msg.bytes > this.sent ||
|
||||
(msg.bytes !== this.file.size && msg.bytes % CHUNK_SIZE !== 0)) throw new Error('Invalid receipt count.');
|
||||
this.acked = msg.bytes; this.onProgress(this.acked, this.file.size); this.wake?.(); this.touch(); return;
|
||||
}
|
||||
if (msg.type === 'end' && !this.file && this.state === 'receiving') {
|
||||
if (this.received !== this.meta.size) throw new Error('Incomplete file.');
|
||||
this.setState('saving');
|
||||
if (this.writable) await this.writable.close();
|
||||
if (this.closed) return;
|
||||
// Treat downloads as opaque files, regardless of the sender's MIME claim.
|
||||
const blob = this.writable ? null : new Blob(this.chunks, { type: 'application/octet-stream' });
|
||||
this.chunks = [];
|
||||
this.control('complete', { bytes: this.received });
|
||||
this.setState('done'); clearTimeout(this.timer);
|
||||
this.onComplete({ blob, meta: this.meta }); return;
|
||||
}
|
||||
if (msg.type === 'complete' && this.file && this.state === 'awaiting-receipt' && msg.bytes === this.file.size && this.acked === this.file.size) {
|
||||
this.setState('done'); clearTimeout(this.timer); this.onComplete({ meta: this.meta }); this.close(); return;
|
||||
}
|
||||
throw new Error('Unexpected transfer message.');
|
||||
}
|
||||
accept(writable = null) {
|
||||
if (this.closed || this.state !== 'choose-storage') throw new Error('File is no longer available.');
|
||||
if (!writable && this.meta.size > MEMORY_LIMIT) throw new Error('Files over 64 MiB require direct-to-disk saving.');
|
||||
this.writable = writable;
|
||||
this.setState('receiving'); this.touch();
|
||||
this.guard(() => this.control('accept'));
|
||||
}
|
||||
async sendFile() {
|
||||
for (let offset = 0; offset < this.file.size; offset += CHUNK_SIZE) {
|
||||
if (this.sent - this.acked >= WINDOW) await new Promise(resolve => { this.wake = resolve; });
|
||||
this.wake = null;
|
||||
if (this.closed) return;
|
||||
if (this.dc.bufferedAmount > MAX_BUFFERED) await waitForBufferDrain(this.dc, { signal: this.controller.signal, timeout: this.timeout });
|
||||
const buffer = await this.file.slice(offset, offset + CHUNK_SIZE).arrayBuffer();
|
||||
if (this.closed) return;
|
||||
this.sent += buffer.byteLength;
|
||||
this.dc.send(buffer);
|
||||
}
|
||||
if (this.closed) return;
|
||||
this.setState('awaiting-receipt'); this.control('end'); this.touch();
|
||||
}
|
||||
fail(err) {
|
||||
if (this.closed) return;
|
||||
this.close(); this.setState('closed'); this.onError(err);
|
||||
}
|
||||
close() {
|
||||
if (this.closed) return;
|
||||
this.closed = true; clearTimeout(this.timer); this.controller.abort(); this.wake?.(); this.wake = null;
|
||||
this.chunks = [];
|
||||
if (this.writable && this.state !== 'done') Promise.resolve().then(() => this.writable.abort()).catch(() => {});
|
||||
this.dc.onmessage = this.dc.onopen = this.dc.onclose = this.dc.onerror = null;
|
||||
this.dc.close();
|
||||
}
|
||||
}
|
||||
+118
-72
@@ -1,98 +1,144 @@
|
||||
// P2P with manual signaling: no server, no third party.
|
||||
// Peers exchange SDP blobs by copy/paste. ICE gathering runs to completion
|
||||
// so the full connection info fits in a single copyable string.
|
||||
|
||||
// Chunking / buffering for the data channel.
|
||||
export const CHUNK_SIZE = 16 * 1024; // 16 KiB per message
|
||||
export const MAX_BUFFERED = 1024 * 1024; // backpressure limit (bytes)
|
||||
|
||||
// Built-in public STUN providers. STUN is a stateless, unencrypted UDP
|
||||
// lookup of your public IP — the server never sees connection or file data.
|
||||
// Manual signaling. Codes are encoded connection details, not encrypted secrets.
|
||||
export const CHUNK_SIZE = 16 * 1024;
|
||||
export const MAX_BUFFERED = 1024 * 1024;
|
||||
export const MAX_SIGNAL_LENGTH = 64 * 1024;
|
||||
export const STUN_PROVIDERS = [
|
||||
{ id: 'google', label: 'Google', url: 'stun:stun.l.google.com:19302' },
|
||||
{ id: 'cloudflare', label: 'Cloudflare', url: 'stun:stun.cloudflare.com:3478' },
|
||||
{ id: 'none', label: 'None (same-network / VPN peers only)', url: null },
|
||||
{ id: 'none', label: 'None (direct connections only)', url: null },
|
||||
];
|
||||
|
||||
// stunUrl: a URL from STUN_PROVIDERS, or a user-supplied "stun:host:port"
|
||||
// string, or null for host candidates only.
|
||||
export function createPeerConnection(stunUrl = null) {
|
||||
return new RTCPeerConnection({
|
||||
iceServers: stunUrl ? [{ urls: stunUrl }] : [],
|
||||
});
|
||||
export function iceConfiguration({ stunUrl = null, allowTurn = false, turnUrl = '', username = '', credential = '' } = {}) {
|
||||
const iceServers = [];
|
||||
if (stunUrl) {
|
||||
if (!/^stuns?:[^\s/?#@]+$/i.test(stunUrl)) throw new Error('Enter a stun: or stuns: server address.');
|
||||
iceServers.push({ urls: stunUrl });
|
||||
}
|
||||
// Credentials and URLs are ignored unless this user explicitly opts in.
|
||||
if (allowTurn) {
|
||||
if (!/^turns?:[^\s/?#@]+(?:\?transport=(?:udp|tcp))?$/i.test(turnUrl) || !username || !credential) {
|
||||
throw new Error('TURN opt-in requires a turn: or turns: address, username and password.');
|
||||
}
|
||||
iceServers.push({ urls: turnUrl, username, credential });
|
||||
}
|
||||
return { iceServers };
|
||||
}
|
||||
|
||||
function waitForIceComplete(pc) {
|
||||
if (pc.iceGatheringState === 'complete') return Promise.resolve();
|
||||
export function createPeerConnection(options) {
|
||||
return new RTCPeerConnection(iceConfiguration(options));
|
||||
}
|
||||
|
||||
export function waitForIceComplete(pc, { signal, timeout = 30000 } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const onChange = () => {
|
||||
if (pc.iceGatheringState === 'complete') {
|
||||
pc.removeEventListener('icegatheringstatechange', onChange);
|
||||
resolve();
|
||||
}
|
||||
let timer;
|
||||
const cleanup = () => {
|
||||
clearTimeout(timer);
|
||||
pc.removeEventListener('icegatheringstatechange', check);
|
||||
pc.removeEventListener('connectionstatechange', check);
|
||||
signal?.removeEventListener('abort', aborted);
|
||||
};
|
||||
pc.addEventListener('icegatheringstatechange', onChange);
|
||||
setTimeout(() => {
|
||||
pc.removeEventListener('icegatheringstatechange', onChange);
|
||||
// Resolve anyway — partial candidate lists often still connect fine.
|
||||
resolve();
|
||||
}, 5000);
|
||||
const finish = (err) => { cleanup(); err ? reject(err) : resolve(); };
|
||||
const aborted = () => finish(new Error('Connection cancelled.'));
|
||||
const check = () => {
|
||||
if (signal?.aborted || pc.connectionState === 'closed') aborted();
|
||||
else if (pc.iceGatheringState === 'complete') finish();
|
||||
};
|
||||
pc.addEventListener('icegatheringstatechange', check);
|
||||
pc.addEventListener('connectionstatechange', check);
|
||||
signal?.addEventListener('abort', aborted, { once: true });
|
||||
timer = setTimeout(() => finish(new Error('Connection gathering timed out. Check the server settings and try again.')), timeout);
|
||||
check();
|
||||
});
|
||||
}
|
||||
|
||||
// Sender side: create an offer and return it as a copyable code.
|
||||
export async function createOfferCode(pc) {
|
||||
await pc.setLocalDescription(await pc.createOffer());
|
||||
await waitForIceComplete(pc);
|
||||
return encodeSignal(pc.localDescription.sdp);
|
||||
export function validateDescription(sdp, { allowTurn = false } = {}) {
|
||||
if (typeof sdp !== 'string' || sdp.length > MAX_SIGNAL_LENGTH || /[^\x09\x0A\x0D\x20-\x7E]/.test(sdp)) {
|
||||
throw new Error('Invalid connection description.');
|
||||
}
|
||||
const lines = sdp.split(/\r?\n/);
|
||||
const media = lines.filter(line => line.startsWith('m='));
|
||||
if (media.length !== 1 || !/^m=application \d+ (?:UDP\/DTLS\/SCTP|DTLS\/SCTP) (?:webrtc-datachannel|\d+)$/.test(media[0])) {
|
||||
throw new Error('Only a single file data channel is supported.');
|
||||
}
|
||||
// Deliberately reject ambiguous fingerprints rather than guessing SDP scope.
|
||||
const fingerprints = lines.filter(line => line.startsWith('a=fingerprint:'));
|
||||
if (fingerprints.length !== 1 || !/^a=fingerprint:sha-256 (?:[\da-f]{2}:){31}[\da-f]{2}$/i.test(fingerprints[0])) {
|
||||
throw new Error('A single full SHA-256 fingerprint is required.');
|
||||
}
|
||||
if (!allowTurn && lines.some(line => /^a=candidate:.*\styp\s+relay(?:\s|$)/i.test(line))) {
|
||||
throw new Error('This code contains a TURN relay. Both people must explicitly enable TURN and create new codes to use a relay.');
|
||||
}
|
||||
return fingerprints[0].slice('a=fingerprint:sha-256 '.length).toUpperCase().replaceAll(':', ' ');
|
||||
}
|
||||
|
||||
// Receiver side: accept an offer code, return the answer code to send back.
|
||||
export async function createAnswerCode(pc, offerText) {
|
||||
await pc.setRemoteDescription({ type: 'offer', sdp: decodeSignal(offerText) });
|
||||
await pc.setLocalDescription(await pc.createAnswer());
|
||||
await waitForIceComplete(pc);
|
||||
return encodeSignal(pc.localDescription.sdp);
|
||||
}
|
||||
|
||||
// Sender side: apply the answer code the receiver sent back.
|
||||
export function acceptAnswerCode(pc, answerText) {
|
||||
return pc.setRemoteDescription({ type: 'answer', sdp: decodeSignal(answerText) });
|
||||
}
|
||||
|
||||
// Anti-MITM check: extracts the DTLS certificate fingerprints from both
|
||||
// descriptions and shortens them for human comparison.
|
||||
// Rule: my "local" must equal the peer's "remote" (and vice versa).
|
||||
// If both match, nobody interposed on the code exchange.
|
||||
export function getFingerprints(pc) {
|
||||
const extract = (sdp) => {
|
||||
const m = sdp?.match(/a=fingerprint:(?:sha-256|sha-384|sha-512) ([0-9A-Fa-f:]+)/);
|
||||
return m ? m[1].toUpperCase() : null;
|
||||
};
|
||||
// The fingerprint is already a certificate hash — its first 5 bytes
|
||||
// (40 bits) are plenty for two humans to read to each other.
|
||||
const shorten = (fp) => (fp ? fp.split(':').slice(0, 5).join(' ') : '—');
|
||||
export function getFingerprints(pc, options) {
|
||||
return {
|
||||
local: shorten(extract(pc.localDescription?.sdp)),
|
||||
remote: shorten(extract(pc.remoteDescription?.sdp)),
|
||||
local: validateDescription(pc.localDescription?.sdp, options),
|
||||
remote: validateDescription(pc.remoteDescription?.sdp, options),
|
||||
};
|
||||
}
|
||||
|
||||
// SDP is ASCII plus CRLFs, so plain base64 is safe and compact enough (~2-4 KB).
|
||||
export function encodeSignal(sdp) {
|
||||
return btoa(sdp).replace(/=+$/, '');
|
||||
const code = btoa(JSON.stringify({ version: 2, sdp })).replace(/=+$/, '');
|
||||
if (code.length > MAX_SIGNAL_LENGTH) throw new Error('Connection code is too large. Reduce the configured network interfaces and try again.');
|
||||
return code;
|
||||
}
|
||||
|
||||
export function decodeSignal(text) {
|
||||
const clean = String(text).trim().replace(/\s+/g, '');
|
||||
const padded = clean + '='.repeat((4 - (clean.length % 4)) % 4);
|
||||
return atob(padded);
|
||||
export function decodeSignal(text, options) {
|
||||
if (typeof text !== 'string' || text.length > MAX_SIGNAL_LENGTH) throw new Error('Connection code is too large.');
|
||||
try {
|
||||
const clean = text.trim().replace(/\s+/g, '');
|
||||
const data = JSON.parse(atob(clean));
|
||||
if (data?.version !== 2) throw new Error('Both people need the current HellCon version.');
|
||||
validateDescription(data.sdp, options);
|
||||
return data.sdp;
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError || err.name === 'InvalidCharacterError') throw new Error('Invalid connection code. Paste the complete code.');
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// Waits until the channel's send buffer drains below MAX_BUFFERED.
|
||||
export function waitForBufferDrain(dc) {
|
||||
export async function createOfferCode(pc, options = {}) {
|
||||
await pc.setLocalDescription(await pc.createOffer());
|
||||
await waitForIceComplete(pc, options);
|
||||
validateDescription(pc.localDescription.sdp, options);
|
||||
return encodeSignal(pc.localDescription.sdp);
|
||||
}
|
||||
|
||||
export async function createAnswerCode(pc, text, options = {}) {
|
||||
await pc.setRemoteDescription({ type: 'offer', sdp: decodeSignal(text, options) });
|
||||
await pc.setLocalDescription(await pc.createAnswer());
|
||||
await waitForIceComplete(pc, options);
|
||||
validateDescription(pc.localDescription.sdp, options);
|
||||
return encodeSignal(pc.localDescription.sdp);
|
||||
}
|
||||
|
||||
export function acceptAnswerCode(pc, text, options) {
|
||||
return pc.setRemoteDescription({ type: 'answer', sdp: decodeSignal(text, options) });
|
||||
}
|
||||
|
||||
export function waitForBufferDrain(dc, { signal, timeout = 60000 } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let timer;
|
||||
const cleanup = () => {
|
||||
clearTimeout(timer);
|
||||
dc.removeEventListener('bufferedamountlow', check);
|
||||
dc.removeEventListener('close', check);
|
||||
dc.removeEventListener('error', failed);
|
||||
signal?.removeEventListener('abort', failed);
|
||||
};
|
||||
const finish = err => { cleanup(); err ? reject(err) : resolve(); };
|
||||
const failed = () => finish(new Error('Transfer interrupted.'));
|
||||
const check = () => {
|
||||
if (signal?.aborted || dc.readyState !== 'open') failed();
|
||||
else if (dc.bufferedAmount <= MAX_BUFFERED / 2) finish();
|
||||
};
|
||||
dc.bufferedAmountLowThreshold = MAX_BUFFERED / 2;
|
||||
return new Promise((resolve) => {
|
||||
dc.addEventListener('bufferedamountlow', resolve, { once: true });
|
||||
dc.addEventListener('bufferedamountlow', check);
|
||||
dc.addEventListener('close', check);
|
||||
dc.addEventListener('error', failed);
|
||||
signal?.addEventListener('abort', failed, { once: true });
|
||||
timer = setTimeout(() => finish(new Error('Transfer stalled.')), timeout);
|
||||
check();
|
||||
});
|
||||
}
|
||||
@@ -239,3 +239,18 @@ p.stun-hint {
|
||||
margin: -0.35rem 0 0;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.network-settings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.7rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
.network-settings legend { color: var(--muted); }
|
||||
.checkbox { display: flex; align-items: start; gap: 0.6rem; }
|
||||
.fp-row { flex-direction: column; align-items: start; }
|
||||
.fp-row code { overflow-wrap: anywhere; line-height: 1.7; font-size: 0.8rem; }
|
||||
.file-chip span { overflow-wrap: anywhere; min-width: 0; }
|
||||
.incoming { display: flex; flex-direction: column; gap: 0.7rem; overflow-wrap: anywhere; }
|
||||
@@ -0,0 +1,216 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { Transfer, MEMORY_LIMIT, FILE_LIMIT, validateMetadata } from '../src/lib/transfer.js';
|
||||
import { CHUNK_SIZE, MAX_BUFFERED } from '../src/lib/webrtc.js';
|
||||
|
||||
class Channel extends EventTarget {
|
||||
readyState = 'open';
|
||||
bufferedAmount = 0;
|
||||
frames = [];
|
||||
send(data) {
|
||||
if (this.readyState !== 'open') throw new Error('closed');
|
||||
this.frames.push(data);
|
||||
queueMicrotask(() => this.peer?.onmessage?.({ data }));
|
||||
}
|
||||
close() { this.readyState = 'closed'; this.dispatchEvent(new Event('close')); }
|
||||
}
|
||||
const tick = () => new Promise(resolve => setImmediate(resolve));
|
||||
async function until(check) {
|
||||
for (let i = 0; i < 500; i++) { if (check()) return; await tick(); }
|
||||
assert.fail('Condition did not become true');
|
||||
}
|
||||
const message = (transfer, type, data = {}) => transfer.enqueue(JSON.stringify({ v: 2, type, ...data }));
|
||||
const meta = (size = 1) => ({ name: 'example.txt', size, mime: 'text/plain' });
|
||||
function receiver(t, options = {}) {
|
||||
const dc = new Channel();
|
||||
const errors = [];
|
||||
const r = new Transfer(dc, { onError: err => errors.push(err.message), ...options });
|
||||
t.after(() => r.close());
|
||||
return { r, dc, errors };
|
||||
}
|
||||
async function prepared(t, size = 1, options = {}) {
|
||||
const result = receiver(t, options);
|
||||
result.r.verify(); message(result.r, 'ready'); message(result.r, 'meta', meta(size));
|
||||
await result.r.queue;
|
||||
assert.equal(result.r.state, 'choose-storage');
|
||||
return result;
|
||||
}
|
||||
function pair(t, size = CHUNK_SIZE * 80 + 3, receiverOptions = {}) {
|
||||
const a = new Channel(), b = new Channel(); a.peer = b; b.peer = a;
|
||||
const source = new Uint8Array(size); source.fill(123);
|
||||
const file = new File([source], 'payload.bin');
|
||||
const errors = [];
|
||||
const sender = new Transfer(a, { file, onError: err => errors.push(err.message) });
|
||||
const receiver = new Transfer(b, { onError: err => errors.push(err.message), ...receiverOptions });
|
||||
t.after(() => { sender.close(); receiver.close(); });
|
||||
return { sender, receiver, a, b, source, errors };
|
||||
}
|
||||
|
||||
test('no filename or contents before both explicit verification confirmations', async t => {
|
||||
const { sender, receiver, a } = pair(t);
|
||||
await tick(); assert.equal(a.frames.length, 0);
|
||||
sender.verify(); await tick();
|
||||
assert.deepEqual(a.frames.map(JSON.parse).map(m => m.type), ['ready']);
|
||||
receiver.verify(); await until(() => receiver.state === 'choose-storage');
|
||||
assert.deepEqual(a.frames.map(JSON.parse).map(m => m.type), ['ready', 'meta']);
|
||||
assert.equal(sender.sent, 0);
|
||||
});
|
||||
|
||||
test('verified, accepted memory transfer preserves bytes and requires receipt ACK', async t => {
|
||||
let result;
|
||||
const { sender, receiver, source, errors } = pair(t, undefined, { onComplete: value => { result = value; } });
|
||||
sender.verify(); receiver.verify();
|
||||
await until(() => receiver.state === 'choose-storage'); receiver.accept();
|
||||
await until(() => sender.state === 'done');
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(new Uint8Array(await result.blob.arrayBuffer()), source);
|
||||
assert.equal(sender.acked, source.length);
|
||||
assert.equal(result.blob.type, 'application/octet-stream');
|
||||
});
|
||||
|
||||
test('empty file still requires acceptance and completion ACK', async t => {
|
||||
const { sender, receiver } = pair(t, 0);
|
||||
sender.verify(); receiver.verify(); await until(() => receiver.state === 'choose-storage');
|
||||
assert.equal(sender.state, 'waiting-accept');
|
||||
receiver.accept(); await until(() => sender.state === 'done');
|
||||
});
|
||||
|
||||
test('disk transfer waits for storage close before acknowledging completion', async t => {
|
||||
let release, saved = 0;
|
||||
const { sender, receiver, source } = pair(t);
|
||||
sender.verify(); receiver.verify(); await until(() => receiver.state === 'choose-storage');
|
||||
receiver.accept({ async write(bytes) { saved += bytes.byteLength; }, close() { return new Promise(resolve => { release = resolve; }); }, async abort() {} });
|
||||
await until(() => receiver.state === 'saving');
|
||||
assert.equal(sender.state, 'awaiting-receipt'); assert.equal(saved, source.length);
|
||||
release(); await until(() => sender.state === 'done');
|
||||
});
|
||||
|
||||
test('slow storage bounds the sender to its acknowledged window', async t => {
|
||||
let release;
|
||||
const { sender, receiver } = pair(t);
|
||||
sender.verify(); receiver.verify(); await until(() => receiver.state === 'choose-storage');
|
||||
receiver.accept({ write() { return new Promise(resolve => { release = resolve; }); }, async close() {}, async abort() { release?.(); } });
|
||||
await until(() => sender.sent === MAX_BUFFERED);
|
||||
await tick(); assert.equal(sender.acked, 0); assert.equal(sender.sent, MAX_BUFFERED);
|
||||
receiver.close(); sender.close(); release?.();
|
||||
});
|
||||
|
||||
for (const [name, input] of [
|
||||
['malformed JSON', '{broken'],
|
||||
['null JSON', 'null'],
|
||||
['binary data before verification', new ArrayBuffer(1)],
|
||||
['oversized binary message', new ArrayBuffer(CHUNK_SIZE + 1)],
|
||||
['oversized control message', ' '.repeat(2049)],
|
||||
['metadata before verification', JSON.stringify({ v: 2, type: 'meta', ...meta() })],
|
||||
['unsupported message object', {}],
|
||||
]) {
|
||||
test(`rejects ${name}`, async t => {
|
||||
const { r, errors } = receiver(t); r.enqueue(input); await r.queue;
|
||||
assert.equal(r.closed, true); assert.equal(errors.length, 1);
|
||||
});
|
||||
}
|
||||
|
||||
test('rejects duplicate metadata without retaining bytes from another file', async t => {
|
||||
const { r } = await prepared(t); r.accept(); r.enqueue(new ArrayBuffer(1));
|
||||
message(r, 'meta', meta()); await r.queue;
|
||||
assert.equal(r.closed, true); assert.equal(r.chunks.length, 0);
|
||||
});
|
||||
|
||||
test('rejects excess bytes and premature end', async t => {
|
||||
const first = await prepared(t); first.r.accept(); first.r.enqueue(new ArrayBuffer(2)); await first.r.queue;
|
||||
assert.equal(first.r.closed, true);
|
||||
const second = await prepared(t, 2); second.r.accept(); second.r.enqueue(new ArrayBuffer(1)); message(second.r, 'end'); await second.r.queue;
|
||||
assert.equal(second.r.closed, true);
|
||||
});
|
||||
|
||||
test('completed files cannot be extended by later frames', async t => {
|
||||
let completes = 0;
|
||||
const { r } = await prepared(t, 1, { onComplete: () => completes++ });
|
||||
r.accept(); r.enqueue(new ArrayBuffer(1)); message(r, 'end'); await r.queue;
|
||||
assert.equal(r.state, 'done'); r.enqueue(new ArrayBuffer(1)); await r.queue;
|
||||
assert.equal(r.closed, true); assert.equal(completes, 1);
|
||||
});
|
||||
|
||||
test('post-completion transport errors preserve the received file (Firefox shutdown)', async t => {
|
||||
let result;
|
||||
const { r, dc, errors } = await prepared(t, 1, { onComplete: value => { result = value; } });
|
||||
r.accept(); r.enqueue(Uint8Array.of(123).buffer); message(r, 'end'); await r.queue;
|
||||
assert.equal(r.state, 'done');
|
||||
dc.onerror(new Event('error'));
|
||||
assert.equal(r.state, 'done'); assert.equal(r.closed, true);
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(new Uint8Array(await result.blob.arrayBuffer()), Uint8Array.of(123));
|
||||
});
|
||||
|
||||
test('transport errors before receipt completion remain fatal', async t => {
|
||||
const { r, dc, errors } = await prepared(t, 1);
|
||||
r.accept(); r.enqueue(new ArrayBuffer(1)); await r.queue;
|
||||
dc.onerror(new Event('error'));
|
||||
assert.equal(r.state, 'closed'); assert.equal(r.chunks.length, 0);
|
||||
assert.deepEqual(errors, ['Data channel failed.']);
|
||||
});
|
||||
|
||||
test('memory limit requires an explicit disk destination for larger files', async t => {
|
||||
const { r } = await prepared(t, MEMORY_LIMIT + 1);
|
||||
assert.throws(() => r.accept(), /direct-to-disk/);
|
||||
assert.equal(r.state, 'choose-storage');
|
||||
});
|
||||
|
||||
test('metadata rejects invalid sizes, misleading names and invalid types', () => {
|
||||
for (const size of [-1, 0.5, '10', NaN, Infinity, FILE_LIMIT + 1]) assert.throws(() => validateMetadata(meta(size)));
|
||||
for (const name of ['', '../secret', 'a\\b', 'bad\u202efile.exe', 'a'.repeat(256)]) assert.throws(() => validateMetadata({ ...meta(), name }));
|
||||
assert.throws(() => validateMetadata({ ...meta(), mime: {} }));
|
||||
});
|
||||
|
||||
test('cancellation aborts pending disk writes and drops retained buffers', async t => {
|
||||
let aborted = false, release;
|
||||
const { r } = await prepared(t);
|
||||
r.accept({ write() { return new Promise(resolve => { release = resolve; }); }, async abort() { aborted = true; release?.(); } });
|
||||
r.enqueue(new ArrayBuffer(1)); await tick(); r.close(); await r.queue;
|
||||
assert.equal(aborted, true); assert.equal(r.chunks.length, 0); assert.equal(r.received, 0);
|
||||
});
|
||||
|
||||
test('peer flooding exceeds bounded queue and aborts storage', async t => {
|
||||
let release;
|
||||
const { r } = await prepared(t, MEMORY_LIMIT);
|
||||
r.accept({ write() { return new Promise(resolve => { release = resolve; }); }, async abort() { release?.(); } });
|
||||
r.enqueue(new ArrayBuffer(CHUNK_SIZE)); await tick();
|
||||
for (let i = 0; i < 130; i++) r.enqueue(new ArrayBuffer(CHUNK_SIZE));
|
||||
assert.equal(r.closed, true); release?.(); await r.queue;
|
||||
});
|
||||
|
||||
test('stalled transfers time out rather than reporting completion', async t => {
|
||||
const { r, errors } = await prepared(t, 1, { timeout: 10 });
|
||||
r.accept(); await new Promise(resolve => setTimeout(resolve, 30));
|
||||
assert.equal(r.closed, true); assert.match(errors[0], /timed out/);
|
||||
});
|
||||
|
||||
test('storage failure never sends successful receipt', async t => {
|
||||
const { r, dc } = await prepared(t);
|
||||
r.accept({ async write() { throw new Error('Disk full'); }, async abort() {} });
|
||||
r.enqueue(new ArrayBuffer(1)); message(r, 'end'); await r.queue;
|
||||
assert.equal(r.closed, true); assert.equal(dc.frames.some(frame => JSON.parse(frame).type === 'complete'), false);
|
||||
});
|
||||
|
||||
test('tiny chunks cannot bypass the memory cap through per-chunk overhead', async t => {
|
||||
const { r, errors } = await prepared(t, CHUNK_SIZE * 2);
|
||||
r.accept(); r.enqueue(new ArrayBuffer(1)); await r.queue;
|
||||
assert.equal(r.closed, true); assert.match(errors[0], /chunk size/);
|
||||
});
|
||||
|
||||
test('forged completion or invalid byte acknowledgments cannot report success', async t => {
|
||||
const first = pair(t);
|
||||
first.sender.verify(); first.receiver.verify();
|
||||
await until(() => first.receiver.state === 'choose-storage');
|
||||
message(first.sender, 'complete', { bytes: first.source.length }); await first.sender.queue;
|
||||
assert.equal(first.sender.state, 'closed');
|
||||
const second = pair(t);
|
||||
second.sender.verify(); second.receiver.verify();
|
||||
await until(() => second.receiver.state === 'choose-storage');
|
||||
// Accept without allowing the real receiver to process file data, then forge an ACK.
|
||||
second.b.onmessage = null;
|
||||
message(second.sender, 'accept');
|
||||
await until(() => second.sender.sent >= CHUNK_SIZE);
|
||||
message(second.sender, 'ack', { bytes: 1 }); await second.sender.queue;
|
||||
assert.equal(second.sender.state, 'closed');
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { iceConfiguration, validateDescription, getFingerprints, encodeSignal, decodeSignal, waitForIceComplete, waitForBufferDrain, MAX_SIGNAL_LENGTH, MAX_BUFFERED } from '../src/lib/webrtc.js';
|
||||
const fingerprint = Array.from({ length: 32 }, (_, i) => i.toString(16).padStart(2, '0')).join(':');
|
||||
const sdp = `v=0\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\na=fingerprint:sha-256 ${fingerprint}\r\n`;
|
||||
|
||||
test('TURN is absent by default and dormant credentials cannot enable it', () => {
|
||||
assert.deepEqual(iceConfiguration(), { iceServers: [] });
|
||||
const settings = { stunUrl: 'stun:example.com:3478', turnUrl: 'turn:relay.example', username: 'user', credential: 'secret' };
|
||||
assert.equal(iceConfiguration(settings).iceServers.length, 1);
|
||||
assert.equal(iceConfiguration({ ...settings, allowTurn: true }).iceServers.length, 2);
|
||||
assert.throws(() => iceConfiguration({ stunUrl: 'turn:relay.example' }));
|
||||
assert.throws(() => iceConfiguration({ allowTurn: true }));
|
||||
});
|
||||
|
||||
test('remote relay candidates require local explicit opt-in', () => {
|
||||
const relayed = sdp + 'a=candidate:1 1 udp 10 192.0.2.1 5000 typ relay raddr 0.0.0.0 rport 0\r\n';
|
||||
assert.throws(() => decodeSignal(encodeSignal(relayed)), /explicitly enable TURN/);
|
||||
assert.equal(decodeSignal(encodeSignal(relayed), { allowTurn: true }), relayed);
|
||||
});
|
||||
|
||||
test('fingerprints show all 32 bytes and reject ambiguous descriptions', () => {
|
||||
const expected = fingerprint.toUpperCase().replaceAll(':', ' ');
|
||||
assert.equal(validateDescription(sdp), expected);
|
||||
assert.deepEqual(getFingerprints({ localDescription: { sdp }, remoteDescription: { sdp } }), { local: expected, remote: expected });
|
||||
assert.throws(() => validateDescription(sdp + `a=fingerprint:sha-256 ${fingerprint}\r\n`));
|
||||
assert.throws(() => validateDescription(sdp.replace(fingerprint, 'AA:BB:CC:DD:EE')));
|
||||
assert.throws(() => validateDescription(sdp + 'm=audio 9 UDP/TLS/RTP/SAVPF 111\r\n'));
|
||||
});
|
||||
|
||||
test('signals round-trip but reject legacy, malformed and oversized codes', () => {
|
||||
assert.equal(decodeSignal(encodeSignal(sdp)), sdp);
|
||||
assert.throws(() => decodeSignal(btoa(sdp)));
|
||||
assert.throws(() => decodeSignal('bad!'));
|
||||
assert.throws(() => decodeSignal('a'.repeat(MAX_SIGNAL_LENGTH + 1)));
|
||||
assert.throws(() => decodeSignal(btoa(JSON.stringify({ version: 1, sdp }))));
|
||||
});
|
||||
|
||||
class Peer extends EventTarget { iceGatheringState = 'gathering'; connectionState = 'new'; }
|
||||
|
||||
test('ICE gathering waits for completion, rejects timeout, and supports cancellation', async () => {
|
||||
const pc = new Peer();
|
||||
const completed = waitForIceComplete(pc, { timeout: 100 });
|
||||
pc.iceGatheringState = 'complete'; pc.dispatchEvent(new Event('icegatheringstatechange')); await completed;
|
||||
await assert.rejects(waitForIceComplete(new Peer(), { timeout: 5 }), /timed out/);
|
||||
const controller = new AbortController();
|
||||
const cancelled = waitForIceComplete(new Peer(), { signal: controller.signal }); controller.abort();
|
||||
await assert.rejects(cancelled, /cancelled/);
|
||||
});
|
||||
|
||||
test('buffer wait resolves when already drained and rejects close or cancellation', async () => {
|
||||
const channel = new EventTarget(); channel.readyState = 'open'; channel.bufferedAmount = 0;
|
||||
await waitForBufferDrain(channel);
|
||||
channel.bufferedAmount = MAX_BUFFERED + 1;
|
||||
const wait = waitForBufferDrain(channel); channel.readyState = 'closed'; channel.dispatchEvent(new Event('close'));
|
||||
await assert.rejects(wait, /interrupted/);
|
||||
channel.readyState = 'open'; const controller = new AbortController();
|
||||
const cancelled = waitForBufferDrain(channel, { signal: controller.signal }); controller.abort();
|
||||
await assert.rejects(cancelled, /interrupted/);
|
||||
});
|
||||
Reference in new issue
Block a user