@lanonasis/oauth-client 1.2.4 → 1.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.
package/dist/index.cjs CHANGED
@@ -368,6 +368,26 @@ var DesktopOAuthFlow = class extends BaseOAuthFlow {
368
368
  };
369
369
 
370
370
  // src/storage/token-storage.ts
371
+ var _fs = null;
372
+ var _path = null;
373
+ var _os = null;
374
+ var _crypto = null;
375
+ async function getNodeModules() {
376
+ if (_fs && _path && _os && _crypto) {
377
+ return { fs: _fs, path: _path, os: _os, crypto: _crypto };
378
+ }
379
+ const [fs, path, os, crypto2] = await Promise.all([
380
+ import("fs"),
381
+ import("path"),
382
+ import("os"),
383
+ import("crypto")
384
+ ]);
385
+ _fs = fs;
386
+ _path = path;
387
+ _os = os;
388
+ _crypto = crypto2;
389
+ return { fs, path, os, crypto: crypto2 };
390
+ }
371
391
  var TokenStorage = class {
372
392
  constructor() {
373
393
  this.storageKey = "lanonasis_mcp_tokens";
@@ -457,33 +477,27 @@ var TokenStorage = class {
457
477
  }
458
478
  async storeToFile(tokenString) {
459
479
  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");
480
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules();
464
481
  const configDir = path.join(os.homedir(), ".lanonasis");
465
482
  const tokenFile = path.join(configDir, "mcp-tokens.enc");
466
- await fs.mkdir(configDir, { recursive: true });
467
- const key = this.getFileEncryptionKey();
483
+ await fs.promises.mkdir(configDir, { recursive: true });
484
+ const key = await this.getFileEncryptionKey();
468
485
  const iv = crypto2.randomBytes(16);
469
486
  const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
470
487
  let encrypted = cipher.update(tokenString, "utf8", "hex");
471
488
  encrypted += cipher.final("hex");
472
489
  const authTag = cipher.getAuthTag().toString("hex");
473
490
  const data = [iv.toString("hex"), authTag, encrypted].join(":");
474
- await fs.writeFile(tokenFile, data, { mode: 384 });
491
+ await fs.promises.writeFile(tokenFile, data, { mode: 384 });
475
492
  }
476
493
  async retrieveFromFile() {
477
494
  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");
495
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules();
482
496
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
483
497
  try {
484
- const data = await fs.readFile(tokenFile, "utf8");
498
+ const data = await fs.promises.readFile(tokenFile, "utf8");
485
499
  const parts = data.split(":");
486
- const key = this.getFileEncryptionKey();
500
+ const key = await this.getFileEncryptionKey();
487
501
  if (parts.length === 3) {
488
502
  const [ivHex, authTagHex, encrypted] = parts;
489
503
  const iv = Buffer.from(ivHex, "hex");
@@ -509,18 +523,15 @@ var TokenStorage = class {
509
523
  }
510
524
  async deleteFile() {
511
525
  if (!this.isNode()) return;
512
- const fs = require("fs").promises;
513
- const path = require("path");
514
- const os = require("os");
526
+ const { fs, path, os } = await getNodeModules();
515
527
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
516
528
  try {
517
- await fs.unlink(tokenFile);
529
+ await fs.promises.unlink(tokenFile);
518
530
  } catch (error) {
519
531
  }
520
532
  }
521
- getFileEncryptionKey() {
522
- const crypto2 = require("crypto");
523
- const os = require("os");
533
+ async getFileEncryptionKey() {
534
+ const { os, crypto: crypto2 } = await getNodeModules();
524
535
  const machineId = os.hostname() + os.userInfo().username;
525
536
  const salt = "lanonasis-mcp-oauth-2024";
526
537
  return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
@@ -660,6 +671,26 @@ var TokenStorage = class {
660
671
  };
661
672
 
662
673
  // src/storage/api-key-storage.ts
674
+ var _fs2 = null;
675
+ var _path2 = null;
676
+ var _os2 = null;
677
+ var _crypto2 = null;
678
+ async function getNodeModules2() {
679
+ if (_fs2 && _path2 && _os2 && _crypto2) {
680
+ return { fs: _fs2, path: _path2, os: _os2, crypto: _crypto2 };
681
+ }
682
+ const [fs, path, os, crypto2] = await Promise.all([
683
+ import("fs"),
684
+ import("path"),
685
+ import("os"),
686
+ import("crypto")
687
+ ]);
688
+ _fs2 = fs;
689
+ _path2 = path;
690
+ _os2 = os;
691
+ _crypto2 = crypto2;
692
+ return { fs, path, os, crypto: crypto2 };
693
+ }
663
694
  var ApiKeyStorage = class {
664
695
  constructor() {
665
696
  this.storageKey = "lanonasis_api_key";
@@ -859,36 +890,30 @@ var ApiKeyStorage = class {
859
890
  // ==================== Node.js File Storage ====================
860
891
  async storeToFile(keyString) {
861
892
  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");
893
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules2();
866
894
  const configDir = path.join(os.homedir(), ".lanonasis");
867
895
  const keyFile = path.join(configDir, "api-key.enc");
868
- await fs.mkdir(configDir, { recursive: true, mode: 448 });
869
- const key = this.getFileEncryptionKey();
896
+ await fs.promises.mkdir(configDir, { recursive: true, mode: 448 });
897
+ const key = await this.getFileEncryptionKey();
870
898
  const iv = crypto2.randomBytes(16);
871
899
  const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
872
900
  let encrypted = cipher.update(keyString, "utf8", "hex");
873
901
  encrypted += cipher.final("hex");
874
902
  const authTag = cipher.getAuthTag();
875
903
  const data = iv.toString("hex") + ":" + authTag.toString("hex") + ":" + encrypted;
876
- await fs.writeFile(keyFile, data, { mode: 384 });
904
+ await fs.promises.writeFile(keyFile, data, { mode: 384 });
877
905
  }
878
906
  async retrieveFromFile() {
879
907
  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");
908
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules2();
884
909
  const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
885
910
  try {
886
- const data = await fs.readFile(keyFile, "utf8");
911
+ const data = await fs.promises.readFile(keyFile, "utf8");
887
912
  const [ivHex, authTagHex, encrypted] = data.split(":");
888
913
  if (!ivHex || !authTagHex || !encrypted) {
889
914
  throw new Error("Invalid encrypted file format");
890
915
  }
891
- const key = this.getFileEncryptionKey();
916
+ const key = await this.getFileEncryptionKey();
892
917
  const iv = Buffer.from(ivHex, "hex");
893
918
  const authTag = Buffer.from(authTagHex, "hex");
894
919
  const decipher = crypto2.createDecipheriv("aes-256-gcm", key, iv);
@@ -902,41 +927,34 @@ var ApiKeyStorage = class {
902
927
  }
903
928
  async deleteFile() {
904
929
  if (!this.isNode()) return;
905
- const fs = require("fs").promises;
906
- const path = require("path");
907
- const os = require("os");
930
+ const { fs, path, os } = await getNodeModules2();
908
931
  const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
909
932
  try {
910
- await fs.unlink(keyFile);
933
+ await fs.promises.unlink(keyFile);
911
934
  } catch (error) {
912
935
  }
913
936
  }
914
937
  async retrieveLegacyFromFile() {
915
938
  if (!this.isNode()) return null;
916
- const fs = require("fs").promises;
917
- const path = require("path");
918
- const os = require("os");
939
+ const { fs, path, os } = await getNodeModules2();
919
940
  const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
920
941
  try {
921
- return await fs.readFile(legacyFile, "utf8");
942
+ return await fs.promises.readFile(legacyFile, "utf8");
922
943
  } catch {
923
944
  return null;
924
945
  }
925
946
  }
926
947
  async deleteLegacyFile() {
927
948
  if (!this.isNode()) return;
928
- const fs = require("fs").promises;
929
- const path = require("path");
930
- const os = require("os");
949
+ const { fs, path, os } = await getNodeModules2();
931
950
  const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
932
951
  try {
933
- await fs.unlink(legacyFile);
952
+ await fs.promises.unlink(legacyFile);
934
953
  } catch {
935
954
  }
936
955
  }
937
- getFileEncryptionKey() {
938
- const crypto2 = require("crypto");
939
- const os = require("os");
956
+ async getFileEncryptionKey() {
957
+ const { os, crypto: crypto2 } = await getNodeModules2();
940
958
  const machineId = os.hostname() + os.userInfo().username;
941
959
  const salt = "lanonasis-mcp-api-key-2024";
942
960
  return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
package/dist/index.mjs CHANGED
@@ -332,6 +332,26 @@ var DesktopOAuthFlow = class extends BaseOAuthFlow {
332
332
  };
333
333
 
334
334
  // src/storage/token-storage.ts
335
+ var _fs = null;
336
+ var _path = null;
337
+ var _os = null;
338
+ var _crypto = null;
339
+ async function getNodeModules() {
340
+ if (_fs && _path && _os && _crypto) {
341
+ return { fs: _fs, path: _path, os: _os, crypto: _crypto };
342
+ }
343
+ const [fs, path, os, crypto2] = await Promise.all([
344
+ import("fs"),
345
+ import("path"),
346
+ import("os"),
347
+ import("crypto")
348
+ ]);
349
+ _fs = fs;
350
+ _path = path;
351
+ _os = os;
352
+ _crypto = crypto2;
353
+ return { fs, path, os, crypto: crypto2 };
354
+ }
335
355
  var TokenStorage = class {
336
356
  constructor() {
337
357
  this.storageKey = "lanonasis_mcp_tokens";
@@ -421,33 +441,27 @@ var TokenStorage = class {
421
441
  }
422
442
  async storeToFile(tokenString) {
423
443
  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");
444
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules();
428
445
  const configDir = path.join(os.homedir(), ".lanonasis");
429
446
  const tokenFile = path.join(configDir, "mcp-tokens.enc");
430
- await fs.mkdir(configDir, { recursive: true });
431
- const key = this.getFileEncryptionKey();
447
+ await fs.promises.mkdir(configDir, { recursive: true });
448
+ const key = await this.getFileEncryptionKey();
432
449
  const iv = crypto2.randomBytes(16);
433
450
  const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
434
451
  let encrypted = cipher.update(tokenString, "utf8", "hex");
435
452
  encrypted += cipher.final("hex");
436
453
  const authTag = cipher.getAuthTag().toString("hex");
437
454
  const data = [iv.toString("hex"), authTag, encrypted].join(":");
438
- await fs.writeFile(tokenFile, data, { mode: 384 });
455
+ await fs.promises.writeFile(tokenFile, data, { mode: 384 });
439
456
  }
440
457
  async retrieveFromFile() {
441
458
  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");
459
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules();
446
460
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
447
461
  try {
448
- const data = await fs.readFile(tokenFile, "utf8");
462
+ const data = await fs.promises.readFile(tokenFile, "utf8");
449
463
  const parts = data.split(":");
450
- const key = this.getFileEncryptionKey();
464
+ const key = await this.getFileEncryptionKey();
451
465
  if (parts.length === 3) {
452
466
  const [ivHex, authTagHex, encrypted] = parts;
453
467
  const iv = Buffer.from(ivHex, "hex");
@@ -473,18 +487,15 @@ var TokenStorage = class {
473
487
  }
474
488
  async deleteFile() {
475
489
  if (!this.isNode()) return;
476
- const fs = __require("fs").promises;
477
- const path = __require("path");
478
- const os = __require("os");
490
+ const { fs, path, os } = await getNodeModules();
479
491
  const tokenFile = path.join(os.homedir(), ".lanonasis", "mcp-tokens.enc");
480
492
  try {
481
- await fs.unlink(tokenFile);
493
+ await fs.promises.unlink(tokenFile);
482
494
  } catch (error) {
483
495
  }
484
496
  }
485
- getFileEncryptionKey() {
486
- const crypto2 = __require("crypto");
487
- const os = __require("os");
497
+ async getFileEncryptionKey() {
498
+ const { os, crypto: crypto2 } = await getNodeModules();
488
499
  const machineId = os.hostname() + os.userInfo().username;
489
500
  const salt = "lanonasis-mcp-oauth-2024";
490
501
  return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
@@ -624,6 +635,26 @@ var TokenStorage = class {
624
635
  };
625
636
 
626
637
  // src/storage/api-key-storage.ts
638
+ var _fs2 = null;
639
+ var _path2 = null;
640
+ var _os2 = null;
641
+ var _crypto2 = null;
642
+ async function getNodeModules2() {
643
+ if (_fs2 && _path2 && _os2 && _crypto2) {
644
+ return { fs: _fs2, path: _path2, os: _os2, crypto: _crypto2 };
645
+ }
646
+ const [fs, path, os, crypto2] = await Promise.all([
647
+ import("fs"),
648
+ import("path"),
649
+ import("os"),
650
+ import("crypto")
651
+ ]);
652
+ _fs2 = fs;
653
+ _path2 = path;
654
+ _os2 = os;
655
+ _crypto2 = crypto2;
656
+ return { fs, path, os, crypto: crypto2 };
657
+ }
627
658
  var ApiKeyStorage = class {
628
659
  constructor() {
629
660
  this.storageKey = "lanonasis_api_key";
@@ -823,36 +854,30 @@ var ApiKeyStorage = class {
823
854
  // ==================== Node.js File Storage ====================
824
855
  async storeToFile(keyString) {
825
856
  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");
857
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules2();
830
858
  const configDir = path.join(os.homedir(), ".lanonasis");
831
859
  const keyFile = path.join(configDir, "api-key.enc");
832
- await fs.mkdir(configDir, { recursive: true, mode: 448 });
833
- const key = this.getFileEncryptionKey();
860
+ await fs.promises.mkdir(configDir, { recursive: true, mode: 448 });
861
+ const key = await this.getFileEncryptionKey();
834
862
  const iv = crypto2.randomBytes(16);
835
863
  const cipher = crypto2.createCipheriv("aes-256-gcm", key, iv);
836
864
  let encrypted = cipher.update(keyString, "utf8", "hex");
837
865
  encrypted += cipher.final("hex");
838
866
  const authTag = cipher.getAuthTag();
839
867
  const data = iv.toString("hex") + ":" + authTag.toString("hex") + ":" + encrypted;
840
- await fs.writeFile(keyFile, data, { mode: 384 });
868
+ await fs.promises.writeFile(keyFile, data, { mode: 384 });
841
869
  }
842
870
  async retrieveFromFile() {
843
871
  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");
872
+ const { fs, path, os, crypto: crypto2 } = await getNodeModules2();
848
873
  const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
849
874
  try {
850
- const data = await fs.readFile(keyFile, "utf8");
875
+ const data = await fs.promises.readFile(keyFile, "utf8");
851
876
  const [ivHex, authTagHex, encrypted] = data.split(":");
852
877
  if (!ivHex || !authTagHex || !encrypted) {
853
878
  throw new Error("Invalid encrypted file format");
854
879
  }
855
- const key = this.getFileEncryptionKey();
880
+ const key = await this.getFileEncryptionKey();
856
881
  const iv = Buffer.from(ivHex, "hex");
857
882
  const authTag = Buffer.from(authTagHex, "hex");
858
883
  const decipher = crypto2.createDecipheriv("aes-256-gcm", key, iv);
@@ -866,41 +891,34 @@ var ApiKeyStorage = class {
866
891
  }
867
892
  async deleteFile() {
868
893
  if (!this.isNode()) return;
869
- const fs = __require("fs").promises;
870
- const path = __require("path");
871
- const os = __require("os");
894
+ const { fs, path, os } = await getNodeModules2();
872
895
  const keyFile = path.join(os.homedir(), ".lanonasis", "api-key.enc");
873
896
  try {
874
- await fs.unlink(keyFile);
897
+ await fs.promises.unlink(keyFile);
875
898
  } catch (error) {
876
899
  }
877
900
  }
878
901
  async retrieveLegacyFromFile() {
879
902
  if (!this.isNode()) return null;
880
- const fs = __require("fs").promises;
881
- const path = __require("path");
882
- const os = __require("os");
903
+ const { fs, path, os } = await getNodeModules2();
883
904
  const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
884
905
  try {
885
- return await fs.readFile(legacyFile, "utf8");
906
+ return await fs.promises.readFile(legacyFile, "utf8");
886
907
  } catch {
887
908
  return null;
888
909
  }
889
910
  }
890
911
  async deleteLegacyFile() {
891
912
  if (!this.isNode()) return;
892
- const fs = __require("fs").promises;
893
- const path = __require("path");
894
- const os = __require("os");
913
+ const { fs, path, os } = await getNodeModules2();
895
914
  const legacyFile = path.join(os.homedir(), ".lanonasis", "api-key.txt");
896
915
  try {
897
- await fs.unlink(legacyFile);
916
+ await fs.promises.unlink(legacyFile);
898
917
  } catch {
899
918
  }
900
919
  }
901
- getFileEncryptionKey() {
902
- const crypto2 = __require("crypto");
903
- const os = __require("os");
920
+ async getFileEncryptionKey() {
921
+ const { os, crypto: crypto2 } = await getNodeModules2();
904
922
  const machineId = os.hostname() + os.userInfo().username;
905
923
  const salt = "lanonasis-mcp-api-key-2024";
906
924
  return crypto2.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lanonasis/oauth-client",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "type": "module",
5
5
  "description": "OAuth and API Key authentication client for Lan Onasis MCP integration",
6
6
  "license": "MIT",