nemfile 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -40,7 +40,7 @@ Getting a screenshot off an iPhone and onto a Windows or Linux machine usually m
40
40
  | Text clips | Paste text on one device, read it on another — a cross-platform clipboard |
41
41
  | One-click copy | Copy an image to the system clipboard, or copy its LAN URL |
42
42
  | Download buttons | Grab any uploaded file back down to whatever device you're on |
43
- | Public tunnel | Optional `localtunnel` URL so the page works outside your Wi-Fi |
43
+ | Public tunnel | Optional Cloudflare Tunnel URL so the page works outside your Wi-Fi |
44
44
  | Standalone binaries | Prebuilt executables for Linux, macOS and Windows — no Node needed |
45
45
 
46
46
  ## Install
@@ -86,7 +86,7 @@ nemfile prints three addresses:
86
86
  ```
87
87
  Local: http://localhost:3333
88
88
  LAN: http://192.168.1.10:3333 ← open this on your phone
89
- Public: https://xxxx.loca.lt ← works outside your Wi-Fi
89
+ Public: https://xxxx.trycloudflare.com ← works outside your Wi-Fi
90
90
  ```
91
91
 
92
92
  Open the **LAN** address on your phone — or scan the QR code shown on the page — and you get an upload box. Anything you drop there appears in the gallery on every connected device, and is written to `uploads/` on your computer.
@@ -95,7 +95,7 @@ To share text instead of a file, paste into the text box and hit send; it shows
95
95
 
96
96
  ## How it works
97
97
 
98
- nemfile starts a small Express server on port `3333` bound to `0.0.0.0`, so any device on the same Wi-Fi can reach it. Uploads are handled by `multer` and written to `./uploads`. A server-sent-events stream keeps every open browser tab in sync, and `qrcode` renders the pairing QR codes. Optionally, `localtunnel` exposes the same page on a public HTTPS URL for when the two devices aren't on the same network.
98
+ nemfile starts a small Express server on port `3333` bound to `0.0.0.0`, so any device on the same Wi-Fi can reach it. Uploads are handled by `multer` and written to `./uploads`. A server-sent-events stream keeps every open browser tab in sync, and `qrcode` renders the pairing QR codes. Optionally, a Cloudflare Tunnel (no account needed) exposes the same page on a public HTTPS URL for when the two devices aren't on the same network.
99
99
 
100
100
  There is no database, no telemetry, and no external service in the default path — the LAN transfer is a direct HTTP request from your phone to your computer.
101
101
 
@@ -111,7 +111,7 @@ Yes — it covers the same job (send a file to a nearby device) but works betwee
111
111
 
112
112
  ### Do my files get uploaded to a cloud server?
113
113
 
114
- No. By default the transfer stays entirely on your local network. Files are saved to a folder on your own computer. The only exception is the optional public tunnel, which relays traffic through `loca.lt` so devices outside your Wi-Fi can reach the page — skip it if you don't need it.
114
+ No. By default the transfer stays entirely on your local network. Files are saved to a folder on your own computer. The only exception is the optional public tunnel, which relays traffic through Cloudflare so devices outside your Wi-Fi can reach the page — skip it if you don't need it.
115
115
 
116
116
  ### What's the maximum file size?
117
117
 
package/bin/nemfile.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nemfile",
3
- "version": "1.0.0",
4
- "description": "Send files, screenshots and text between your phone, iPad and computer over local Wi-Fi — no cloud, no account, no app install. One command: npx nemfile.",
3
+ "version": "1.0.2",
4
+ "description": "Send files, screenshots and text between your phone, iPad and computer over local Wi-Fi \u2014 no cloud, no account, no app install. One command: npx nemfile.",
5
5
  "keywords": [
6
6
  "file-transfer",
7
7
  "share-files",
@@ -31,7 +31,7 @@
31
31
  "offline",
32
32
  "privacy",
33
33
  "tunnel",
34
- "localtunnel",
34
+ "cloudflare-tunnel",
35
35
  "express",
36
36
  "cli",
37
37
  "zero-config",
@@ -76,13 +76,14 @@
76
76
  "node20-win-x64"
77
77
  ],
