@dotenvx/primitives 0.4.0 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.cjs +20 -4
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -5390,7 +5390,7 @@ var require_compat = __commonJS({
5390
5390
  const isAEAD = algorithm === "aes-256-gcm" || algorithm === "chacha20-poly1305";
5391
5391
  const authTagLength = isAEAD ? AEAD_TAG_LENGTH : 0;
5392
5392
  const options = isAEAD ? { authTagLength } : void 0;
5393
- const encrypt = (plainText) => {
5393
+ const encrypt2 = (plainText) => {
5394
5394
  const cipher = (0, node_crypto_1.createCipheriv)(algorithm, key, nonce, options);
5395
5395
  if (isAEAD && AAD !== void 0) {
5396
5396
  cipher.setAAD(AAD);
@@ -5415,7 +5415,7 @@ var require_compat = __commonJS({
5415
5415
  return (0, utils_1.concatBytes)(updated, finalized);
5416
5416
  };
5417
5417
  return {
5418
- encrypt,
5418
+ encrypt: encrypt2,
5419
5419
  decrypt: decrypt2
5420
5420
  };
5421
5421
  };
@@ -5826,13 +5826,13 @@ var require_dist = __commonJS({
5826
5826
  "use strict";
5827
5827
  Object.defineProperty(exports2, "__esModule", { value: true });
5828
5828
  exports2.PublicKey = exports2.PrivateKey = exports2.ECIES_CONFIG = void 0;
5829
- exports2.encrypt = encrypt;
5829
+ exports2.encrypt = encrypt2;
5830
5830
  exports2.decrypt = decrypt2;
5831
5831
  var utils_1 = require_utils();
5832
5832
  var config_js_1 = require_config();
5833
5833
  var index_js_1 = require_keys();
5834
5834
  var index_js_2 = require_utils4();
5835
- function encrypt(receiverRawPK, data, config = config_js_1.ECIES_CONFIG) {
5835
+ function encrypt2(receiverRawPK, data, config = config_js_1.ECIES_CONFIG) {
5836
5836
  const curve = config.ellipticCurve;
5837
5837
  const ephemeralSK = new index_js_1.PrivateKey(void 0, curve);
5838
5838
  const receiverPK = receiverRawPK instanceof Uint8Array ? new index_js_1.PublicKey(receiverRawPK, curve) : index_js_1.PublicKey.fromHex(receiverRawPK, curve);
@@ -6002,6 +6002,20 @@ var require_derive = __commonJS({
6002
6002
  }
6003
6003
  });
6004
6004
 
6005
+ // src/encrypt.js
6006
+ var require_encrypt = __commonJS({
6007
+ "src/encrypt.js"(exports2, module2) {
6008
+ var { encrypt: eciesEncrypt } = require_dist();
6009
+ var { PREFIX } = require_encrypted();
6010
+ function encrypt2(publicKeyHex, value) {
6011
+ const ciphertext = eciesEncrypt(publicKeyHex, Buffer.from(value));
6012
+ const encoded = Buffer.from(ciphertext, "hex").toString("base64");
6013
+ return `${PREFIX}${encoded}`;
6014
+ }
6015
+ module2.exports = encrypt2;
6016
+ }
6017
+ });
6018
+
6005
6019
  // src/evaluate.js
6006
6020
  var require_evaluate = __commonJS({
6007
6021
  "src/evaluate.js"(exports2, module2) {
@@ -6257,6 +6271,7 @@ var require_parse = __commonJS({
6257
6271
  // src/index.js
6258
6272
  var decrypt = require_decrypt();
6259
6273
  var derive = require_derive();
6274
+ var encrypt = require_encrypt();
6260
6275
  var encrypted = require_encrypted();
6261
6276
  var evaluate = require_evaluate();
6262
6277
  var expand = require_expand();
@@ -6266,6 +6281,7 @@ var scan = require_scan();
6266
6281
  module.exports = {
6267
6282
  decrypt,
6268
6283
  derive,
6284
+ encrypt,
6269
6285
  encrypted,
6270
6286
  evaluate,
6271
6287
  expand,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.0",
2
+ "version": "0.5.0",
3
3
  "name": "@dotenvx/primitives",
4
4
  "description": "a secure dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",