@lanonasis/oauth-client 1.2.3 → 1.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.
@@ -42,4 +42,4 @@ declare class MCPClient {
42
42
  deleteMemory(id: string): Promise<void>;
43
43
  }
44
44
 
45
- export { MCPClient, OAuthConfig };
45
+ export { MCPClient, type MCPClientConfig, OAuthConfig };
package/dist/browser.d.ts CHANGED
@@ -42,4 +42,4 @@ declare class MCPClient {
42
42
  deleteMemory(id: string): Promise<void>;
43
43
  }
44
44
 
45
- export { MCPClient, OAuthConfig };
45
+ export { MCPClient, type MCPClientConfig, OAuthConfig };
package/dist/index.cjs CHANGED
@@ -368,6 +368,11 @@ var DesktopOAuthFlow = class extends BaseOAuthFlow {
368
368
  };
369
369
 
370
370
  // src/storage/token-storage.ts
371
+ var fs = __toESM(require("fs"), 1);
372
+ var path = __toESM(require("path"), 1);
373
+ var os = __toESM(require("os"), 1);
374
+ var crypto2 = __toESM(require("crypto"), 1);
375
+ var fsPromises = fs.promises;
371
376
  var TokenStorage = class {
372
377
  constructor() {
373
378
  this.storageKey = "lanonasis_mcp_tokens";
@@ -457,13 +462,9 @@ var TokenStorage = class {
457
462
  }
458
463
  async storeToFile(tokenString) {
459
464
  if (!this.isNode()) return;
460
- const fs = require("fs").promises;
461
- const path = require("path");
462
- const os = require("os");
463
- const crypto2 = require("crypto");
464
465
  const configDir = path.join(os.homedir(), ".lanonasis");
465
466
  const tokenFile = path.join(configDir, "mcp-tokens.enc");
466
- await fs.mkdir(configDir, { recursive: true });
467
+ await fsPromises.mkdir(configDir, { recursive: true });
467
468
  const key = this.getFileEncryptionKey();
468
469
  const iv = crypto2.randomBytes(16);
469
470
  const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
@@ -471,17 +472,13 @@ var TokenStorage = class {
471
472
  encrypted += cipher.final("hex");
472
473
  const authTag = cipher.getAuthTag().toString("hex");
473
474
  const data = [iv.toString("hex"), authTag, encrypted].join(":");
474
- await fs.writeFile(tokenFile, data, { mode: 384 });
475
+ await fsPromises.writeFile(tokenFile, data, { mode: 384 });
475
476
  }
476
477
  async retrieveFromFile() {
477
478
  if (!this.isNode()) return null;
478
- const fs = require("fs").promises;
479
- const path = require("path");
480
- const os = require("os");
481
- const crypto2 = require("crypto");
482
479
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
483
480
  try {
484
- const data = await fs.readFile(tokenFile, "utf8");
481
+ const data = await fsPromises.readFile(tokenFile, "utf8");
485
482
  const parts = data.split(":");
486
483
  const key = this.getFileEncryptionKey();
487
484
  if (parts.length === 3) {
@@ -509,18 +506,13 @@ var TokenStorage = class {
509
506
  }
510
507
  async deleteFile() {
511
508
  if (!this.isNode()) return;
512
- const fs = require("fs").promises;
513
- const path = require("path");
514
- const os = require("os");
515
509
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
516
510
  try {
517
- await fs.unlink(tokenFile);
511
+ await fsPromises.unlink(tokenFile);
518
512
  } catch (error) {
519
513
  }
520
514
  }
521
515
  getFileEncryptionKey() {
522
- const crypto2 = require("crypto");
523
- const os = require("os");
524
516
  const machineId = os.hostname() + os.userInfo().username;
525
517
  const salt = "lanonasis-mcp-oauth-2024";
526
518
  return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
@@ -660,6 +652,11 @@ var TokenStorage = class {
660
652
  };
661
653
 
662
654
  // src/storage/api-key-storage.ts
655
+ var fs2 = __toESM(require("fs"), 1);
656
+ var path2 = __toESM(require("path"), 1);
657
+ var os2 = __toESM(require("os"), 1);
658
+ var crypto3 = __toESM(require("crypto"), 1);
659
+ var fsPromises2 = fs2.promises;
663
660
  var ApiKeyStorage = class {
664
661
  constructor() {
665
662
  this.storageKey = "lanonasis_api_key";
@@ -859,31 +856,23 @@ var ApiKeyStorage = class {
859
856
  // ==================== Node.js File Storage ====================
860
857
  async storeToFile(keyString) {
861
858
  if (!this.isNode()) return;
862
- const fs = require("fs").promises;
863
- const path = require("path");
864
- const os = require("os");
865
- const crypto2 = require("crypto");
866
- const configDir = path.join(os.homedir(), ".lanonasis");
867
- const keyFile = path.join(configDir, "api-key.enc");
868
- await fs.mkdir(configDir, { recursive: true, mode: 448 });
859
+ const configDir = path2.join(os2.homedir(), ".lanonasis");
860
+ const keyFile = path2.join(configDir, "api-key.enc");
861
+ await fsPromises2.mkdir(configDir, { recursive: true, mode: 448 });
869
862
  const key = this.getFileEncryptionKey();
870
- const iv = crypto2.randomBytes(16);
871
- const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
863
+ const iv = crypto3.randomBytes(16);
864
+ const cipher = crypto3.createCipheriv("aes-256-gcm", key, iv);
872
865
  let encrypted = cipher.update(keyString, "utf8", "hex");
873
866
  encrypted += cipher.final("hex");
874
867
  const authTag = cipher.getAuthTag();
875
868
  const data = iv.toString("hex") + ":" + authTag.toString("hex") + ":" + encrypted;
876
- await fs.writeFile(keyFile, data, { mode: 384 });
869
+ await fsPromises2.writeFile(keyFile, data, { mode: 384 });
877
870
  }
878
871
  async retrieveFromFile() {
879
872
  if (!this.isNode()) return null;
880
- const fs = require("fs").promises;
881
- const path = require("path");
882
- const os = require("os");
883
- const crypto2 = require("crypto");
884
- const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
873
+ const keyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.enc");
885
874
  try {
886
- const data = await fs.readFile(keyFile, "utf8");
875
+ const data = await fsPromises2.readFile(keyFile, "utf8");
887
876
  const [ivHex, authTagHex, encrypted] = data.split(":");
888
877
  if (!ivHex || !authTagHex || !encrypted) {
889
878
  throw new Error("Invalid encrypted file format");
@@ -891,7 +880,7 @@ var ApiKeyStorage = class {
891
880
  const key = this.getFileEncryptionKey();
892
881
  const iv = Buffer.from(ivHex, "hex");
893
882
  const authTag = Buffer.from(authTagHex, "hex");
894
- const decipher = crypto2.createDecipheriv("aes-256-gcm", key, iv);
883
+ const decipher = crypto3.createDecipheriv("aes-256-gcm", key, iv);
895
884
  decipher.setAuthTag(authTag);
896
885
  let decrypted = decipher.update(encrypted, "hex", "utf8");
897
886
  decrypted += decipher.final("utf8");
@@ -902,44 +891,33 @@ var ApiKeyStorage = class {
902
891
  }
903
892
  async deleteFile() {
904
893
  if (!this.isNode()) return;
905
- const fs = require("fs").promises;
906
- const path = require("path");
907
- const os = require("os");
908
- const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
894
+ const keyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.enc");
909
895
  try {
910
- await fs.unlink(keyFile);
896
+ await fsPromises2.unlink(keyFile);
911
897
  } catch (error) {
912
898
  }
913
899
  }
914
900
  async retrieveLegacyFromFile() {
915
901
  if (!this.isNode()) return null;
916
- const fs = require("fs").promises;
917
- const path = require("path");
918
- const os = require("os");
919
- const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
902
+ const legacyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.txt");
920
903
  try {
921
- return await fs.readFile(legacyFile, "utf8");
904
+ return await fsPromises2.readFile(legacyFile, "utf8");
922
905
  } catch {
923
906
  return null;
924
907
  }
925
908
  }
926
909
  async deleteLegacyFile() {
927
910
  if (!this.isNode()) return;
928
- const fs = require("fs").promises;
929
- const path = require("path");
930
- const os = require("os");
931
- const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
911
+ const legacyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.txt");
932
912
  try {
933
- await fs.unlink(legacyFile);
913
+ await fsPromises2.unlink(legacyFile);
934
914
  } catch {
935
915
  }
936
916
  }
937
917
  getFileEncryptionKey() {
938
- const crypto2 = require("crypto");
939
- const os = require("os");
940
- const machineId = os.hostname() + os.userInfo().username;
918
+ const machineId = os2.hostname() + os2.userInfo().username;
941
919
  const salt = "lanonasis-mcp-api-key-2024";
942
- return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
920
+ return crypto3.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
943
921
  }
944
922
  // ==================== Web Encryption ====================
945
923
  async encrypt(text) {
package/dist/index.mjs CHANGED
@@ -332,6 +332,11 @@ var DesktopOAuthFlow = class extends BaseOAuthFlow {
332
332
  };
333
333
 
334
334
  // src/storage/token-storage.ts
335
+ import * as fs from "fs";
336
+ import * as path from "path";
337
+ import * as os from "os";
338
+ import * as crypto2 from "crypto";
339
+ var fsPromises = fs.promises;
335
340
  var TokenStorage = class {
336
341
  constructor() {
337
342
  this.storageKey = "lanonasis_mcp_tokens";
@@ -421,13 +426,9 @@ var TokenStorage = class {
421
426
  }
422
427
  async storeToFile(tokenString) {
423
428
  if (!this.isNode()) return;
424
- const fs = __require("fs").promises;
425
- const path = __require("path");
426
- const os = __require("os");
427
- const crypto2 = __require("crypto");
428
429
  const configDir = path.join(os.homedir(), ".lanonasis");
429
430
  const tokenFile = path.join(configDir, "mcp-tokens.enc");
430
- await fs.mkdir(configDir, { recursive: true });
431
+ await fsPromises.mkdir(configDir, { recursive: true });
431
432
  const key = this.getFileEncryptionKey();
432
433
  const iv = crypto2.randomBytes(16);
433
434
  const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
@@ -435,17 +436,13 @@ var TokenStorage = class {
435
436
  encrypted += cipher.final("hex");
436
437
  const authTag = cipher.getAuthTag().toString("hex");
437
438
  const data = [iv.toString("hex"), authTag, encrypted].join(":");
438
- await fs.writeFile(tokenFile, data, { mode: 384 });
439
+ await fsPromises.writeFile(tokenFile, data, { mode: 384 });
439
440
  }
440
441
  async retrieveFromFile() {
441
442
  if (!this.isNode()) return null;
442
- const fs = __require("fs").promises;
443
- const path = __require("path");
444
- const os = __require("os");
445
- const crypto2 = __require("crypto");
446
443
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
447
444
  try {
448
- const data = await fs.readFile(tokenFile, "utf8");
445
+ const data = await fsPromises.readFile(tokenFile, "utf8");
449
446
  const parts = data.split(":");
450
447
  const key = this.getFileEncryptionKey();
451
448
  if (parts.length === 3) {
@@ -473,18 +470,13 @@ var TokenStorage = class {
473
470
  }
474
471
  async deleteFile() {
475
472
  if (!this.isNode()) return;
476
- const fs = __require("fs").promises;
477
- const path = __require("path");
478
- const os = __require("os");
479
473
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
480
474
  try {
481
- await fs.unlink(tokenFile);
475
+ await fsPromises.unlink(tokenFile);
482
476
  } catch (error) {
483
477
  }
484
478
  }
485
479
  getFileEncryptionKey() {
486
- const crypto2 = __require("crypto");
487
- const os = __require("os");
488
480
  const machineId = os.hostname() + os.userInfo().username;
489
481
  const salt = "lanonasis-mcp-oauth-2024";
490
482
  return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
@@ -624,6 +616,11 @@ var TokenStorage = class {
624
616
  };
625
617
 
626
618
  // src/storage/api-key-storage.ts
619
+ import * as fs2 from "fs";
620
+ import * as path2 from "path";
621
+ import * as os2 from "os";
622
+ import * as crypto3 from "crypto";
623
+ var fsPromises2 = fs2.promises;
627
624
  var ApiKeyStorage = class {
628
625
  constructor() {
629
626
  this.storageKey = "lanonasis_api_key";
@@ -823,31 +820,23 @@ var ApiKeyStorage = class {
823
820
  // ==================== Node.js File Storage ====================
824
821
  async storeToFile(keyString) {
825
822
  if (!this.isNode()) return;
826
- const fs = __require("fs").promises;
827
- const path = __require("path");
828
- const os = __require("os");
829
- const crypto2 = __require("crypto");
830
- const configDir = path.join(os.homedir(), ".lanonasis");
831
- const keyFile = path.join(configDir, "api-key.enc");
832
- await fs.mkdir(configDir, { recursive: true, mode: 448 });
823
+ const configDir = path2.join(os2.homedir(), ".lanonasis");
824
+ const keyFile = path2.join(configDir, "api-key.enc");
825
+ await fsPromises2.mkdir(configDir, { recursive: true, mode: 448 });
833
826
  const key = this.getFileEncryptionKey();
834
- const iv = crypto2.randomBytes(16);
835
- const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
827
+ const iv = crypto3.randomBytes(16);
828
+ const cipher = crypto3.createCipheriv("aes-256-gcm", key, iv);
836
829
  let encrypted = cipher.update(keyString, "utf8", "hex");
837
830
  encrypted += cipher.final("hex");
838
831
  const authTag = cipher.getAuthTag();
839
832
  const data = iv.toString("hex") + ":" + authTag.toString("hex") + ":" + encrypted;
840
- await fs.writeFile(keyFile, data, { mode: 384 });
833
+ await fsPromises2.writeFile(keyFile, data, { mode: 384 });
841
834
  }
842
835
  async retrieveFromFile() {
843
836
  if (!this.isNode()) return null;
844
- const fs = __require("fs").promises;
845
- const path = __require("path");
846
- const os = __require("os");
847
- const crypto2 = __require("crypto");
848
- const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
837
+ const keyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.enc");
849
838
  try {
850
- const data = await fs.readFile(keyFile, "utf8");
839
+ const data = await fsPromises2.readFile(keyFile, "utf8");
851
840
  const [ivHex, authTagHex, encrypted] = data.split(":");
852
841
  if (!ivHex || !authTagHex || !encrypted) {
853
842
  throw new Error("Invalid encrypted file format");
@@ -855,7 +844,7 @@ var ApiKeyStorage = class {
855
844
  const key = this.getFileEncryptionKey();
856
845
  const iv = Buffer.from(ivHex, "hex");
857
846
  const authTag = Buffer.from(authTagHex, "hex");
858
- const decipher = crypto2.createDecipheriv("aes-256-gcm", key, iv);
847
+ const decipher = crypto3.createDecipheriv("aes-256-gcm", key, iv);
859
848
  decipher.setAuthTag(authTag);
860
849
  let decrypted = decipher.update(encrypted, "hex", "utf8");
861
850
  decrypted += decipher.final("utf8");
@@ -866,44 +855,33 @@ var ApiKeyStorage = class {
866
855
  }
867
856
  async deleteFile() {
868
857
  if (!this.isNode()) return;
869
- const fs = __require("fs").promises;
870
- const path = __require("path");
871
- const os = __require("os");
872
- const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
858
+ const keyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.enc");
873
859
  try {
874
- await fs.unlink(keyFile);
860
+ await fsPromises2.unlink(keyFile);
875
861
  } catch (error) {
876
862
  }
877
863
  }
878
864
  async retrieveLegacyFromFile() {
879
865
  if (!this.isNode()) return null;
880
- const fs = __require("fs").promises;
881
- const path = __require("path");
882
- const os = __require("os");
883
- const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
866
+ const legacyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.txt");
884
867
  try {
885
- return await fs.readFile(legacyFile, "utf8");
868
+ return await fsPromises2.readFile(legacyFile, "utf8");
886
869
  } catch {
887
870
  return null;
888
871
  }
889
872
  }
890
873
  async deleteLegacyFile() {
891
874
  if (!this.isNode()) return;
892
- const fs = __require("fs").promises;
893
- const path = __require("path");
894
- const os = __require("os");
895
- const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
875
+ const legacyFile = path2.join(os2.homedir(), ".lanonasis", "api-key.txt");
896
876
  try {
897
- await fs.unlink(legacyFile);
877
+ await fsPromises2.unlink(legacyFile);
898
878
  } catch {
899
879
  }
900
880
  }
901
881
  getFileEncryptionKey() {
902
- const crypto2 = __require("crypto");
903
- const os = __require("os");
904
- const machineId = os.hostname() + os.userInfo().username;
882
+ const machineId = os2.hostname() + os2.userInfo().username;
905
883
  const salt = "lanonasis-mcp-api-key-2024";
906
- return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
884
+ return crypto3.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
907
885
  }
908
886
  // ==================== Web Encryption ====================
909
887
  async encrypt(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lanonasis/oauth-client",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "type": "module",
5
5
  "description": "OAuth and API Key authentication client for Lan Onasis MCP integration",
6
6
  "license": "MIT",
@@ -51,7 +51,7 @@
51
51
  "desktop"
52
52
  ],
53
53
  "dependencies": {
54
- "cross-fetch": "^3.2.0",
54
+ "cross-fetch": "^4.0.0",
55
55
  "keytar": "^7.9.0",
56
56
  "open": "^9.1.0"
57
57
  },