78
78
  "assets": [
79
- "node_modules/qrcode/**/*"
79
+ "node_modules/qrcode/**/*",
80
+ "node_modules/cloudflared/bin/**/*"
80
81
  ],
81
82
  "outputPath": "dist"
82
83
  },
83
84
  "dependencies": {
85
+ "cloudflared": "^0.7.3",
84
86
  "express": "^4.18.2",
85
- "localtunnel": "^2.0.2",
86
87
  "multer": "^1.4.5-lts.1",
87
88
  "qrcode": "^1.5.4"
88
89
  }
package/server.js CHANGED
@@ -4,7 +4,7 @@ const path = require('path');
4
4
  const fs = require('fs');
5
5
  const os = require('os');
6
6
  const QRCode = require('qrcode');
7
- const localtunnel = require('localtunnel');
7
+ const { Tunnel } = require('cloudflared');
8
8
 
9
9
  const app = express();
10
10
  const PORT = 3333;
@@ -81,7 +81,7 @@ app.get('/', async (req, res) => {
81
81
  <div class="thumb-meta">${f}</div>
82
82
  </a>
83
83
  <a class="thumb-dl" href="${url}" download="${f}" title="Download">↓</a>
84
- <button class="thumb-ln" data-url="${url}" onclick="copyLink(this)" title="Copy LAN link">URL</button>
84
+ <button class="thumb-ln" data-url="${url}" onclick="copyLink(this)" title="Copy link">URL</button>
85
85
  ${copyBtn}
86
86
  </div>`;
87
87
  }).join('');
@@ -536,7 +536,10 @@ app.get('/', async (req, res) => {
536
536
  border-left:2px solid var(--accent);
537
537
  }
538
538
  .qr.tunnel::before { border-color: var(--accent); }
539
- .qr img { display:block; width:96px; height:96px; }
539
+ .qr a { display: block; color: inherit; text-decoration: none; cursor: pointer; }
540
+ .qr img { display:block; width:96px; height:96px; transition: opacity .15s; }
541
+ .qr a:hover img { opacity: .8; }
542
+ .qr a:hover .qr-tag { color: var(--accent); }
540
543
  .qr-tag {
541
544
  font-size: 0.5rem;
542
545
  text-transform: uppercase;
@@ -649,19 +652,22 @@ app.get('/', async (req, res) => {
649
652
 
650
653
  <div class="qr-group">
651
654
  <div class="qr">
652
- <img src="${qrLan}" alt="LAN QR">
653
- <div class="qr-tag">// LAN</div>
654
- <div class="qr-url">${lanUrl}</div>
655
+ <a href="${lanUrl}" target="_blank" rel="noopener" title="Open ${lanUrl}">
656
+ <img src="${qrLan}" alt="LAN QR">
657
+ <div class="qr-tag">// LAN</div>
658
+ <div class="qr-url">${lanUrl}</div>
659
+ </a>
655
660
  </div>
656
661
  ${qrPublic ? `<div class="qr tunnel">
657
- <img src="${qrPublic}" alt="Public QR">
658
- <div class="qr-tag">// PUBLIC</div>
659
- <div class="qr-url">${publicUrl}</div>
662
+ <a href="${publicUrl}" target="_blank" rel="noopener" title="Open ${publicUrl}">
663
+ <img src="${qrPublic}" alt="Public QR">
664
+ <div class="qr-tag">// PUBLIC</div>
665
+ <div class="qr-url">${publicUrl}</div>
666
+ </a>
660
667
  </div>` : ''}
661
668
  </div>
662
669
 
663
670
  <script>
664
- const LAN_BASE = '${lanUrl}';
665
671
  const input = document.getElementById('fileInput');
666
672
  const statusEl = document.getElementById('status');
667
673
  const dropzone = document.getElementById('dropzone');
@@ -742,7 +748,7 @@ app.get('/', async (req, res) => {
742
748
  : '';
743
749
  const div = document.createElement('div');
744
750
  div.className = 'thumb' + (isNew ? ' thumb-new' : '');
745
- div.innerHTML = '<a href="' + url + '" target="_blank">' + preview + '<div class="thumb-meta">' + filename + '</div></a><a class="thumb-dl" href="' + url + '" download="' + filename + '" title="Download">↓</a><button class="thumb-ln" data-url="' + url + '" onclick="copyLink(this)" title="Copy LAN link">URL</button>' + copyBtn;
751
+ div.innerHTML = '<a href="' + url + '" target="_blank">' + preview + '<div class="thumb-meta">' + filename + '</div></a><a class="thumb-dl" href="' + url + '" download="' + filename + '" title="Download">↓</a><button class="thumb-ln" data-url="' + url + '" onclick="copyLink(this)" title="Copy link">URL</button>' + copyBtn;
746
752
  gallery.prepend(div);
747
753
  countEl.textContent = gallery.querySelectorAll('.thumb').length;
748
754
  if (isNew) setTimeout(() => div.classList.remove('thumb-new'), 4000);
@@ -803,11 +809,14 @@ app.get('/', async (req, res) => {
803
809
  flashBtn(btn, ok ? 'OK' : 'ERR', 'ok');
804
810
  }
805
811
 
806
- // Copy the file's LAN address, e.g. http://192.168.1.10:3333/uploads/x.png
812
+ // Copy the file's address using the origin the visitor is actually on
813
+ // (localhost, the LAN IP, or the public tunnel) — not a fixed LAN address,
814
+ // so the copied link still works for whoever pasted it.
807
815
  async function copyLink(btn) {
808
- const ok = await copyText(LAN_BASE + btn.dataset.url);
816
+ const fullUrl = location.origin + btn.dataset.url;
817
+ const ok = await copyText(fullUrl);
809
818
  flashBtn(btn, ok ? 'OK' : 'ERR', 'copied');
810
- setStatus(ok ? '// LINK COPIED — ' + LAN_BASE + btn.dataset.url : '// COPY FAILED', ok);
819
+ setStatus(ok ? '// LINK COPIED — ' + fullUrl : '// COPY FAILED', ok);
811
820
  setTimeout(() => setStatus('// AWAITING INPUT', false), 3000);
812
821
  }
813
822
 
@@ -897,22 +906,23 @@ app.listen(PORT, '0.0.0.0', async () => {
897
906
  }
898
907
 
899
908
  console.log('\n Starting public tunnel...');
900
- try {
901
- const tunnel = await localtunnel({ port: PORT });
902
- publicUrl = tunnel.url;
903
- console.log(' Public: ' + publicUrl + ' ← use this outside LAN\n');
904
- console.log(' (First visit may ask for confirmation — click "Click to Continue")\n');
905
909
 
906
- tunnel.on('close', () => {
907
- publicUrl = null;
908
- console.log(' Tunnel closed.');
909
- });
910
- tunnel.on('error', err => {
911
- publicUrl = null;
912
- console.error(' Tunnel error:', err.message);
913
- });
914
- } catch (err) {
915
- console.error(' Could not create tunnel:', err.message);
916
- console.log(' → LAN only.\n');
917
- }
910
+ // Quick Tunnel (trycloudflare.com): anonymous, no Cloudflare account, no
911
+ // DNS setup — the binary itself is fetched automatically on `npm install`.
912
+ // Unlike the localtunnel relay this replaced, it doesn't silently die after
913
+ // a couple of requests, so a phone and a computer can both stay open on
914
+ // the gallery at once.
915
+ const tunnel = Tunnel.quick(`http://localhost:${PORT}`);
916
+
917
+ tunnel.once('url', url => {
918
+ publicUrl = url;
919
+ console.log(' Public: ' + publicUrl + ' ← use this outside LAN\n');
920
+ });
921
+ tunnel.on('error', err => {
922
+ console.error(' Tunnel error:', err.message);
923
+ });
924
+ tunnel.on('exit', () => {
925
+ publicUrl = null;
926
+ console.log(' Tunnel closed.');
927
+ });
918
928
  });