@seaveyon/harness-switch 0.16.0 → 0.16.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/README.md CHANGED
@@ -90,7 +90,7 @@ Use **Import / Export** in the top bar to create one `.hsw-backup` file containi
90
90
 
91
91
  On the destination machine, select the bundle and enter the migration password. The UI shows profile counts and same-name conflicts before it writes anything. Import keeps destination profiles by default; overwriting is an explicit choice. Restoring the exported activation state is optional.
92
92
 
93
- A Codex official-login cache (`$CODEX_HOME/auth.json`) is **excluded by default**. When a valid cache is available, you may explicitly include it in the encrypted bundle and then make a second explicit choice to write it on the destination. This carries a reusable Codex/ChatGPT login session: share such a bundle only with a trusted recipient, and expect upstream expiry or revocation to still require a fresh `codex login`. An existing destination cache is backed up before replacement; copied caches are written as the destination user with mode `0600`.
93
+ A Codex official-login cache (`$CODEX_HOME/auth.json`) is **excluded by default**. When a valid cache is available, you may explicitly include it in the encrypted bundle. Import offers the separate migration choice only when the bundled and destination JSON values differ. This carries a reusable Codex/ChatGPT login session: share such a bundle only with a trusted recipient, and expect upstream expiry or revocation to still require a fresh `codex login`. An existing destination cache is backed up before replacement; copied caches are written as the destination user with mode `0600`.
94
94
 
95
95
  Keep the migration password separately from the bundle. It cannot be recovered from the export file.
96
96
 
