@quiverai/sdk 0.1.3 → 0.1.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.
Files changed (185) hide show
  1. package/README.md +8 -11
  2. package/_speakeasy/.github/action-inputs-config.json +53 -0
  3. package/_speakeasy/.github/action-security-config.json +88 -0
  4. package/dist/commonjs/funcs/modelsListModels.js +1 -1
  5. package/dist/commonjs/funcs/modelsRetrieveModel.js +1 -1
  6. package/dist/commonjs/funcs/svgCheckVectorizability.js +1 -1
  7. package/dist/commonjs/funcs/svgCreateSVGAnimation.js +1 -1
  8. package/dist/commonjs/funcs/svgCreateSVGCollection.js +1 -1
  9. package/dist/commonjs/funcs/svgCreateSVGEdit.js +1 -1
  10. package/dist/commonjs/funcs/svgCreateSVGGeneration.js +1 -1
  11. package/dist/commonjs/funcs/svgCreateSVGVectorization.js +1 -1
  12. package/dist/commonjs/lib/config.d.ts +3 -3
  13. package/dist/commonjs/lib/config.js +3 -3
  14. package/dist/commonjs/lib/config.js.map +1 -1
  15. package/dist/esm/funcs/modelsListModels.js +1 -1
  16. package/dist/esm/funcs/modelsRetrieveModel.js +1 -1
  17. package/dist/esm/funcs/svgCheckVectorizability.js +1 -1
  18. package/dist/esm/funcs/svgCreateSVGAnimation.js +1 -1
  19. package/dist/esm/funcs/svgCreateSVGCollection.js +1 -1
  20. package/dist/esm/funcs/svgCreateSVGEdit.js +1 -1
  21. package/dist/esm/funcs/svgCreateSVGGeneration.js +1 -1
  22. package/dist/esm/funcs/svgCreateSVGVectorization.js +1 -1
  23. package/dist/esm/lib/config.d.ts +3 -3
  24. package/dist/esm/lib/config.js +3 -3
  25. package/dist/esm/lib/config.js.map +1 -1
  26. package/examples/package-lock.json +611 -0
  27. package/jsr.json +1 -1
  28. package/package.json +5 -1
  29. package/src/funcs/modelsListModels.ts +1 -1
  30. package/src/funcs/modelsRetrieveModel.ts +1 -1
  31. package/src/funcs/svgCheckVectorizability.ts +1 -1
  32. package/src/funcs/svgCreateSVGAnimation.ts +1 -1
  33. package/src/funcs/svgCreateSVGCollection.ts +1 -1
  34. package/src/funcs/svgCreateSVGEdit.ts +1 -1
  35. package/src/funcs/svgCreateSVGGeneration.ts +1 -1
  36. package/src/funcs/svgCreateSVGVectorization.ts +1 -1
  37. package/src/lib/config.ts +3 -3
  38. package/.speakeasy/temp/reformatted4022478357.json +0 -3500
  39. package/.speakeasy/temp/registry_9588e5.json +0 -1
  40. package/examples/node_modules/.package-lock.json +0 -161
  41. package/examples/node_modules/@esbuild/darwin-arm64/package.json +0 -20
  42. package/examples/node_modules/@types/node/assert/strict.d.ts +0 -8
  43. package/examples/node_modules/@types/node/assert.d.ts +0 -1062
  44. package/examples/node_modules/@types/node/async_hooks.d.ts +0 -605
  45. package/examples/node_modules/@types/node/buffer.buffer.d.ts +0 -471
  46. package/examples/node_modules/@types/node/buffer.d.ts +0 -1936
  47. package/examples/node_modules/@types/node/child_process.d.ts +0 -1475
  48. package/examples/node_modules/@types/node/cluster.d.ts +0 -577
  49. package/examples/node_modules/@types/node/compatibility/disposable.d.ts +0 -16
  50. package/examples/node_modules/@types/node/compatibility/index.d.ts +0 -9
  51. package/examples/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  52. package/examples/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
  53. package/examples/node_modules/@types/node/console.d.ts +0 -452
  54. package/examples/node_modules/@types/node/constants.d.ts +0 -21
  55. package/examples/node_modules/@types/node/crypto.d.ts +0 -4590
  56. package/examples/node_modules/@types/node/dgram.d.ts +0 -597
  57. package/examples/node_modules/@types/node/diagnostics_channel.d.ts +0 -578
  58. package/examples/node_modules/@types/node/dns/promises.d.ts +0 -479
  59. package/examples/node_modules/@types/node/dns.d.ts +0 -871
  60. package/examples/node_modules/@types/node/domain.d.ts +0 -170
  61. package/examples/node_modules/@types/node/events.d.ts +0 -977
  62. package/examples/node_modules/@types/node/fs/promises.d.ts +0 -1270
  63. package/examples/node_modules/@types/node/fs.d.ts +0 -4375
  64. package/examples/node_modules/@types/node/globals.d.ts +0 -172
  65. package/examples/node_modules/@types/node/globals.typedarray.d.ts +0 -38
  66. package/examples/node_modules/@types/node/http.d.ts +0 -2049
  67. package/examples/node_modules/@types/node/http2.d.ts +0 -2631
  68. package/examples/node_modules/@types/node/https.d.ts +0 -578
  69. package/examples/node_modules/@types/node/index.d.ts +0 -93
  70. package/examples/node_modules/@types/node/inspector.generated.d.ts +0 -3966
  71. package/examples/node_modules/@types/node/module.d.ts +0 -539
  72. package/examples/node_modules/@types/node/net.d.ts +0 -1012
  73. package/examples/node_modules/@types/node/os.d.ts +0 -506
  74. package/examples/node_modules/@types/node/package.json +0 -140
  75. package/examples/node_modules/@types/node/path.d.ts +0 -200
  76. package/examples/node_modules/@types/node/perf_hooks.d.ts +0 -961
  77. package/examples/node_modules/@types/node/process.d.ts +0 -1957
  78. package/examples/node_modules/@types/node/punycode.d.ts +0 -117
  79. package/examples/node_modules/@types/node/querystring.d.ts +0 -152
  80. package/examples/node_modules/@types/node/readline/promises.d.ts +0 -162
  81. package/examples/node_modules/@types/node/readline.d.ts +0 -589
  82. package/examples/node_modules/@types/node/repl.d.ts +0 -430
  83. package/examples/node_modules/@types/node/sea.d.ts +0 -153
  84. package/examples/node_modules/@types/node/stream/consumers.d.ts +0 -38
  85. package/examples/node_modules/@types/node/stream/promises.d.ts +0 -90
  86. package/examples/node_modules/@types/node/stream/web.d.ts +0 -533
  87. package/examples/node_modules/@types/node/stream.d.ts +0 -1675
  88. package/examples/node_modules/@types/node/string_decoder.d.ts +0 -67
  89. package/examples/node_modules/@types/node/test.d.ts +0 -1787
  90. package/examples/node_modules/@types/node/timers/promises.d.ts +0 -108
  91. package/examples/node_modules/@types/node/timers.d.ts +0 -286
  92. package/examples/node_modules/@types/node/tls.d.ts +0 -1255
  93. package/examples/node_modules/@types/node/trace_events.d.ts +0 -197
  94. package/examples/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -468
  95. package/examples/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -34
  96. package/examples/node_modules/@types/node/ts5.6/index.d.ts +0 -93
  97. package/examples/node_modules/@types/node/tty.d.ts +0 -208
  98. package/examples/node_modules/@types/node/url.d.ts +0 -964
  99. package/examples/node_modules/@types/node/util.d.ts +0 -2331
  100. package/examples/node_modules/@types/node/v8.d.ts +0 -809
  101. package/examples/node_modules/@types/node/vm.d.ts +0 -1001
  102. package/examples/node_modules/@types/node/wasi.d.ts +0 -181
  103. package/examples/node_modules/@types/node/web-globals/abortcontroller.d.ts +0 -34
  104. package/examples/node_modules/@types/node/web-globals/domexception.d.ts +0 -68
  105. package/examples/node_modules/@types/node/web-globals/events.d.ts +0 -97
  106. package/examples/node_modules/@types/node/web-globals/fetch.d.ts +0 -46
  107. package/examples/node_modules/@types/node/worker_threads.d.ts +0 -715
  108. package/examples/node_modules/@types/node/zlib.d.ts +0 -540
  109. package/examples/node_modules/dotenv/config.d.ts +0 -1
  110. package/examples/node_modules/dotenv/config.js +0 -9
  111. package/examples/node_modules/dotenv/lib/cli-options.js +0 -17
  112. package/examples/node_modules/dotenv/lib/env-options.js +0 -28
  113. package/examples/node_modules/dotenv/lib/main.d.ts +0 -162
  114. package/examples/node_modules/dotenv/lib/main.js +0 -386
  115. package/examples/node_modules/dotenv/package.json +0 -62
  116. package/examples/node_modules/esbuild/install.js +0 -289
  117. package/examples/node_modules/esbuild/lib/main.d.ts +0 -716
  118. package/examples/node_modules/esbuild/lib/main.js +0 -2242
  119. package/examples/node_modules/esbuild/package.json +0 -49
  120. package/examples/node_modules/get-tsconfig/dist/index.mjs +0 -7
  121. package/examples/node_modules/get-tsconfig/package.json +0 -46
  122. package/examples/node_modules/resolve-pkg-maps/dist/index.mjs +0 -1
  123. package/examples/node_modules/resolve-pkg-maps/package.json +0 -42
  124. package/examples/node_modules/tsx/dist/cjs/api/index.mjs +0 -1
  125. package/examples/node_modules/tsx/dist/cjs/index.mjs +0 -1
  126. package/examples/node_modules/tsx/dist/cli.mjs +0 -55
  127. package/examples/node_modules/tsx/dist/client-BQVF1NaW.mjs +0 -1
  128. package/examples/node_modules/tsx/dist/esm/api/index.mjs +0 -1
  129. package/examples/node_modules/tsx/dist/esm/index.mjs +0 -2
  130. package/examples/node_modules/tsx/dist/get-pipe-path-BHW2eJdv.mjs +0 -1
  131. package/examples/node_modules/tsx/dist/index-7AaEi15b.mjs +0 -14
  132. package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +0 -1
  133. package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +0 -3
  134. package/examples/node_modules/tsx/dist/loader.mjs +0 -1
  135. package/examples/node_modules/tsx/dist/node-features-_8ZFwP_x.mjs +0 -1
  136. package/examples/node_modules/tsx/dist/package-CeBgXWuR.mjs +0 -1
  137. package/examples/node_modules/tsx/dist/patch-repl.mjs +0 -1
  138. package/examples/node_modules/tsx/dist/preflight.mjs +0 -1
  139. package/examples/node_modules/tsx/dist/register-B7jrtLTO.mjs +0 -1
  140. package/examples/node_modules/tsx/dist/register-CFH5oNdT.mjs +0 -4
  141. package/examples/node_modules/tsx/dist/repl.mjs +0 -3
  142. package/examples/node_modules/tsx/dist/require-DQxpCAr4.mjs +0 -1
  143. package/examples/node_modules/tsx/dist/suppress-warnings.mjs +0 -1
  144. package/examples/node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs +0 -1
  145. package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +0 -5
  146. package/examples/node_modules/tsx/package.json +0 -68
  147. package/examples/node_modules/undici-types/agent.d.ts +0 -31
  148. package/examples/node_modules/undici-types/api.d.ts +0 -43
  149. package/examples/node_modules/undici-types/balanced-pool.d.ts +0 -29
  150. package/examples/node_modules/undici-types/cache.d.ts +0 -36
  151. package/examples/node_modules/undici-types/client.d.ts +0 -108
  152. package/examples/node_modules/undici-types/connector.d.ts +0 -34
  153. package/examples/node_modules/undici-types/content-type.d.ts +0 -21
  154. package/examples/node_modules/undici-types/cookies.d.ts +0 -28
  155. package/examples/node_modules/undici-types/diagnostics-channel.d.ts +0 -66
  156. package/examples/node_modules/undici-types/dispatcher.d.ts +0 -256
  157. package/examples/node_modules/undici-types/env-http-proxy-agent.d.ts +0 -21
  158. package/examples/node_modules/undici-types/errors.d.ts +0 -149
  159. package/examples/node_modules/undici-types/eventsource.d.ts +0 -61
  160. package/examples/node_modules/undici-types/fetch.d.ts +0 -209
  161. package/examples/node_modules/undici-types/file.d.ts +0 -39
  162. package/examples/node_modules/undici-types/filereader.d.ts +0 -54
  163. package/examples/node_modules/undici-types/formdata.d.ts +0 -108
  164. package/examples/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  165. package/examples/node_modules/undici-types/global-origin.d.ts +0 -7
  166. package/examples/node_modules/undici-types/handlers.d.ts +0 -15
  167. package/examples/node_modules/undici-types/header.d.ts +0 -4
  168. package/examples/node_modules/undici-types/index.d.ts +0 -71
  169. package/examples/node_modules/undici-types/interceptors.d.ts +0 -17
  170. package/examples/node_modules/undici-types/mock-agent.d.ts +0 -50
  171. package/examples/node_modules/undici-types/mock-client.d.ts +0 -25
  172. package/examples/node_modules/undici-types/mock-errors.d.ts +0 -12
  173. package/examples/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  174. package/examples/node_modules/undici-types/mock-pool.d.ts +0 -25
  175. package/examples/node_modules/undici-types/package.json +0 -55
  176. package/examples/node_modules/undici-types/patch.d.ts +0 -33
  177. package/examples/node_modules/undici-types/pool-stats.d.ts +0 -19
  178. package/examples/node_modules/undici-types/pool.d.ts +0 -39
  179. package/examples/node_modules/undici-types/proxy-agent.d.ts +0 -28
  180. package/examples/node_modules/undici-types/readable.d.ts +0 -65
  181. package/examples/node_modules/undici-types/retry-agent.d.ts +0 -8
  182. package/examples/node_modules/undici-types/retry-handler.d.ts +0 -116
  183. package/examples/node_modules/undici-types/util.d.ts +0 -18
  184. package/examples/node_modules/undici-types/webidl.d.ts +0 -228
  185. package/examples/node_modules/undici-types/websocket.d.ts +0 -150
