@walldock/agent 0.2.3 → 0.2.5

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/dist/auth.js CHANGED
@@ -134,8 +134,15 @@ async function validateStoredToken(api) {
134
134
  }
135
135
  return { token, deviceId: v.deviceId, deviceName: v.deviceName };
136
136
  }
137
- catch {
138
- // Network error try cached identity for offline start
137
+ catch (err) {
138
+ // Auth errors mean the token is genuinely invalid — clear it and re-pair
139
+ const msg = err instanceof Error ? err.message.toLowerCase() : '';
140
+ if (msg.includes('invalid device token') || msg.includes('http 401') || msg.includes('http 403')) {
141
+ await storage.deleteDeviceToken();
142
+ await storage.clearDeviceIdentity();
143
+ return null;
144
+ }
145
+ // Genuine network error (offline, timeout) — start offline with cached identity
139
146
  const cached = await storage.getDeviceIdentity();
140
147
  if (cached)
141
148
  return { token, ...cached };
package/dist/main.js CHANGED
@@ -100,6 +100,23 @@ async function main() {
100
100
  }
101
101
  console.log('Device unlinked. Starting pairing…\n');
102
102
  }
103
+ // --register-startup: (re-)register the startup entry without going through pairing
104
+ if (args.includes('--register-startup')) {
105
+ const globalBin = await (0, startup_1.getGlobalBin)();
106
+ if (!globalBin) {
107
+ console.error('walldock-agent is not globally installed. Run: npm install -g @walldock/agent');
108
+ process.exit(1);
109
+ }
110
+ try {
111
+ await (0, startup_1.registerStartup)();
112
+ console.log(`✓ Registered for startup (${(0, startup_1.startupDescription)()})`);
113
+ }
114
+ catch (err) {
115
+ console.error(`Failed to register startup: ${err}`);
116
+ process.exit(1);
117
+ }
118
+ return;
119
+ }
103
120
  // --status: print current link status
104
121
  if (args.includes('--status')) {
105
122
  const identity = await storage.getDeviceIdentity();
package/dist/startup.js CHANGED
@@ -110,13 +110,22 @@ async function unregisterMacOS() {
110
110
  // ─── Windows ─────────────────────────────────────────────────────────────────
111
111
  const REG_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
112
112
  const REG_VALUE = 'WalldockAgent';
113
+ // VBScript launcher: runs walldock-agent.cmd silently (windowStyle=0 = hidden).
114
+ // Stored in %APPDATA%\walldock\ so it survives package updates — the .cmd
115
+ // wrapper always resolves to whichever version is currently installed.
116
+ const VBS_PATH = path.join(process.env['APPDATA'] ?? os.homedir(), 'walldock', 'launch-agent.vbs');
113
117
  async function registerWindows() {
114
118
  const binPath = await resolveGlobalBin();
115
- const cmd = `"${binPath}" --tray`;
116
- await exec('reg', ['add', REG_KEY, '/v', REG_VALUE, '/t', 'REG_SZ', '/d', cmd, '/f']);
119
+ await fs.mkdir(path.dirname(VBS_PATH), { recursive: true });
120
+ // windowStyle=0 = hidden, WaitOnReturn=False
121
+ await fs.writeFile(VBS_PATH, `CreateObject("WScript.Shell").Run """${binPath}"" --tray", 0, False\n`, 'utf8');
122
+ const wscript = path.join(process.env['SystemRoot'] ?? 'C:\\Windows', 'System32', 'wscript.exe');
123
+ const cmd = `"${wscript}" "${VBS_PATH}"`;
124
+ await exec('reg', ['add', REG_KEY, '/v', REG_VALUE, '/t', 'REG_SZ', '/d', cmd, '/f'], { windowsHide: true, encoding: 'utf8' });
117
125
  }
118
126
  async function unregisterWindows() {
119
- await exec('reg', ['delete', REG_KEY, '/v', REG_VALUE, '/f']).catch(() => undefined);
127
+ await exec('reg', ['delete', REG_KEY, '/v', REG_VALUE, '/f'], { windowsHide: true, encoding: 'utf8' }).catch(() => undefined);
128
+ await fs.unlink(VBS_PATH).catch(() => undefined);
120
129
  }
121
130
  // ─── Linux ───────────────────────────────────────────────────────────────────
122
131
  const SYSTEMD_USER_DIR = path.join(os.homedir(), '.config', 'systemd', 'user');
@@ -195,7 +204,7 @@ function startupDescription() {
195
204
  if (process.platform === 'darwin')
196
205
  return `LaunchAgent at ${PLIST_PATH}`;
197
206
  if (process.platform === 'win32')
198
- return `Registry: ${REG_KEY}\\${REG_VALUE}`;
207
+ return `Registry Run key → wscript launcher at ${VBS_PATH}`;
199
208
  return `systemd user service (or ${DESKTOP_PATH})`;
200
209
  }
201
210
  /** Returns the resolved global bin path, or null if not globally installed. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walldock/agent",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Walldock desktop agent — sync wallpapers across all your screens",
5
5
  "license": "MIT",
6
6
  "main": "dist/main.js",