@@ -130,7 +130,7 @@ The dashboard header can switch between local login users such as `root` and `al
130
130
 
131
131
  “Sync user config” performs a one-time copy of another user's profiles and referenced Provider Vault credentials into the selected user. Secrets are decrypted only on the server and re-encrypted with the destination user's local key. Active state, backups and native config files are not copied. Same-name profiles are skipped by default and can be explicitly overwritten.
132
132
 
133
- A source user's Codex official-login cache (`auth.json`) is the sole optional exception: it remains unchecked by default and requires an irreversible confirmation that identifies the source and destination users. Choose it only when the destination user is allowed to use that login session. The previous destination cache is backed up, and the replacement is destination-owned with mode `0600`; source ownership and permissions are never copied.
133
+ A source user's Codex official-login cache (`auth.json`) is the sole optional exception. The migration choice appears only when the source and destination JSON values differ; it remains unchecked by default and requires an irreversible confirmation that identifies both users. Choose it only when the destination user is allowed to use that login session. The previous destination cache is backed up, and the replacement is destination-owned with mode `0600`; source ownership and permissions are never copied.
134
134
 
135
135
  Cross-user writes require access to the destination home. Managing both `root` and regular users therefore normally requires running harness-switch as root; newly created files and directories are assigned to the destination UID/GID. The Web password then grants control over every exposed user's configs, so keep the loopback bind and SSH tunnel. Use `HSW_USERS=root,alice` to restrict the manageable accounts.
136
136
 
@@ -13625,6 +13625,7 @@ import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv
13625
13625
  // src/services/codex-login-cache.ts
13626
13626
  import { lstatSync } from "fs";
13627
13627
  import { join as join11 } from "path";
13628
+ import { isDeepStrictEqual } from "util";
13628
13629
  var AUTH_FILE = "auth.json";
13629
13630
  var MAX_CACHE_BYTES = 1024 * 1024;
13630
13631
  var ICodexLoginCacheService = createDecorator("codexLoginCacheService");
@@ -13658,6 +13659,11 @@ class CodexLoginCacheService {
13658
13659
  this.validate(content);
13659
13660
  return content;
13660
13661
  }
13662
+ matchesCurrent(content) {
13663
+ this.validate(content);
13664
+ const current = this.readOptional();
13665
+ return current !== undefined && isDeepStrictEqual(JSON.parse(content), JSON.parse(current));
13666
+ }
13661
13667
  validate(content) {
13662
13668
  if (Buffer.byteLength(content, "utf8") > MAX_CACHE_BYTES) {
13663
13669
  throw new HttpError(400, "Codex \u767B\u5F55\u7F13\u5B58\u8FC7\u5927\uFF0C\u62D2\u7EDD\u8FC1\u79FB");
@@ -13812,6 +13818,7 @@ class TransferService {
13812
13818
  const payload = this.decrypt(envelope, passphrase);
13813
13819
  const existing = this.readStore();
13814
13820
  const plan = this.planImport(payload, existing, conflictPolicy, restoreActive);
13821
+ const targetCodexLoginCacheExists = this.codexLoginCache.exists();
13815
13822
  return {
13816
13823
  exportedAt: payload.exportedAt,
13817
13824
  profileCount: payload.profiles.length,
@@ -13826,7 +13833,8 @@ class TransferService {
13826
13833
  codexActivationAuthEffect: plan.codexActivationAuthEffect,
13827
13834
  codexLoginCache: {
13828
13835
  available: payload.codexLoginCache !== undefined,
13829
- targetExists: this.codexLoginCache.exists()
13836
+ targetExists: targetCodexLoginCacheExists,
13837
+ migrationNeeded: payload.codexLoginCache !== undefined && !this.codexLoginCache.matchesCurrent(payload.codexLoginCache)
13830
13838
  }
13831
13839
  };
13832
13840
  }
@@ -13836,7 +13844,7 @@ class TransferService {
13836
13844
  if (migrateCodexLoginCache && payload.codexLoginCache === undefined) {
13837
13845
  throw new HttpError(400, "\u5BFC\u51FA\u5305\u4E0D\u5305\u542B\u53EF\u8FC1\u79FB\u7684 Codex \u767B\u5F55\u7F13\u5B58");
13838
13846
  }
13839
- const cacheWrite = migrateCodexLoginCache ? [
13847
+ const cacheWrite = migrateCodexLoginCache && !this.codexLoginCache.matchesCurrent(payload.codexLoginCache) ? [
13840
13848
  {
13841
13849
  ...this.codexLoginCache.prepareWrite(payload.codexLoginCache),
13842
13850
  format: "json",
@@ -14142,7 +14150,7 @@ function createUpdateRoutes(_services) {
14142
14150
  }
14143
14151
 
14144
14152
  // src/services/user-sync.ts
14145
- import { isDeepStrictEqual } from "util";
14153
+ import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
14146
14154
  var IUserSyncService = createDecorator("userSyncService");
14147
14155
  var _dec = [
14148
14156
  inject(IEnvironmentService, IUserService, IFileService, ICryptoService, ICodexLoginCacheService, ILiveWriteService, IActivationService)
@@ -14171,6 +14179,8 @@ class UserSyncService {
14171
14179
  const source = this.requireSource(sourceUsername, target);
14172
14180
  const portable = this.readPortable(source);
14173
14181
  const targetPortable = this.readPortable(target);
14182
+ const sourceCodexLoginCache = this.environment.runAsUser(source, () => this.codexLoginCache.readOptional());
14183
+ const targetCodexLoginCacheExists = this.codexLoginCache.exists();
14174
14184
  const conflicts = [];
14175
14185
  let profileCount = 0;
14176
14186
  const referencedProviders = new Set;
@@ -14192,8 +14202,9 @@ class UserSyncService {
14192
14202
  providerCount: referencedProviders.size,
14193
14203
  conflicts,
14194
14204
  codexLoginCache: {
14195
- available: this.environment.runAsUser(source, () => this.codexLoginCache.exists()),
14196
- targetExists: this.codexLoginCache.exists()
14205
+ available: sourceCodexLoginCache !== undefined,
14206
+ targetExists: targetCodexLoginCacheExists,
14207
+ migrationNeeded: sourceCodexLoginCache !== undefined && !this.codexLoginCache.matchesCurrent(sourceCodexLoginCache)
14197
14208
  }
14198
14209
  };
14199
14210
  }
@@ -14211,7 +14222,7 @@ class UserSyncService {
14211
14222
  if (migrateCodexLoginCache && cacheContent === undefined) {
14212
14223
  throw new HttpError(400, "\u6765\u6E90\u7528\u6237\u6CA1\u6709\u53EF\u8FC1\u79FB\u7684 Codex \u767B\u5F55\u7F13\u5B58");
14213
14224
  }
14214
- const cacheWrite = cacheContent ? [
14225
+ const cacheWrite = cacheContent && !this.codexLoginCache.matchesCurrent(cacheContent) ? [
14215
14226
  {
14216
14227
  ...this.codexLoginCache.prepareWrite(cacheContent),
14217
14228
  format: "json",
@@ -14349,7 +14360,7 @@ class UserSyncService {
14349
14360
  return this.files.readJsonStrict(this.environment.files.profiles, {});
14350
14361
  }
14351
14362
  profilesEqual(source, sourceProviders, target, targetProviders) {
14352
- return isDeepStrictEqual(this.comparableProfile(source, sourceProviders), this.comparableProfile(target, targetProviders));
14363
+ return isDeepStrictEqual2(this.comparableProfile(source, sourceProviders), this.comparableProfile(target, targetProviders));
14353
14364
  }
14354
14365
  comparableProfile(profile, providers) {
14355
14366
  const { updated_at: _updatedAt, provider_id: providerId, ...content } = profile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seaveyon/harness-switch",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "A secure web control plane that switches API providers for Claude Code, Codex, Kimi Code, Pi and DeepSeek Harness by writing their native config files on SSH servers.",
5
5
  "keywords": [
6
6
  "claude-code",