@@ -1,162 +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
- * Suppress all output (except errors).
46
- *
47
- * example: `require('dotenv').config({ quiet: true })`
48
- */
49
- quiet?: boolean;
50
-
51
- /**
52
- * Default: `false`
53
- *
54
- * Turn on logging to help debug why certain keys or values are not being set as you expect.
55
- *
56
- * example: `require('dotenv').config({ debug: process.env.DEBUG })`
57
- */
58
- debug?: boolean;
59
-
60
- /**
61
- * Default: `false`
62
- *
63
- * Override any environment variables that have already been set on your machine with values from your .env file.
64
- *
65
- * example: `require('dotenv').config({ override: true })`
66
- */
67
- override?: boolean;
68
-
69
- /**
70
- * Default: `process.env`
71
- *
72
- * Specify an object to write your secrets to. Defaults to process.env environment variables.
73
- *
74
- * example: `const processEnv = {}; require('dotenv').config({ processEnv: processEnv })`
75
- */
76
- processEnv?: DotenvPopulateInput;
77
-
78
- /**
79
- * Default: `undefined`
80
- *
81
- * 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.
82
- *
83
- * example: `require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' })`
84
- */
85
- DOTENV_KEY?: string;
86
- }
87
-
88
- export interface DotenvConfigOutput {
89
- error?: Error;
90
- parsed?: DotenvParseOutput;
91
- }
92
-
93
- export interface DotenvPopulateOptions {
94
- /**
95
- * Default: `false`
96
- *
97
- * Turn on logging to help debug why certain keys or values are not being set as you expect.
98
- *
99
- * example: `require('dotenv').config({ debug: process.env.DEBUG })`
100
- */
101
- debug?: boolean;
102
-
103
- /**
104
- * Default: `false`
105
- *
106
- * Override any environment variables that have already been set on your machine with values from your .env file.
107
- *
108
- * example: `require('dotenv').config({ override: true })`
109
- */
110
- override?: boolean;
111
- }
112
-
113
- export interface DotenvPopulateInput {
114
- [name: string]: string;
115
- }
116
-
117
- /**
118
- * 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.
119
- *
120
- * See https://dotenvx.com/docs
121
- *
122
- * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', quiet: false, debug: true, override: false }`
123
- * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
124
- *
125
- */
126
- export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
127
-
128
- /**
129
- * Loads `.env` file contents into process.env.
130
- *
131
- * See https://dotenvx.com/docs
132
- *
133
- * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', quiet: false, debug: true, override: false }`
134
- * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
135
- *
136
- */
137
- export function configDotenv(options?: DotenvConfigOptions): DotenvConfigOutput;
138
-
139
- /**
140
- * Loads `source` json contents into `target` like process.env.
141
- *
142
- * See https://dotenvx.com/docs
143
- *
144
- * @param processEnv - the target JSON object. in most cases use process.env but you can also pass your own JSON object
145
- * @param parsed - the source JSON object
146
- * @param options - additional options. example: `{ quiet: false, debug: true, override: false }`
147
- * @returns {void}
148
- *
149
- */
150
- export function populate(processEnv: DotenvPopulateInput, parsed: DotenvPopulateInput, options?: DotenvConfigOptions): void;
151
-
152
- /**
153
- * Decrypt ciphertext
154
- *
155
- * See https://dotenvx.com/docs
156
- *
157
- * @param encrypted - the encrypted ciphertext string
158
- * @param keyStr - the decryption key string
159
- * @returns {string}
160
- *
161
- */
162
- export function decrypt(encrypted: string, keyStr: string): string;
@@ -1,386 +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
- options = options || {}
52
-
53
- const vaultPath = _vaultPath(options)
54
- options.path = vaultPath // parse .env.vault
55
- const result = DotenvModule.configDotenv(options)
56
- if (!result.parsed) {
57
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
58
- err.code = 'MISSING_DATA'
59
- throw err
60
- }
61
-
62
- // handle scenario for comma separated keys - for use with key rotation
63
- // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
64
- const keys = _dotenvKey(options).split(',')
65
- const length = keys.length
66
-
67
- let decrypted
68
- for (let i = 0; i < length; i++) {
69
- try {
70
- // Get full key
71
- const key = keys[i].trim()
72
-
73
- // Get instructions for decrypt
74
- const attrs = _instructions(result, key)
75
-
76
- // Decrypt
77
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)
78
-
79
- break
80
- } catch (error) {
81
- // last key
82
- if (i + 1 >= length) {
83
- throw error
84
- }
85
- // try next key
86
- }
87
- }
88
-
89
- // Parse decrypted .env string
90
- return DotenvModule.parse(decrypted)
91
- }
92
-
93
- function _warn (message) {
94
- console.log(`[dotenv@${version}][WARN] ${message}`)
95
- }
96
-
97
- function _debug (message) {
98
- console.log(`[dotenv@${version}][DEBUG] ${message}`)
99
- }
100
-
101
- function _log (message) {
102
- console.log(`[dotenv@${version}] ${message}`)
103
- }
104
-
105
- function _dotenvKey (options) {
106
- // prioritize developer directly setting options.DOTENV_KEY
107
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
108
- return options.DOTENV_KEY
109
- }
110
-
111
- // secondary infra already contains a DOTENV_KEY environment variable
112
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
113
- return process.env.DOTENV_KEY
114
- }
115
-
116
- // fallback to empty string
117
- return ''
118
- }
119
-
120
- function _instructions (result, dotenvKey) {
121
- // Parse DOTENV_KEY. Format is a URI
122
- let uri
123
- try {
124
- uri = new URL(dotenvKey)
125
- } catch (error) {
126
- if (error.code === 'ERR_INVALID_URL') {
127
- 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')
128
- err.code = 'INVALID_DOTENV_KEY'
129
- throw err
130
- }
131
-
132
- throw error
133
- }
134
-
135
- // Get decrypt key
136
- const key = uri.password
137
- if (!key) {
138
- const err = new Error('INVALID_DOTENV_KEY: Missing key part')
139
- err.code = 'INVALID_DOTENV_KEY'
140
- throw err
141
- }
142
-
143
- // Get environment
144
- const environment = uri.searchParams.get('environment')
145
- if (!environment) {
146
- const err = new Error('INVALID_DOTENV_KEY: Missing environment part')
147
- err.code = 'INVALID_DOTENV_KEY'
148
- throw err
149
- }
150
-
151
- // Get ciphertext payload
152
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`
153
- const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION
154
- if (!ciphertext) {
155
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
156
- err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'
157
- throw err
158
- }
159
-
160
- return { ciphertext, key }
161
- }
162
-
163
- function _vaultPath (options) {
164
- let possibleVaultPath = null
165
-
166
- if (options && options.path && options.path.length > 0) {
167
- if (Array.isArray(options.path)) {
168
- for (const filepath of options.path) {
169
- if (fs.existsSync(filepath)) {
170
- possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`
171
- }
172
- }
173
- } else {
174
- possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`
175
- }
176
- } else {
177
- possibleVaultPath = path.resolve(process.cwd(), '.env.vault')
178
- }
179
-
180
- if (fs.existsSync(possibleVaultPath)) {
181
- return possibleVaultPath
182
- }
183
-
184
- return null
185
- }
186
-
187
- function _resolveHome (envPath) {
188
- return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
189
- }
190
-
191
- function _configVault (options) {
192
- const debug = Boolean(options && options.debug)
193
- const quiet = options && 'quiet' in options ? options.quiet : true
194
-
195
- if (debug || !quiet) {
196
- _log('Loading env from encrypted .env.vault')
197
- }
198
-
199
- const parsed = DotenvModule._parseVault(options)
200
-
201
- let processEnv = process.env
202
- if (options && options.processEnv != null) {
203
- processEnv = options.processEnv
204
- }
205
-
206
- DotenvModule.populate(processEnv, parsed, options)
207
-
208
- return { parsed }
209
- }
210
-
211
- function configDotenv (options) {
212
- const dotenvPath = path.resolve(process.cwd(), '.env')
213
- let encoding = 'utf8'
214
- const debug = Boolean(options && options.debug)
215
- const quiet = options && 'quiet' in options ? options.quiet : true
216
-
217
- if (options && options.encoding) {
218
- encoding = options.encoding
219
- } else {
220
- if (debug) {
221
- _debug('No encoding is specified. UTF-8 is used by default')
222
- }
223
- }
224
-
225
- let optionPaths = [dotenvPath] // default, look for .env
226
- if (options && options.path) {
227
- if (!Array.isArray(options.path)) {
228
- optionPaths = [_resolveHome(options.path)]
229
- } else {
230
- optionPaths = [] // reset default
231
- for (const filepath of options.path) {
232
- optionPaths.push(_resolveHome(filepath))
233
- }
234
- }
235
- }
236
-
237
- // Build the parsed data in a temporary object (because we need to return it). Once we have the final
238
- // parsed data, we will combine it with process.env (or options.processEnv if provided).
239
- let lastError
240
- const parsedAll = {}
241
- for (const path of optionPaths) {
242
- try {
243
- // Specifying an encoding returns a string instead of a buffer
244
- const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))
245
-
246
- DotenvModule.populate(parsedAll, parsed, options)
247
- } catch (e) {
248
- if (debug) {
249
- _debug(`Failed to load ${path} ${e.message}`)
250
- }
251
- lastError = e
252
- }
253
- }
254
-
255
- let processEnv = process.env
256
- if (options && options.processEnv != null) {
257
- processEnv = options.processEnv
258
- }
259
-
260
- DotenvModule.populate(processEnv, parsedAll, options)
261
-
262
- if (debug || !quiet) {
263
- const keysCount = Object.keys(parsedAll).length
264
- const shortPaths = []
265
- for (const filePath of optionPaths) {
266
- try {
267
- const relative = path.relative(process.cwd(), filePath)
268
- shortPaths.push(relative)
269
- } catch (e) {
270
- if (debug) {
271
- _debug(`Failed to load ${filePath} ${e.message}`)
272
- }
273
- lastError = e
274
- }
275
- }
276
-
277
- _log(`injecting env (${keysCount}) from ${shortPaths.join(',')}`)
278
- }
279
-
280
- if (lastError) {
281
- return { parsed: parsedAll, error: lastError }
282
- } else {
283
- return { parsed: parsedAll }
284
- }
285
- }
286
-
287
- // Populates process.env from .env file
288
- function config (options) {
289
- // fallback to original dotenv if DOTENV_KEY is not set
290
- if (_dotenvKey(options).length === 0) {
291
- return DotenvModule.configDotenv(options)
292
- }
293
-
294
- const vaultPath = _vaultPath(options)
295
-
296
- // dotenvKey exists but .env.vault file does not exist
297
- if (!vaultPath) {
298
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)
299
-
300
- return DotenvModule.configDotenv(options)
301
- }
302
-
303
- return DotenvModule._configVault(options)
304
- }
305
-
306
- function decrypt (encrypted, keyStr) {
307
- const key = Buffer.from(keyStr.slice(-64), 'hex')
308
- let ciphertext = Buffer.from(encrypted, 'base64')
309
-
310
- const nonce = ciphertext.subarray(0, 12)
311
- const authTag = ciphertext.subarray(-16)
312
- ciphertext = ciphertext.subarray(12, -16)
313
-
314
- try {
315
- const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)
316
- aesgcm.setAuthTag(authTag)
317
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
318
- } catch (error) {
319
- const isRange = error instanceof RangeError
320
- const invalidKeyLength = error.message === 'Invalid key length'
321
- const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'
322
-
323
- if (isRange || invalidKeyLength) {
324
- const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')
325
- err.code = 'INVALID_DOTENV_KEY'
326
- throw err
327
- } else if (decryptionFailed) {
328
- const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')
329
- err.code = 'DECRYPTION_FAILED'
330
- throw err
331
- } else {
332
- throw error
333
- }
334
- }
335
- }
336
-
337
- // Populate process.env with parsed values
338
- function populate (processEnv, parsed, options = {}) {
339
- const debug = Boolean(options && options.debug)
340
- const override = Boolean(options && options.override)
341
-
342
- if (typeof parsed !== 'object') {
343
- const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
344
- err.code = 'OBJECT_REQUIRED'
345
- throw err
346
- }
347
-
348
- // Set process.env
349
- for (const key of Object.keys(parsed)) {
350
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
351
- if (override === true) {
352
- processEnv[key] = parsed[key]
353
- }
354
-
355
- if (debug) {
356
- if (override === true) {
357
- _debug(`"${key}" is already defined and WAS overwritten`)
358
- } else {
359
- _debug(`"${key}" is already defined and was NOT overwritten`)
360
- }
361
- }
362
- } else {
363
- processEnv[key] = parsed[key]
364
- }
365
- }
366
- }
367
-
368
- const DotenvModule = {
369
- configDotenv,
370
- _configVault,
371
- _parseVault,
372
- config,
373
- decrypt,
374
- parse,
375
- populate
376
- }
377
-
378
- module.exports.configDotenv = DotenvModule.configDotenv
379
- module.exports._configVault = DotenvModule._configVault
380
- module.exports._parseVault = DotenvModule._parseVault
381
- module.exports.config = DotenvModule.config
382
- module.exports.decrypt = DotenvModule.decrypt
383
- module.exports.parse = DotenvModule.parse
384
- module.exports.populate = DotenvModule.populate
385
-
386
- module.exports = DotenvModule
@@ -1,62 +0,0 @@
1
- {
2
- "name": "dotenv",
3
- "version": "16.6.1",
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
- "pretest": "npm run lint && npm run dts-check",
25
- "test": "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
26
- "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
27
- "prerelease": "npm test",
28
- "release": "standard-version"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "git://github.com/motdotla/dotenv.git"
33
- },
34
- "homepage": "https://github.com/motdotla/dotenv#readme",
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
- "@types/node": "^18.11.3",
49
- "decache": "^4.6.2",
50
- "sinon": "^14.0.1",
51
- "standard": "^17.0.0",
52
- "standard-version": "^9.5.0",
53
- "tap": "^19.2.0",
54
- "typescript": "^4.8.4"
55
- },
56
- "engines": {
57
- "node": ">=12"
58
- },
59
- "browser": {
60
- "fs": false
61
- }
62
- }