p2p-envsync 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,16 +1,34 @@
1
1
  {
2
2
  "name": "p2p-envsync",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "P2P encrypted .env sync for dev teams — LAN-first, offline-first, zero server",
5
- "keywords": ["env", "dotenv", "sync", "p2p", "encrypted", "secrets", "team", "developer-tools"],
5
+ "keywords": [
6
+ "env",
7
+ "dotenv",
8
+ "sync",
9
+ "p2p",
10
+ "encrypted",
11
+ "secrets",
12
+ "team",
13
+ "developer-tools"
14
+ ],
6
15
  "author": "RismanRJ",
7
16
  "license": "MIT",
8
17
  "type": "commonjs",
9
18
  "bin": {
10
19
  "envsync": "./cli.js"
11
20
  },
12
- "main": "tray/main.js",
13
- "files": ["lib.js", "cli.js", "net.js", "backup.js", "notify.js", "mesh.js", "signal.js", "tray/", "LICENSE"],
21
+ "files": [
22
+ "lib.js",
23
+ "cli.js",
24
+ "net.js",
25
+ "backup.js",
26
+ "notify.js",
27
+ "mesh.js",
28
+ "signal.js",
29
+ "tray/",
30
+ "LICENSE"
31
+ ],
14
32
  "scripts": {
15
33
  "test": "node --test test/",
16
34
  "tray": "electron ."
package/tray/launch.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawn } = require('child_process');
5
+ const path = require('path');
6
+
7
+ let electronPath;
8
+ try {
9
+ electronPath = require('electron');
10
+ } catch {
11
+ console.error('Electron not found. Install the tray package: npm install -g p2p-envsync-tray');
12
+ process.exit(1);
13
+ }
14
+
15
+ const appPath = path.join(__dirname, 'main.js');
16
+ const child = spawn(electronPath, [appPath], { stdio: 'inherit' });
17
+ child.on('exit', (code) => process.exit(code || 0));
package/tray/main.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // Sync/Review/Reveal actions, plus Create/Join Room. No renderer/window
5
5
  // needed -- Tray + native Menu + dialog + osascript prompts cover it.
6
6
 
7
- const { app, Tray, Menu, nativeImage, dialog } = require('electron');
7
+ const { app, Tray, Menu, nativeImage, dialog, BrowserWindow } = require('electron');
8
8
  const { spawn, execFileSync } = require('child_process');
9
9
  const path = require('path');
10
10
  const lib = require('../lib');
@@ -102,6 +102,26 @@ function joinRoomFlow(refresh) {
102
102
  refresh();
103
103
  }
104
104
 
105
+ function showScrollableWindow(title, lines, onUnmask) {
106
+ const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
107
+ const unmaskBtn = onUnmask ? `<button onclick="require('electron').ipcRenderer.send('unmask')" style="margin-top:12px;padding:6px 16px;cursor:pointer">Unmask</button>` : '';
108
+ const html = `<html><head><title>${esc(title)}</title><style>
109
+ body{font-family:monospace;font-size:13px;padding:16px;margin:0;background:#1e1e1e;color:#d4d4d4;word-break:break-all}
110
+ pre{white-space:pre-wrap;margin:0}
111
+ button{background:#333;color:#d4d4d4;border:1px solid #555;border-radius:4px;font-size:13px}
112
+ button:hover{background:#444}
113
+ </style></head><body><pre>${lines.map(esc).join('\n') || '(empty)'}</pre>${unmaskBtn}</body></html>`;
114
+ const win = new BrowserWindow({ width: 620, height: 500, title, webPreferences: { nodeIntegration: true, contextIsolation: false } });
115
+ win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`);
116
+ win.setMenuBarVisibility(false);
117
+ if (onUnmask) {
118
+ const { ipcMain } = require('electron');
119
+ const handler = () => { win.close(); onUnmask(); };
120
+ ipcMain.once('unmask', handler);
121
+ win.on('closed', () => ipcMain.removeListener('unmask', handler));
122
+ }
123
+ }
124
+
105
125
  function showDiff(name, reveal) {
106
126
  const history = lib.readHistory(name);
107
127
  if (!history.length) {
@@ -117,10 +137,7 @@ function showDiff(name, reveal) {
117
137
  if (reveal) {
118
138
  lib.appendHistory(name, { ts: Date.now(), values: last.values, diff: {}, reveal: Object.keys(last.diff) });
119
139
  }
120
- dialog.showMessageBox({
121
- title: `${name} -- last change ${new Date(last.ts).toISOString()}`,
122
- message: lines.join('\n') || '(no changes)',
123
- });
140
+ showScrollableWindow(`${name} -- last change ${new Date(last.ts).toISOString()}`, lines);
124
141
  }
125
142
 
126
143
  function showPreview(name, reveal) {
@@ -130,13 +147,11 @@ function showPreview(name, reveal) {
130
147
  if (reveal) {
131
148
  lib.appendHistory(name, { ts: Date.now(), values, diff: {}, reveal: keys });
132
149
  }
133
- dialog.showMessageBox({
134
- title: `${name} -- current values${reveal ? ' (revealed)' : ' (masked)'}`,
135
- message: lines.join('\n') || '(no values tracked yet)',
136
- buttons: reveal ? ['Close'] : ['Close', 'Unmask'],
137
- }).then((res) => {
138
- if (!reveal && res.response === 1) showPreview(name, true);
139
- });
150
+ showScrollableWindow(
151
+ `${name} -- current values${reveal ? ' (revealed)' : ' (masked)'}`,
152
+ lines,
153
+ reveal ? null : () => showPreview(name, true),
154
+ );
140
155
  }
141
156
 
142
157
  // Electron's main process has no controlling terminal, so `gh auth login`