qr-secure-send 1.0.0

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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git init:*)",
5
+ "Bash(git add:*)",
6
+ "Bash(git stash:*)"
7
+ ]
8
+ }
9
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Degenddy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # QR Secure Send
2
+
3
+ Encrypt and transfer secrets (passwords, keys, tokens) between devices via QR code. Everything runs client-side — no data leaves your browser.
4
+
5
+ ## How It Works
6
+
7
+ 1. **Sender** enters a secret and a shared passphrase, then generates a QR code
8
+ 2. **Receiver** enters the same passphrase, opens the camera, and scans the QR code
9
+ 3. The secret is decrypted and displayed on the receiver's device
10
+
11
+ ## Security
12
+
13
+ - **AES-256-GCM** authenticated encryption
14
+ - **PBKDF2** key derivation with 310,000 iterations
15
+ - Random salt and IV per encryption — no key reuse
16
+ - Fully client-side — zero network requests for your data
17
+
18
+ ## Quick Start
19
+
20
+ ```bash
21
+ npm start
22
+ ```
23
+
24
+ Opens on [http://localhost:3000](http://localhost:3000).
25
+
26
+ > Camera access requires HTTPS or localhost.
27
+
28
+ ## License
29
+
30
+ MIT
package/index.html ADDED
@@ -0,0 +1,529 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>QR Secure Send</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/qrcode@1.5.4/build/qrcode.min.js"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/html5-qrcode@2.3.8/html5-qrcode.min.js"></script>
9
+ <style>
10
+ * { box-sizing: border-box; margin: 0; padding: 0; }
11
+
12
+ body {
13
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
14
+ background: #0f1117;
15
+ color: #e1e4e8;
16
+ min-height: 100vh;
17
+ display: flex;
18
+ flex-direction: column;
19
+ align-items: center;
20
+ }
21
+
22
+ header {
23
+ text-align: center;
24
+ padding: 2rem 1rem 1rem;
25
+ }
26
+
27
+ header h1 {
28
+ font-size: 1.5rem;
29
+ font-weight: 600;
30
+ color: #f0f0f0;
31
+ }
32
+
33
+ header p {
34
+ font-size: 0.85rem;
35
+ color: #8b949e;
36
+ margin-top: 0.25rem;
37
+ }
38
+
39
+ .tabs {
40
+ display: flex;
41
+ gap: 0;
42
+ margin: 1rem 0;
43
+ border-radius: 8px;
44
+ overflow: hidden;
45
+ border: 1px solid #30363d;
46
+ }
47
+
48
+ .tab-btn {
49
+ padding: 0.6rem 2rem;
50
+ background: #161b22;
51
+ color: #8b949e;
52
+ border: none;
53
+ cursor: pointer;
54
+ font-size: 0.95rem;
55
+ font-weight: 500;
56
+ transition: all 0.2s;
57
+ }
58
+
59
+ .tab-btn.active {
60
+ background: #238636;
61
+ color: #fff;
62
+ }
63
+
64
+ .tab-btn:hover:not(.active) {
65
+ background: #1c2129;
66
+ color: #c9d1d9;
67
+ }
68
+
69
+ .panel {
70
+ display: none;
71
+ width: 100%;
72
+ max-width: 480px;
73
+ padding: 0 1rem 2rem;
74
+ }
75
+
76
+ .panel.active { display: block; }
77
+
78
+ .card {
79
+ background: #161b22;
80
+ border: 1px solid #30363d;
81
+ border-radius: 10px;
82
+ padding: 1.5rem;
83
+ margin-bottom: 1rem;
84
+ }
85
+
86
+ label {
87
+ display: block;
88
+ font-size: 0.8rem;
89
+ color: #8b949e;
90
+ margin-bottom: 0.4rem;
91
+ font-weight: 500;
92
+ text-transform: uppercase;
93
+ letter-spacing: 0.5px;
94
+ }
95
+
96
+ input[type="text"],
97
+ input[type="password"],
98
+ textarea {
99
+ width: 100%;
100
+ padding: 0.65rem 0.8rem;
101
+ background: #0d1117;
102
+ border: 1px solid #30363d;
103
+ border-radius: 6px;
104
+ color: #e1e4e8;
105
+ font-size: 0.95rem;
106
+ font-family: inherit;
107
+ margin-bottom: 1rem;
108
+ transition: border-color 0.2s;
109
+ }
110
+
111
+ input:focus, textarea:focus {
112
+ outline: none;
113
+ border-color: #238636;
114
+ }
115
+
116
+ textarea { resize: vertical; min-height: 80px; }
117
+
118
+ button.primary {
119
+ width: 100%;
120
+ padding: 0.7rem;
121
+ background: #238636;
122
+ color: #fff;
123
+ border: none;
124
+ border-radius: 6px;
125
+ font-size: 0.95rem;
126
+ font-weight: 500;
127
+ cursor: pointer;
128
+ transition: background 0.2s;
129
+ }
130
+
131
+ button.primary:hover { background: #2ea043; }
132
+ button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
133
+
134
+ button.secondary {
135
+ width: 100%;
136
+ padding: 0.7rem;
137
+ background: #21262d;
138
+ color: #c9d1d9;
139
+ border: 1px solid #30363d;
140
+ border-radius: 6px;
141
+ font-size: 0.95rem;
142
+ font-weight: 500;
143
+ cursor: pointer;
144
+ transition: background 0.2s;
145
+ }
146
+
147
+ button.secondary:hover { background: #30363d; }
148
+
149
+ #qr-output {
150
+ text-align: center;
151
+ margin-top: 1rem;
152
+ }
153
+
154
+ #qr-output canvas {
155
+ border-radius: 8px;
156
+ max-width: 100%;
157
+ }
158
+
159
+ #scanner-region {
160
+ width: 100%;
161
+ border-radius: 8px;
162
+ overflow: hidden;
163
+ }
164
+
165
+ #scanner-region video { border-radius: 8px; }
166
+
167
+ .result-box {
168
+ display: none;
169
+ margin-top: 1rem;
170
+ padding: 1rem;
171
+ background: #0d1117;
172
+ border: 1px solid #238636;
173
+ border-radius: 8px;
174
+ word-break: break-all;
175
+ }
176
+
177
+ .result-box .label {
178
+ font-size: 0.75rem;
179
+ color: #238636;
180
+ text-transform: uppercase;
181
+ letter-spacing: 0.5px;
182
+ margin-bottom: 0.4rem;
183
+ }
184
+
185
+ .result-box .value {
186
+ font-family: "SF Mono", "Fira Code", monospace;
187
+ font-size: 0.95rem;
188
+ color: #f0f0f0;
189
+ user-select: all;
190
+ }
191
+
192
+ .copy-btn {
193
+ margin-top: 0.6rem;
194
+ padding: 0.4rem 0.8rem;
195
+ background: #21262d;
196
+ color: #c9d1d9;
197
+ border: 1px solid #30363d;
198
+ border-radius: 4px;
199
+ font-size: 0.8rem;
200
+ cursor: pointer;
201
+ }
202
+
203
+ .copy-btn:hover { background: #30363d; }
204
+
205
+ .error {
206
+ color: #f85149;
207
+ font-size: 0.85rem;
208
+ margin-top: 0.5rem;
209
+ }
210
+
211
+ .info {
212
+ color: #8b949e;
213
+ font-size: 0.8rem;
214
+ margin-top: 0.5rem;
215
+ text-align: center;
216
+ }
217
+
218
+ .toggle-vis {
219
+ position: absolute;
220
+ right: 10px;
221
+ top: 50%;
222
+ transform: translateY(-50%);
223
+ background: none;
224
+ border: none;
225
+ color: #8b949e;
226
+ cursor: pointer;
227
+ font-size: 0.8rem;
228
+ padding: 0.2rem 0.4rem;
229
+ }
230
+
231
+ .input-wrap {
232
+ position: relative;
233
+ margin-bottom: 1rem;
234
+ }
235
+
236
+ .input-wrap input { margin-bottom: 0; padding-right: 3.5rem; }
237
+
238
+ .btn-row {
239
+ display: flex;
240
+ gap: 0.5rem;
241
+ margin-top: 0.5rem;
242
+ }
243
+
244
+ .btn-row button { flex: 1; }
245
+ </style>
246
+ </head>
247
+ <body>
248
+ <header>
249
+ <h1>QR Secure Send</h1>
250
+ <p>Encrypt and transfer secrets via QR code</p>
251
+ </header>
252
+
253
+ <div class="tabs">
254
+ <button class="tab-btn active" data-tab="send">Send</button>
255
+ <button class="tab-btn" data-tab="receive">Receive</button>
256
+ </div>
257
+
258
+ <!-- SEND PANEL -->
259
+ <div id="send" class="panel active">
260
+ <div class="card">
261
+ <label for="secret">Secret / Password</label>
262
+ <div class="input-wrap">
263
+ <input type="password" id="secret" placeholder="Enter your secret..." autocomplete="off">
264
+ <button class="toggle-vis" data-target="secret">show</button>
265
+ </div>
266
+
267
+ <label for="send-passphrase">Encryption Passphrase</label>
268
+ <div class="input-wrap">
269
+ <input type="password" id="send-passphrase" placeholder="Shared passphrase..." autocomplete="off">
270
+ <button class="toggle-vis" data-target="send-passphrase">show</button>
271
+ </div>
272
+
273
+ <button class="primary" id="generate-btn">Generate QR Code</button>
274
+ <div id="send-error" class="error"></div>
275
+ </div>
276
+
277
+ <div id="qr-output"></div>
278
+ <p id="qr-info" class="info" style="display:none">
279
+ Show this QR code to the receiving device's camera.
280
+ </p>
281
+ </div>
282
+
283
+ <!-- RECEIVE PANEL -->
284
+ <div id="receive" class="panel">
285
+ <div class="card">
286
+ <label for="recv-passphrase">Decryption Passphrase</label>
287
+ <div class="input-wrap">
288
+ <input type="password" id="recv-passphrase" placeholder="Same passphrase used to encrypt..." autocomplete="off">
289
+ <button class="toggle-vis" data-target="recv-passphrase">show</button>
290
+ </div>
291
+
292
+ <div class="btn-row">
293
+ <button class="primary" id="scan-btn">Start Camera</button>
294
+ <button class="secondary" id="stop-btn" style="display:none">Stop</button>
295
+ </div>
296
+ <div id="recv-error" class="error"></div>
297
+ </div>
298
+
299
+ <div id="scanner-region"></div>
300
+
301
+ <div id="recv-result" class="result-box">
302
+ <div class="label">Decrypted Secret</div>
303
+ <div class="value" id="recv-value"></div>
304
+ <button class="copy-btn" id="copy-btn">Copy to clipboard</button>
305
+ </div>
306
+ </div>
307
+
308
+ <script>
309
+ // --- Crypto helpers using Web Crypto API (AES-256-GCM + PBKDF2) ---
310
+
311
+ async function deriveKey(passphrase, salt) {
312
+ const enc = new TextEncoder();
313
+ const keyMaterial = await crypto.subtle.importKey(
314
+ "raw", enc.encode(passphrase), "PBKDF2", false, ["deriveKey"]
315
+ );
316
+ return crypto.subtle.deriveKey(
317
+ { name: "PBKDF2", salt, iterations: 310000, hash: "SHA-256" },
318
+ keyMaterial,
319
+ { name: "AES-GCM", length: 256 },
320
+ false,
321
+ ["encrypt", "decrypt"]
322
+ );
323
+ }
324
+
325
+ async function encryptSecret(secret, passphrase) {
326
+ const enc = new TextEncoder();
327
+ const salt = crypto.getRandomValues(new Uint8Array(16));
328
+ const iv = crypto.getRandomValues(new Uint8Array(12));
329
+ const key = await deriveKey(passphrase, salt);
330
+ const ciphertext = await crypto.subtle.encrypt(
331
+ { name: "AES-GCM", iv },
332
+ key,
333
+ enc.encode(secret)
334
+ );
335
+ // Pack: salt (16) + iv (12) + ciphertext, then base64
336
+ const packed = new Uint8Array(salt.length + iv.length + new Uint8Array(ciphertext).length);
337
+ packed.set(salt, 0);
338
+ packed.set(iv, salt.length);
339
+ packed.set(new Uint8Array(ciphertext), salt.length + iv.length);
340
+ return btoa(String.fromCharCode(...packed));
341
+ }
342
+
343
+ async function decryptSecret(encoded, passphrase) {
344
+ const raw = Uint8Array.from(atob(encoded), c => c.charCodeAt(0));
345
+ const salt = raw.slice(0, 16);
346
+ const iv = raw.slice(16, 28);
347
+ const ciphertext = raw.slice(28);
348
+ const key = await deriveKey(passphrase, salt);
349
+ const dec = new TextDecoder();
350
+ const plaintext = await crypto.subtle.decrypt(
351
+ { name: "AES-GCM", iv },
352
+ key,
353
+ ciphertext
354
+ );
355
+ return dec.decode(plaintext);
356
+ }
357
+
358
+ // --- Tab switching ---
359
+
360
+ const tabBtns = document.querySelectorAll(".tab-btn");
361
+ const panels = document.querySelectorAll(".panel");
362
+
363
+ tabBtns.forEach(btn => {
364
+ btn.addEventListener("click", () => {
365
+ tabBtns.forEach(b => b.classList.remove("active"));
366
+ panels.forEach(p => p.classList.remove("active"));
367
+ btn.classList.add("active");
368
+ document.getElementById(btn.dataset.tab).classList.add("active");
369
+ // Stop scanner when switching away
370
+ if (btn.dataset.tab !== "receive" && scanner) {
371
+ stopScanner();
372
+ }
373
+ });
374
+ });
375
+
376
+ // --- Show/hide toggle ---
377
+
378
+ document.querySelectorAll(".toggle-vis").forEach(btn => {
379
+ btn.addEventListener("click", () => {
380
+ const input = document.getElementById(btn.dataset.target);
381
+ if (input.type === "password") {
382
+ input.type = "text";
383
+ btn.textContent = "hide";
384
+ } else {
385
+ input.type = "password";
386
+ btn.textContent = "show";
387
+ }
388
+ });
389
+ });
390
+
391
+ // --- QR Generation ---
392
+
393
+ document.getElementById("generate-btn").addEventListener("click", async () => {
394
+ const secret = document.getElementById("secret").value.trim();
395
+ const passphrase = document.getElementById("send-passphrase").value;
396
+ const errEl = document.getElementById("send-error");
397
+ const output = document.getElementById("qr-output");
398
+ const info = document.getElementById("qr-info");
399
+
400
+ errEl.textContent = "";
401
+ output.innerHTML = "";
402
+ info.style.display = "none";
403
+
404
+ if (!secret) { errEl.textContent = "Please enter a secret."; return; }
405
+ if (!passphrase) { errEl.textContent = "Please enter a passphrase."; return; }
406
+
407
+ try {
408
+ const encrypted = await encryptSecret(secret, passphrase);
409
+ const payload = "QRSEC:" + encrypted;
410
+
411
+ if (payload.length > 2953) {
412
+ errEl.textContent = "Secret is too long for a single QR code. Keep it under ~2000 characters.";
413
+ return;
414
+ }
415
+
416
+ await QRCode.toCanvas(output, payload, {
417
+ width: 320,
418
+ margin: 2,
419
+ color: { dark: "#000000", light: "#ffffff" },
420
+ errorCorrectionLevel: "M"
421
+ });
422
+
423
+ // Move the canvas out of any extra wrapper
424
+ const canvas = output.querySelector("canvas");
425
+ if (canvas) {
426
+ output.innerHTML = "";
427
+ output.appendChild(canvas);
428
+ }
429
+
430
+ info.style.display = "block";
431
+ } catch (e) {
432
+ errEl.textContent = "Failed to generate QR code: " + e.message;
433
+ }
434
+ });
435
+
436
+ // --- QR Scanner ---
437
+
438
+ let scanner = null;
439
+
440
+ async function startScanner() {
441
+ const passphrase = document.getElementById("recv-passphrase").value;
442
+ const errEl = document.getElementById("recv-error");
443
+ const resultBox = document.getElementById("recv-result");
444
+
445
+ errEl.textContent = "";
446
+ resultBox.style.display = "none";
447
+
448
+ if (!passphrase) {
449
+ errEl.textContent = "Enter the decryption passphrase first.";
450
+ return;
451
+ }
452
+
453
+ document.getElementById("scan-btn").style.display = "none";
454
+ document.getElementById("stop-btn").style.display = "block";
455
+
456
+ scanner = new Html5Qrcode("scanner-region");
457
+
458
+ try {
459
+ await scanner.start(
460
+ { facingMode: "environment" },
461
+ { fps: 10, qrbox: { width: 250, height: 250 } },
462
+ async (decodedText) => {
463
+ if (!decodedText.startsWith("QRSEC:")) {
464
+ errEl.textContent = "Not a QR Secure Send code.";
465
+ return;
466
+ }
467
+
468
+ try {
469
+ const encrypted = decodedText.slice(6);
470
+ const secret = await decryptSecret(encrypted, passphrase);
471
+
472
+ document.getElementById("recv-value").textContent = secret;
473
+ resultBox.style.display = "block";
474
+ errEl.textContent = "";
475
+ stopScanner();
476
+ } catch (e) {
477
+ errEl.textContent = "Decryption failed. Wrong passphrase?";
478
+ }
479
+ },
480
+ () => {} // ignore scan failures (no QR in frame)
481
+ );
482
+ } catch (e) {
483
+ errEl.textContent = "Camera error: " + e.message;
484
+ document.getElementById("scan-btn").style.display = "block";
485
+ document.getElementById("stop-btn").style.display = "none";
486
+ scanner = null;
487
+ }
488
+ }
489
+
490
+ async function stopScanner() {
491
+ if (scanner) {
492
+ try { await scanner.stop(); } catch (_) {}
493
+ scanner = null;
494
+ }
495
+ document.getElementById("scanner-region").innerHTML = "";
496
+ document.getElementById("scan-btn").style.display = "block";
497
+ document.getElementById("stop-btn").style.display = "none";
498
+ }
499
+
500
+ document.getElementById("scan-btn").addEventListener("click", startScanner);
501
+ document.getElementById("stop-btn").addEventListener("click", stopScanner);
502
+
503
+ // --- Copy to clipboard ---
504
+
505
+ document.getElementById("copy-btn").addEventListener("click", async () => {
506
+ const value = document.getElementById("recv-value").textContent;
507
+ try {
508
+ await navigator.clipboard.writeText(value);
509
+ document.getElementById("copy-btn").textContent = "Copied!";
510
+ setTimeout(() => {
511
+ document.getElementById("copy-btn").textContent = "Copy to clipboard";
512
+ }, 2000);
513
+ } catch (_) {
514
+ // Fallback
515
+ const ta = document.createElement("textarea");
516
+ ta.value = value;
517
+ document.body.appendChild(ta);
518
+ ta.select();
519
+ document.execCommand("copy");
520
+ document.body.removeChild(ta);
521
+ document.getElementById("copy-btn").textContent = "Copied!";
522
+ setTimeout(() => {
523
+ document.getElementById("copy-btn").textContent = "Copy to clipboard";
524
+ }, 2000);
525
+ }
526
+ });
527
+ </script>
528
+ </body>
529
+ </html>
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "qr-secure-send",
3
+ "version": "1.0.0",
4
+ "description": "Encrypt and transfer secrets via QR code",
5
+ "keywords": ["qr", "qrcode", "encryption", "password", "secure", "transfer"],
6
+ "author": "",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/degenddy/qr-secure-send.git"
11
+ },
12
+ "scripts": {
13
+ "start": "npx serve -l 3000"
14
+ }
15
+ }