@hasna/accounts 0.1.13 → 0.1.14

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/cli.js CHANGED
@@ -42835,6 +42835,22 @@ function readKeychainAccount() {
42835
42835
  return;
42836
42836
  }
42837
42837
  }
42838
+ function bufferText(value) {
42839
+ if (typeof value === "string")
42840
+ return value;
42841
+ if (value instanceof Uint8Array)
42842
+ return new TextDecoder().decode(value);
42843
+ return;
42844
+ }
42845
+ function keychainWriteFailureMessage(err) {
42846
+ const record = err && typeof err === "object" ? err : {};
42847
+ const stderr = bufferText(record.stderr);
42848
+ const stdout = bufferText(record.stdout);
42849
+ const detail = (stderr || stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).at(-1);
42850
+ if (detail)
42851
+ return detail;
42852
+ return typeof record.status === "number" ? `security exited with status ${record.status}` : "security command failed";
42853
+ }
42838
42854
  function writeClaudeKeychain(cred) {
42839
42855
  if (!keychainSupported()) {
42840
42856
  throw new AccountsError("macOS keychain is only available on darwin");
@@ -42848,7 +42864,7 @@ function writeClaudeKeychain(cred) {
42848
42864
  stdio: ["ignore", "pipe", "pipe"]
42849
42865
  });
42850
42866
  } catch (err) {
42851
- throw new AccountsError(`keychain write failed: ${err.message}`);
42867
+ throw new AccountsError(`keychain write failed: ${keychainWriteFailureMessage(err)}`);
42852
42868
  }
42853
42869
  }
42854
42870
 
package/dist/index.js CHANGED
@@ -4481,6 +4481,22 @@ function readKeychainAccount() {
4481
4481
  return;
4482
4482
  }
4483
4483
  }
4484
+ function bufferText(value) {
4485
+ if (typeof value === "string")
4486
+ return value;
4487
+ if (value instanceof Uint8Array)
4488
+ return new TextDecoder().decode(value);
4489
+ return;
4490
+ }
4491
+ function keychainWriteFailureMessage(err) {
4492
+ const record = err && typeof err === "object" ? err : {};
4493
+ const stderr = bufferText(record.stderr);
4494
+ const stdout = bufferText(record.stdout);
4495
+ const detail = (stderr || stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).at(-1);
4496
+ if (detail)
4497
+ return detail;
4498
+ return typeof record.status === "number" ? `security exited with status ${record.status}` : "security command failed";
4499
+ }
4484
4500
  function writeClaudeKeychain(cred) {
4485
4501
  if (!keychainSupported()) {
4486
4502
  throw new AccountsError("macOS keychain is only available on darwin");
@@ -4494,7 +4510,7 @@ function writeClaudeKeychain(cred) {
4494
4510
  stdio: ["ignore", "pipe", "pipe"]
4495
4511
  });
4496
4512
  } catch (err) {
4497
- throw new AccountsError(`keychain write failed: ${err.message}`);
4513
+ throw new AccountsError(`keychain write failed: ${keychainWriteFailureMessage(err)}`);
4498
4514
  }
4499
4515
  }
4500
4516
 
@@ -8,6 +8,7 @@ export interface KeychainCredential {
8
8
  export declare function assertAllowedKeychainCredential(cred: KeychainCredential): void;
9
9
  /** Read Claude Code OAuth payload from macOS login keychain. */
10
10
  export declare function readClaudeKeychain(): KeychainCredential | undefined;
11
+ export declare function keychainWriteFailureMessage(err: unknown): string;
11
12
  /** Write Claude Code credentials into the login keychain (replaces existing entry). */
12
13
  export declare function writeClaudeKeychain(cred: KeychainCredential): void;
13
14
  //# sourceMappingURL=keychain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/lib/keychain.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,yFAAyF;AACzF,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAU9E;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,IAAI,kBAAkB,GAAG,SAAS,CAgBnE;AAgBD,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAqBlE"}
1
+ {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/lib/keychain.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,yFAAyF;AACzF,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAU9E;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,IAAI,kBAAkB,GAAG,SAAS,CAgBnE;AAsBD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAWhE;AAED,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAqBlE"}
package/dist/mcp.js CHANGED
@@ -17129,6 +17129,22 @@ function readKeychainAccount() {
17129
17129
  return;
17130
17130
  }
17131
17131
  }
17132
+ function bufferText(value) {
17133
+ if (typeof value === "string")
17134
+ return value;
17135
+ if (value instanceof Uint8Array)
17136
+ return new TextDecoder().decode(value);
17137
+ return;
17138
+ }
17139
+ function keychainWriteFailureMessage(err) {
17140
+ const record3 = err && typeof err === "object" ? err : {};
17141
+ const stderr = bufferText(record3.stderr);
17142
+ const stdout = bufferText(record3.stdout);
17143
+ const detail = (stderr || stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).at(-1);
17144
+ if (detail)
17145
+ return detail;
17146
+ return typeof record3.status === "number" ? `security exited with status ${record3.status}` : "security command failed";
17147
+ }
17132
17148
  function writeClaudeKeychain(cred) {
17133
17149
  if (!keychainSupported()) {
17134
17150
  throw new AccountsError("macOS keychain is only available on darwin");
@@ -17142,7 +17158,7 @@ function writeClaudeKeychain(cred) {
17142
17158
  stdio: ["ignore", "pipe", "pipe"]
17143
17159
  });
17144
17160
  } catch (err) {
17145
- throw new AccountsError(`keychain write failed: ${err.message}`);
17161
+ throw new AccountsError(`keychain write failed: ${keychainWriteFailureMessage(err)}`);
17146
17162
  }
17147
17163
  }
17148
17164
 
@@ -17603,7 +17619,7 @@ function ok(data) {
17603
17619
  function fail(message) {
17604
17620
  return { content: [{ type: "text", text: JSON.stringify({ error: message }) }], isError: true };
17605
17621
  }
17606
- var server = new Server({ name: "accounts", version: "0.1.13" }, { capabilities: { tools: {} } });
17622
+ var server = new Server({ name: "accounts", version: "0.1.14" }, { capabilities: { tools: {} } });
17607
17623
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
17608
17624
  tools: [
17609
17625
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/accounts",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Manage and switch between multiple Claude Code (and other AI coding tool) profiles/accounts locally — isolated config dirs, per-account email, one-command switching.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",