@dotenvx/primitives 0.5.0 → 0.7.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 +27 -6
  2. package/package.json +3 -2
package/dist/index.cjs CHANGED
@@ -5964,8 +5964,9 @@ var require_decrypt = __commonJS({
5964
5964
  var { decrypt: eciesDecrypt } = require_dist();
5965
5965
  var Errors = require_errors();
5966
5966
  var encrypted2 = require_encrypted();
5967
- function decrypt2(privateKeyHex, encryptedValue) {
5968
- if (!encrypted2(encryptedValue)) {
5967
+ function decrypt2(privateKeyHex, encryptedValue, options = {}) {
5968
+ const value = options.prefix === false ? `${encrypted2.PREFIX}${encryptedValue}` : encryptedValue;
5969
+ if (!encrypted2(value)) {
5969
5970
  return encryptedValue;
5970
5971
  }
5971
5972
  if (!privateKeyHex || privateKeyHex.length < 1) {
@@ -5973,7 +5974,7 @@ var require_decrypt = __commonJS({
5973
5974
  }
5974
5975
  try {
5975
5976
  const privateKey = Buffer.from(privateKeyHex, "hex");
5976
- const ciphertext = Buffer.from(encryptedValue.substring(encrypted2.PREFIX.length), "base64");
5977
+ const ciphertext = Buffer.from(value.substring(encrypted2.PREFIX.length), "base64");
5977
5978
  return Buffer.from(eciesDecrypt(privateKey, ciphertext)).toString("utf8");
5978
5979
  } catch (e) {
5979
5980
  if (e.message === "Invalid private key") {
@@ -6007,9 +6008,12 @@ var require_encrypt = __commonJS({
6007
6008
  "src/encrypt.js"(exports2, module2) {
6008
6009
  var { encrypt: eciesEncrypt } = require_dist();
6009
6010
  var { PREFIX } = require_encrypted();
6010
- function encrypt2(publicKeyHex, value) {
6011
+ function encrypt2(publicKeyHex, value, options = {}) {
6011
6012
  const ciphertext = eciesEncrypt(publicKeyHex, Buffer.from(value));
6012
6013
  const encoded = Buffer.from(ciphertext, "hex").toString("base64");
6014
+ if (options.prefix === false) {
6015
+ return encoded;
6016
+ }
6013
6017
  return `${PREFIX}${encoded}`;
6014
6018
  }
6015
6019
  module2.exports = encrypt2;
@@ -6095,6 +6099,21 @@ var require_expand = __commonJS({
6095
6099
  }
6096
6100
  });
6097
6101
 
6102
+ // src/keypair.js
6103
+ var require_keypair = __commonJS({
6104
+ "src/keypair.js"(exports2, module2) {
6105
+ var { PrivateKey } = require_dist();
6106
+ function keypair2() {
6107
+ const kp = new PrivateKey();
6108
+ return {
6109
+ publicKey: kp.publicKey.toHex(),
6110
+ privateKey: Buffer.from(kp.secret).toString("hex")
6111
+ };
6112
+ }
6113
+ module2.exports = keypair2;
6114
+ }
6115
+ });
6116
+
6098
6117
  // src/scan.js
6099
6118
  var require_scan = __commonJS({
6100
6119
  "src/scan.js"(exports2, module2) {
@@ -6222,8 +6241,8 @@ var require_parse = __commonJS({
6222
6241
  return Object.prototype.hasOwnProperty.call(processEnv, name);
6223
6242
  }
6224
6243
  let publicKeyHex;
6225
- let runningParsed = {};
6226
- let literals = {};
6244
+ const runningParsed = {};
6245
+ const literals = {};
6227
6246
  const { parsed } = scan2(src, ({ name, value, quote }) => {
6228
6247
  let parsedValue = value;
6229
6248
  if (name.startsWith("DOTENV_PUBLIC_KEY")) {
@@ -6275,6 +6294,7 @@ var encrypt = require_encrypt();
6275
6294
  var encrypted = require_encrypted();
6276
6295
  var evaluate = require_evaluate();
6277
6296
  var expand = require_expand();
6297
+ var keypair = require_keypair();
6278
6298
  var keyring = require_keyring();
6279
6299
  var parse = require_parse();
6280
6300
  var scan = require_scan();
@@ -6285,6 +6305,7 @@ module.exports = {
6285
6305
  encrypted,
6286
6306
  evaluate,
6287
6307
  expand,
6308
+ keypair,
6288
6309
  keyring,
6289
6310
  parse,
6290
6311
  scan
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.0",
2
+ "version": "0.7.0",
3
3
  "name": "@dotenvx/primitives",
4
4
  "description": "a secure dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -31,8 +31,9 @@
31
31
  "standard:fix": "standard src --fix"
32
32
  },
33
33
  "devDependencies": {
34
+ "eciesjs": "^0.5.0",
34
35
  "esbuild": "^0.28.1",
35
- "eciesjs": "^0.5.0"
36
+ "standard": "^17.1.2"
36
37
  },
37
38
  "publishConfig": {
38
39
  "access": "public"