@arki/env 0.0.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +196 -0
- package/README.md +231 -62
- package/dist/api.json +597 -0
- package/dist/core/define-env.d.ts +29 -4
- package/dist/core/define-env.d.ts.map +1 -1
- package/dist/core/define-env.js +85 -15
- package/dist/core/define-env.js.map +1 -1
- package/dist/core/describe.d.ts +29 -0
- package/dist/core/describe.d.ts.map +1 -0
- package/dist/core/describe.js +25 -0
- package/dist/core/describe.js.map +1 -0
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +13 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +7 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/secret.d.ts +56 -0
- package/dist/core/secret.d.ts.map +1 -0
- package/dist/core/secret.js +85 -0
- package/dist/core/secret.js.map +1 -0
- package/dist/errors.json +128 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/node/codec.d.ts +63 -0
- package/dist/node/codec.d.ts.map +1 -0
- package/dist/node/codec.js +182 -0
- package/dist/node/codec.js.map +1 -0
- package/dist/node/edit.d.ts +112 -0
- package/dist/node/edit.d.ts.map +1 -0
- package/dist/node/edit.js +268 -0
- package/dist/node/edit.js.map +1 -0
- package/dist/node/errors.d.ts +119 -0
- package/dist/node/errors.d.ts.map +1 -0
- package/dist/node/errors.js +144 -0
- package/dist/node/errors.js.map +1 -0
- package/dist/node/files.d.ts +9 -0
- package/dist/node/files.d.ts.map +1 -0
- package/dist/node/files.js +35 -0
- package/dist/node/files.js.map +1 -0
- package/dist/node/index.d.ts +20 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +13 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/key-schemas.d.ts +25 -0
- package/dist/node/key-schemas.d.ts.map +1 -0
- package/dist/node/key-schemas.js +38 -0
- package/dist/node/key-schemas.js.map +1 -0
- package/dist/node/keys.d.ts +54 -0
- package/dist/node/keys.d.ts.map +1 -0
- package/dist/node/keys.js +76 -0
- package/dist/node/keys.js.map +1 -0
- package/dist/node/load.d.ts +103 -0
- package/dist/node/load.d.ts.map +1 -0
- package/dist/node/load.js +306 -0
- package/dist/node/load.js.map +1 -0
- package/dist/node/operation-telemetry.d.ts +3 -0
- package/dist/node/operation-telemetry.d.ts.map +1 -0
- package/dist/node/operation-telemetry.js +53 -0
- package/dist/node/operation-telemetry.js.map +1 -0
- package/dist/node/references.d.ts +16 -0
- package/dist/node/references.d.ts.map +1 -0
- package/dist/node/references.js +72 -0
- package/dist/node/references.js.map +1 -0
- package/dist/node/register.d.ts +2 -0
- package/dist/node/register.d.ts.map +1 -0
- package/dist/node/register.js +19 -0
- package/dist/node/register.js.map +1 -0
- package/dist/{contracts → presets}/common.d.ts +1 -1
- package/dist/presets/common.d.ts.map +1 -0
- package/dist/{contracts → presets}/common.js +4 -8
- package/dist/presets/common.js.map +1 -0
- package/dist/{contracts → presets}/index.d.ts +5 -5
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +15 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/{contracts → presets}/parsing.d.ts +2 -2
- package/dist/presets/parsing.d.ts.map +1 -0
- package/dist/{contracts → presets}/parsing.js +13 -5
- package/dist/presets/parsing.js.map +1 -0
- package/dist/{contracts → presets}/urls.d.ts +1 -1
- package/dist/presets/urls.d.ts.map +1 -0
- package/dist/{contracts → presets}/urls.js +1 -1
- package/dist/presets/urls.js.map +1 -0
- package/docs/agent-guide.md +121 -0
- package/docs/upgrades/0.0.11-to-0.1.0.md +62 -0
- package/docs/upgrades/0.1.0-to-0.2.0.md +73 -0
- package/docs/upgrades/typed-node-outcomes.md +13 -0
- package/llms.txt +30 -0
- package/package.json +27 -20
- package/src/core/define-env.ts +101 -20
- package/src/core/describe.ts +52 -0
- package/src/core/errors.ts +14 -0
- package/src/core/index.ts +7 -2
- package/src/core/secret.ts +127 -0
- package/src/index.ts +3 -2
- package/src/node/codec.ts +220 -0
- package/src/node/edit.ts +279 -0
- package/src/node/errors.ts +147 -0
- package/src/node/files.ts +41 -0
- package/src/node/index.ts +48 -0
- package/src/node/key-schemas.ts +44 -0
- package/src/node/keys.ts +93 -0
- package/src/node/load.ts +386 -0
- package/src/node/operation-telemetry.ts +56 -0
- package/src/node/references.ts +90 -0
- package/src/node/register.ts +18 -0
- package/src/{contracts → presets}/common.ts +4 -8
- package/src/presets/index.ts +18 -0
- package/src/{contracts → presets}/parsing.ts +12 -5
- package/src/{contracts → presets}/urls.ts +1 -1
- package/dist/contracts/common.d.ts.map +0 -1
- package/dist/contracts/common.js.map +0 -1
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -14
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/parsing.d.ts.map +0 -1
- package/dist/contracts/parsing.js.map +0 -1
- package/dist/contracts/urls.d.ts.map +0 -1
- package/dist/contracts/urls.js.map +0 -1
- package/dist/dot.d.ts +0 -67
- package/dist/dot.d.ts.map +0 -1
- package/dist/dot.js +0 -65
- package/dist/dot.js.map +0 -1
- package/src/contracts/index.ts +0 -17
- package/src/dot.ts +0 -94
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File edits behind `dot env init | set | encrypt | decrypt | rotate`. Each write goes to a temp file
|
|
3
|
+
* first and is renamed into place, so an interrupted command never leaves half a file.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { InvalidInput, isFailure } from '@arki/failure';
|
|
8
|
+
import { decryptValue, encryptValue, envHeader, envValues, generateKeypair, isEncrypted, isKeyName, keyNamesFor, parseEnv, publicKeyOf, readEnvValue, setEnvValue, } from './codec.js';
|
|
9
|
+
import { DecryptionFailed, FileWriteFailed, MissingPrivateKey, MissingPublicKey, RotationIncomplete, } from './errors.js';
|
|
10
|
+
import { readEnvText, writeEnvText } from './files.js';
|
|
11
|
+
import { parsePublicKey } from './key-schemas.js';
|
|
12
|
+
import { findPrivateKey, KEYS_FILE, keysFileCandidates, writePrivateKey } from './keys.js';
|
|
13
|
+
import { nodeOperation } from './operation-telemetry.js';
|
|
14
|
+
/** The public key in a file's header, or `undefined` when it has none. */
|
|
15
|
+
export function publicKeyIn(file) {
|
|
16
|
+
if (!existsSync(file))
|
|
17
|
+
return;
|
|
18
|
+
const text = readEnvText(file);
|
|
19
|
+
if (isFailure(text))
|
|
20
|
+
return text;
|
|
21
|
+
const key = readEnvValue(parseEnv(text), keyNamesFor(path.basename(file)).publicKey);
|
|
22
|
+
if (key === undefined)
|
|
23
|
+
return;
|
|
24
|
+
return parsePublicKey(key);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Give `file` a dotenvx header, creating the file if needed. Reuses the private key of the same
|
|
28
|
+
* environment when one is already reachable (so every `.env.development` in a repo shares one key);
|
|
29
|
+
* otherwise generates a keypair and stores the private key in `<root>/.env.keys`.
|
|
30
|
+
*/
|
|
31
|
+
export function initEnvFile(file, options) {
|
|
32
|
+
return nodeOperation('init', () => {
|
|
33
|
+
const existing = publicKeyIn(file);
|
|
34
|
+
if (isFailure(existing))
|
|
35
|
+
return existing;
|
|
36
|
+
if (existing !== undefined)
|
|
37
|
+
return { file, publicKey: existing, headerAdded: false };
|
|
38
|
+
const names = keyNamesFor(path.basename(file));
|
|
39
|
+
const found = findPrivateKey(file, { root: options.root, env: options.env ?? process.env });
|
|
40
|
+
if (isFailure(found))
|
|
41
|
+
return found;
|
|
42
|
+
const reused = found?.keys[0];
|
|
43
|
+
let publicKey;
|
|
44
|
+
let keysWritten;
|
|
45
|
+
if (reused === undefined) {
|
|
46
|
+
const pair = generateKeypair();
|
|
47
|
+
if (isFailure(pair))
|
|
48
|
+
return pair;
|
|
49
|
+
keysWritten = path.join(options.root, KEYS_FILE);
|
|
50
|
+
const written = writePrivateKey(keysWritten, names.privateKey, pair.privateKey, path.basename(file));
|
|
51
|
+
if (isFailure(written))
|
|
52
|
+
return written;
|
|
53
|
+
publicKey = pair.publicKey;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
publicKey = publicKeyOf(reused);
|
|
57
|
+
}
|
|
58
|
+
const body = existsSync(file) ? readEnvText(file) : '';
|
|
59
|
+
if (isFailure(body))
|
|
60
|
+
return body;
|
|
61
|
+
const written = writeEnvText(file, `${envHeader(path.basename(file), publicKey)}\n${body}`);
|
|
62
|
+
if (isFailure(written))
|
|
63
|
+
return written;
|
|
64
|
+
return keysWritten === undefined
|
|
65
|
+
? { file, publicKey, headerAdded: true }
|
|
66
|
+
: { file, publicKey, headerAdded: true, keysWritten };
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set `key` in `file`, encrypted to the file's public key unless `plain`. Returns `false` when the
|
|
71
|
+
* file already held exactly this plaintext value (an encrypted value is always rewritten, because
|
|
72
|
+
* the same plaintext never encrypts to the same bytes).
|
|
73
|
+
*/
|
|
74
|
+
export function setEnvFileValue(file, key, value, options) {
|
|
75
|
+
return nodeOperation('set', () => {
|
|
76
|
+
const text = existsSync(file) ? readEnvText(file) : '';
|
|
77
|
+
if (isFailure(text))
|
|
78
|
+
return text;
|
|
79
|
+
let stored = value;
|
|
80
|
+
if (!options.plain) {
|
|
81
|
+
const publicKey = readEnvValue(parseEnv(text), keyNamesFor(path.basename(file)).publicKey);
|
|
82
|
+
if (publicKey === undefined)
|
|
83
|
+
return MissingPublicKey({ file });
|
|
84
|
+
const parsedKey = parsePublicKey(publicKey);
|
|
85
|
+
if (isFailure(parsedKey))
|
|
86
|
+
return parsedKey;
|
|
87
|
+
const encrypted = encryptValue(value, parsedKey);
|
|
88
|
+
if (isFailure(encrypted))
|
|
89
|
+
return encrypted;
|
|
90
|
+
stored = encrypted;
|
|
91
|
+
}
|
|
92
|
+
const next = setEnvValue(text, key, stored);
|
|
93
|
+
if (isFailure(next))
|
|
94
|
+
return next;
|
|
95
|
+
if (next === text)
|
|
96
|
+
return false;
|
|
97
|
+
const written = writeEnvText(file, next);
|
|
98
|
+
return isFailure(written) ? written : true;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Encrypt plaintext values in place: the listed keys, or every value. Returns the keys encrypted. */
|
|
102
|
+
export function encryptEnvFile(file, keys) {
|
|
103
|
+
return nodeOperation('encrypt_file', () => {
|
|
104
|
+
const text = readEnvText(file);
|
|
105
|
+
if (isFailure(text))
|
|
106
|
+
return text;
|
|
107
|
+
const publicKey = readEnvValue(parseEnv(text), keyNamesFor(path.basename(file)).publicKey);
|
|
108
|
+
if (publicKey === undefined)
|
|
109
|
+
return MissingPublicKey({ file });
|
|
110
|
+
const parsedKey = parsePublicKey(publicKey);
|
|
111
|
+
if (isFailure(parsedKey))
|
|
112
|
+
return parsedKey;
|
|
113
|
+
let next = text;
|
|
114
|
+
const done = [];
|
|
115
|
+
for (const [key, entry] of envValues(parseEnv(text))) {
|
|
116
|
+
if (isKeyName(key) || isEncrypted(entry.value) || (keys !== undefined && !keys.includes(key)))
|
|
117
|
+
continue;
|
|
118
|
+
const encrypted = encryptValue(entry.value, parsedKey);
|
|
119
|
+
if (isFailure(encrypted))
|
|
120
|
+
return encrypted;
|
|
121
|
+
const updated = setEnvValue(next, key, encrypted);
|
|
122
|
+
if (isFailure(updated))
|
|
123
|
+
return updated;
|
|
124
|
+
next = updated;
|
|
125
|
+
done.push(key);
|
|
126
|
+
}
|
|
127
|
+
if (done.length > 0) {
|
|
128
|
+
const written = writeEnvText(file, next);
|
|
129
|
+
if (isFailure(written))
|
|
130
|
+
return written;
|
|
131
|
+
}
|
|
132
|
+
return done;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** Decrypt values in place with `privateKeys`: the listed keys, or every value. Returns the keys decrypted. */
|
|
136
|
+
export function decryptEnvFile(file, privateKeys, keys) {
|
|
137
|
+
return nodeOperation('decrypt_file', () => {
|
|
138
|
+
const text = readEnvText(file);
|
|
139
|
+
if (isFailure(text))
|
|
140
|
+
return text;
|
|
141
|
+
let next = text;
|
|
142
|
+
const done = [];
|
|
143
|
+
for (const [key, entry] of envValues(parseEnv(text))) {
|
|
144
|
+
if (!isEncrypted(entry.value) || (keys !== undefined && !keys.includes(key)))
|
|
145
|
+
continue;
|
|
146
|
+
const decrypted = decryptWithAny(entry.value, privateKeys);
|
|
147
|
+
if (isFailure(decrypted))
|
|
148
|
+
return decrypted;
|
|
149
|
+
const updated = setEnvValue(next, key, decrypted);
|
|
150
|
+
if (isFailure(updated))
|
|
151
|
+
return updated;
|
|
152
|
+
next = updated;
|
|
153
|
+
done.push(key);
|
|
154
|
+
}
|
|
155
|
+
if (done.length > 0) {
|
|
156
|
+
const written = writeEnvText(file, next);
|
|
157
|
+
if (isFailure(written))
|
|
158
|
+
return written;
|
|
159
|
+
}
|
|
160
|
+
return done;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Re-encrypt every file of one environment to a new keypair, in one step: decrypt everything first
|
|
165
|
+
* (so a wrong key changes nothing), then write each file, then the new private key. All `files` must
|
|
166
|
+
* share a file name (`.env.production`), because they share a key name.
|
|
167
|
+
*/
|
|
168
|
+
export function rotateEnvFiles(files, options) {
|
|
169
|
+
const first = files[0];
|
|
170
|
+
if (first === undefined)
|
|
171
|
+
return InvalidInput({ issues: [{ message: 'No files to rotate.' }] });
|
|
172
|
+
const names = keyNamesFor(path.basename(first));
|
|
173
|
+
if (files.some(file => keyNamesFor(path.basename(file)).privateKey !== names.privateKey)) {
|
|
174
|
+
return InvalidInput({ issues: [{ message: 'Rotate takes files of one environment at a time.' }] });
|
|
175
|
+
}
|
|
176
|
+
return nodeOperation('rotate', () => {
|
|
177
|
+
const pair = generateKeypair();
|
|
178
|
+
if (isFailure(pair))
|
|
179
|
+
return pair;
|
|
180
|
+
const previousKeys = new Set();
|
|
181
|
+
const keysFile = path.join(options.root, KEYS_FILE);
|
|
182
|
+
const keyStores = new Set([keysFile]);
|
|
183
|
+
const plans = [];
|
|
184
|
+
for (const file of files) {
|
|
185
|
+
for (const candidate of keysFileCandidates(file, options.root)) {
|
|
186
|
+
if (existsSync(candidate))
|
|
187
|
+
keyStores.add(candidate);
|
|
188
|
+
}
|
|
189
|
+
const text = readEnvText(file);
|
|
190
|
+
if (isFailure(text))
|
|
191
|
+
return text;
|
|
192
|
+
const found = findPrivateKey(file, { root: options.root, env: options.env ?? process.env });
|
|
193
|
+
if (isFailure(found))
|
|
194
|
+
return found;
|
|
195
|
+
for (const key of found?.keys ?? [])
|
|
196
|
+
previousKeys.add(key);
|
|
197
|
+
let next = text;
|
|
198
|
+
let values = 0;
|
|
199
|
+
for (const [key, entry] of envValues(parseEnv(text))) {
|
|
200
|
+
let value;
|
|
201
|
+
if (key === names.publicKey)
|
|
202
|
+
value = pair.publicKey;
|
|
203
|
+
else if (isEncrypted(entry.value)) {
|
|
204
|
+
if (found === undefined)
|
|
205
|
+
return MissingPrivateKey({ file });
|
|
206
|
+
const decrypted = decryptWithAny(entry.value, found.keys);
|
|
207
|
+
if (isFailure(decrypted))
|
|
208
|
+
return decrypted;
|
|
209
|
+
const encrypted = encryptValue(decrypted, pair.publicKey);
|
|
210
|
+
if (isFailure(encrypted))
|
|
211
|
+
return encrypted;
|
|
212
|
+
value = encrypted;
|
|
213
|
+
values++;
|
|
214
|
+
}
|
|
215
|
+
else
|
|
216
|
+
continue;
|
|
217
|
+
const updated = setEnvValue(next, key, value);
|
|
218
|
+
if (isFailure(updated))
|
|
219
|
+
return updated;
|
|
220
|
+
next = updated;
|
|
221
|
+
}
|
|
222
|
+
if (readEnvValue(parseEnv(text), names.publicKey) === undefined)
|
|
223
|
+
next = `${envHeader(path.basename(file), pair.publicKey)}\n${next}`;
|
|
224
|
+
plans.push({ file, next, values });
|
|
225
|
+
}
|
|
226
|
+
// Persist both generations BEFORE any ciphertext changes. An interruption at any later point
|
|
227
|
+
// leaves every old/new file recoverable from this key store, including a partial rotation.
|
|
228
|
+
for (const store of keyStores) {
|
|
229
|
+
const staged = writePrivateKey(store, names.privateKey, pair.privateKey, path.basename(first), {
|
|
230
|
+
preserve: [...previousKeys],
|
|
231
|
+
});
|
|
232
|
+
if (isFailure(staged))
|
|
233
|
+
return staged;
|
|
234
|
+
}
|
|
235
|
+
let completedFiles = 0;
|
|
236
|
+
for (const plan of plans) {
|
|
237
|
+
const written = writeEnvText(plan.file, plan.next);
|
|
238
|
+
if (isFailure(written))
|
|
239
|
+
return RotationIncomplete({ keysFile, completedFiles, totalFiles: plans.length }, { cause: written });
|
|
240
|
+
completedFiles++;
|
|
241
|
+
}
|
|
242
|
+
// Do not retire the old generation until every committed file reads back exactly as planned.
|
|
243
|
+
for (const plan of plans) {
|
|
244
|
+
const confirmed = readEnvText(plan.file);
|
|
245
|
+
if (isFailure(confirmed) || confirmed !== plan.next)
|
|
246
|
+
return RotationIncomplete({ keysFile, completedFiles, totalFiles: plans.length }, { cause: isFailure(confirmed) ? confirmed : FileWriteFailed({ file: plan.file }) });
|
|
247
|
+
}
|
|
248
|
+
for (const store of keyStores) {
|
|
249
|
+
const finalized = writePrivateKey(store, names.privateKey, pair.privateKey, path.basename(first));
|
|
250
|
+
if (isFailure(finalized))
|
|
251
|
+
return RotationIncomplete({ keysFile, completedFiles, totalFiles: plans.length }, { cause: finalized });
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
privateKeyName: names.privateKey,
|
|
255
|
+
files: plans.map(({ file, values }) => ({ file, values })),
|
|
256
|
+
keysFile,
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function decryptWithAny(value, privateKeys) {
|
|
261
|
+
for (const privateKey of privateKeys) {
|
|
262
|
+
const decrypted = decryptValue(value, privateKey);
|
|
263
|
+
if (!isFailure(decrypted))
|
|
264
|
+
return decrypted;
|
|
265
|
+
}
|
|
266
|
+
return DecryptionFailed();
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/node/edit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,SAAS,EACT,eAAe,EACf,WAAW,EACX,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO;IAC9B,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACjC,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC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;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,WAAqC;IAC1E,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IAC9C,CAAC;IACD,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** A dotenv value has no lossless quoting.
|
|
2
|
+
* @fix Use encryption or a value supported by dotenv quoting.
|
|
3
|
+
* @verify bun run test
|
|
4
|
+
*/
|
|
5
|
+
export declare const UnrepresentableValue: import("@arki/failure").FailureDefinition<"env.unrepresentable_value", undefined>;
|
|
6
|
+
/** Cryptographic encryption failed.
|
|
7
|
+
* @fix Verify the public key and runtime crypto support.
|
|
8
|
+
* @verify bun run test
|
|
9
|
+
*/
|
|
10
|
+
export declare const EncryptionFailed: import("@arki/failure").FailureDefinition<"env.encryption_failed", undefined>;
|
|
11
|
+
/** Ciphertext authentication or decoding failed.
|
|
12
|
+
* @fix Restore the correct private key or reset the damaged value.
|
|
13
|
+
* @verify bun run test
|
|
14
|
+
*/
|
|
15
|
+
export declare const DecryptionFailed: import("@arki/failure").FailureDefinition<"env.decryption_failed", undefined>;
|
|
16
|
+
/** The runtime could not generate a keypair.
|
|
17
|
+
* @fix Restore runtime crypto support.
|
|
18
|
+
* @verify bun run test
|
|
19
|
+
*/
|
|
20
|
+
export declare const KeyGenerationFailed: import("@arki/failure").FailureDefinition<"env.key_generation_failed", undefined>;
|
|
21
|
+
/** An env file could not be read.
|
|
22
|
+
* @fix Check the path, file type and access permissions.
|
|
23
|
+
* @verify bun run test
|
|
24
|
+
*/
|
|
25
|
+
export declare const FileReadFailed: import("@arki/failure").FailureDefinition<"env.file_read_failed", import("@standard-schema/spec").StandardSchemaV1<{
|
|
26
|
+
file: string;
|
|
27
|
+
}, {
|
|
28
|
+
file: string;
|
|
29
|
+
}>>;
|
|
30
|
+
/** An env file could not be replaced.
|
|
31
|
+
* @fix Check disk space and parent-directory permissions.
|
|
32
|
+
* @verify bun run test
|
|
33
|
+
*/
|
|
34
|
+
export declare const FileWriteFailed: import("@arki/failure").FailureDefinition<"env.file_write_failed", import("@standard-schema/spec").StandardSchemaV1<{
|
|
35
|
+
file: string;
|
|
36
|
+
}, {
|
|
37
|
+
file: string;
|
|
38
|
+
}>>;
|
|
39
|
+
/** The target file has no public key.
|
|
40
|
+
* @fix Initialize the file before encrypting values.
|
|
41
|
+
* @verify bun run test
|
|
42
|
+
*/
|
|
43
|
+
export declare const MissingPublicKey: import("@arki/failure").FailureDefinition<"env.missing_public_key", import("@standard-schema/spec").StandardSchemaV1<{
|
|
44
|
+
file: string;
|
|
45
|
+
}, {
|
|
46
|
+
file: string;
|
|
47
|
+
}>>;
|
|
48
|
+
/** No private key is available.
|
|
49
|
+
* @fix Restore the environment key from its backup.
|
|
50
|
+
* @verify bun run test
|
|
51
|
+
*/
|
|
52
|
+
export declare const MissingPrivateKey: import("@arki/failure").FailureDefinition<"env.missing_private_key", import("@standard-schema/spec").StandardSchemaV1<{
|
|
53
|
+
file: string;
|
|
54
|
+
}, {
|
|
55
|
+
file: string;
|
|
56
|
+
}>>;
|
|
57
|
+
/** Rotation stopped after its recovery keys were saved.
|
|
58
|
+
* @fix Keep the staged key file and retry rotation.
|
|
59
|
+
* @verify bun run test
|
|
60
|
+
*/
|
|
61
|
+
export declare const RotationIncomplete: import("@arki/failure").FailureDefinition<"env.rotation_incomplete", import("@standard-schema/spec").StandardSchemaV1<{
|
|
62
|
+
keysFile: string;
|
|
63
|
+
completedFiles: number;
|
|
64
|
+
totalFiles: number;
|
|
65
|
+
}, {
|
|
66
|
+
keysFile: string;
|
|
67
|
+
completedFiles: number;
|
|
68
|
+
totalFiles: number;
|
|
69
|
+
}>>;
|
|
70
|
+
/** A secret provider rejected a read.
|
|
71
|
+
* @fix Check the provider CLI installation, login and reference.
|
|
72
|
+
* @verify bun run test
|
|
73
|
+
*/
|
|
74
|
+
export declare const ReferenceFailed: import("@arki/failure").FailureDefinition<"env.reference_failed", import("@standard-schema/spec").StandardSchemaV1<{
|
|
75
|
+
scheme: string;
|
|
76
|
+
}, {
|
|
77
|
+
scheme: string;
|
|
78
|
+
}>>;
|
|
79
|
+
/** Loading was cancelled.
|
|
80
|
+
* @fix Handle cancellation at the calling boundary.
|
|
81
|
+
* @verify bun run test
|
|
82
|
+
*/
|
|
83
|
+
export declare const EnvCancelled: import("@arki/failure").FailureDefinition<"env.cancelled", undefined>;
|
|
84
|
+
/** The aggregate load deadline elapsed.
|
|
85
|
+
* @fix Increase the budget or restore provider responsiveness.
|
|
86
|
+
* @verify bun run test
|
|
87
|
+
*/
|
|
88
|
+
export declare const EnvDeadline: import("@arki/failure").FailureDefinition<"env.deadline", undefined>;
|
|
89
|
+
/** Loader problem codes are derived from their canonical definitions. */
|
|
90
|
+
export declare const ENV_FILES_ERROR_CODES: {
|
|
91
|
+
readonly missingPrivateKey: "env.missing_private_key";
|
|
92
|
+
readonly cannotDecrypt: "env.decryption_failed";
|
|
93
|
+
readonly unresolvedReference: "env.reference_failed";
|
|
94
|
+
readonly cannotRead: "env.file_read_failed";
|
|
95
|
+
readonly cancelled: "env.cancelled";
|
|
96
|
+
readonly deadline: "env.deadline";
|
|
97
|
+
};
|
|
98
|
+
/** One or more env entries could not be loaded. Public data excludes values and raw causes.
|
|
99
|
+
* @fix Address each named problem before starting the app.
|
|
100
|
+
* @verify bun run test
|
|
101
|
+
*/
|
|
102
|
+
export declare const EnvFilesFailed: import("@arki/failure").FailureDefinition<"env.files_failed", import("@standard-schema/spec").StandardSchemaV1<{
|
|
103
|
+
environment: string;
|
|
104
|
+
errors: {
|
|
105
|
+
code: "env.cancelled" | "env.deadline" | "env.decryption_failed" | "env.file_read_failed" | "env.missing_private_key" | "env.reference_failed";
|
|
106
|
+
message: string;
|
|
107
|
+
file: string;
|
|
108
|
+
key?: string | undefined;
|
|
109
|
+
}[];
|
|
110
|
+
}, {
|
|
111
|
+
environment: string;
|
|
112
|
+
errors: {
|
|
113
|
+
code: "env.cancelled" | "env.deadline" | "env.decryption_failed" | "env.file_read_failed" | "env.missing_private_key" | "env.reference_failed";
|
|
114
|
+
message: string;
|
|
115
|
+
file: string;
|
|
116
|
+
key?: string | undefined;
|
|
117
|
+
}[];
|
|
118
|
+
}>>;
|
|
119
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/node/errors.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,mFAI/B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,+EAI3B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,+EAI3B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,mFAI9B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;GAKzB,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;GAK1B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;GAI3B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;GAI5B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;GAU7B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;GAK1B,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,YAAY,uEAIvB,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,WAAW,sEAItB,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,qBAAqB;aAChC,iBAAiB;aACjB,aAAa;aACb,mBAAmB;aACnB,UAAU;aACV,SAAS;aACT,QAAQ;CACA,CAAC;AAOX;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;GAKzB,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineFailure } from '@arki/failure';
|
|
3
|
+
/** A dotenv value has no lossless quoting.
|
|
4
|
+
* @fix Use encryption or a value supported by dotenv quoting.
|
|
5
|
+
* @verify bun run test
|
|
6
|
+
*/
|
|
7
|
+
export const UnrepresentableValue = defineFailure('env.unrepresentable_value', {
|
|
8
|
+
message: 'The value cannot be stored losslessly in dotenv text',
|
|
9
|
+
status: 422,
|
|
10
|
+
remediation: 'Encrypt the value or remove the unsupported combination of quotes and line breaks.',
|
|
11
|
+
});
|
|
12
|
+
/** Cryptographic encryption failed.
|
|
13
|
+
* @fix Verify the public key and runtime crypto support.
|
|
14
|
+
* @verify bun run test
|
|
15
|
+
*/
|
|
16
|
+
export const EncryptionFailed = defineFailure('env.encryption_failed', {
|
|
17
|
+
message: 'Cannot encrypt the env value',
|
|
18
|
+
status: 500,
|
|
19
|
+
remediation: 'Verify the public key and runtime crypto support.',
|
|
20
|
+
});
|
|
21
|
+
/** Ciphertext authentication or decoding failed.
|
|
22
|
+
* @fix Restore the correct private key or reset the damaged value.
|
|
23
|
+
* @verify bun run test
|
|
24
|
+
*/
|
|
25
|
+
export const DecryptionFailed = defineFailure('env.decryption_failed', {
|
|
26
|
+
message: 'Cannot decrypt the env value',
|
|
27
|
+
status: 422,
|
|
28
|
+
remediation: 'Restore the correct private key or reset the damaged encrypted value.',
|
|
29
|
+
});
|
|
30
|
+
/** The runtime could not generate a keypair.
|
|
31
|
+
* @fix Restore runtime crypto support.
|
|
32
|
+
* @verify bun run test
|
|
33
|
+
*/
|
|
34
|
+
export const KeyGenerationFailed = defineFailure('env.key_generation_failed', {
|
|
35
|
+
message: 'Cannot generate an env keypair',
|
|
36
|
+
status: 500,
|
|
37
|
+
remediation: 'Restore runtime crypto support before retrying.',
|
|
38
|
+
});
|
|
39
|
+
/** An env file could not be read.
|
|
40
|
+
* @fix Check the path, file type and access permissions.
|
|
41
|
+
* @verify bun run test
|
|
42
|
+
*/
|
|
43
|
+
export const FileReadFailed = defineFailure('env.file_read_failed', {
|
|
44
|
+
data: z.object({ file: z.string() }),
|
|
45
|
+
message: 'Cannot read env file {file}',
|
|
46
|
+
status: 500,
|
|
47
|
+
remediation: 'Check the file path, type and access permissions.',
|
|
48
|
+
});
|
|
49
|
+
/** An env file could not be replaced.
|
|
50
|
+
* @fix Check disk space and parent-directory permissions.
|
|
51
|
+
* @verify bun run test
|
|
52
|
+
*/
|
|
53
|
+
export const FileWriteFailed = defineFailure('env.file_write_failed', {
|
|
54
|
+
data: z.object({ file: z.string() }),
|
|
55
|
+
message: 'Cannot write env file {file}',
|
|
56
|
+
status: 500,
|
|
57
|
+
remediation: 'Check disk space and parent-directory permissions before retrying.',
|
|
58
|
+
});
|
|
59
|
+
/** The target file has no public key.
|
|
60
|
+
* @fix Initialize the file before encrypting values.
|
|
61
|
+
* @verify bun run test
|
|
62
|
+
*/
|
|
63
|
+
export const MissingPublicKey = defineFailure('env.missing_public_key', {
|
|
64
|
+
data: z.object({ file: z.string() }),
|
|
65
|
+
message: 'Env file {file} has no public key header',
|
|
66
|
+
remediation: 'Initialize the file before encrypting values.',
|
|
67
|
+
});
|
|
68
|
+
/** No private key is available.
|
|
69
|
+
* @fix Restore the environment key from its backup.
|
|
70
|
+
* @verify bun run test
|
|
71
|
+
*/
|
|
72
|
+
export const MissingPrivateKey = defineFailure('env.missing_private_key', {
|
|
73
|
+
data: z.object({ file: z.string() }),
|
|
74
|
+
message: 'No private key is available for {file}',
|
|
75
|
+
remediation: 'Restore the environment private key from its backup or shell variable.',
|
|
76
|
+
});
|
|
77
|
+
/** Rotation stopped after its recovery keys were saved.
|
|
78
|
+
* @fix Keep the staged key file and retry rotation.
|
|
79
|
+
* @verify bun run test
|
|
80
|
+
*/
|
|
81
|
+
export const RotationIncomplete = defineFailure('env.rotation_incomplete', {
|
|
82
|
+
data: z.object({
|
|
83
|
+
keysFile: z.string(),
|
|
84
|
+
completedFiles: z.number().int().nonnegative(),
|
|
85
|
+
totalFiles: z.number().int().nonnegative(),
|
|
86
|
+
}),
|
|
87
|
+
message: 'Env rotation stopped; recovery keys are saved in {keysFile}',
|
|
88
|
+
status: 500,
|
|
89
|
+
remediation: 'Keep the staged key file: it contains keys for both old and new ciphertext. Repair the filesystem and retry rotation.',
|
|
90
|
+
});
|
|
91
|
+
/** A secret provider rejected a read.
|
|
92
|
+
* @fix Check the provider CLI installation, login and reference.
|
|
93
|
+
* @verify bun run test
|
|
94
|
+
*/
|
|
95
|
+
export const ReferenceFailed = defineFailure('env.reference_failed', {
|
|
96
|
+
data: z.object({ scheme: z.string() }),
|
|
97
|
+
message: 'Cannot resolve the {scheme} secret reference',
|
|
98
|
+
status: 502,
|
|
99
|
+
remediation: 'Check the provider CLI installation, login and reference; inspect the local cause privately.',
|
|
100
|
+
});
|
|
101
|
+
/** Loading was cancelled.
|
|
102
|
+
* @fix Handle cancellation at the calling boundary.
|
|
103
|
+
* @verify bun run test
|
|
104
|
+
*/
|
|
105
|
+
export const EnvCancelled = defineFailure('env.cancelled', {
|
|
106
|
+
message: 'Env loading was cancelled',
|
|
107
|
+
status: 499,
|
|
108
|
+
remediation: 'Honor cancellation at the calling boundary.',
|
|
109
|
+
});
|
|
110
|
+
/** The aggregate load deadline elapsed.
|
|
111
|
+
* @fix Increase the budget or restore provider responsiveness.
|
|
112
|
+
* @verify bun run test
|
|
113
|
+
*/
|
|
114
|
+
export const EnvDeadline = defineFailure('env.deadline', {
|
|
115
|
+
message: 'The env loading deadline elapsed',
|
|
116
|
+
status: 504,
|
|
117
|
+
remediation: 'Increase the load budget or restore provider responsiveness.',
|
|
118
|
+
});
|
|
119
|
+
/** Loader problem codes are derived from their canonical definitions. */
|
|
120
|
+
export const ENV_FILES_ERROR_CODES = {
|
|
121
|
+
missingPrivateKey: MissingPrivateKey.code,
|
|
122
|
+
cannotDecrypt: DecryptionFailed.code,
|
|
123
|
+
unresolvedReference: ReferenceFailed.code,
|
|
124
|
+
cannotRead: FileReadFailed.code,
|
|
125
|
+
cancelled: EnvCancelled.code,
|
|
126
|
+
deadline: EnvDeadline.code,
|
|
127
|
+
};
|
|
128
|
+
const problem = z.object({
|
|
129
|
+
code: z.enum(Object.values(ENV_FILES_ERROR_CODES)),
|
|
130
|
+
message: z.string(),
|
|
131
|
+
file: z.string(),
|
|
132
|
+
key: z.string().optional(),
|
|
133
|
+
});
|
|
134
|
+
/** One or more env entries could not be loaded. Public data excludes values and raw causes.
|
|
135
|
+
* @fix Address each named problem before starting the app.
|
|
136
|
+
* @verify bun run test
|
|
137
|
+
*/
|
|
138
|
+
export const EnvFilesFailed = defineFailure('env.files_failed', {
|
|
139
|
+
data: z.object({ environment: z.string(), errors: z.array(problem) }),
|
|
140
|
+
message: 'Cannot load the env files',
|
|
141
|
+
status: 500,
|
|
142
|
+
remediation: 'Address each named file/key problem before starting the application.',
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/node/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,2BAA2B,EAAE;IAC7E,OAAO,EAAE,sDAAsD;IAC/D,MAAM,EAAE,GAAG;IACX,WAAW,EAAE,oFAAoF;CAClG,CAAC,CAAC;AACH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC,uBAAuB,EAAE;IACrE,OAAO,EAAE,8BAA8B;IACvC,MAAM,EAAE,GAAG;IACX,WAAW,EAAE,mDAAmD;CACjE,CAAC,CAAC;AACH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa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I;IACpC,mBAAmB,EAAE,eAAe,CAAC,IAAI;IACzC,UAAU,EAAE,cAAc,CAAC,IAAI;IAC/B,SAAS,EAAE,YAAY,CAAC,IAAI;IAC5B,QAAQ,EAAE,WAAW,CAAC,IAAI;CAClB,CAAC;AACX,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAClD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC3B,CAAC,CAAC;AACH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,kBAAkB,EAAE;IAC9D,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IACrE,OAAO,EAAE,2BAA2B;IACpC,MAAM,EAAE,GAAG;IACX,WAAW,EAAE,sEAAsE;CACpF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Foreign filesystem errors stay private; public outcomes identify only the file. */
|
|
2
|
+
export declare function readEnvText(file: string): string | import("@arki/failure").Failure<"env.file_read_failed", {
|
|
3
|
+
file: string;
|
|
4
|
+
}>;
|
|
5
|
+
/** Each replacement is atomic; owner-only new files and key stores never follow a planted temp symlink. */
|
|
6
|
+
export declare function writeEnvText(file: string, text: string, privateFile?: boolean): import("@arki/failure").Failure<"env.file_write_failed", {
|
|
7
|
+
file: string;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/node/files.ts"],"names":[],"mappings":"AASA,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM;;GAOvC;AAED,2GAA2G;AAC3G,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,UAAQ;;eAoB3E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { attempt } from '@arki/failure';
|
|
5
|
+
import { FileReadFailed, FileWriteFailed } from './errors.js';
|
|
6
|
+
import { nodeOperation } from './operation-telemetry.js';
|
|
7
|
+
/** Foreign filesystem errors stay private; public outcomes identify only the file. */
|
|
8
|
+
export function readEnvText(file) {
|
|
9
|
+
return nodeOperation('file.read', () => attempt(() => readFileSync(file, 'utf8'), error => FileReadFailed({ file }, { cause: error })));
|
|
10
|
+
}
|
|
11
|
+
/** Each replacement is atomic; owner-only new files and key stores never follow a planted temp symlink. */
|
|
12
|
+
export function writeEnvText(file, text, privateFile = false) {
|
|
13
|
+
return nodeOperation('file.write', () => {
|
|
14
|
+
let temp;
|
|
15
|
+
try {
|
|
16
|
+
const mode = privateFile ? 0o600 : existsSync(file) ? statSync(file).mode & 0o777 : 0o600;
|
|
17
|
+
temp = path.join(path.dirname(file), `.${path.basename(file)}.${randomUUID()}.tmp`);
|
|
18
|
+
writeFileSync(temp, text, { flag: 'wx', mode });
|
|
19
|
+
renameSync(temp, file);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (temp !== undefined) {
|
|
24
|
+
try {
|
|
25
|
+
unlinkSync(temp);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
/* The failed write may not have created a file. */
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return FileWriteFailed({ file }, { cause: error });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/node/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpG,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,sFAAsF;AACtF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,CACrC,OAAO,CACL,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAChC,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CACpD,CACF,CAAC;AACJ,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAY,EAAE,WAAW,GAAG,KAAK;IAC1E,OAAO,aAAa,CAAC,YAAY,EAAE,GAAG,EAAE;QACtC,IAAI,IAAwB,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YAC1F,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,MAAM,CAAC,CAAC;YACpF,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAChD,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvB,OAAO;QACT,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC;oBACH,UAAU,CAAC,IAAI,CAAC,CAAC;gBACnB,CAAC;gBAAC,MAAM,CAAC;oBACP,mDAAmD;gBACrD,CAAC;YACH,CAAC;YACD,OAAO,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encrypted env files in the dotenvx 2.x format, for Node, Bun and Deno: load them into the
|
|
3
|
+
* environment (`loadEnvFiles`), edit them (`initEnvFile`, `setEnvFileValue`, ...), and the codec
|
|
4
|
+
* underneath. The Dot CLI's `dot env` commands are built on these.
|
|
5
|
+
*/
|
|
6
|
+
export { decryptValue, ENCRYPTED_PREFIX, encryptValue, envHeader, envValues, generateKeypair, isEncrypted, isKeyName, keyNamesFor, parseEnv, publicKeyOf, readEnvValue, removeEnvValue, setEnvValue, } from './codec.js';
|
|
7
|
+
export type { EnvDocument, EnvEntry, EnvKeypair } from './codec.js';
|
|
8
|
+
export { decryptEnvFile, encryptEnvFile, initEnvFile, publicKeyIn, rotateEnvFiles, setEnvFileValue } from './edit.js';
|
|
9
|
+
export type { InitResult, RotateResult } from './edit.js';
|
|
10
|
+
export { findPrivateKey, KEYS_FILE, keysFileCandidates, writePrivateKey } from './keys.js';
|
|
11
|
+
export type { FoundPrivateKey, PrivateKeySource } from './keys.js';
|
|
12
|
+
export { envDirs, ENV_FILES_ERROR_CODES, findRoot, formatEnvFilesErrors, loadEnvFiles, secretValues } from './load.js';
|
|
13
|
+
export type { EnvFilesError, EnvFilesReport, EnvFileValue, EnvValueKind, LoadEnvFilesOptions } from './load.js';
|
|
14
|
+
export { DEFAULT_RESOLVERS, referenceScheme } from './references.js';
|
|
15
|
+
export type { ReferenceResolver } from './references.js';
|
|
16
|
+
export type { ReferenceOptions } from './references.js';
|
|
17
|
+
export { DecryptionFailed, EncryptionFailed, EnvCancelled, EnvDeadline, EnvFilesFailed, FileReadFailed, FileWriteFailed, KeyGenerationFailed, MissingPrivateKey, MissingPublicKey, ReferenceFailed, RotationIncomplete, UnrepresentableValue, } from './errors.js';
|
|
18
|
+
export { envPrivateKeySchema, envPublicKeySchema, parsePrivateKey, parsePublicKey } from './key-schemas.js';
|
|
19
|
+
export type { EnvPrivateKey, EnvPublicKey } from './key-schemas.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,eAAe,EACf,WAAW,EACX,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACtH,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,M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