@axiom-lattice/local-stores 3.2.5 → 3.2.6

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/local-stores@3.2.5 build /home/runner/work/agentic/agentic/packages/local-stores
2
+ > @axiom-lattice/local-stores@3.2.6 build /home/runner/work/agentic/agentic/packages/local-stores
3
3
  > tsup src/index.ts --format cjs,esm --dts --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,13 +8,13 @@
8
8
  CLI Target: es2020
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 243.72 KB
12
- CJS dist/index.js.map 442.40 KB
13
- CJS ⚡️ Build success in 522ms
14
- ESM dist/index.mjs 239.07 KB
15
- ESM dist/index.mjs.map 438.65 KB
16
- ESM ⚡️ Build success in 528ms
11
+ CJS dist/index.js 244.66 KB
12
+ CJS dist/index.js.map 443.82 KB
13
+ CJS ⚡️ Build success in 637ms
14
+ ESM dist/index.mjs 240.04 KB
15
+ ESM dist/index.mjs.map 440.11 KB
16
+ ESM ⚡️ Build success in 646ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 9966ms
19
- DTS dist/index.d.ts 44.69 KB
20
- DTS dist/index.d.mts 44.69 KB
18
+ DTS ⚡️ Build success in 10963ms
19
+ DTS dist/index.d.ts 45.28 KB
20
+ DTS dist/index.d.mts 45.28 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @axiom-lattice/local-stores
2
2
 
