@dotenvx/next-env 2.1.0 → 2.1.2
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/dist/index.cjs +105 -13
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6120,7 +6120,22 @@ var require_dist = __commonJS({
|
|
|
6120
6120
|
var fs2 = require("fs");
|
|
6121
6121
|
var derive2 = require_derive();
|
|
6122
6122
|
var scan2 = require_scan();
|
|
6123
|
-
function keysFromFile(filepath = ".env.keys") {
|
|
6123
|
+
async function keysFromFile(filepath = ".env.keys") {
|
|
6124
|
+
try {
|
|
6125
|
+
const src = await fs2.promises.readFile(filepath, "utf8");
|
|
6126
|
+
const { parsed } = scan2(src);
|
|
6127
|
+
const result = [];
|
|
6128
|
+
for (const name in parsed) {
|
|
6129
|
+
if (name.startsWith("DOTENV_PRIVATE_KEY")) {
|
|
6130
|
+
result.push(parsed[name][parsed[name].length - 1]);
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
return result;
|
|
6134
|
+
} catch (_e) {
|
|
6135
|
+
return [];
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6138
|
+
function keysFromFileSync(filepath = ".env.keys") {
|
|
6124
6139
|
try {
|
|
6125
6140
|
const src = fs2.readFileSync(filepath, "utf8");
|
|
6126
6141
|
const { parsed } = scan2(src);
|
|
@@ -6135,12 +6150,47 @@ var require_dist = __commonJS({
|
|
|
6135
6150
|
return [];
|
|
6136
6151
|
}
|
|
6137
6152
|
}
|
|
6138
|
-
function keyring2(options = {}) {
|
|
6153
|
+
async function keyring2(options = {}) {
|
|
6154
|
+
const ring = options.ring || {};
|
|
6155
|
+
const provider = options.provider;
|
|
6156
|
+
const processEnv2 = options.processEnv || process.env;
|
|
6157
|
+
const keysFilepaths = Array.isArray(options.fk) ? options.fk : [options.fk || ".env.keys"];
|
|
6158
|
+
const privateKeyValues = [];
|
|
6159
|
+
for (const filepath of keysFilepaths) {
|
|
6160
|
+
privateKeyValues.push(...await keysFromFile(filepath));
|
|
6161
|
+
}
|
|
6162
|
+
for (const name in processEnv2) {
|
|
6163
|
+
if (name.startsWith("DOTENV_PRIVATE_KEY")) {
|
|
6164
|
+
privateKeyValues.push(processEnv2[name]);
|
|
6165
|
+
}
|
|
6166
|
+
}
|
|
6167
|
+
for (const privateKeyHex of privateKeyValues) {
|
|
6168
|
+
try {
|
|
6169
|
+
const publicKeyHex = derive2(privateKeyHex);
|
|
6170
|
+
ring[publicKeyHex] = privateKeyHex;
|
|
6171
|
+
} catch (_e) {
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
if (typeof provider === "function") {
|
|
6175
|
+
for (const publicKeyHex in ring) {
|
|
6176
|
+
if (ring[publicKeyHex]) {
|
|
6177
|
+
continue;
|
|
6178
|
+
}
|
|
6179
|
+
const privateKeyHex = await provider(publicKeyHex);
|
|
6180
|
+
if (privateKeyHex) {
|
|
6181
|
+
ring[publicKeyHex] = privateKeyHex;
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
return ring;
|
|
6186
|
+
}
|
|
6187
|
+
function keyringSync2(options = {}) {
|
|
6139
6188
|
const ring = options.ring || {};
|
|
6189
|
+
const provider = options.provider;
|
|
6140
6190
|
const processEnv2 = options.processEnv || process.env;
|
|
6141
6191
|
const keysFilepaths = Array.isArray(options.fk) ? options.fk : [options.fk || ".env.keys"];
|
|
6142
6192
|
const privateKeyValues = keysFilepaths.reduce((acc, filepath) => {
|
|
6143
|
-
return acc.concat(
|
|
6193
|
+
return acc.concat(keysFromFileSync(filepath));
|
|
6144
6194
|
}, []);
|
|
6145
6195
|
for (const name in processEnv2) {
|
|
6146
6196
|
if (name.startsWith("DOTENV_PRIVATE_KEY")) {
|
|
@@ -6154,9 +6204,21 @@ var require_dist = __commonJS({
|
|
|
6154
6204
|
} catch (_e) {
|
|
6155
6205
|
}
|
|
6156
6206
|
}
|
|
6207
|
+
if (typeof provider === "function") {
|
|
6208
|
+
for (const publicKeyHex in ring) {
|
|
6209
|
+
if (ring[publicKeyHex]) {
|
|
6210
|
+
continue;
|
|
6211
|
+
}
|
|
6212
|
+
const privateKeyHex = provider(publicKeyHex);
|
|
6213
|
+
if (privateKeyHex) {
|
|
6214
|
+
ring[publicKeyHex] = privateKeyHex;
|
|
6215
|
+
}
|
|
6216
|
+
}
|
|
6217
|
+
}
|
|
6157
6218
|
return ring;
|
|
6158
6219
|
}
|
|
6159
6220
|
module22.exports = keyring2;
|
|
6221
|
+
module22.exports.sync = keyringSync2;
|
|
6160
6222
|
}
|
|
6161
6223
|
});
|
|
6162
6224
|
var require_publickeys = __commonJS2({
|
|
@@ -6179,6 +6241,7 @@ var require_dist = __commonJS({
|
|
|
6179
6241
|
"src/parse.js"(exports22, module22) {
|
|
6180
6242
|
var decrypt2 = require_decrypt();
|
|
6181
6243
|
var keyring2 = require_keyring();
|
|
6244
|
+
var keyringSync2 = require_keyring().sync;
|
|
6182
6245
|
var encrypted2 = require_encrypted();
|
|
6183
6246
|
var evaluate2 = require_evaluate();
|
|
6184
6247
|
var expand2 = require_expand();
|
|
@@ -6211,21 +6274,41 @@ var require_dist = __commonJS({
|
|
|
6211
6274
|
}
|
|
6212
6275
|
return value;
|
|
6213
6276
|
}
|
|
6214
|
-
function
|
|
6277
|
+
async function parse2(src, options = {}) {
|
|
6278
|
+
const { overload, processEnv: processEnv2, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
6279
|
+
const ring = await keyring2({ processEnv: processEnv2, ring: initialRing, fk, provider });
|
|
6280
|
+
return parseWithRing(src, { overload, processEnv: processEnv2, ring, publicKeyHexes });
|
|
6281
|
+
}
|
|
6282
|
+
function parseSync22(src, options = {}) {
|
|
6283
|
+
const { overload, processEnv: processEnv2, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
6284
|
+
const ring = keyringSync2({ processEnv: processEnv2, ring: initialRing, fk, provider });
|
|
6285
|
+
return parseWithRing(src, { overload, processEnv: processEnv2, ring, publicKeyHexes });
|
|
6286
|
+
}
|
|
6287
|
+
function keyringOptions(src, options = {}) {
|
|
6215
6288
|
const overload = options.overload;
|
|
6216
6289
|
const processEnv2 = options.processEnv || process.env;
|
|
6290
|
+
const fk = options.fk;
|
|
6291
|
+
const provider = options.provider;
|
|
6217
6292
|
const publicKeyHexes = publickeys2(src);
|
|
6218
|
-
|
|
6293
|
+
const ring = {};
|
|
6219
6294
|
for (const publicKeyHex of publicKeyHexes) {
|
|
6220
6295
|
ring[publicKeyHex] = "";
|
|
6221
6296
|
}
|
|
6222
|
-
|
|
6297
|
+
return { overload, processEnv: processEnv2, fk, provider, publicKeyHexes, ring };
|
|
6298
|
+
}
|
|
6299
|
+
function parseWithRing(src, options = {}) {
|
|
6300
|
+
const overload = options.overload;
|
|
6301
|
+
const processEnv2 = options.processEnv || process.env;
|
|
6302
|
+
const ring = options.ring || {};
|
|
6303
|
+
const publicKeyHexes = options.publicKeyHexes || [];
|
|
6223
6304
|
function inProcessEnv(name) {
|
|
6224
6305
|
return Object.prototype.hasOwnProperty.call(processEnv2, name);
|
|
6225
6306
|
}
|
|
6226
6307
|
const runningParsed = {};
|
|
6227
6308
|
const literals = {};
|
|
6228
6309
|
const parsed = {};
|
|
6310
|
+
const injected = {};
|
|
6311
|
+
const existed = {};
|
|
6229
6312
|
scan2(src, ({ name, value, quote }) => {
|
|
6230
6313
|
let parsedValue = value;
|
|
6231
6314
|
if (!overload && inProcessEnv(name)) {
|
|
@@ -6245,7 +6328,7 @@ var require_dist = __commonJS({
|
|
|
6245
6328
|
}
|
|
6246
6329
|
}
|
|
6247
6330
|
if (!encryptedPrefixed && !evaled && quote !== "'" && (!processEnv2[name] || overload)) {
|
|
6248
|
-
parsedValue = resolveEscapeSequences(expand2(parsedValue, { processEnv: processEnv2, runningParsed, literals }));
|
|
6331
|
+
parsedValue = resolveEscapeSequences(expand2(parsedValue, { overload, processEnv: processEnv2, runningParsed, literals }));
|
|
6249
6332
|
}
|
|
6250
6333
|
if (quote === "'") {
|
|
6251
6334
|
literals[name] = parsedValue;
|
|
@@ -6253,15 +6336,20 @@ var require_dist = __commonJS({
|
|
|
6253
6336
|
runningParsed[name] = parsedValue;
|
|
6254
6337
|
parsed[name] = parsedValue;
|
|
6255
6338
|
if (Object.prototype.hasOwnProperty.call(processEnv2, name) && !overload) {
|
|
6339
|
+
existed[name] = processEnv2[name];
|
|
6256
6340
|
} else {
|
|
6341
|
+
injected[name] = parsed[name];
|
|
6257
6342
|
}
|
|
6258
6343
|
return parsedValue;
|
|
6259
6344
|
});
|
|
6260
6345
|
return {
|
|
6261
|
-
parsed
|
|
6346
|
+
parsed,
|
|
6347
|
+
injected,
|
|
6348
|
+
existed
|
|
6262
6349
|
};
|
|
6263
6350
|
}
|
|
6264
|
-
module22.exports =
|
|
6351
|
+
module22.exports = parse2;
|
|
6352
|
+
module22.exports.sync = parseSync22;
|
|
6265
6353
|
}
|
|
6266
6354
|
});
|
|
6267
6355
|
var require_sealed = __commonJS2({
|
|
@@ -6293,7 +6381,9 @@ var require_dist = __commonJS({
|
|
|
6293
6381
|
var expand = require_expand();
|
|
6294
6382
|
var keypair = require_keypair();
|
|
6295
6383
|
var keyring = require_keyring();
|
|
6296
|
-
var
|
|
6384
|
+
var keyringSync = require_keyring().sync;
|
|
6385
|
+
var parse = require_parse();
|
|
6386
|
+
var parseSync2 = require_parse().sync;
|
|
6297
6387
|
var publickeys = require_publickeys();
|
|
6298
6388
|
var scan = require_scan();
|
|
6299
6389
|
var sealed = require_sealed();
|
|
@@ -6306,7 +6396,9 @@ var require_dist = __commonJS({
|
|
|
6306
6396
|
expand,
|
|
6307
6397
|
keypair,
|
|
6308
6398
|
keyring,
|
|
6309
|
-
|
|
6399
|
+
keyringSync,
|
|
6400
|
+
parse,
|
|
6401
|
+
parseSync: parseSync2,
|
|
6310
6402
|
publickeys,
|
|
6311
6403
|
scan,
|
|
6312
6404
|
sealed
|
|
@@ -6317,7 +6409,7 @@ var require_dist = __commonJS({
|
|
|
6317
6409
|
// index.cjs
|
|
6318
6410
|
var fs = require("fs");
|
|
6319
6411
|
var path = require("path");
|
|
6320
|
-
var {
|
|
6412
|
+
var { parseSync } = require_dist();
|
|
6321
6413
|
var initialEnv;
|
|
6322
6414
|
var combinedEnv;
|
|
6323
6415
|
var parsedEnv;
|
|
@@ -6359,7 +6451,7 @@ function processEnv(loadedEnvFiles, dir, log = console, forceReload = false, onR
|
|
|
6359
6451
|
const parsed = {};
|
|
6360
6452
|
for (const envFile of loadedEnvFiles) {
|
|
6361
6453
|
try {
|
|
6362
|
-
const result =
|
|
6454
|
+
const result = parseSync(envFile.contents);
|
|
6363
6455
|
if (result.parsed && !previousLoadedEnvFiles.some(
|
|
6364
6456
|
(item) => item.contents === envFile.contents && item.path === envFile.path
|
|
6365
6457
|
)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotenvx/next-env",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "dotenvx drop-in replacement for @next/env",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"prepublishOnly": "npm pack --dry-run"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@dotenvx/primitives": "
|
|
26
|
+
"@dotenvx/primitives": "1.0.1",
|
|
27
27
|
"esbuild": "^0.28.1"
|
|
28
28
|
}
|
|
29
29
|
}
|