@dotenvx/dotenvx 2.31.1 → 2.32.1

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 (47) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/README.md +100 -28
  3. package/package.json +3 -3
  4. package/src/cli/actions/check.js +45 -38
  5. package/src/cli/actions/encrypt.js +3 -5
  6. package/src/cli/actions/init.js +23 -13
  7. package/src/cli/actions/protectStdin.js +19 -3
  8. package/src/cli/actions/run.js +15 -11
  9. package/src/cli/actions/set.js +2 -4
  10. package/src/cli/commands/primitives.js +1 -1
  11. package/src/cli/dotenvx.js +8 -7
  12. package/src/lib/custodians/managed/armor/index.js +1 -1
  13. package/src/lib/custodians/managed/armor/store.js +11 -3
  14. package/src/lib/{envfile → envspec}/discovery/discoverEnvFiles.js +1 -1
  15. package/src/lib/{envfile → envspec}/discovery/scanSource.js +1 -1
  16. package/src/lib/{envfile/parsing/envfile.peggy → envspec/parsing/envspec.peggy} +17 -10
  17. package/src/lib/{envfile/parsing/envfileParser.js → envspec/parsing/envspecParser.js} +575 -455
  18. package/src/lib/{envfile/parsing/formatEnvfileSyntaxError.js → envspec/parsing/formatEnvspecSyntaxError.js} +1 -1
  19. package/src/lib/{envfile/parsing/readEnvfile.js → envspec/parsing/readEnvspec.js} +38 -27
  20. package/src/lib/{envfile/rendering/normalizeEnvfile.js → envspec/rendering/normalizeEnvspec.js} +7 -10
  21. package/src/lib/envspec/rendering/previewEnvspec.js +51 -0
  22. package/src/lib/envspec/rendering/renderEnvspec.js +30 -0
  23. package/src/lib/envspec/validation/diagnosticLocation.js +29 -0
  24. package/src/lib/envspec/validation/protectEnvspec.js +39 -0
  25. package/src/lib/envspec/validation/validateEnvspec.js +57 -0
  26. package/src/lib/helpers/custodySelect.js +25 -0
  27. package/src/lib/helpers/errors.js +7 -6
  28. package/src/lib/helpers/isPublicKey.js +3 -0
  29. package/src/lib/helpers/plaintextKeys.js +9 -0
  30. package/src/lib/helpers/prompts.js +7 -1
  31. package/src/lib/helpers/redactedValues.js +10 -4
  32. package/src/lib/helpers/selectKeyStorage.js +62 -17
  33. package/src/lib/helpers/storeKeyStorage.js +19 -0
  34. package/src/lib/services/armorDown.js +1 -0
  35. package/src/lib/services/armorMove.js +1 -0
  36. package/src/lib/services/armorPull.js +1 -0
  37. package/src/lib/services/armorPush.js +1 -0
  38. package/src/lib/services/armorUp.js +1 -0
  39. package/src/lib/services/init.js +27 -22
  40. package/src/lib/services/validate.js +20 -10
  41. package/src/lib/transforms/encrypt.js +28 -14
  42. package/src/lib/transforms/set.js +5 -6
  43. package/src/lib/envfile/rendering/renderEnvfile.js +0 -26
  44. package/src/lib/envfile/validation/validateEnvfile.js +0 -24
  45. /package/src/lib/{envfile → envspec}/discovery/extractEnvKeys.js +0 -0
  46. /package/src/lib/{envfile → envspec}/validation/encryptedSources.js +0 -0
  47. /package/src/lib/{envfile → envspec}/validation/validate.js +0 -0