3
+ ## 3.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [726c98a]
8
+ - @axiom-lattice/core@7.0.0
9
+
3
10
  ## 3.2.5
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -468,6 +468,17 @@ declare class LocalConnectionStore implements ConnectionStore {
468
468
  private db;
469
469
  constructor(db: DatabaseWrapper);
470
470
  private ensureColumn;
471
+ /**
472
+ * Re-encrypt declared secret fields that are still stored as plaintext.
473
+ *
474
+ * A plugin can mark a field as a secret after connections already exist (e.g.
475
+ * a field renamed from a plaintext key to a password), leaving legacy rows
476
+ * with plaintext where ciphertext is now expected. This one-time, idempotent
477
+ * pass encrypts any declared secret field that does not look like our
478
+ * ciphertext; values that do look encrypted are left untouched, so genuine
479
+ * ciphertext written under another key is never destroyed.
480
+ */
481
+ private reencryptLegacySecrets;
471
482
  listByTenant(tenantId: string): Promise<ConnectionEntry[]>;
472
483
  listByType(tenantId: string, type: string): Promise<ConnectionEntry[]>;
473
484
  getByKey(tenantId: string, type: string, key: string): Promise<ConnectionEntry | null>;
package/dist/index.d.ts CHANGED
@@ -468,6 +468,17 @@ declare class LocalConnectionStore implements ConnectionStore {
468
468
  private db;
469
469
  constructor(db: DatabaseWrapper);
470
470
  private ensureColumn;
471
+ /**
472
+ * Re-encrypt declared secret fields that are still stored as plaintext.
473
+ *
474
+ * A plugin can mark a field as a secret after connections already exist (e.g.
475
+ * a field renamed from a plaintext key to a password), leaving legacy rows
476
+ * with plaintext where ciphertext is now expected. This one-time, idempotent
477
+ * pass encrypts any declared secret field that does not look like our
478
+ * ciphertext; values that do look encrypted are left untouched, so genuine
479
+ * ciphertext written under another key is never destroyed.
480
+ */
481
+ private reencryptLegacySecrets;
471
482
  listByTenant(tenantId: string): Promise<ConnectionEntry[]>;
472
483
  listByType(tenantId: string, type: string): Promise<ConnectionEntry[]>;
473
484
  getByKey(tenantId: string, type: string, key: string): Promise<ConnectionEntry | null>;
package/dist/index.js CHANGED
@@ -2108,6 +2108,7 @@ var LocalConnectionStore = class {
2108
2108
  this.db = db;
2109
2109
  ensureTable(db, DDL9);
2110
2110
  this.ensureColumn("connection_configs", "secret_fields", "secret_fields TEXT");
2111
+ this.reencryptLegacySecrets();
2111
2112
  }
2112
2113
  ensureColumn(table, column, ddl2) {
2113
2114
  const cols = this.db.prepare(`PRAGMA table_info(${table})`).all();
@@ -2115,6 +2116,44 @@ var LocalConnectionStore = class {
2115
2116
  this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${ddl2}`);
2116
2117
  }
2117
2118
  }
2119
+ /**
2120
+ * Re-encrypt declared secret fields that are still stored as plaintext.
2121
+ *
2122
+ * A plugin can mark a field as a secret after connections already exist (e.g.
2123
+ * a field renamed from a plaintext key to a password), leaving legacy rows
2124
+ * with plaintext where ciphertext is now expected. This one-time, idempotent
2125
+ * pass encrypts any declared secret field that does not look like our
2126
+ * ciphertext; values that do look encrypted are left untouched, so genuine
2127
+ * ciphertext written under another key is never destroyed.
2128
+ */
2129
+ reencryptLegacySecrets() {
2130
+ const rows2 = this.db.prepare(
2131
+ `SELECT id, tenant_id, config, secret_fields FROM connection_configs WHERE secret_fields IS NOT NULL`
2132
+ ).all();
2133
+ for (const row of rows2) {
2134
+ const secretFields = parseSecretFields(row.secret_fields);
2135
+ if (!secretFields?.length) continue;
2136
+ let config;
2137
+ try {
2138
+ config = JSON.parse(row.config);
2139
+ } catch {
2140
+ continue;
2141
+ }
2142
+ let changed = false;
2143
+ for (const field of secretFields) {
2144
+ const value = config[field];
2145
+ if (typeof value === "string" && value.length > 0 && !(0, import_core2.isEncryptedValue)(value)) {
2146
+ config[field] = (0, import_core2.encrypt)(value);
2147
+ changed = true;
2148
+ }
2149
+ }
2150
+ if (changed) {
2151
+ this.db.prepare(
2152
+ `UPDATE connection_configs SET config = ?, updated_at = ? WHERE tenant_id = ? AND id = ?`
2153
+ ).run(JSON.stringify(config), nowISO(), row.tenant_id, row.id);
2154
+ }
2155
+ }
2156
+ }
2118
2157
  async listByTenant(tenantId) {
2119
2158
  const rows2 = this.db.prepare(
2120
2159
  `SELECT * FROM connection_configs WHERE tenant_id = ? ORDER BY created_at`
@@ -2480,28 +2519,18 @@ var LocalMcpServerConfigStore = class {
2480
2519
  function mapRowToEntry3(row) {
2481
2520
  const config = JSON.parse(row.config);
2482
2521
  if (config.env && row.is_env_encrypted) {
2483
- try {
2484
- const decryptedEnv = {};
2485
- for (const [key, value] of Object.entries(config.env)) {
2486
- decryptedEnv[key] = (0, import_core3.decrypt)(value);
2487
- }
2488
- config.env = decryptedEnv;
2489
- } catch (error) {
2490
- console.error("Failed to decrypt MCP server env:", error);
2491
- throw new Error("Failed to decrypt MCP server configuration");
2522
+ const decryptedEnv = {};
2523
+ for (const [key, value] of Object.entries(config.env)) {
2524
+ decryptedEnv[key] = (0, import_core3.safeDecrypt)(value);
2492
2525
  }
2526
+ config.env = decryptedEnv;
2493
2527
  }
2494
2528
  if (config.headers && row.is_env_encrypted) {
2495
- try {
2496
- const decryptedHeaders = {};
2497
- for (const [key, value] of Object.entries(config.headers)) {
2498
- decryptedHeaders[key] = (0, import_core3.decrypt)(value);
2499
- }
2500
- config.headers = decryptedHeaders;
2501
- } catch (error) {
2502
- console.error("Failed to decrypt MCP server headers:", error);
2503
- throw new Error("Failed to decrypt MCP server configuration");
2529
+ const decryptedHeaders = {};
2530
+ for (const [key, value] of Object.entries(config.headers)) {
2531
+ decryptedHeaders[key] = (0, import_core3.safeDecrypt)(value);
2504
2532
  }
2533
+ config.headers = decryptedHeaders;
2505
2534
  }
2506
2535
  return {
2507
2536
  id: row.id,
@@ -2817,12 +2846,7 @@ var LocalModelProviderStore = class {
2817
2846
  function mapRowToEntry4(row) {
2818
2847
  let apiKey;
2819
2848
  if (row.api_key_enc) {
2820
- try {
2821
- apiKey = (0, import_core4.decrypt)(row.api_key_enc);
2822
- } catch (error) {
2823
- console.error("Failed to decrypt model provider API key:", error);
2824
- throw new Error("Failed to decrypt model provider API key");
2825
- }
2849
+ apiKey = (0, import_core4.safeDecrypt)(row.api_key_enc);
2826
2850
  }
2827
2851
  return {
2828
2852
  id: row.id,
@@ -4488,15 +4512,9 @@ var LocalA2AApiKeyStore = class {
4488
4512
  }
4489
4513
  };
4490
4514
  function mapRowToRecord(row) {
4491
- let key = "";
4492
- try {
4493
- key = (0, import_core5.decrypt)(row.key_value);
4494
- } catch {
4495
- key = row.key_value;
4496
- }
4497
4515
  return {
4498
4516
  id: row.id,
4499
- key,
4517
+ key: (0, import_core5.safeDecrypt)(row.key_value),
4500
4518
  tenantId: row.tenant_id,
4501
4519
  projectId: row.project_id,
4502
4520
  assistantIds: parseAssistantIds(row.assistant_ids),