crenvo 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +40 -41
  2. package/package.json +7 -5
package/README.md CHANGED
@@ -1,60 +1,59 @@
1
1
  # crenvo
2
- A Laravel-inspired, zero-dependency, TypeScript-ready CLI and Library for env file encryption
3
2
 
4
- ```crenvo = crypto + env```
3
+ A Laravel-inspired, zero-dependency, TypeScript-ready CLI and library for env file encryption.
5
4
 
6
- ## 1. The idea
5
+ `crenvo = crypto + env`
7
6
 
8
- ```artisan``` provides ```php artisan key:generate``` to support env variable encryption.
7
+ ---
9
8
 
10
- NodeJS provides a ton of tools to perform encryption and file manipulation without the need of extra libraries.
9
+ ## 1. Introduction
11
10
 
12
- With those 2 thoughts in mind, I created this package to deal with a task many may have to deal with.
11
+ Inspired by Laravel's `php artisan key:generate`, **crenvo** brings secure environment variable encryption to the Node.js ecosystem. By utilizing native Node.js crypto capabilities, this package allows you to manage sensitive secrets without external dependencies.
13
12
 
14
- ## 2. CLI commands
13
+ ---
15
14
 
16
- ### ```npx crenv code:generate --envFile <path>```
15
+ ## 2. CLI Commands
17
16
 
18
- Run this command to create a ```ENC_CODE``` in your env file.
17
+ ### `npx crenv code:generate --envFile <path>`
18
+ Run this command to create an `ENC_CODE` in your env file.
19
+ * **--envFile / -e**: Specify file path (Default: `.env` in project root).
19
20
 
20
- Use ```--envFile```/```-e``` option to specify your file path. By default, it is ```.env``` in the project root directory.
21
+ ### `npx crenv encrypt <input> --envFile <path> --writeAs <field>`
22
+ Encrypt a string value using the code in the env file.
23
+ * **--envFile / -e**: Specify file path.
24
+ * **--writeAs / -w**: Write the result into the env file under the given variable name.
21
25
 
22
- ### ```npx crenv encrypt <input> --envFile <path> --writeAs <field>```
26
+ ### `npx crenv decrypt <input> --envFile <path>`
27
+ Decrypt a string value using the code in the env file.
28
+ * **--envFile / -e**: Specify file path.
23
29
 
24
- Run this command to encrypt a string value using the code in env the file and print out the result.
30
+ ---
25
31
 
26
- Use ```--envFile```/```-e``` option to specify your file path. By default, it is ```.env``` in the project root directory.
32
+ ## 3. Utility Functions
27
33
 
28
- Use ```--writeAs```/```-w``` option to write the encrypted into the env file under the given variable name.
34
+ | Function | Signature | Description |
35
+ | :--- | :--- | :--- |
36
+ | `setCode` | `(envFile?: string) => void` | Create an `ENC_CODE` in your env file. |
37
+ | `getCode` | `(envFile?: string) => Promise<string>` | Retrieve the value of `ENC_CODE`. |
38
+ | `getKeyIv` | `(envFile?: string) => Promise<string[]>` | Retrieve the Encryption KEY and IV. |
39
+ | `encrypt` | `(str: string, envFile?: string) => Promise<string>` | Encrypt a string value. |
40
+ | `encryptAndSet` | `(str: string, field: string, envFile?: string) => Promise<string>` | Encrypt and write to a specific field. |
41
+ | `decrypt` | `(str: string, envFile?: string) => Promise<string>` | Decrypt a string value. |
29
42
 
30
- ### ```npx crenv decrypt <input> --envFile <path>```
43
+ ### Code Implementation Example
31
44
 
32
- Run this command to decrypt a string value using the code in env the file and print out the result.
45
+ ```typescript
46
+ import { encrypt, decrypt, setCode } from 'crenvo';
33
47
 
34
- Use ```--envFile```/```-e``` option to specify your file path. By default, it is ```.env``` in the project root directory.
48
+ async function example() {
49
+ // Initialize key if not present
50
+ await setCode('.env');
35
51
 
36
- ## 3. Utility functions
52
+ // Encrypt a value
53
+ const encrypted = await encrypt("my_secret_key");
54
+ console.log(`Encrypted: ${encrypted}`);
37
55
 
38
- ### ```setCode(envFile?: string = '.env') => void```
39
-
40
- Create a ```ENC_CODE``` in your env file.
41
-
42
- ### ```getCode(envFile?: string = '.env') => Promise<string>```
43
-
44
- Retrieve the value of ```ENC_CODE``` in your env file.
45
-
46
- ### ```getKeyIv(envFile?: string = '.env') => Promise<string[]>```
47
-
48
- Retrieve the Encryption KEY and IV from decrypting the value of ```ENC_CODE``` in your env file.
49
-
50
- ### ```encrypt(str: string, envFile?: string = '.env') => Promise<string>```
51
-
52
- Encrypt a string value using the code in env the file.
53
-
54
- ### ```encryptAndSet(str: string, field: string, envFile?: string = '.env') => Promise<string>```
55
-
56
- Encrypt a string value using the code in env the file and write it under the name specified by ```field```.
57
-
58
- ### ```decrypt(str: string, envFile?: string = '.env') => Promise<string>```
59
-
60
- Decrypt a string value using the code in env the file.
56
+ // Decrypt the value
57
+ const original = await decrypt(encrypted);
58
+ console.log(`Original: ${original}`);
59
+ }
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "crenvo",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A Laravel-inspired, zero-dependency CLI and Library for env file encryption",
5
5
  "keywords": [
6
6
  "env",
7
- "encrypt"
7
+ "encrypt",
8
+ "crenv",
9
+ "crenvo"
8
10
  ],
9
- "homepage": "https://github.com/blackkat98/crenv#readme",
11
+ "homepage": "https://github.com/blackkat98/crenvo#readme",
10
12
  "bugs": {
11
- "url": "https://github.com/blackkat98/crenv/issues"
13
+ "url": "https://github.com/blackkat98/crenvo/issues"
12
14
  },
13
15
  "repository": {
14
16
  "type": "git",
15
- "url": "git+https://github.com/blackkat98/crenv.git"
17
+ "url": "git+https://github.com/blackkat98/crenvo.git"
16
18
  },
17
19
  "license": "ISC",
18
20
  "author": "blackkat98",