@@ -0,0 +1,19 @@
1
+ const selectKeyStorage = require('./selectKeyStorage')
2
+ const custodians = require('../custodians')
3
+
4
+ async function storeKeyStorage (storage, publicKey, privateKey, options, context) {
5
+ // Preserve the operation context so locked custody can reuse its passphrase.
6
+ context.allowCustodyBack = true
7
+ while (true) {
8
+ storage = storage || await selectKeyStorage(options)
9
+ try {
10
+ const stored = await custodians.store(storage, publicKey, privateKey, context)
11
+ return { storage, stored }
12
+ } catch (error) {
13
+ if (error.code !== 'KEY_CUSTODY_BACK') throw error
14
+ storage = undefined
15
+ }
16
+ }
17
+ }
18
+
19
+ module.exports = storeKeyStorage
@@ -46,6 +46,7 @@ class ArmorDown {
46
46
  if (choices.length > 1) {
47
47
  team = await prompts.select({
48
48
  message: 'Select team',
49
+ prefix: '⛨',
49
50
  choices
50
51
  }, {
51
52
  input: process.stdin,
@@ -34,6 +34,7 @@ class ArmorMove {
34
34
  }))
35
35
  team = await prompts.select({
36
36
  message: 'Select team',
37
+ prefix: '⛨',
37
38
  choices
38
39
  }, {
39
40
  input: process.stdin,
@@ -46,6 +46,7 @@ class ArmorPull {
46
46
  if (choices.length > 1) {
47
47
  team = await prompts.select({
48
48
  message: 'Select team',
49
+ prefix: '⛨',
49
50
  choices
50
51
  }, {
51
52
  input: process.stdin,
@@ -41,6 +41,7 @@ class ArmorPush {
41
41
  if (choices.length > 1) {
42
42
  team = await prompts.select({
43
43
  message: 'Select team',
44
+ prefix: '⛨',
44
45
  choices
45
46
  }, {
46
47
  input: process.stdin,
@@ -41,6 +41,7 @@ class ArmorUp {
41
41
  if (choices.length > 1) {
42
42
  team = await prompts.select({
43
43
  message: 'Select team',
44
+ prefix: '⛨',
44
45
  choices
45
46
  }, {
46
47
  input: process.stdin,
@@ -2,24 +2,24 @@ const fs = require('node:fs')
2
2
  const path = require('node:path')
3
3
  const { scan, encrypted } = require('@dotenvx/primitives')
4
4
 
5
- const normalizeEnvfile = require('../envfile/rendering/normalizeEnvfile')
6
- const renderEnvfile = require('../envfile/rendering/renderEnvfile')
5
+ const normalizeEnvspec = require('../envspec/rendering/normalizeEnvspec')
6
+ const renderEnvspec = require('../envspec/rendering/renderEnvspec')
7
+ const isPublicKey = require('../helpers/isPublicKey')
7
8
 
8
9
  function declaration (name) {
9
- if (/(^|_)port$/i.test(name)) return { name, type: 'port' }
10
- if (/(^|_)url$/i.test(name)) return { name, type: 'url' }
11
- return { name }
10
+ const item = { name }
11
+ if (/(^|_)port$/i.test(name)) item.type = 'port'
12
+ if (/(^|_)url$/i.test(name)) item.type = 'url'
13
+ if (isPublicKey(name)) item.redacted = false
14
+ return item
12
15
  }
13
16
 
14
- module.exports = function init ({ directory = process.cwd(), envFile, envFiles, sourceKeys = [], onFile = () => {} } = {}) {
15
- const target = path.resolve(directory, 'Envfile')
16
- // lstat also preserves dangling symlinks. Never overwrite an existing Envfile.
17
- try {
18
- fs.lstatSync(target)
19
- return { created: false }
20
- } catch (error) {
21
- if (error.code !== 'ENOENT') throw error
22
- }
17
+ module.exports = function init ({ directory = process.cwd(), envFile, envFiles, sourceKeys = [], overwrite = false, stdout = false, onFile = () => {} } = {}) {
18
+ const target = path.resolve(directory, 'Envspec')
19
+ const existing = stdout ? undefined : fs.lstatSync(target, { throwIfNoEntry: false })
20
+ if (existing && !overwrite) return { created: false }
21
+ if (existing && !existing.isFile()) throw new Error(`Cannot replace Envspec: expected a regular file (${target})`)
22
+ const seen = new Set()
23
23
 
24
24
  const sources = []
25
25
  const names = new Set()
@@ -27,6 +27,9 @@ module.exports = function init ({ directory = process.cwd(), envFile, envFiles,
27
27
  const candidates = envFiles || (envFile ? [envFile] : ['.env.example', '.env'])
28
28
  const relativeFilename = candidate => path.relative(path.resolve(directory), path.resolve(directory, candidate)).split(path.sep).join('/')
29
29
  for (const candidate of candidates) {
30
+ const resolved = path.resolve(directory, candidate)
31
+ if (seen.has(resolved)) continue
32
+ seen.add(resolved)
30
33
  let src
31
34
  try {
32
35
  src = fs.readFileSync(path.resolve(directory, candidate), 'utf8')
@@ -37,16 +40,17 @@ module.exports = function init ({ directory = process.cwd(), envFile, envFiles,
37
40
  onFile(candidate)
38
41
  sources.push(candidate)
39
42
  // scan preserves every assignment as an array, without decrypting or expanding.
40
- const entries = Object.entries(scan(src).parsed).filter(([key]) => !key.startsWith('DOTENV_PUBLIC_KEY'))
43
+ const allEntries = Object.entries(scan(src).parsed)
44
+ const entries = allEntries.filter(([key]) => !key.startsWith('DOTENV_PUBLIC_KEY'))
41
45
  for (const [key] of entries) {
42
46
  if (!/^DOTENV_PRIVATE_KEY(?:_|$)/.test(key)) names.add(key)
43
47
  }
48
+ const hasEncryptedValues = entries.some(([key, values]) => !/^DOTENV_PRIVATE_KEY(?:_|$)/.test(key) && values.some(value => encrypted(value)))
44
49
  files.push({
45
50
  filename: relativeFilename(candidate),
46
51
  hasValues: entries.length > 0,
47
- encrypted: entries.length > 0 && entries.every(([, values]) => values.every(value => encrypted(value))),
48
52
  declarations: entries.filter(([key]) => !/^DOTENV_PRIVATE_KEY(?:_|$)/.test(key)).map(([key, values]) => ({
49
- ...declaration(key), encrypted: values.some(value => encrypted(value))
53
+ ...declaration(key), encrypted: values.some(value => encrypted(value)) || (!hasEncryptedValues && !key.endsWith('_PLAIN'))
50
54
  }))
51
55
  })
52
56
  }
@@ -57,15 +61,16 @@ module.exports = function init ({ directory = process.cwd(), envFile, envFiles,
57
61
  const addedFromSource = names.size - inputCount
58
62
  const keys = [...names]
59
63
  const invalid = keys.filter(key => !/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))
60
- if (invalid.length) throw new Error(`Unsupported Envfile variable names: ${invalid.join(', ')}`)
64
+ if (invalid.length) throw new Error(`Unsupported Envspec variable names: ${invalid.join(', ')}`)
61
65
 
62
- const document = normalizeEnvfile({ files, codeDeclarations })
63
- const content = renderEnvfile(document)
66
+ const document = normalizeEnvspec({ files, codeDeclarations })
67
+ const content = renderEnvspec(document)
68
+ if (stdout) return { created: false, content }
64
69
  try {
65
- fs.writeFileSync(target, content, { flag: 'wx' })
70
+ fs.writeFileSync(target, content, { flag: overwrite ? fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_TRUNC | fs.constants.O_NOFOLLOW : 'wx' })
66
71
  } catch (error) {
67
72
  if (error.code === 'EEXIST') return { created: false }
68
73
  throw error
69
74
  }
70
- return { created: true, source: sources.join(', '), count: keys.length, addedFromSource }
75
+ return { created: true, replaced: Boolean(existing), source: sources.join(', '), count: keys.length, addedFromSource }
71
76
  }
@@ -2,23 +2,31 @@ const envsResolver = require('../resolvers/envs')
2
2
  const Session = require('../../db/session')
3
3
  const buildCommandEnvs = require('../helpers/buildCommandEnvs')
4
4
  const resolveEnvKeysFile = require('../helpers/resolveEnvKeysFile')
5
- const readEnvfile = require('../envfile/parsing/readEnvfile')
6
- const validateEnvfile = require('../envfile/validation/validateEnvfile')
5
+ const readEnvspec = require('../envspec/parsing/readEnvspec')
6
+ const validateEnvspec = require('../envspec/validation/validateEnvspec')
7
7
  const normalizeDotenvConfigPath = require('../helpers/normalizeDotenvConfigPath')
8
8
  const Errors = require('../helpers/errors')
9
9
  const { determine } = require('../helpers/envResolution')
10
+ const path = require('node:path')
11
+ const resolveDirectoryFilepath = require('../helpers/resolveDirectoryFilepath')
10
12
 
11
13
  // Load once and validate the final values; callers own presentation and execution.
12
- module.exports = async function validate ({ envs = [], options = {}, processEnv = { ...process.env }, requireEnvfile = true, command, onStatus } = {}) {
13
- envs = buildCommandEnvs(normalizeDotenvConfigPath(envs, processEnv), options.convention)
14
+ module.exports = async function validate ({ envs = [], options = {}, processEnv = { ...process.env }, requireEnvspec = true, command, onStatus, onKey } = {}) {
15
+ envs = normalizeDotenvConfigPath(envs, processEnv)
16
+ const requiredFilepaths = new Set(envs.filter(env => env.type === 'envFile').flatMap(env => {
17
+ const resolved = resolveDirectoryFilepath(env.value, '.env')
18
+ // A directory with a convention selects optional layers rather than one file.
19
+ return options.convention && resolved !== env.value ? [] : [path.resolve(resolved)]
20
+ }))
21
+ envs = buildCommandEnvs(envs, options.convention)
14
22
  envs = determine(envs, processEnv)
15
- const schema = readEnvfile(undefined, envs.filter(env => env.type === 'envFile').map(env => env.value))
16
- if (requireEnvfile && !schema.exists) throw new Errors().envfileRequired()
23
+ const schema = readEnvspec(undefined, envs.filter(env => env.type === 'envFile').map(env => env.value))
24
+ if (requireEnvspec && !schema.exists) throw new Errors().envspecRequired()
17
25
 
18
26
  const session = new Session()
19
27
  const proxyToken = options.token || processEnv.DOTENVX_TOKEN
20
28
  const noArmor = options.armor === false || (!proxyToken && (await session.noArmor()))
21
- if (schema.proxyRules.size > 0 && noArmor) throw new Error('Envfile proxy requires Armor. Enable Armor and authenticate before running.')
29
+ if (schema.proxyRules.size > 0 && noArmor) throw new Error('Envspec proxy requires Armor. Enable Armor and authenticate before running.')
22
30
  const proxyCredentials = noArmor ? undefined : []
23
31
  const { processedEnvs, readableFilepaths } = await envsResolver({
24
32
  envs,
@@ -40,7 +48,7 @@ module.exports = async function validate ({ envs = [], options = {}, processEnv
40
48
  let proxyError
41
49
  for (const name of schema.proxyRules.keys()) {
42
50
  if (processEnv[name] !== undefined && !(proxyCredentials || []).some(credential => credential.name === name && credential.placeholder === processEnv[name])) {
43
- proxyError = new Error(`Envfile proxy requires an encrypted ${name} loaded from an env file. Remove plaintext or shell overrides, or use --overload.`)
51
+ proxyError = new Error(`Envspec proxy requires an encrypted ${name} loaded from an env file. Remove plaintext or shell overrides, or use --overload.`)
44
52
  break
45
53
  }
46
54
  }
@@ -49,11 +57,13 @@ module.exports = async function validate ({ envs = [], options = {}, processEnv
49
57
  processEnv,
50
58
  processedEnvs,
51
59
  readableFilepaths,
52
- hasEnvfile: schema.exists,
60
+ requiredFilepaths,
61
+ hasEnvspec: schema.exists,
62
+ schema,
53
63
  proxyCredentials,
54
64
  proxyToken,
55
65
  session,
56
66
  proxyError,
57
- validationError: validateEnvfile(schema, processEnv, processedEnvs)
67
+ validationError: validateEnvspec(schema, processEnv, processedEnvs, onKey)
58
68
  }
59
69
  }
@@ -1,5 +1,6 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
+ const fs = require('node:fs')
3
4
  const { encrypted, encrypt, scan, upsert, publickeys, keypair } = require('@dotenvx/primitives')
4
5
 
5
6
  const TYPE_ENV_FILE = 'envFile'
@@ -11,8 +12,8 @@ const detectEncoding = require('./../helpers/detectEncoding')
11
12
  const { isDotenvPublicKey, isPlainKey, mutateSrc } = require('../helpers/cryptography')
12
13
  const keynames = require('../conventions/keynames')
13
14
 
14
- const selectKeyStorage = require('../helpers/selectKeyStorage')
15
- const custodians = require('../custodians')
15
+ const storeKeyStorage = require('../helpers/storeKeyStorage')
16
+ const readEnvspec = require('../envspec/parsing/readEnvspec')
16
17
 
17
18
  async function encryptTransform (options = {}) {
18
19
  const envs = options.envs || []
@@ -20,7 +21,7 @@ async function encryptTransform (options = {}) {
20
21
  const ek = options.ek
21
22
  const fk = options.fk || '.env.keys'
22
23
  let storage
23
- const custodyContext = {}
24
+ const custodyContext = { token: options.token }
24
25
  const noCreate = options.noCreate
25
26
 
26
27
  const processedEnvs = []
@@ -52,6 +53,11 @@ async function encryptTransform (options = {}) {
52
53
  const row = { keys: [], type: TYPE_ENV_FILE, filepath, envFilepath, changed: false }
53
54
 
54
55
  try {
56
+ const policyPath = path.resolve('Envspec')
57
+ const schema = readEnvspec(policyPath, [filepath])
58
+ if (!schema.exists && fs.lstatSync(policyPath, { throwIfNoEntry: false })) {
59
+ throw new Error(`Cannot read Envspec: ${policyPath}`)
60
+ }
55
61
  const fileExists = await fsx.exists(filepath)
56
62
  if (!fileExists && !noCreate) {
57
63
  row.envSrc = SAMPLE_ENV_KIT
@@ -61,16 +67,28 @@ async function encryptTransform (options = {}) {
61
67
  row.envSrc = await fsx.readFileX(filepath, { encoding })
62
68
  }
63
69
 
64
- if (row.envSrc.trim().length === 0) {
70
+ if (!schema.exists && row.envSrc.trim().length === 0) {
65
71
  row.envSrc = SAMPLE_ENV_KIT
66
72
  row.changed = true
67
73
  }
68
74
 
75
+ const { parsed } = scan(row.envSrc, { ik, ek })
76
+ const selected = Object.entries(parsed).filter(([key]) => {
77
+ if (isDotenvPublicKey(key)) return false
78
+ return schema.exists ? (schema.encryptionRules.get(key) ?? schema.encrypted) : !isPlainKey(key)
79
+ })
80
+ if (schema.exists && !selected.some(([, values]) => values.some(value => !encrypted(value)))) {
81
+ // A missing file still needs writing even when its initial values are
82
+ // exempt from encryption. Avoid generating keys, but preserve creation.
83
+ if (row.changed) changedFilepaths.push(envFilepath)
84
+ else unchangedFilepaths.push(envFilepath)
85
+ processedEnvs.push(row)
86
+ continue
87
+ }
88
+
69
89
  let publicKey = publickeys(row.envSrc)[0]
70
90
 
71
91
  if (!publicKey) {
72
- storage = storage || await selectKeyStorage(options)
73
-
74
92
  // upsert public key to .env file
75
93
  const kp = keypair() // local
76
94
  publicKey = kp.publicKey
@@ -81,18 +99,14 @@ async function encryptTransform (options = {}) {
81
99
 
82
100
  const comment = path.basename(envFilepath)
83
101
 
84
- const stored = await custodians.store(storage, publicKey, privateKey, Object.assign(custodyContext, { keysSrc, privateKeyName, comment, keysFilepath: fk }))
102
+ const result = await storeKeyStorage(storage, publicKey, privateKey, options, Object.assign(custodyContext, { keysSrc, privateKeyName, comment, keysFilepath: fk }))
103
+ storage = result.storage
104
+ const stored = result.stored
85
105
  if (Object.prototype.hasOwnProperty.call(stored, 'keysSrc')) keysSrc = stored.keysSrc
86
106
  if (stored.nativePrivateKeyAdded) row.nativePrivateKeyAdded = true
87
107
  }
88
108
 
89
- const { parsed } = scan(row.envSrc, { ik, ek })
90
-
91
- for (const [key, values] of Object.entries(parsed)) {
92
- if (isDotenvPublicKey(key) || isPlainKey(key)) {
93
- continue
94
- }
95
-
109
+ for (const [key, values] of selected) {
96
110
  const transformedValues = []
97
111
  for (const value of values) {
98
112
  if (encrypted(value)) {
@@ -11,8 +11,7 @@ const { isPlainKey, mutateSrc } = require('../helpers/cryptography')
11
11
  const keynames = require('../conventions/keynames')
12
12
  const Errors = require('../helpers/errors')
13
13
 
14
- const selectKeyStorage = require('../helpers/selectKeyStorage')
15
- const custodians = require('../custodians')
14
+ const storeKeyStorage = require('../helpers/storeKeyStorage')
16
15
 
17
16
  async function setTransform (options = {}) {
18
17
  const envs = options.envs || []
@@ -21,7 +20,7 @@ async function setTransform (options = {}) {
21
20
  const fk = options.fk || '.env.keys'
22
21
  const noArmor = options.noArmor
23
22
  let storage
24
- const custodyContext = {}
23
+ const custodyContext = { token: options.token }
25
24
  const noNative = options.noNative
26
25
  const noCreate = options.noCreate
27
26
  const noEncrypt = !options.encrypt || isPlainKey(key)
@@ -73,8 +72,6 @@ async function setTransform (options = {}) {
73
72
 
74
73
  // only create if missing public key and encryption needed
75
74
  if (!publicKey && !noEncrypt) {
76
- storage = storage || await selectKeyStorage(options)
77
-
78
75
  // upsert public key to .env file
79
76
  const kp = keypair() // local
80
77
  publicKey = kp.publicKey
@@ -85,7 +82,9 @@ async function setTransform (options = {}) {
85
82
 
86
83
  const comment = path.basename(envFilepath)
87
84
 
88
- const stored = await custodians.store(storage, publicKey, privateKey, Object.assign(custodyContext, { keysSrc, privateKeyName, comment, keysFilepath: fk }))
85
+ const result = await storeKeyStorage(storage, publicKey, privateKey, options, Object.assign(custodyContext, { keysSrc, privateKeyName, comment, keysFilepath: fk }))
86
+ storage = result.storage
87
+ const stored = result.stored
89
88
  if (Object.prototype.hasOwnProperty.call(stored, 'keysSrc')) keysSrc = stored.keysSrc
90
89
  if (stored.nativePrivateKeyAdded) row.nativePrivateKeyAdded = true
91
90
  }
@@ -1,26 +0,0 @@
1
- function declaration (item) {
2
- let line = `env "${item.name}"`
3
- if (item.type) line += `, type: "${item.type}"`
4
- if (item.encrypted !== undefined) line += `, encrypted: ${item.encrypted}`
5
- if (item.optional !== undefined) line += `, optional: ${item.optional}`
6
- return line
7
- }
8
-
9
- module.exports = function renderEnvfile (document) {
10
- const sections = [`encrypted ${document.encrypted}`]
11
- if (document.declarations.length) sections.push(document.declarations.map(declaration).join('\n'))
12
- for (const file of document.files) {
13
- const quote = file.filename.includes('"') ? "'" : '"'
14
- if (file.filename.includes(quote) || /[\r\n\0*?[\]{}]/.test(file.filename)) {
15
- throw new Error(`Unsupported Envfile filename: ${file.filename}`)
16
- }
17
- const lines = [`file ${quote}${file.filename}${quote} do`]
18
- if (file.encrypted !== undefined) lines.push(` encrypted ${file.encrypted}`)
19
- lines.push(...file.declarations.map(item => ` ${declaration(item)}`), 'end')
20
- sections.push(lines.join('\n'))
21
- }
22
- if (document.codeDeclarations.length) {
23
- sections.push('# additionally found in code\n' + document.codeDeclarations.map(declaration).join('\n'))
24
- }
25
- return sections.join('\n\n') + '\n'
26
- }
@@ -1,24 +0,0 @@
1
- const validate = require('./validate')
2
- const encryptedSources = require('./encryptedSources')
3
- const Errors = require('../../helpers/errors')
4
-
5
- module.exports = function validateEnvfile (schema, env, processedEnvs) {
6
- const messages = new Set()
7
- const schemas = schema.schemas || [schema]
8
- const sources = schemas.some(rules => rules.encryptedKeys.length > 0) ? encryptedSources(processedEnvs) : undefined
9
- for (const rules of schemas) {
10
- const { requiredKeys, types, enums, ranges, encryptedKeys } = rules
11
- const required = Object.fromEntries(requiredKeys.map(key => [key, '']))
12
- const validation = validate(required, env, {
13
- types,
14
- enums,
15
- ranges,
16
- encryptedKeys,
17
- encryptedSources: sources
18
- })
19
- for (const error of validation.errors) messages.add(error.message)
20
- }
21
- if (messages.size > 0) {
22
- return new Errors({ message: [...messages].join('; ') }).invalidEnv()
23
- }
24
- }