fss-link 1.1.0 → 1.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.
Files changed (2) hide show
  1. package/bundle/fss-link.js +58 -9
  2. package/package.json +1 -1
@@ -22084,7 +22084,7 @@ async function createContentGeneratorConfig(config, authType) {
22084
22084
  async function createContentGenerator(config, gcConfig, sessionId2) {
22085
22085
  if (DEBUG_CONTENT)
22086
22086
  console.log(`\u{1F41B} DEBUG createContentGenerator: authType=${config.authType}, apiKey=${config.apiKey}, baseUrl=${config.baseUrl}`);
22087
- const version = "1.1.0";
22087
+ const version = "1.1.1";
22088
22088
  const userAgent = `FSS-Link/${version} (${process.platform}; ${process.arch})`;
22089
22089
  const baseHeaders = {
22090
22090
  "User-Agent": userAgent
@@ -82943,6 +82943,7 @@ var ModelDatabase;
82943
82943
  var init_model_database = __esm({
82944
82944
  "packages/cli/src/config/model-database.ts"() {
82945
82945
  init_database_utils();
82946
+ init_database();
82946
82947
  ModelDatabase = class {
82947
82948
  constructor(db) {
82948
82949
  this.db = db;
@@ -83004,7 +83005,7 @@ var init_model_database = __esm({
83004
83005
  if (!this.db) {
83005
83006
  throw new Error("Database not initialized");
83006
83007
  }
83007
- const encryptedApiKey = config.apiKey || null;
83008
+ const encryptedApiKey = config.apiKey ? FSSLinkDatabase.encryptApiKey(config.apiKey) : null;
83008
83009
  const normalizedEndpointUrl = config.endpointUrl || "";
83009
83010
  const existingRecord = await safeQueryFirstWithLocking(
83010
83011
  this.db,
@@ -83244,7 +83245,7 @@ var init_model_database = __esm({
83244
83245
  authType: record.auth_type,
83245
83246
  modelName: record.model_name,
83246
83247
  endpointUrl: record.endpoint_url || void 0,
83247
- apiKey: record.api_key || void 0,
83248
+ apiKey: record.api_key ? FSSLinkDatabase.decryptApiKey(record.api_key) : void 0,
83248
83249
  displayName: record.display_name || void 0,
83249
83250
  isFavorite: record.is_favorite === 1,
83250
83251
  isActive: record.is_active === 1,
@@ -84545,15 +84546,63 @@ var init_database = __esm({
84545
84546
  * Legacy encryption methods (maintained for compatibility)
84546
84547
  */
84547
84548
  encrypt(value) {
84548
- const cipher = crypto13.createCipher("aes-256-cbc", this.encryptionKey);
84549
- let encrypted = cipher.update(value, "utf8", "hex");
84549
+ if (!value) return value;
84550
+ const iv = crypto13.randomBytes(16);
84551
+ const cipher = crypto13.createCipheriv("aes-256-cbc", this.encryptionKey, iv);
84552
+ let encrypted = iv.toString("hex") + ":";
84553
+ encrypted += cipher.update(value, "utf8", "hex");
84550
84554
  encrypted += cipher.final("hex");
84551
84555
  return encrypted;
84552
84556
  }
84553
84557
  decrypt(value) {
84558
+ if (!value) return value;
84559
+ try {
84560
+ const parts = value.split(":");
84561
+ const iv = Buffer.from(parts[0], "hex");
84562
+ const encrypted = parts[1];
84563
+ const decipher = crypto13.createDecipheriv("aes-256-cbc", this.encryptionKey, iv);
84564
+ let decrypted = decipher.update(encrypted, "hex", "utf8");
84565
+ decrypted += decipher.final("utf8");
84566
+ return decrypted;
84567
+ } catch (error) {
84568
+ return value;
84569
+ }
84570
+ }
84571
+ /**
84572
+ * Static encryption methods for use across database classes
84573
+ */
84574
+ static getEncryptionKey() {
84575
+ const keyPath = path57.join(USER_SETTINGS_DIR, "db.key");
84576
+ if (fs51.existsSync(keyPath)) {
84577
+ return fs51.readFileSync(keyPath);
84578
+ } else {
84579
+ const key = crypto13.randomBytes(32);
84580
+ if (!fs51.existsSync(USER_SETTINGS_DIR)) {
84581
+ fs51.mkdirSync(USER_SETTINGS_DIR, { recursive: true });
84582
+ }
84583
+ fs51.writeFileSync(keyPath, key);
84584
+ return key;
84585
+ }
84586
+ }
84587
+ static encryptApiKey(value) {
84588
+ if (!value) return value;
84589
+ const key = this.getEncryptionKey();
84590
+ const iv = crypto13.randomBytes(16);
84591
+ const cipher = crypto13.createCipheriv("aes-256-cbc", key, iv);
84592
+ let encrypted = iv.toString("hex") + ":";
84593
+ encrypted += cipher.update(value, "utf8", "hex");
84594
+ encrypted += cipher.final("hex");
84595
+ return encrypted;
84596
+ }
84597
+ static decryptApiKey(value) {
84598
+ if (!value) return value;
84554
84599
  try {
84555
- const decipher = crypto13.createDecipher("aes-256-cbc", this.encryptionKey);
84556
- let decrypted = decipher.update(value, "hex", "utf8");
84600
+ const key = this.getEncryptionKey();
84601
+ const parts = value.split(":");
84602
+ const iv = Buffer.from(parts[0], "hex");
84603
+ const encrypted = parts[1];
84604
+ const decipher = crypto13.createDecipheriv("aes-256-cbc", key, iv);
84605
+ let decrypted = decipher.update(encrypted, "hex", "utf8");
84557
84606
  decrypted += decipher.final("utf8");
84558
84607
  return decrypted;
84559
84608
  } catch (error) {
@@ -93827,7 +93876,7 @@ async function getPackageJson() {
93827
93876
  // packages/cli/src/utils/version.ts
93828
93877
  async function getCliVersion() {
93829
93878
  const pkgJson = await getPackageJson();
93830
- return "1.1.0";
93879
+ return "1.1.1";
93831
93880
  }
93832
93881
 
93833
93882
  // packages/cli/src/ui/commands/aboutCommand.ts
@@ -93879,7 +93928,7 @@ import open4 from "open";
93879
93928
  import process11 from "node:process";
93880
93929
 
93881
93930
  // packages/cli/src/generated/git-commit.ts
93882
- var GIT_COMMIT_INFO = "7b22143f";
93931
+ var GIT_COMMIT_INFO = "5495c6a2";
93883
93932
 
93884
93933
  // packages/cli/src/ui/commands/bugCommand.ts
93885
93934
  init_dist2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fss-link",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },