bluelamp 3.0.7 → 3.0.9

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 (175) hide show
  1. package/bin/bluelamp-base +4 -7
  2. package/lib/mcp-server/dist/InteractiveLogin.js +27 -0
  3. package/lib/mcp-server/dist/PortalAuthClient.js +1 -0
  4. package/lib/mcp-server/dist/TokenManager.js +20 -0
  5. package/lib/mcp-server/dist/plugins/plugin-manager.d.ts.map +1 -1
  6. package/lib/mcp-server/dist/plugins/plugin-manager.js +1 -1
  7. package/lib/mcp-server/dist/plugins/plugin-manager.js.map +1 -1
  8. package/lib/mcp-server/dist/secure-mcp-server.d.ts.map +1 -1
  9. package/lib/mcp-server/dist/secure-mcp-server.js +18 -16
  10. package/lib/mcp-server/dist/secure-mcp-server.js.map +1 -1
  11. package/lib/mcp-server/dist/security/ApiKeyManager.d.ts.map +1 -1
  12. package/lib/mcp-server/dist/security/ApiKeyManager.js.map +1 -1
  13. package/lib/mcp-server/dist/security/PortalAuthClient.d.ts.map +1 -1
  14. package/lib/mcp-server/dist/security/PortalAuthClient.js +1 -205
  15. package/lib/mcp-server/dist/security/PortalAuthClient.js.map +1 -1
  16. package/lib/mcp-server/dist/security/SimpleAuthManager.js +1 -1
  17. package/lib/mcp-server/dist/security/SlotAuthClient.d.ts +47 -0
  18. package/lib/mcp-server/dist/security/SlotAuthClient.d.ts.map +1 -0
  19. package/lib/mcp-server/dist/security/SlotAuthClient.js +9 -0
  20. package/lib/mcp-server/dist/security/SlotAuthClient.js.map +1 -0
  21. package/lib/mcp-server/dist/security/TokenManager.d.ts.map +1 -1
  22. package/lib/mcp-server/dist/security/TokenManager.js.map +1 -1
  23. package/lib/mcp-server/node_modules/.package-lock.json +26 -0
  24. package/lib/mcp-server/node_modules/dotenv/CHANGELOG.md +592 -0
  25. package/lib/mcp-server/node_modules/dotenv/LICENSE +23 -0
  26. package/lib/mcp-server/node_modules/dotenv/README-es.md +405 -0
  27. package/lib/mcp-server/node_modules/dotenv/README.md +692 -0
  28. package/lib/mcp-server/node_modules/dotenv/SECURITY.md +1 -0
  29. package/lib/mcp-server/node_modules/dotenv/config.d.ts +1 -0
  30. package/lib/mcp-server/node_modules/dotenv/config.js +9 -0
  31. package/lib/mcp-server/node_modules/dotenv/lib/cli-options.js +17 -0
  32. package/lib/mcp-server/node_modules/dotenv/lib/env-options.js +28 -0
  33. package/lib/mcp-server/node_modules/dotenv/lib/main.d.ts +170 -0
  34. package/lib/mcp-server/node_modules/dotenv/lib/main.js +431 -0
  35. package/lib/mcp-server/node_modules/dotenv/package.json +62 -0
  36. package/lib/mcp-server/node_modules/typescript/LICENSE.txt +55 -0
  37. package/lib/mcp-server/node_modules/typescript/README.md +50 -0
  38. package/lib/mcp-server/node_modules/typescript/SECURITY.md +41 -0
  39. package/lib/mcp-server/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  40. package/lib/mcp-server/node_modules/typescript/bin/tsc +2 -0
  41. package/lib/mcp-server/node_modules/typescript/bin/tsserver +2 -0
  42. package/lib/mcp-server/node_modules/typescript/lib/_tsc.js +133792 -0
  43. package/lib/mcp-server/node_modules/typescript/lib/_tsserver.js +659 -0
  44. package/lib/mcp-server/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  45. package/lib/mcp-server/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
  46. package/lib/mcp-server/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
  47. package/lib/mcp-server/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
  48. package/lib/mcp-server/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
  49. package/lib/mcp-server/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
  50. package/lib/mcp-server/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
  51. package/lib/mcp-server/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
  52. package/lib/mcp-server/node_modules/typescript/lib/lib.d.ts +22 -0
  53. package/lib/mcp-server/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
  54. package/lib/mcp-server/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
  55. package/lib/mcp-server/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
  56. package/lib/mcp-server/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
  57. package/lib/mcp-server/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
  58. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
  59. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
  60. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
  61. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
  62. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
  63. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
  64. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
  65. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
  66. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
  67. package/lib/mcp-server/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  68. package/lib/mcp-server/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
  69. package/lib/mcp-server/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
  70. package/lib/mcp-server/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
  71. package/lib/mcp-server/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
  72. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
  73. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
  74. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
  75. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
  76. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
  77. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
  78. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
  79. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
  80. package/lib/mcp-server/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
  81. package/lib/mcp-server/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  82. package/lib/mcp-server/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
  83. package/lib/mcp-server/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
  84. package/lib/mcp-server/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
  85. package/lib/mcp-server/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
  86. package/lib/mcp-server/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
  87. package/lib/mcp-server/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
  88. package/lib/mcp-server/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
  89. package/lib/mcp-server/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
  90. package/lib/mcp-server/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
  91. package/lib/mcp-server/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
  92. package/lib/mcp-server/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
  93. package/lib/mcp-server/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
  94. package/lib/mcp-server/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
  95. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
  96. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
  97. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
  98. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
  99. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
  100. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
  101. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
  102. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
  103. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
  104. package/lib/mcp-server/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  105. package/lib/mcp-server/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
  106. package/lib/mcp-server/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
  107. package/lib/mcp-server/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
  108. package/lib/mcp-server/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
  109. package/lib/mcp-server/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
  110. package/lib/mcp-server/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
  111. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
  112. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
  113. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
  114. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
  115. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
  116. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
  117. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
  118. package/lib/mcp-server/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
  119. package/lib/mcp-server/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
  120. package/lib/mcp-server/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
  121. package/lib/mcp-server/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
  122. package/lib/mcp-server/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
  123. package/lib/mcp-server/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
  124. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
  125. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
  126. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
  127. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
  128. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
  129. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
  130. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
  131. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
  132. package/lib/mcp-server/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
  133. package/lib/mcp-server/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
  134. package/lib/mcp-server/node_modules/typescript/lib/lib.es6.d.ts +23 -0
  135. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
  136. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
  137. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
  138. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
  139. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
  140. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
  141. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.float16.d.ts +443 -0
  142. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
  143. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
  144. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
  145. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
  146. package/lib/mcp-server/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
  147. package/lib/mcp-server/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
  148. package/lib/mcp-server/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
  149. package/lib/mcp-server/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
  150. package/lib/mcp-server/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
  151. package/lib/mcp-server/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
  152. package/lib/mcp-server/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
  153. package/lib/mcp-server/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
  154. package/lib/mcp-server/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
  155. package/lib/mcp-server/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
  156. package/lib/mcp-server/node_modules/typescript/lib/tsc.js +8 -0
  157. package/lib/mcp-server/node_modules/typescript/lib/tsserver.js +8 -0
  158. package/lib/mcp-server/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  159. package/lib/mcp-server/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  160. package/lib/mcp-server/node_modules/typescript/lib/typesMap.json +497 -0
  161. package/lib/mcp-server/node_modules/typescript/lib/typescript.d.ts +11438 -0
  162. package/lib/mcp-server/node_modules/typescript/lib/typescript.js +200253 -0
  163. package/lib/mcp-server/node_modules/typescript/lib/typingsInstaller.js +8 -0
  164. package/lib/mcp-server/node_modules/typescript/lib/watchGuard.js +53 -0
  165. package/lib/mcp-server/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
  166. package/lib/mcp-server/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
  167. package/lib/mcp-server/node_modules/typescript/package.json +120 -0
  168. package/lib/mcp-server/package-lock.json +13 -0
  169. package/lib/mcp-server/package.json +1 -0
  170. package/lib/mcp-server/src/plugins/plugin-manager.ts +0 -146
  171. package/lib/mcp-server/src/secure-mcp-server.ts +21 -10
  172. package/lib/mcp-server/src/security/ApiKeyManager.ts +1 -1
  173. package/lib/mcp-server/src/security/SlotAuthClient.ts +225 -0
  174. package/lib/mcp-server/src/security/TokenManager.ts +1 -1
  175. package/package.json +2 -1
