@dotenvx/primitives 1.3.0 → 1.3.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.
- package/dist/index.cjs +24 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8072,6 +8072,7 @@ var require_publickeys = __commonJS({
|
|
|
8072
8072
|
var require_parse2 = __commonJS({
|
|
8073
8073
|
"src/parse.js"(exports2, module2) {
|
|
8074
8074
|
var decrypt2 = require_decrypt();
|
|
8075
|
+
var Errors = require_errors();
|
|
8075
8076
|
var keyring2 = require_keyring();
|
|
8076
8077
|
var keyringSync2 = require_keyring().sync;
|
|
8077
8078
|
var encrypted2 = require_encrypted();
|
|
@@ -8116,6 +8117,17 @@ var require_parse2 = __commonJS({
|
|
|
8116
8117
|
}
|
|
8117
8118
|
return value;
|
|
8118
8119
|
}
|
|
8120
|
+
function unresolvedEncryptedError(unresolved) {
|
|
8121
|
+
const keys = Object.keys(unresolved);
|
|
8122
|
+
if (keys.length === 0) {
|
|
8123
|
+
return null;
|
|
8124
|
+
}
|
|
8125
|
+
const error = new Errors({ message: `could not decrypt ${keys.join(", ")}` }).decryptionFailed();
|
|
8126
|
+
return {
|
|
8127
|
+
code: error.code,
|
|
8128
|
+
message: error.message
|
|
8129
|
+
};
|
|
8130
|
+
}
|
|
8119
8131
|
async function parse2(src, options = {}) {
|
|
8120
8132
|
const { overload, array, ik, ek, processEnv, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
8121
8133
|
const ring = await keyring2({ processEnv, ring: initialRing, fk, provider });
|
|
@@ -8159,13 +8171,18 @@ var require_parse2 = __commonJS({
|
|
|
8159
8171
|
const parsed = {};
|
|
8160
8172
|
const injected = {};
|
|
8161
8173
|
const existed = {};
|
|
8174
|
+
const unresolvedEncrypted = {};
|
|
8162
8175
|
scan2(src, ({ name, value, quote }) => {
|
|
8163
8176
|
let parsedValue = value;
|
|
8164
8177
|
if (!overload && inProcessEnv(name)) {
|
|
8165
8178
|
parsedValue = processEnv[name];
|
|
8166
8179
|
}
|
|
8180
|
+
const encryptedBefore = encrypted2(parsedValue);
|
|
8167
8181
|
if (!exclude(name) && (ik.length === 0 || include(name))) {
|
|
8168
8182
|
parsedValue = decryptWithKeyring(ring, parsedValue, publicKeyHexes);
|
|
8183
|
+
if (encryptedBefore && encrypted2(parsedValue)) {
|
|
8184
|
+
unresolvedEncrypted[name] = true;
|
|
8185
|
+
}
|
|
8169
8186
|
}
|
|
8170
8187
|
const encryptedPrefixed = encrypted2(parsedValue);
|
|
8171
8188
|
let evaled = false;
|
|
@@ -8209,10 +8226,16 @@ var require_parse2 = __commonJS({
|
|
|
8209
8226
|
}
|
|
8210
8227
|
return parsedValue;
|
|
8211
8228
|
});
|
|
8229
|
+
const errors = [];
|
|
8230
|
+
const error = unresolvedEncryptedError(unresolvedEncrypted);
|
|
8231
|
+
if (error) {
|
|
8232
|
+
errors.push(error);
|
|
8233
|
+
}
|
|
8212
8234
|
return {
|
|
8213
8235
|
parsed,
|
|
8214
8236
|
injected,
|
|
8215
|
-
existed
|
|
8237
|
+
existed,
|
|
8238
|
+
errors
|
|
8216
8239
|
};
|
|
8217
8240
|
}
|
|
8218
8241
|
module2.exports = parse2;
|
package/package.json
CHANGED