@edirect/encrypt-modules 11.0.49 → 11.0.50

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/README.md CHANGED
@@ -1,149 +1,34 @@
1
1
  # @edirect/encrypt-modules
2
2
 
3
- Encryption utilities for eDirect NestJS applications. Provides four NestJS modules for different encryption algorithms: **PGP**, **Binary PGP**, **AES-256**, and **RSA** plus a **ZIP** module for password-protected archive creation.
3
+ Encryption utilities and modules for Edirect applications. Provides services and helpers for encrypting and decrypting data, including support for PGP and other algorithms.
4
4
 
5
5
  ## Features
6
6
 
7
- - **PGP** encryption/decryption using OpenPGP.js (`openpgp`)
8
- - **Binary PGP** for binary data encryption
9
- - **AES-256-CBC** (and other AES variants) using Node.js native `crypto`
10
- - **RSA** encryption/decryption using `node-rsa`
11
- - **ZIP** password-protected archive creation
12
- - NestJS module integration for each encryption type
7
+ - PGP encryption and decryption helpers
8
+ - Utilities for secure data handling
9
+ - Integrates with NestJS and other Edirect modules
13
10
 
14
11
  ## Installation
15
12
 
16
- ```sh
17
- pnpm add @edirect/encrypt-modules
18
- # or
13
+ ```bash
19
14
  npm install @edirect/encrypt-modules
20
15
  ```
21
16
 
22
- ## Available Modules
17
+ ## Usage
23
18
 
24
- ### PGP Encryption (`PgpEncryptModule`)
19
+ Import and use the encryption services in your application:
25
20
 
26
- Asymmetric encryption using OpenPGP keys:
27
-
28
- ```ts
29
- import { Module } from '@nestjs/common';
30
- import { PgpEncryptModule } from '@edirect/encrypt-modules';
31
-
32
- @Module({
33
- imports: [PgpEncryptModule],
34
- })
35
- export class AppModule {}
36
- ```
37
-
38
- ```ts
39
- import { Injectable } from '@nestjs/common';
21
+ ```typescript
40
22
  import { PgpEncryptService } from '@edirect/encrypt-modules';
41
23
 
42
- @Injectable()
43
- export class SecureDataService {
44
- constructor(private readonly pgp: PgpEncryptService) {}
45
-
46
- async encryptPayload(data: string, publicKey: string): Promise<string> {
47
- return this.pgp.encrypt(publicKey, data);
48
- }
49
-
50
- async decryptPayload(
51
- encryptedData: string,
52
- privateKey: string,
53
- passphrase?: string
54
- ): Promise<string> {
55
- return this.pgp.decrypt(privateKey, encryptedData, passphrase);
56
- }
57
- }
58
- ```
59
-
60
- **`PgpEncryptService` API:**
61
-
62
- | Method | Signature | Description |
63
- | --------- | ------------------------------------------------------------------------------- | ------------------------------------ |
64
- | `encrypt` | `(pgpKey: string, dataToEncrypt: string): Promise<string>` | Encrypt data using a PGP public key |
65
- | `decrypt` | `(pgpKey: string, encryptedData: string, passphrase?: string): Promise<string>` | Decrypt data using a PGP private key |
66
-
67
- ### AES Encryption (`AesEncryptModule`)
68
-
69
- Symmetric encryption using Node.js `crypto`:
70
-
71
- ```ts
72
- import { AesEncryptModule } from '@edirect/encrypt-modules';
73
-
74
- @Module({ imports: [AesEncryptModule] })
75
- export class AppModule {}
76
- ```
77
-
78
- ```ts
79
- import { AesEncryptService } from '@edirect/encrypt-modules';
80
-
81
- // Default: AES-256-CBC
82
- const encrypted = aesService.encrypt(
83
- 'secret data',
84
- 'my-32-char-passphrase-here!!!!!'
85
- );
86
- const decrypted = aesService.decrypt(
24
+ const encrypted = await PgpEncryptService.encrypt(data, publicKey);
25
+ const decrypted = await PgpEncryptService.decrypt(
87
26
  encrypted,
88
- 'my-32-char-passphrase-here!!!!!'
27
+ privateKey,
28
+ passphrase
89
29
  );
90
-
91
- // With custom IV and encoding
92
- const encrypted2 = aesService.encrypt('data', passphrase, {
93
- iv: customIv,
94
- encryptionMethod: 'aes-256-cbc',
95
- outputEncoding: 'base64',
96
- });
97
30
  ```