@@ -0,0 +1,9 @@
1
+ (function () {
2
+ require('./lib/main').config(
3
+ Object.assign(
4
+ {},
5
+ require('./lib/env-options'),
6
+ require('./lib/cli-options')(process.argv)
7
+ )
8
+ )
9
+ })()
@@ -0,0 +1,17 @@
1
+ const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/
2
+
3
+ module.exports = function optionMatcher (args) {
4
+ const options = args.reduce(function (acc, cur) {
5
+ const matches = cur.match(re)
6
+ if (matches) {
7
+ acc[matches[1]] = matches[2]
8
+ }
9
+ return acc
10
+ }, {})
11
+
12
+ if (!('quiet' in options)) {
13
+ options.quiet = 'true'
14
+ }
15
+
16
+ return options
17
+ }
@@ -0,0 +1,28 @@
1
+ // ../config.js accepts options via environment variables
2
+ const options = {}
3
+
4
+ if (process.env.DOTENV_CONFIG_ENCODING != null) {
5
+ options.encoding = process.env.DOTENV_CONFIG_ENCODING
6
+ }
7
+
8
+ if (process.env.DOTENV_CONFIG_PATH != null) {
9
+ options.path = process.env.DOTENV_CONFIG_PATH
10
+ }
11
+
12
+ if (process.env.DOTENV_CONFIG_QUIET != null) {
13
+ options.quiet = process.env.DOTENV_CONFIG_QUIET
14
+ }
15
+
16
+ if (process.env.DOTENV_CONFIG_DEBUG != null) {
17
+ options.debug = process.env.DOTENV_CONFIG_DEBUG
18
+ }
19
+
20
+ if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
21
+ options.override = process.env.DOTENV_CONFIG_OVERRIDE
22
+ }
23
+
24
+ if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
25
+ options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY
26
+ }
27
+
28
+ module.exports = options
@@ -0,0 +1,170 @@
1
+ // TypeScript Version: 3.0
2
+ /// <reference types="node" />
3
+ import type { URL } from 'url';
4
+
5
+ export interface DotenvParseOutput {
6
+ [name: string]: string;
7
+ }
8
+
9
+ export interface DotenvPopulateOutput {
10
+ [name: string]: string;
11
+ }
12
+
13
+ /**
14
+ * Parses a string or buffer in the .env file format into an object.
15
+ *
16
+ * See https://dotenvx.com/docs
17
+ *
18
+ * @param src - contents to be parsed. example: `'DB_HOST=localhost'`
19
+ * @returns an object with keys and values based on `src`. example: `{ DB_HOST : 'localhost' }`
20
+ */
21
+ export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
22
+ src: string | Buffer
23
+ ): T;
24
+
25
+ export interface DotenvConfigOptions {
26
+ /**
27
+ * Default: `path.resolve(process.cwd(), '.env')`
28
+ *
29
+ * Specify a custom path if your file containing environment variables is located elsewhere.
30
+ * Can also be an array of strings, specifying multiple paths.
31
+ *
32
+ * example: `require('dotenv').config({ path: '/custom/path/to/.env' })`
33
+ * example: `require('dotenv').config({ path: ['/path/to/first.env', '/path/to/second.env'] })`
34
+ */
35
+ path?: string | string[] | URL;
36
+
37
+ /**
38
+ * Default: `utf8`
39
+ *
40
+ * Specify the encoding of your file containing environment variables.
41
+ *
42
+ * example: `require('dotenv').config({ encoding: 'latin1' })`
43
+ */
44
+ encoding?: string;
45
+
46
+ /**
47
+ * Default: `false`
48
+ *
49
+ * Suppress all output (except errors).
50
+ *
51
+ * example: `require('dotenv').config({ quiet: true })`
52
+ */
53
+ quiet?: boolean;
54
+
55
+ /**
56
+ * Default: `false`
57
+ *
58
+ * Turn on logging to help debug why certain keys or values are not being set as you expect.
59
+ *
60
+ * example: `require('dotenv').config({ debug: process.env.DEBUG })`
61
+ */
62
+ debug?: boolean;
63
+
64
+ /**
65
+ * Default: `false`
66
+ *
67
+ * Override any environment variables that have already been set on your machine with values from your .env file.
68
+ *
69
+ * example: `require('dotenv').config({ override: true })`
70
+ */
71
+ override?: boolean;
72
+
73
+ /**
74
+ * Default: `process.env`
75
+ *
76
+ * Specify an object to write your secrets to. Defaults to process.env environment variables.
77
+ *
78
+ * example: `const processEnv = {}; require('dotenv').config({ processEnv: processEnv })`
79
+ */
80
+ processEnv?: DotenvPopulateInput;
81
+
82
+ /**
83
+ * Default: `undefined`
84
+ *
85
+ * Pass the DOTENV_KEY directly to config options. Defaults to looking for process.env.DOTENV_KEY environment variable. Note this only applies to decrypting .env.vault files. If passed as null or undefined, or not passed at all, dotenv falls back to its traditional job of parsing a .env file.
86
+ *
87
+ * example: `require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' })`
88
+ */
89
+ DOTENV_KEY?: string;
90
+ }
91
+
92
+ export interface DotenvConfigOutput {
93
+ error?: Error;
94
+ parsed?: DotenvParseOutput;
95
+ }
96
+
97
+ export interface DotenvPopulateOptions {
98
+ /**
99
+ * Default: `false`
100
+ *
101
+ * Turn on logging to help debug why certain keys or values are not being set as you expect.
102
+ *
103
+ * example: `require('dotenv').config({ debug: process.env.DEBUG })`
104
+ */
105
+ debug?: boolean;
106
+
107
+ /**
108
+ * Default: `false`
109
+ *
110
+ * Override any environment variables that have already been set on your machine with values from your .env file.
111
+ *
112
+ * example: `require('dotenv').config({ override: true })`
113
+ */
114
+ override?: boolean;
115
+ }
116
+
117
+ export interface DotenvPopulateInput {
118
+ [name: string]: string;
119
+ }
120
+
121
+ /**
122
+ * Loads `.env` file contents into process.env by default. If `DOTENV_KEY` is present, it smartly attempts to load encrypted `.env.vault` file contents into process.env.
123
+ *
124
+ * See https://dotenvx.com/docs
125
+ *
126
+ * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', quiet: false, debug: true, override: false }`
127
+ * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
128
+ *
129
+ */
130
+ export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
131
+
132
+ /**
133
+ * Loads `.env` file contents into process.env.
134
+ *
135
+ * See https://dotenvx.com/docs
136
+ *
137
+ * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', quiet: false, debug: true, override: false }`
138
+ * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
139
+ *
140
+ */
141
+ export function configDotenv(options?: DotenvConfigOptions): DotenvConfigOutput;
142
+
143
+ /**
144
+ * Loads `source` json contents into `target` like process.env.
145
+ *
146
+ * See https://dotenvx.com/docs
147
+ *
148
+ * @param processEnv - the target JSON object. in most cases use process.env but you can also pass your own JSON object
149
+ * @param parsed - the source JSON object
150
+ * @param options - additional options. example: `{ quiet: false, debug: true, override: false }`
151
+ * @returns an object with the keys and values that were actually set
152
+ *
153
+ */
154
+ export function populate(
155
+ processEnv: DotenvPopulateInput,
156
+ parsed: DotenvPopulateInput,
157
+ options?: DotenvConfigOptions
158
+ ): DotenvPopulateOutput;
159
+
160
+ /**
161
+ * Decrypt ciphertext
162
+ *
163
+ * See https://dotenvx.com/docs
164
+ *
165
+ * @param encrypted - the encrypted ciphertext string
166
+ * @param keyStr - the decryption key string
167
+ * @returns {string}
168
+ *
169
+ */
170
+ export function decrypt(encrypted: string, keyStr: string): string;
@@ -0,0 +1,431 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const os = require('os')
4
+ const crypto = require('crypto')
5
+ const packageJson = require('../package.json')
6
+
7
+ const version = packageJson.version
8
+
9
+ // Array of tips to display randomly
10
+ const TIPS = [
11
+ '🔐 encrypt with Dotenvx: https://dotenvx.com',
12
+ '🔐 prevent committing .env to code: https://dotenvx.com/precommit',
13
+ '🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
14
+ '📡 observe env with Radar: https://dotenvx.com/radar',
15
+ '📡 auto-backup env with Radar: https://dotenvx.com/radar',
16
+ '📡 version env with Radar: https://dotenvx.com/radar',
17
+ '🛠️ run anywhere with `dotenvx run -- yourcommand`',
18
+ '⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
19
+ '⚙️ enable debug logging with { debug: true }',
20
+ '⚙️ override existing env vars with { override: true }',
21
+ '⚙️ suppress all logs with { quiet: true }',
22
+ '⚙️ write to custom object with { processEnv: myObject }',
23
+ '⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
24
+ ]
25
+
26
+ // Get a random tip from the tips array
27
+ function _getRandomTip () {
28
+ return TIPS[Math.floor(Math.random() * TIPS.length)]
29
+ }
30
+
31
+ function parseBoolean (value) {
32
+ if (typeof value === 'string') {
33
+ return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
34
+ }
35
+ return Boolean(value)
36
+ }
37
+
38
+ function supportsAnsi () {
39
+ return process.stdout.isTTY // && process.env.TERM !== 'dumb'
40
+ }
41
+
42
+ function dim (text) {
43
+ return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
44
+ }
45
+
46
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
47
+
48
+ // Parse src into an Object
49
+ function parse (src) {
50
+ const obj = {}
51
+
52
+ // Convert buffer to string
53
+ let lines = src.toString()
54
+
55
+ // Convert line breaks to same format
56
+ lines = lines.replace(/\r\n?/mg, '\n')
57
+
58
+ let match
59
+ while ((match = LINE.exec(lines)) != null) {
60
+ const key = match[1]
61
+
62
+ // Default undefined or null to empty string
63
+ let value = (match[2] || '')
64
+
65
+ // Remove whitespace
66
+ value = value.trim()
67
+
68
+ // Check if double quoted
69
+ const maybeQuote = value[0]
70
+
71
+ // Remove surrounding quotes
72
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2')
73
+
74
+ // Expand newlines if double quoted
75
+ if (maybeQuote === '"') {
76
+ value = value.replace(/\\n/g, '\n')
77
+ value = value.replace(/\\r/g, '\r')
78
+ }
79
+
80
+ // Add to object
81
+ obj[key] = value
82
+ }
83
+
84
+ return obj
85
+ }
86
+
87
+ function _parseVault (options) {
88
+ options = options || {}
89
+
90
+ const vaultPath = _vaultPath(options)
91
+ options.path = vaultPath // parse .env.vault
92
+ const result = DotenvModule.configDotenv(options)
93
+ if (!result.parsed) {
94
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
95
+ err.code = 'MISSING_DATA'
96
+ throw err
97
+ }
98
+
99
+ // handle scenario for comma separated keys - for use with key rotation
100
+ // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
101
+ const keys = _dotenvKey(options).split(',')
102
+ const length = keys.length
103
+
104
+ let decrypted
105
+ for (let i = 0; i < length; i++) {
106
+ try {
107
+ // Get full key
108
+ const key = keys[i].trim()
109
+
110
+ // Get instructions for decrypt
111
+ const attrs = _instructions(result, key)
112
+
113
+ // Decrypt
114
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)
115
+
116
+ break
117
+ } catch (error) {
118
+ // last key
119
+ if (i + 1 >= length) {
120
+ throw error
121
+ }
122
+ // try next key
123
+ }
124
+ }
125
+
126
+ // Parse decrypted .env string
127
+ return DotenvModule.parse(decrypted)
128
+ }
129
+
130
+ function _warn (message) {
131
+ console.error(`[dotenv@${version}][WARN] ${message}`)
132
+ }
133
+
134
+ function _debug (message) {
135
+ console.log(`[dotenv@${version}][DEBUG] ${message}`)
136
+ }
137
+
138
+ function _log (message) {
139
+ console.log(`[dotenv@${version}] ${message}`)
140
+ }
141
+
142
+ function _dotenvKey (options) {
143
+ // prioritize developer directly setting options.DOTENV_KEY
144
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
145
+ return options.DOTENV_KEY
146
+ }
147
+
148
+ // secondary infra already contains a DOTENV_KEY environment variable
149
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
150
+ return process.env.DOTENV_KEY
151
+ }
152
+
153
+ // fallback to empty string
154
+ return ''
155
+ }
156
+
157
+ function _instructions (result, dotenvKey) {
158
+ // Parse DOTENV_KEY. Format is a URI
159
+ let uri
160
+ try {
161
+ uri = new URL(dotenvKey)
162
+ } catch (error) {
163
+ if (error.code === 'ERR_INVALID_URL') {
164
+ const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development')
165
+ err.code = 'INVALID_DOTENV_KEY'
166
+ throw err
167
+ }
168
+
169
+ throw error
170
+ }
171
+
172
+ // Get decrypt key
173
+ const key = uri.password
174
+ if (!key) {
175
+ const err = new Error('INVALID_DOTENV_KEY: Missing key part')
176
+ err.code = 'INVALID_DOTENV_KEY'
177
+ throw err
178
+ }
179
+
180
+ // Get environment
181
+ const environment = uri.searchParams.get('environment')
182
+ if (!environment) {
183
+ const err = new Error('INVALID_DOTENV_KEY: Missing environment part')
184
+ err.code = 'INVALID_DOTENV_KEY'
185
+ throw err
186
+ }
187
+
188
+ // Get ciphertext payload
189
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`
190
+ const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION
191
+ if (!ciphertext) {
192
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
193
+ err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'
194
+ throw err
195
+ }
196
+
197
+ return { ciphertext, key }
198
+ }
199
+
200
+ function _vaultPath (options) {
201
+ let possibleVaultPath = null
202
+
203
+ if (options && options.path && options.path.length > 0) {
204
+ if (Array.isArray(options.path)) {
205
+ for (const filepath of options.path) {
206
+ if (fs.existsSync(filepath)) {
207
+ possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`
208
+ }
209
+ }
210
+ } else {
211
+ possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`
212
+ }
213
+ } else {
214
+ possibleVaultPath = path.resolve(process.cwd(), '.env.vault')
215
+ }
216
+
217
+ if (fs.existsSync(possibleVaultPath)) {
218
+ return possibleVaultPath
219
+ }
220
+
221
+ return null
222
+ }
223
+
224
+ function _resolveHome (envPath) {
225
+ return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
226
+ }
227
+
228
+ function _configVault (options) {
229
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug))
230
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet))
231
+
232
+ if (debug || !quiet) {
233
+ _log('Loading env from encrypted .env.vault')
234
+ }
235
+
236
+ const parsed = DotenvModule._parseVault(options)
237
+
238
+ let processEnv = process.env
239
+ if (options && options.processEnv != null) {
240
+ processEnv = options.processEnv
241
+ }
242
+
243
+ DotenvModule.populate(processEnv, parsed, options)
244
+
245
+ return { parsed }
246
+ }
247
+
248
+ function configDotenv (options) {
249
+ const dotenvPath = path.resolve(process.cwd(), '.env')
250
+ let encoding = 'utf8'
251
+ let processEnv = process.env
252
+ if (options && options.processEnv != null) {
253
+ processEnv = options.processEnv
254
+ }
255
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug))
256
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet))
257
+
258
+ if (options && options.encoding) {
259
+ encoding = options.encoding
260
+ } else {
261
+ if (debug) {
262
+ _debug('No encoding is specified. UTF-8 is used by default')
263
+ }
264
+ }
265
+
266
+ let optionPaths = [dotenvPath] // default, look for .env
267
+ if (options && options.path) {
268
+ if (!Array.isArray(options.path)) {
269
+ optionPaths = [_resolveHome(options.path)]
270
+ } else {
271
+ optionPaths = [] // reset default
272
+ for (const filepath of options.path) {
273
+ optionPaths.push(_resolveHome(filepath))
274
+ }
275
+ }
276
+ }
277
+
278
+ // Build the parsed data in a temporary object (because we need to return it). Once we have the final
279
+ // parsed data, we will combine it with process.env (or options.processEnv if provided).
280
+ let lastError
281
+ const parsedAll = {}
282
+ for (const path of optionPaths) {
283
+ try {
284
+ // Specifying an encoding returns a string instead of a buffer
285
+ const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))
286
+
287
+ DotenvModule.populate(parsedAll, parsed, options)
288
+ } catch (e) {
289
+ if (debug) {
290
+ _debug(`Failed to load ${path} ${e.message}`)
291
+ }
292
+ lastError = e
293
+ }
294
+ }
295
+
296
+ const populated = DotenvModule.populate(processEnv, parsedAll, options)
297
+
298
+ // handle user settings DOTENV_CONFIG_ options inside .env file(s)
299
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug)
300
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet)
301
+
302
+ if (debug || !quiet) {
303
+ const keysCount = Object.keys(populated).length
304
+ const shortPaths = []
305
+ for (const filePath of optionPaths) {
306
+ try {
307
+ const relative = path.relative(process.cwd(), filePath)
308
+ shortPaths.push(relative)
309
+ } catch (e) {
310
+ if (debug) {
311
+ _debug(`Failed to load ${filePath} ${e.message}`)
312
+ }
313
+ lastError = e
314
+ }
315
+ }
316
+
317
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`)
318
+ }
319
+
320
+ if (lastError) {
321
+ return { parsed: parsedAll, error: lastError }
322
+ } else {
323
+ return { parsed: parsedAll }
324
+ }
325
+ }
326
+
327
+ // Populates process.env from .env file
328
+ function config (options) {
329
+ // fallback to original dotenv if DOTENV_KEY is not set
330
+ if (_dotenvKey(options).length === 0) {
331
+ return DotenvModule.configDotenv(options)
332
+ }
333
+
334
+ const vaultPath = _vaultPath(options)
335
+
336
+ // dotenvKey exists but .env.vault file does not exist
337
+ if (!vaultPath) {
338
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)
339
+
340
+ return DotenvModule.configDotenv(options)
341
+ }
342
+
343
+ return DotenvModule._configVault(options)
344
+ }
345
+
346
+ function decrypt (encrypted, keyStr) {
347
+ const key = Buffer.from(keyStr.slice(-64), 'hex')
348
+ let ciphertext = Buffer.from(encrypted, 'base64')
349
+
350
+ const nonce = ciphertext.subarray(0, 12)
351
+ const authTag = ciphertext.subarray(-16)
352
+ ciphertext = ciphertext.subarray(12, -16)
353
+
354
+ try {
355
+ const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)
356
+ aesgcm.setAuthTag(authTag)
357
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
358
+ } catch (error) {
359
+ const isRange = error instanceof RangeError
360
+ const invalidKeyLength = error.message === 'Invalid key length'
361
+ const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'
362
+
363
+ if (isRange || invalidKeyLength) {
364
+ const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')
365
+ err.code = 'INVALID_DOTENV_KEY'
366
+ throw err
367
+ } else if (decryptionFailed) {
368
+ const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')
369
+ err.code = 'DECRYPTION_FAILED'
370
+ throw err
371
+ } else {
372
+ throw error
373
+ }
374
+ }
375
+ }
376
+
377
+ // Populate process.env with parsed values
378
+ function populate (processEnv, parsed, options = {}) {
379
+ const debug = Boolean(options && options.debug)
380
+ const override = Boolean(options && options.override)
381
+ const populated = {}
382
+
383
+ if (typeof parsed !== 'object') {
384
+ const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
385
+ err.code = 'OBJECT_REQUIRED'
386
+ throw err
387
+ }
388
+
389
+ // Set process.env
390
+ for (const key of Object.keys(parsed)) {
391
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
392
+ if (override === true) {
393
+ processEnv[key] = parsed[key]
394
+ populated[key] = parsed[key]
395
+ }
396
+
397
+ if (debug) {
398
+ if (override === true) {
399
+ _debug(`"${key}" is already defined and WAS overwritten`)
400
+ } else {
401
+ _debug(`"${key}" is already defined and was NOT overwritten`)
402
+ }
403
+ }
404
+ } else {
405
+ processEnv[key] = parsed[key]
406
+ populated[key] = parsed[key]
407
+ }
408
+ }
409
+
410
+ return populated
411
+ }
412
+
413
+ const DotenvModule = {
414
+ configDotenv,
415
+ _configVault,
416
+ _parseVault,
417
+ config,
418
+ decrypt,
419
+ parse,
420
+ populate
421
+ }
422
+
423
+ module.exports.configDotenv = DotenvModule.configDotenv
424
+ module.exports._configVault = DotenvModule._configVault
425
+ module.exports._parseVault = DotenvModule._parseVault
426
+ module.exports.config = DotenvModule.config
427
+ module.exports.decrypt = DotenvModule.decrypt
428
+ module.exports.parse = DotenvModule.parse
429
+ module.exports.populate = DotenvModule.populate
430
+
431
+ module.exports = DotenvModule