@fireberry/sdk 0.0.4 → 0.0.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.
Files changed (276) hide show
  1. package/{node_modules/asynckit/LICENSE → LICENSE.md} +2 -2
  2. package/README.md +136 -37
  3. package/dist/cjs/constants/index.d.ts +18 -0
  4. package/dist/cjs/constants/index.d.ts.map +1 -0
  5. package/dist/cjs/constants/index.js +21 -0
  6. package/dist/cjs/constants/index.js.map +1 -0
  7. package/dist/cjs/context/context.d.ts +7 -0
  8. package/dist/cjs/context/context.d.ts.map +1 -0
  9. package/dist/cjs/context/context.js +11 -0
  10. package/dist/cjs/context/context.js.map +1 -0
  11. package/dist/cjs/context/index.d.ts +2 -0
  12. package/dist/cjs/context/index.d.ts.map +1 -0
  13. package/dist/cjs/context/index.js.map +1 -0
  14. package/dist/cjs/fireberrySDK.client.d.ts +32 -0
  15. package/dist/cjs/fireberrySDK.client.d.ts.map +1 -0
  16. package/dist/cjs/fireberrySDK.client.js +102 -0
  17. package/dist/cjs/fireberrySDK.client.js.map +1 -0
  18. package/dist/cjs/iframeMessageManager.d.ts +13 -0
  19. package/dist/cjs/iframeMessageManager.d.ts.map +1 -0
  20. package/dist/cjs/iframeMessageManager.js +88 -0
  21. package/dist/cjs/iframeMessageManager.js.map +1 -0
  22. package/dist/cjs/types/index.d.ts +86 -0
  23. package/dist/cjs/types/index.d.ts.map +1 -0
  24. package/dist/{fireberryAPI/types.js → cjs/types/index.js} +1 -1
  25. package/dist/cjs/types/index.js.map +1 -0
  26. package/dist/esm/constants/index.d.ts +18 -0
  27. package/dist/esm/constants/index.d.ts.map +1 -0
  28. package/dist/esm/constants/index.js +18 -0
  29. package/dist/esm/constants/index.js.map +1 -0
  30. package/dist/esm/context/context.d.ts +7 -0
  31. package/dist/esm/context/context.d.ts.map +1 -0
  32. package/dist/esm/context/context.js +7 -0
  33. package/dist/esm/context/context.js.map +1 -0
  34. package/dist/esm/context/index.d.ts +2 -0
  35. package/dist/esm/context/index.d.ts.map +1 -0
  36. package/dist/esm/context/index.js +2 -0
  37. package/dist/esm/context/index.js.map +1 -0
  38. package/dist/esm/fireberrySDK.client.d.ts +32 -0
  39. package/dist/esm/fireberrySDK.client.d.ts.map +1 -0
  40. package/dist/esm/fireberrySDK.client.js +98 -0
  41. package/dist/esm/fireberrySDK.client.js.map +1 -0
  42. package/dist/esm/iframeMessageManager.d.ts +13 -0
  43. package/dist/esm/iframeMessageManager.d.ts.map +1 -0
  44. package/dist/esm/iframeMessageManager.js +84 -0
  45. package/dist/esm/iframeMessageManager.js.map +1 -0
  46. package/dist/esm/types/index.d.ts +86 -0
  47. package/dist/esm/types/index.d.ts.map +1 -0
  48. package/dist/esm/types/index.js +2 -0
  49. package/dist/esm/types/index.js.map +1 -0
  50. package/package.json +54 -27
  51. package/.eslintrc.json +0 -36
  52. package/.prettierrc.json +0 -7
  53. package/.vscode/settings.json +0 -35
  54. package/dist/base.fireberrySDK.d.ts +0 -7
  55. package/dist/base.fireberrySDK.js +0 -10
  56. package/dist/base.fireberrySDK.js.map +0 -1
  57. package/dist/context/context.d.ts +0 -13
  58. package/dist/context/context.js +0 -22
  59. package/dist/context/context.js.map +0 -1
  60. package/dist/context/context.record.test.d.ts +0 -1
  61. package/dist/context/context.record.test.js +0 -45
  62. package/dist/context/context.record.test.js.map +0 -1
  63. package/dist/context/index.d.ts +0 -5
  64. package/dist/context/index.js.map +0 -1
  65. package/dist/context/record.d.ts +0 -9
  66. package/dist/context/record.js +0 -33
  67. package/dist/context/record.js.map +0 -1
  68. package/dist/context/user.d.ts +0 -5
  69. package/dist/context/user.js +0 -27
  70. package/dist/context/user.js.map +0 -1
  71. package/dist/fireberry.sdk.d.ts +0 -4
  72. package/dist/fireberry.sdk.js +0 -13
  73. package/dist/fireberry.sdk.js.map +0 -1
  74. package/dist/fireberryAPI/fireberryV2Api.d.ts +0 -17
  75. package/dist/fireberryAPI/fireberryV2Api.js +0 -54
  76. package/dist/fireberryAPI/fireberryV2Api.js.map +0 -1
  77. package/dist/fireberryAPI/fireberryV2Api.test.d.ts +0 -1
  78. package/dist/fireberryAPI/fireberryV2Api.test.js +0 -56
  79. package/dist/fireberryAPI/fireberryV2Api.test.js.map +0 -1
  80. package/dist/fireberryAPI/index.d.ts +0 -2
  81. package/dist/fireberryAPI/index.js +0 -21
  82. package/dist/fireberryAPI/index.js.map +0 -1
  83. package/dist/fireberryAPI/types.d.ts +0 -10
  84. package/dist/fireberryAPI/types.js.map +0 -1
  85. package/dist/fireberrySDK.client.d.ts +0 -5
  86. package/dist/fireberrySDK.client.js +0 -13
  87. package/dist/fireberrySDK.client.js.map +0 -1
  88. package/dist/fireberrySDK.server.d.ts +0 -6
  89. package/dist/fireberrySDK.server.js +0 -12
  90. package/dist/fireberrySDK.server.js.map +0 -1
  91. package/dist/index.d.ts +0 -6
  92. package/dist/index.js +0 -25
  93. package/dist/index.js.map +0 -1
  94. package/dist/utils/axios.util.d.ts +0 -6
  95. package/dist/utils/axios.util.js +0 -24
  96. package/dist/utils/axios.util.js.map +0 -1
  97. package/dist/utils/index.d.ts +0 -2
  98. package/dist/utils/index.js +0 -19
  99. package/dist/utils/index.js.map +0 -1
  100. package/dist/utils/queryParam.util.d.ts +0 -1
  101. package/dist/utils/queryParam.util.js +0 -12
  102. package/dist/utils/queryParam.util.js.map +0 -1
  103. package/jest.config.ts +0 -10
  104. package/node_modules/asynckit/README.md +0 -233
  105. package/node_modules/asynckit/bench.js +0 -76
  106. package/node_modules/asynckit/index.js +0 -6
  107. package/node_modules/asynckit/lib/abort.js +0 -29
  108. package/node_modules/asynckit/lib/async.js +0 -34
  109. package/node_modules/asynckit/lib/defer.js +0 -26
  110. package/node_modules/asynckit/lib/iterate.js +0 -75
  111. package/node_modules/asynckit/lib/readable_asynckit.js +0 -91
  112. package/node_modules/asynckit/lib/readable_parallel.js +0 -25
  113. package/node_modules/asynckit/lib/readable_serial.js +0 -25
  114. package/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
  115. package/node_modules/asynckit/lib/state.js +0 -37
  116. package/node_modules/asynckit/lib/streamify.js +0 -141
  117. package/node_modules/asynckit/lib/terminator.js +0 -29
  118. package/node_modules/asynckit/package.json +0 -63
  119. package/node_modules/asynckit/parallel.js +0 -43
  120. package/node_modules/asynckit/serial.js +0 -17
  121. package/node_modules/asynckit/serialOrdered.js +0 -75
  122. package/node_modules/asynckit/stream.js +0 -21
  123. package/node_modules/axios/CHANGELOG.md +0 -874
  124. package/node_modules/axios/LICENSE +0 -7
  125. package/node_modules/axios/MIGRATION_GUIDE.md +0 -3
  126. package/node_modules/axios/README.md +0 -1650
  127. package/node_modules/axios/SECURITY.md +0 -6
  128. package/node_modules/axios/dist/axios.js +0 -3448
  129. package/node_modules/axios/dist/axios.js.map +0 -1
  130. package/node_modules/axios/dist/axios.min.js +0 -2
  131. package/node_modules/axios/dist/axios.min.js.map +0 -1
  132. package/node_modules/axios/dist/browser/axios.cjs +0 -3258
  133. package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
  134. package/node_modules/axios/dist/esm/axios.js +0 -3281
  135. package/node_modules/axios/dist/esm/axios.js.map +0 -1
  136. package/node_modules/axios/dist/esm/axios.min.js +0 -2
  137. package/node_modules/axios/dist/esm/axios.min.js.map +0 -1
  138. package/node_modules/axios/dist/node/axios.cjs +0 -4354
  139. package/node_modules/axios/dist/node/axios.cjs.map +0 -1
  140. package/node_modules/axios/index.d.cts +0 -542
  141. package/node_modules/axios/index.d.ts +0 -559
  142. package/node_modules/axios/index.js +0 -43
  143. package/node_modules/axios/lib/adapters/README.md +0 -37
  144. package/node_modules/axios/lib/adapters/adapters.js +0 -77
  145. package/node_modules/axios/lib/adapters/http.js +0 -685
  146. package/node_modules/axios/lib/adapters/xhr.js +0 -260
  147. package/node_modules/axios/lib/axios.js +0 -89
  148. package/node_modules/axios/lib/cancel/CancelToken.js +0 -121
  149. package/node_modules/axios/lib/cancel/CanceledError.js +0 -25
  150. package/node_modules/axios/lib/cancel/isCancel.js +0 -5
  151. package/node_modules/axios/lib/core/Axios.js +0 -225
  152. package/node_modules/axios/lib/core/AxiosError.js +0 -100
  153. package/node_modules/axios/lib/core/AxiosHeaders.js +0 -298
  154. package/node_modules/axios/lib/core/InterceptorManager.js +0 -71
  155. package/node_modules/axios/lib/core/README.md +0 -8
  156. package/node_modules/axios/lib/core/buildFullPath.js +0 -21
  157. package/node_modules/axios/lib/core/dispatchRequest.js +0 -81
  158. package/node_modules/axios/lib/core/mergeConfig.js +0 -106
  159. package/node_modules/axios/lib/core/settle.js +0 -27
  160. package/node_modules/axios/lib/core/transformData.js +0 -28
  161. package/node_modules/axios/lib/defaults/index.js +0 -156
  162. package/node_modules/axios/lib/defaults/transitional.js +0 -7
  163. package/node_modules/axios/lib/env/README.md +0 -3
  164. package/node_modules/axios/lib/env/classes/FormData.js +0 -2
  165. package/node_modules/axios/lib/env/data.js +0 -1
  166. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -191
  167. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -58
  168. package/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
  169. package/node_modules/axios/lib/helpers/README.md +0 -7
  170. package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -28
  171. package/node_modules/axios/lib/helpers/bind.js +0 -7
  172. package/node_modules/axios/lib/helpers/buildURL.js +0 -63
  173. package/node_modules/axios/lib/helpers/callbackify.js +0 -16
  174. package/node_modules/axios/lib/helpers/combineURLs.js +0 -15
  175. package/node_modules/axios/lib/helpers/cookies.js +0 -42
  176. package/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -26
  177. package/node_modules/axios/lib/helpers/formDataToJSON.js +0 -95
  178. package/node_modules/axios/lib/helpers/formDataToStream.js +0 -111
  179. package/node_modules/axios/lib/helpers/fromDataURI.js +0 -53
  180. package/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -15
  181. package/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  182. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -67
  183. package/node_modules/axios/lib/helpers/null.js +0 -2
  184. package/node_modules/axios/lib/helpers/parseHeaders.js +0 -55
  185. package/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
  186. package/node_modules/axios/lib/helpers/readBlob.js +0 -15
  187. package/node_modules/axios/lib/helpers/speedometer.js +0 -55
  188. package/node_modules/axios/lib/helpers/spread.js +0 -28
  189. package/node_modules/axios/lib/helpers/throttle.js +0 -33
  190. package/node_modules/axios/lib/helpers/toFormData.js +0 -219
  191. package/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -18
  192. package/node_modules/axios/lib/helpers/validator.js +0 -91
  193. package/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
  194. package/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
  195. package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
  196. package/node_modules/axios/lib/platform/browser/index.js +0 -13
  197. package/node_modules/axios/lib/platform/common/utils.js +0 -47
  198. package/node_modules/axios/lib/platform/index.js +0 -7
  199. package/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
  200. package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
  201. package/node_modules/axios/lib/platform/node/index.js +0 -12
  202. package/node_modules/axios/lib/utils.js +0 -723
  203. package/node_modules/axios/package.json +0 -218
  204. package/node_modules/combined-stream/License +0 -19
  205. package/node_modules/combined-stream/Readme.md +0 -138
  206. package/node_modules/combined-stream/lib/combined_stream.js +0 -208
  207. package/node_modules/combined-stream/package.json +0 -25
  208. package/node_modules/delayed-stream/.npmignore +0 -1
  209. package/node_modules/delayed-stream/License +0 -19
  210. package/node_modules/delayed-stream/Makefile +0 -7
  211. package/node_modules/delayed-stream/Readme.md +0 -141
  212. package/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
  213. package/node_modules/delayed-stream/package.json +0 -27
  214. package/node_modules/dotenv/CHANGELOG.md +0 -475
  215. package/node_modules/dotenv/LICENSE +0 -23
  216. package/node_modules/dotenv/README-es.md +0 -448
  217. package/node_modules/dotenv/README.md +0 -728
  218. package/node_modules/dotenv/config.d.ts +0 -1
  219. package/node_modules/dotenv/config.js +0 -9
  220. package/node_modules/dotenv/lib/cli-options.js +0 -11
  221. package/node_modules/dotenv/lib/env-options.js +0 -24
  222. package/node_modules/dotenv/lib/main.d.ts +0 -153
  223. package/node_modules/dotenv/lib/main.js +0 -361
  224. package/node_modules/dotenv/package.json +0 -65
  225. package/node_modules/follow-redirects/LICENSE +0 -18
  226. package/node_modules/follow-redirects/README.md +0 -155
  227. package/node_modules/follow-redirects/debug.js +0 -15
  228. package/node_modules/follow-redirects/http.js +0 -1
  229. package/node_modules/follow-redirects/https.js +0 -1
  230. package/node_modules/follow-redirects/index.js +0 -672
  231. package/node_modules/follow-redirects/package.json +0 -58
  232. package/node_modules/form-data/License +0 -19
  233. package/node_modules/form-data/README.md.bak +0 -358
  234. package/node_modules/form-data/Readme.md +0 -358
  235. package/node_modules/form-data/index.d.ts +0 -62
  236. package/node_modules/form-data/lib/browser.js +0 -2
  237. package/node_modules/form-data/lib/form_data.js +0 -501
  238. package/node_modules/form-data/lib/populate.js +0 -10
  239. package/node_modules/form-data/package.json +0 -68
  240. package/node_modules/mime-db/HISTORY.md +0 -507
  241. package/node_modules/mime-db/LICENSE +0 -23
  242. package/node_modules/mime-db/README.md +0 -100
  243. package/node_modules/mime-db/db.json +0 -8519
  244. package/node_modules/mime-db/index.js +0 -12
  245. package/node_modules/mime-db/package.json +0 -60
  246. package/node_modules/mime-types/HISTORY.md +0 -397
  247. package/node_modules/mime-types/LICENSE +0 -23
  248. package/node_modules/mime-types/README.md +0 -113
  249. package/node_modules/mime-types/index.js +0 -188
  250. package/node_modules/mime-types/package.json +0 -44
  251. package/node_modules/proxy-from-env/.eslintrc +0 -29
  252. package/node_modules/proxy-from-env/.travis.yml +0 -10
  253. package/node_modules/proxy-from-env/LICENSE +0 -20
  254. package/node_modules/proxy-from-env/README.md +0 -131
  255. package/node_modules/proxy-from-env/index.js +0 -108
  256. package/node_modules/proxy-from-env/package.json +0 -34
  257. package/node_modules/proxy-from-env/test.js +0 -483
  258. package/src/base.fireberrySDK.ts +0 -7
  259. package/src/context/context.record.test.ts +0 -47
  260. package/src/context/context.ts +0 -28
  261. package/src/context/index.ts +0 -6
  262. package/src/context/record.ts +0 -22
  263. package/src/context/user.ts +0 -15
  264. package/src/fireberry.sdk.ts +0 -14
  265. package/src/fireberryAPI/fireberryV2Api.test.ts +0 -57
  266. package/src/fireberryAPI/fireberryV2Api.ts +0 -61
  267. package/src/fireberryAPI/index.ts +0 -2
  268. package/src/fireberryAPI/types.ts +0 -10
  269. package/src/fireberrySDK.client.ts +0 -10
  270. package/src/fireberrySDK.server.ts +0 -8
  271. package/src/index.ts +0 -9
  272. package/src/utils/axios.util.ts +0 -20
  273. package/src/utils/index.ts +0 -2
  274. package/src/utils/queryParam.util.ts +0 -8
  275. package/tsconfig.json +0 -123
  276. /package/dist/{context → cjs/context}/index.js +0 -0
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
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
- })()
@@ -1,11 +0,0 @@
1
- const re = /^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/
2
-
3
- module.exports = function optionMatcher (args) {
4
- return 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
- }
@@ -1,24 +0,0 @@
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_DEBUG != null) {
13
- options.debug = process.env.DOTENV_CONFIG_DEBUG
14
- }
15
-
16
- if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
17
- options.override = process.env.DOTENV_CONFIG_OVERRIDE
18
- }
19
-
20
- if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
21
- options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY
22
- }
23
-
24
- module.exports = options
@@ -1,153 +0,0 @@
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
- /**
10
- * Parses a string or buffer in the .env file format into an object.
11
- *
12
- * See https://dotenvx.com/docs
13
- *
14
- * @param src - contents to be parsed. example: `'DB_HOST=localhost'`
15
- * @returns an object with keys and values based on `src`. example: `{ DB_HOST : 'localhost' }`
16
- */
17
- export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
18
- src: string | Buffer
19
- ): T;
20
-
21
- export interface DotenvConfigOptions {
22
- /**
23
- * Default: `path.resolve(process.cwd(), '.env')`
24
- *
25
- * Specify a custom path if your file containing environment variables is located elsewhere.
26
- * Can also be an array of strings, specifying multiple paths.
27
- *
28
- * example: `require('dotenv').config({ path: '/custom/path/to/.env' })`
29
- * example: `require('dotenv').config({ path: ['/path/to/first.env', '/path/to/second.env'] })`
30
- */
31
- path?: string | string[] | URL;
32
-
33
- /**
34
- * Default: `utf8`
35
- *
36
- * Specify the encoding of your file containing environment variables.
37
- *
38
- * example: `require('dotenv').config({ encoding: 'latin1' })`
39
- */
40
- encoding?: string;
41
-
42
- /**
43
- * Default: `false`
44
- *
45
- * Turn on logging to help debug why certain keys or values are not being set as you expect.
46
- *
47
- * example: `require('dotenv').config({ debug: process.env.DEBUG })`
48
- */
49
- debug?: boolean;
50
-
51
- /**
52
- * Default: `false`
53
- *
54
- * Override any environment variables that have already been set on your machine with values from your .env file.
55
- *
56
- * example: `require('dotenv').config({ override: true })`
57
- */
58
- override?: boolean;
59
-
60
- /**
61
- * Default: `process.env`
62
- *
63
- * Specify an object to write your secrets to. Defaults to process.env environment variables.
64
- *
65
- * example: `const processEnv = {}; require('dotenv').config({ processEnv: processEnv })`
66
- */
67
- processEnv?: DotenvPopulateInput;
68
-
69
- /**
70
- * Default: `undefined`
71
- *
72
- * 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.
73
- *
74
- * example: `require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' })`
75
- */
76
- DOTENV_KEY?: string;
77
- }
78
-
79
- export interface DotenvConfigOutput {
80
- error?: Error;
81
- parsed?: DotenvParseOutput;
82
- }
83
-
84
- export interface DotenvPopulateOptions {
85
- /**
86
- * Default: `false`
87
- *
88
- * Turn on logging to help debug why certain keys or values are not being set as you expect.
89
- *
90
- * example: `require('dotenv').config({ debug: process.env.DEBUG })`
91
- */
92
- debug?: boolean;
93
-
94
- /**
95
- * Default: `false`
96
- *
97
- * Override any environment variables that have already been set on your machine with values from your .env file.
98
- *
99
- * example: `require('dotenv').config({ override: true })`
100
- */
101
- override?: boolean;
102
- }
103
-
104
- export interface DotenvPopulateInput {
105
- [name: string]: string;
106
- }
107
-
108
- /**
109
- * 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.
110
- *
111
- * See https://dotenvx.com/docs
112
- *
113
- * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', debug: true, override: false }`
114
- * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
115
- *
116
- */
117
- export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
118
-
119
- /**
120
- * Loads `.env` file contents into process.env.
121
- *
122
- * See https://dotenvx.com/docs
123
- *
124
- * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', debug: true, override: false }`
125
- * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
126
- *
127
- */
128
- export function configDotenv(options?: DotenvConfigOptions): DotenvConfigOutput;
129
-
130
- /**
131
- * Loads `source` json contents into `target` like process.env.
132
- *
133
- * See https://dotenvx.com/docs
134
- *
135
- * @param processEnv - the target JSON object. in most cases use process.env but you can also pass your own JSON object
136
- * @param parsed - the source JSON object
137
- * @param options - additional options. example: `{ debug: true, override: false }`
138
- * @returns {void}
139
- *
140
- */
141
- export function populate(processEnv: DotenvPopulateInput, parsed: DotenvPopulateInput, options?: DotenvConfigOptions): void;
142
-
143
- /**
144
- * Decrypt ciphertext
145
- *
146
- * See https://dotenvx.com/docs
147
- *
148
- * @param encrypted - the encrypted ciphertext string
149
- * @param keyStr - the decryption key string
150
- * @returns {string}
151
- *
152
- */
153
- export function decrypt(encrypted: string, keyStr: string): string;
@@ -1,361 +0,0 @@
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
- const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
10
-
11
- // Parse src into an Object
12
- function parse (src) {
13
- const obj = {}
14
-
15
- // Convert buffer to string
16
- let lines = src.toString()
17
-
18
- // Convert line breaks to same format
19
- lines = lines.replace(/\r\n?/mg, '\n')
20
-
21
- let match
22
- while ((match = LINE.exec(lines)) != null) {
23
- const key = match[1]
24
-
25
- // Default undefined or null to empty string
26
- let value = (match[2] || '')
27
-
28
- // Remove whitespace
29
- value = value.trim()
30
-
31
- // Check if double quoted
32
- const maybeQuote = value[0]
33
-
34
- // Remove surrounding quotes
35
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2')
36
-
37
- // Expand newlines if double quoted
38
- if (maybeQuote === '"') {
39
- value = value.replace(/\\n/g, '\n')
40
- value = value.replace(/\\r/g, '\r')
41
- }
42
-
43
- // Add to object
44
- obj[key] = value
45
- }
46
-
47
- return obj
48
- }
49
-
50
- function _parseVault (options) {
51
- const vaultPath = _vaultPath(options)
52
-
53
- // Parse .env.vault
54
- const result = DotenvModule.configDotenv({ path: vaultPath })
55
- if (!result.parsed) {
56
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
57
- err.code = 'MISSING_DATA'
58
- throw err
59
- }
60
-
61
- // handle scenario for comma separated keys - for use with key rotation
62
- // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
63
- const keys = _dotenvKey(options).split(',')
64
- const length = keys.length
65
-
66
- let decrypted
67
- for (let i = 0; i < length; i++) {
68
- try {
69
- // Get full key
70
- const key = keys[i].trim()
71
-
72
- // Get instructions for decrypt
73
- const attrs = _instructions(result, key)
74
-
75
- // Decrypt
76
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)
77
-
78
- break
79
- } catch (error) {
80
- // last key
81
- if (i + 1 >= length) {
82
- throw error
83
- }
84
- // try next key
85
- }
86
- }
87
-
88
- // Parse decrypted .env string
89
- return DotenvModule.parse(decrypted)
90
- }
91
-
92
- function _log (message) {
93
- console.log(`[dotenv@${version}][INFO] ${message}`)
94
- }
95
-
96
- function _warn (message) {
97
- console.log(`[dotenv@${version}][WARN] ${message}`)
98
- }
99
-
100
- function _debug (message) {
101
- console.log(`[dotenv@${version}][DEBUG] ${message}`)
102
- }
103
-
104
- function _dotenvKey (options) {
105
- // prioritize developer directly setting options.DOTENV_KEY
106
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
107
- return options.DOTENV_KEY
108
- }
109
-
110
- // secondary infra already contains a DOTENV_KEY environment variable
111
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
112
- return process.env.DOTENV_KEY
113
- }
114
-
115
- // fallback to empty string
116
- return ''
117
- }
118
-
119
- function _instructions (result, dotenvKey) {
120
- // Parse DOTENV_KEY. Format is a URI
121
- let uri
122
- try {
123
- uri = new URL(dotenvKey)
124
- } catch (error) {
125
- if (error.code === 'ERR_INVALID_URL') {
126
- 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')
127
- err.code = 'INVALID_DOTENV_KEY'
128
- throw err
129
- }
130
-
131
- throw error
132
- }
133
-
134
- // Get decrypt key
135
- const key = uri.password
136
- if (!key) {
137
- const err = new Error('INVALID_DOTENV_KEY: Missing key part')
138
- err.code = 'INVALID_DOTENV_KEY'
139
- throw err
140
- }
141
-
142
- // Get environment
143
- const environment = uri.searchParams.get('environment')
144
- if (!environment) {
145
- const err = new Error('INVALID_DOTENV_KEY: Missing environment part')
146
- err.code = 'INVALID_DOTENV_KEY'
147
- throw err
148
- }
149
-
150
- // Get ciphertext payload
151
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`
152
- const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION
153
- if (!ciphertext) {
154
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
155
- err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'
156
- throw err
157
- }
158
-
159
- return { ciphertext, key }
160
- }
161
-
162
- function _vaultPath (options) {
163
- let possibleVaultPath = null
164
-
165
- if (options && options.path && options.path.length > 0) {
166
- if (Array.isArray(options.path)) {
167
- for (const filepath of options.path) {
168
- if (fs.existsSync(filepath)) {
169
- possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`
170
- }
171
- }
172
- } else {
173
- possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`
174
- }
175
- } else {
176
- possibleVaultPath = path.resolve(process.cwd(), '.env.vault')
177
- }
178
-
179
- if (fs.existsSync(possibleVaultPath)) {
180
- return possibleVaultPath
181
- }
182
-
183
- return null
184
- }
185
-
186
- function _resolveHome (envPath) {
187
- return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
188
- }
189
-
190
- function _configVault (options) {
191
- _log('Loading env from encrypted .env.vault')
192
-
193
- const parsed = DotenvModule._parseVault(options)
194
-
195
- let processEnv = process.env
196
- if (options && options.processEnv != null) {
197
- processEnv = options.processEnv
198
- }
199
-
200
- DotenvModule.populate(processEnv, parsed, options)
201
-
202
- return { parsed }
203
- }
204
-
205
- function configDotenv (options) {
206
- const dotenvPath = path.resolve(process.cwd(), '.env')
207
- let encoding = 'utf8'
208
- const debug = Boolean(options && options.debug)
209
-
210
- if (options && options.encoding) {
211
- encoding = options.encoding
212
- } else {
213
- if (debug) {
214
- _debug('No encoding is specified. UTF-8 is used by default')
215
- }
216
- }
217
-
218
- let optionPaths = [dotenvPath] // default, look for .env
219
- if (options && options.path) {
220
- if (!Array.isArray(options.path)) {
221
- optionPaths = [_resolveHome(options.path)]
222
- } else {
223
- optionPaths = [] // reset default
224
- for (const filepath of options.path) {
225
- optionPaths.push(_resolveHome(filepath))
226
- }
227
- }
228
- }
229
-
230
- // Build the parsed data in a temporary object (because we need to return it). Once we have the final
231
- // parsed data, we will combine it with process.env (or options.processEnv if provided).
232
- let lastError
233
- const parsedAll = {}
234
- for (const path of optionPaths) {
235
- try {
236
- // Specifying an encoding returns a string instead of a buffer
237
- const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))
238
-
239
- DotenvModule.populate(parsedAll, parsed, options)
240
- } catch (e) {
241
- if (debug) {
242
- _debug(`Failed to load ${path} ${e.message}`)
243
- }
244
- lastError = e
245
- }
246
- }
247
-
248
- let processEnv = process.env
249
- if (options && options.processEnv != null) {
250
- processEnv = options.processEnv
251
- }
252
-
253
- DotenvModule.populate(processEnv, parsedAll, options)
254
-
255
- if (lastError) {
256
- return { parsed: parsedAll, error: lastError }
257
- } else {
258
- return { parsed: parsedAll }
259
- }
260
- }
261
-
262
- // Populates process.env from .env file
263
- function config (options) {
264
- // fallback to original dotenv if DOTENV_KEY is not set
265
- if (_dotenvKey(options).length === 0) {
266
- return DotenvModule.configDotenv(options)
267
- }
268
-
269
- const vaultPath = _vaultPath(options)
270
-
271
- // dotenvKey exists but .env.vault file does not exist
272
- if (!vaultPath) {
273
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)
274
-
275
- return DotenvModule.configDotenv(options)
276
- }
277
-
278
- return DotenvModule._configVault(options)
279
- }
280
-
281
- function decrypt (encrypted, keyStr) {
282
- const key = Buffer.from(keyStr.slice(-64), 'hex')
283
- let ciphertext = Buffer.from(encrypted, 'base64')
284
-
285
- const nonce = ciphertext.subarray(0, 12)
286
- const authTag = ciphertext.subarray(-16)
287
- ciphertext = ciphertext.subarray(12, -16)
288
-
289
- try {
290
- const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)
291
- aesgcm.setAuthTag(authTag)
292
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
293
- } catch (error) {
294
- const isRange = error instanceof RangeError
295
- const invalidKeyLength = error.message === 'Invalid key length'
296
- const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'
297
-
298
- if (isRange || invalidKeyLength) {
299
- const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')
300
- err.code = 'INVALID_DOTENV_KEY'
301
- throw err
302
- } else if (decryptionFailed) {
303
- const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')
304
- err.code = 'DECRYPTION_FAILED'
305
- throw err
306
- } else {
307
- throw error
308
- }
309
- }
310
- }
311
-
312
- // Populate process.env with parsed values
313
- function populate (processEnv, parsed, options = {}) {
314
- const debug = Boolean(options && options.debug)
315
- const override = Boolean(options && options.override)
316
-
317
- if (typeof parsed !== 'object') {
318
- const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
319
- err.code = 'OBJECT_REQUIRED'
320
- throw err
321
- }
322
-
323
- // Set process.env
324
- for (const key of Object.keys(parsed)) {
325
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
326
- if (override === true) {
327
- processEnv[key] = parsed[key]
328
- }
329
-
330
- if (debug) {
331
- if (override === true) {
332
- _debug(`"${key}" is already defined and WAS overwritten`)
333
- } else {
334
- _debug(`"${key}" is already defined and was NOT overwritten`)
335
- }
336
- }
337
- } else {
338
- processEnv[key] = parsed[key]
339
- }
340
- }
341
- }
342
-
343
- const DotenvModule = {
344
- configDotenv,
345
- _configVault,
346
- _parseVault,
347
- config,
348
- decrypt,
349
- parse,
350
- populate
351
- }
352
-
353
- module.exports.configDotenv = DotenvModule.configDotenv
354
- module.exports._configVault = DotenvModule._configVault
355
- module.exports._parseVault = DotenvModule._parseVault
356
- module.exports.config = DotenvModule.config
357
- module.exports.decrypt = DotenvModule.decrypt
358
- module.exports.parse = DotenvModule.parse
359
- module.exports.populate = DotenvModule.populate
360
-
361
- module.exports = DotenvModule
@@ -1,65 +0,0 @@
1
- {
2
- "name": "dotenv",
3
- "version": "16.4.5",
4
- "description": "Loads environment variables from .env file",
5
- "main": "lib/main.js",
6
- "types": "lib/main.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./lib/main.d.ts",
10
- "require": "./lib/main.js",
11
- "default": "./lib/main.js"
12
- },
13
- "./config": "./config.js",
14
- "./config.js": "./config.js",
15
- "./lib/env-options": "./lib/env-options.js",
16
- "./lib/env-options.js": "./lib/env-options.js",
17
- "./lib/cli-options": "./lib/cli-options.js",
18
- "./lib/cli-options.js": "./lib/cli-options.js",
19
- "./package.json": "./package.json"
20
- },
21
- "scripts": {
22
- "dts-check": "tsc --project tests/types/tsconfig.json",
23
- "lint": "standard",
24
- "lint-readme": "standard-markdown",
25
- "pretest": "npm run lint && npm run dts-check",
26
- "test": "tap tests/*.js --100 -Rspec",
27
- "test:coverage": "tap --coverage-report=lcov",
28
- "prerelease": "npm test",
29
- "release": "standard-version"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "git://github.com/motdotla/dotenv.git"
34
- },
35
- "funding": "https://dotenvx.com",
36
- "keywords": [
37
- "dotenv",
38
- "env",
39
- ".env",
40
- "environment",
41
- "variables",
42
- "config",
43
- "settings"
44
- ],
45
- "readmeFilename": "README.md",
46
- "license": "BSD-2-Clause",
47
- "devDependencies": {
48
- "@definitelytyped/dtslint": "^0.0.133",
49
- "@types/node": "^18.11.3",
50
- "decache": "^4.6.1",
51
- "sinon": "^14.0.1",
52
- "standard": "^17.0.0",
53
- "standard-markdown": "^7.1.0",
54
- "standard-version": "^9.5.0",
55
- "tap": "^16.3.0",
56
- "tar": "^6.1.11",
57
- "typescript": "^4.8.4"
58
- },
59
- "engines": {
60
- "node": ">=12"
61
- },
62
- "browser": {
63
- "fs": false
64
- }
65
- }
@@ -1,18 +0,0 @@
1
- Copyright 2014–present Olivier Lalonde <olalonde@gmail.com>, James Talmage <james@talmage.io>, Ruben Verborgh
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- this software and associated documentation files (the "Software"), to deal in
5
- the Software without restriction, including without limitation the rights to
6
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
- of the Software, and to permit persons to whom the Software is furnished to do
8
- so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
18
- IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.