98
31
 
99
- **`AesEncryptService` API:**
100
-
101
- | Method | Signature | Description |
102
- | --------- | ----------------------------------------------------------------------------------------------------- | -------------------------- |
103
- | `encrypt` | `(message: string, passphrase: CipherKey, options?: IaesEncryptOptionalParameters): string` | Synchronous AES encryption |
104
- | `decrypt` | `(encryptedMessage: string, passphrase: BinaryLike, options?: IaesDecryptOptionalParameters): string` | Synchronous AES decryption |
105
-
106
- ### RSA Encryption (`RsaEncryptModule`)
107
-
108
- Asymmetric encryption using `node-rsa`:
109
-
110
- ```ts
111
- import { RsaEncryptModule } from '@edirect/encrypt-modules';
112
-
113
- @Module({ imports: [RsaEncryptModule] })
114
- export class AppModule {}
115
- ```
116
-
117
- ```ts
118
- import { RsaEncryptService } from '@edirect/encrypt-modules';
119
-
120
- const encrypted = rsaService.encrypt(data, 512, 'utf8');
121
- const decrypted = rsaService.decrypt(encrypted, privateKey, 'utf8');
122
- ```
123
-
124
- ### ZIP with Password (`ZipEncryptModule`)
125
-
126
- Create password-protected ZIP archives:
127
-
128
- ```ts
129
- import { ZipEncryptModule } from '@edirect/encrypt-modules';
130
-
131
- @Module({ imports: [ZipEncryptModule] })
132
- export class AppModule {}
133
- ```
134
-
135
- ## AES Optional Parameters
136
-
137
- | Option | Type | Default | Description |
138
- | ------------------ | ------------------ | --------------- | ---------------------------------- |
139
- | `iv` | `BinaryLike` | Random | Initialization vector |
140
- | `encryptionMethod` | `string` | `'aes-256-cbc'` | Cipher algorithm |
141
- | `inputEncoding` | `Encoding` | `'utf8'` | Input data encoding |
142
- | `outputEncoding` | `Encoding` | `'hex'` | Output encoding for encrypted data |
143
- | `options` | `TransformOptions` | — | Additional stream options |
144
-
145
- ## Security Notes
32
+ ## Environment Variables
146
33
 
147
- - Never hardcode encryption keys in source code. Use environment variables.
148
- - For PGP keys, store them in secure secret management (e.g., Kubernetes Secrets, AWS Secrets Manager).
149
- - AES keys must be exactly 32 bytes for AES-256. Use a key derivation function (KDF) if your passphrase is shorter.
34
+ This package does not require environment variables by default, but you may provide keys or secrets via environment variables as needed for your encryption setup.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/encrypt-modules",
3
- "version": "11.0.48",
3
+ "version": "11.0.46",
4
4
  "description": "Encrypt Modules",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@nestjs/common": "^11.1.16",
20
+ "@nestjs/common": "^11.1.12",
21
21
  "archiver": "7.0.1",
22
22
  "archiver-zip-encrypted": "^2.0.0",
23
23
  "node-rsa": "1.1.1",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/archiver": "^7.0.0",
30
- "@types/node": "^25.4.0",
30
+ "@types/node": "^25.0.10",
31
31
  "@types/node-rsa": "^1.1.4",
32
32
  "@types/stream-buffers": "^3.0.8"
33
33
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/encrypt-modules",
3
- "version": "11.0.49",
3
+ "version": "11.0.50",
4
4
  "description": "Encrypt Modules",
5
5
  "packageScope": "@edirect",
6
6
  "main": "./dist/src/index.js",
@@ -50,4 +50,4 @@
50
50
  }
51
51
  }
52
52
  }
53
- }
53
+ }