@dotenvx/next-env 2.0.2 → 2.0.3

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 (2) hide show
  1. package/dist/index.cjs +25 -7
  2. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -5350,7 +5350,7 @@ var require_dist = __commonJS({
5350
5350
  const isAEAD = algorithm === "aes-256-gcm" || algorithm === "chacha20-poly1305";
5351
5351
  const authTagLength = isAEAD ? AEAD_TAG_LENGTH : 0;
5352
5352
  const options = isAEAD ? { authTagLength } : void 0;
5353
- const encrypt = (plainText) => {
5353
+ const encrypt2 = (plainText) => {
5354
5354
  const cipher = (0, node_crypto_1.createCipheriv)(algorithm, key, nonce, options);
5355
5355
  if (isAEAD && AAD !== void 0) {
5356
5356
  cipher.setAAD(AAD);
@@ -5375,7 +5375,7 @@ var require_dist = __commonJS({
5375
5375
  return (0, utils_1.concatBytes)(updated, finalized);
5376
5376
  };
5377
5377
  return {
5378
- encrypt,
5378
+ encrypt: encrypt2,
5379
5379
  decrypt: decrypt2
5380
5380
  };
5381
5381
  };
@@ -5768,13 +5768,13 @@ var require_dist = __commonJS({
5768
5768
  "use strict";
5769
5769
  Object.defineProperty(exports22, "__esModule", { value: true });
5770
5770
  exports22.PublicKey = exports22.PrivateKey = exports22.ECIES_CONFIG = void 0;
5771
- exports22.encrypt = encrypt;
5771
+ exports22.encrypt = encrypt2;
5772
5772
  exports22.decrypt = decrypt2;
5773
5773
  var utils_1 = require_utils();
5774
5774
  var config_js_1 = require_config();
5775
5775
  var index_js_1 = require_keys();
5776
5776
  var index_js_2 = require_utils4();
5777
- function encrypt(receiverRawPK, data, config = config_js_1.ECIES_CONFIG) {
5777
+ function encrypt2(receiverRawPK, data, config = config_js_1.ECIES_CONFIG) {
5778
5778
  const curve = config.ellipticCurve;
5779
5779
  const ephemeralSK = new index_js_1.PrivateKey(void 0, curve);
5780
5780
  const receiverPK = receiverRawPK instanceof Uint8Array ? new index_js_1.PublicKey(receiverRawPK, curve) : index_js_1.PublicKey.fromHex(receiverRawPK, curve);
@@ -5900,8 +5900,9 @@ var require_dist = __commonJS({
5900
5900
  var { decrypt: eciesDecrypt } = require_dist2();
5901
5901
  var Errors = require_errors();
5902
5902
  var encrypted2 = require_encrypted();
5903
- function decrypt2(privateKeyHex, encryptedValue) {
5904
- if (!encrypted2(encryptedValue)) {
5903
+ function decrypt2(privateKeyHex, encryptedValue, options = {}) {
5904
+ const value = options.prefix === false ? `${encrypted2.PREFIX}${encryptedValue}` : encryptedValue;
5905
+ if (!encrypted2(value)) {
5905
5906
  return encryptedValue;
5906
5907
  }
5907
5908
  if (!privateKeyHex || privateKeyHex.length < 1) {
@@ -5909,7 +5910,7 @@ var require_dist = __commonJS({
5909
5910
  }
5910
5911
  try {
5911
5912
  const privateKey = Buffer.from(privateKeyHex, "hex");
5912
- const ciphertext = Buffer.from(encryptedValue.substring(encrypted2.PREFIX.length), "base64");
5913
+ const ciphertext = Buffer.from(value.substring(encrypted2.PREFIX.length), "base64");
5913
5914
  return Buffer.from(eciesDecrypt(privateKey, ciphertext)).toString("utf8");
5914
5915
  } catch (e) {
5915
5916
  if (e.message === "Invalid private key") {
@@ -5935,6 +5936,21 @@ var require_dist = __commonJS({
5935
5936
  module22.exports = derive2;
5936
5937
  }
5937
5938
  });
5939
+ var require_encrypt = __commonJS2({
5940
+ "src/encrypt.js"(exports22, module22) {
5941
+ var { encrypt: eciesEncrypt } = require_dist2();
5942
+ var { PREFIX } = require_encrypted();
5943
+ function encrypt2(publicKeyHex, value, options = {}) {
5944
+ const ciphertext = eciesEncrypt(publicKeyHex, Buffer.from(value));
5945
+ const encoded = Buffer.from(ciphertext, "hex").toString("base64");
5946
+ if (options.prefix === false) {
5947
+ return encoded;
5948
+ }
5949
+ return `${PREFIX}${encoded}`;
5950
+ }
5951
+ module22.exports = encrypt2;
5952
+ }
5953
+ });
5938
5954
  var require_evaluate = __commonJS2({
5939
5955
  "src/evaluate.js"(exports22, module22) {
5940
5956
  var { execSync } = require("child_process");
@@ -6179,6 +6195,7 @@ var require_dist = __commonJS({
6179
6195
  });
6180
6196
  var decrypt = require_decrypt();
6181
6197
  var derive = require_derive();
6198
+ var encrypt = require_encrypt();
6182
6199
  var encrypted = require_encrypted();
6183
6200
  var evaluate = require_evaluate();
6184
6201
  var expand = require_expand();
@@ -6188,6 +6205,7 @@ var require_dist = __commonJS({
6188
6205
  module2.exports = {
6189
6206
  decrypt,
6190
6207
  derive,
6208
+ encrypt,
6191
6209
  encrypted,
6192
6210
  evaluate,
6193
6211
  expand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotenvx/next-env",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
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": "0.4.0",
26
+ "@dotenvx/primitives": "^0.6.0",
27
27
  "esbuild": "^0.28.1"
28
28
  }
29
29
  }