@edirect/encrypt-modules 11.0.48 → 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/README.md +21 -15
- package/dist/README.md +16 -125
- package/dist/package.json +3 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -59,9 +59,9 @@ export class SecureDataService {
|
|
|
59
59
|
|
|
60
60
|
**`PgpEncryptService` API:**
|
|
61
61
|
|
|
62
|
-
| Method
|
|
63
|
-
|
|
64
|
-
| `encrypt` | `(pgpKey: string, dataToEncrypt: string): Promise<string>`
|
|
62
|
+
| Method | Signature | Description |
|
|
63
|
+
| --------- | ------------------------------------------------------------------------------- | ------------------------------------ |
|
|
64
|
+
| `encrypt` | `(pgpKey: string, dataToEncrypt: string): Promise<string>` | Encrypt data using a PGP public key |
|
|
65
65
|
| `decrypt` | `(pgpKey: string, encryptedData: string, passphrase?: string): Promise<string>` | Decrypt data using a PGP private key |
|
|
66
66
|
|
|
67
67
|
### AES Encryption (`AesEncryptModule`)
|
|
@@ -79,8 +79,14 @@ export class AppModule {}
|
|
|
79
79
|
import { AesEncryptService } from '@edirect/encrypt-modules';
|
|
80
80
|
|
|
81
81
|
// Default: AES-256-CBC
|
|
82
|
-
const encrypted = aesService.encrypt(
|
|
83
|
-
|
|
82
|
+
const encrypted = aesService.encrypt(
|
|
83
|
+
'secret data',
|
|
84
|
+
'my-32-char-passphrase-here!!!!!'
|
|
85
|
+
);
|
|
86
|
+
const decrypted = aesService.decrypt(
|
|
87
|
+
encrypted,
|
|
88
|
+
'my-32-char-passphrase-here!!!!!'
|
|
89
|
+
);
|
|
84
90
|
|
|
85
91
|
// With custom IV and encoding
|
|
86
92
|
const encrypted2 = aesService.encrypt('data', passphrase, {
|
|
@@ -92,9 +98,9 @@ const encrypted2 = aesService.encrypt('data', passphrase, {
|
|
|
92
98
|
|
|
93
99
|
**`AesEncryptService` API:**
|
|
94
100
|
|
|
95
|
-
| Method
|
|
96
|
-
|
|
97
|
-
| `encrypt` | `(message: string, passphrase: CipherKey, options?: IaesEncryptOptionalParameters): string`
|
|
101
|
+
| Method | Signature | Description |
|
|
102
|
+
| --------- | ----------------------------------------------------------------------------------------------------- | -------------------------- |
|
|
103
|
+
| `encrypt` | `(message: string, passphrase: CipherKey, options?: IaesEncryptOptionalParameters): string` | Synchronous AES encryption |
|
|
98
104
|
| `decrypt` | `(encryptedMessage: string, passphrase: BinaryLike, options?: IaesDecryptOptionalParameters): string` | Synchronous AES decryption |
|
|
99
105
|
|
|
100
106
|
### RSA Encryption (`RsaEncryptModule`)
|
|
@@ -128,13 +134,13 @@ export class AppModule {}
|
|
|
128
134
|
|
|
129
135
|
## AES Optional Parameters
|
|
130
136
|
|
|
131
|
-
| Option
|
|
132
|
-
|
|
133
|
-
| `iv`
|
|
134
|
-
| `encryptionMethod` | `string`
|
|
135
|
-
| `inputEncoding`
|
|
136
|
-
| `outputEncoding`
|
|
137
|
-
| `options`
|
|
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 |
|
|
138
144
|
|
|
139
145
|
## Security Notes
|
|
140
146
|
|
package/dist/README.md
CHANGED
|
@@ -1,143 +1,34 @@
|
|
|
1
1
|
# @edirect/encrypt-modules
|
|
2
2
|
|
|
3
|
-
Encryption utilities for
|
|
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
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
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
|
-
```
|
|
17
|
-
pnpm add @edirect/encrypt-modules
|
|
18
|
-
# or
|
|
13
|
+
```bash
|
|
19
14
|
npm install @edirect/encrypt-modules
|
|
20
15
|
```
|
|
21
16
|
|
|
22
|
-
##
|
|
17
|
+
## Usage
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
Import and use the encryption services in your application:
|
|
25
20
|
|
|
26
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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('secret data', 'my-32-char-passphrase-here!!!!!');
|
|
83
|
-
const decrypted = aesService.decrypt(encrypted, 'my-32-char-passphrase-here!!!!!');
|
|
84
|
-
|
|
85
|
-
// With custom IV and encoding
|
|
86
|
-
const encrypted2 = aesService.encrypt('data', passphrase, {
|
|
87
|
-
iv: customIv,
|
|
88
|
-
encryptionMethod: 'aes-256-cbc',
|
|
89
|
-
outputEncoding: 'base64',
|
|
90
|
-
});
|
|
24
|
+
const encrypted = await PgpEncryptService.encrypt(data, publicKey);
|
|
25
|
+
const decrypted = await PgpEncryptService.decrypt(
|
|
26
|
+
encrypted,
|
|
27
|
+
privateKey,
|
|
28
|
+
passphrase
|
|
29
|
+
);
|
|
91
30
|
```
|
|
92
31
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
| Method | Signature | Description |
|
|
96
|
-
|--------|-----------|-------------|
|
|
97
|
-
| `encrypt` | `(message: string, passphrase: CipherKey, options?: IaesEncryptOptionalParameters): string` | Synchronous AES encryption |
|
|
98
|
-
| `decrypt` | `(encryptedMessage: string, passphrase: BinaryLike, options?: IaesDecryptOptionalParameters): string` | Synchronous AES decryption |
|
|
99
|
-
|
|
100
|
-
### RSA Encryption (`RsaEncryptModule`)
|
|
101
|
-
|
|
102
|
-
Asymmetric encryption using `node-rsa`:
|
|
103
|
-
|
|
104
|
-
```ts
|
|
105
|
-
import { RsaEncryptModule } from '@edirect/encrypt-modules';
|
|
106
|
-
|
|
107
|
-
@Module({ imports: [RsaEncryptModule] })
|
|
108
|
-
export class AppModule {}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
import { RsaEncryptService } from '@edirect/encrypt-modules';
|
|
113
|
-
|
|
114
|
-
const encrypted = rsaService.encrypt(data, 512, 'utf8');
|
|
115
|
-
const decrypted = rsaService.decrypt(encrypted, privateKey, 'utf8');
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### ZIP with Password (`ZipEncryptModule`)
|
|
119
|
-
|
|
120
|
-
Create password-protected ZIP archives:
|
|
121
|
-
|
|
122
|
-
```ts
|
|
123
|
-
import { ZipEncryptModule } from '@edirect/encrypt-modules';
|
|
124
|
-
|
|
125
|
-
@Module({ imports: [ZipEncryptModule] })
|
|
126
|
-
export class AppModule {}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## AES Optional Parameters
|
|
130
|
-
|
|
131
|
-
| Option | Type | Default | Description |
|
|
132
|
-
|--------|------|---------|-------------|
|
|
133
|
-
| `iv` | `BinaryLike` | Random | Initialization vector |
|
|
134
|
-
| `encryptionMethod` | `string` | `'aes-256-cbc'` | Cipher algorithm |
|
|
135
|
-
| `inputEncoding` | `Encoding` | `'utf8'` | Input data encoding |
|
|
136
|
-
| `outputEncoding` | `Encoding` | `'hex'` | Output encoding for encrypted data |
|
|
137
|
-
| `options` | `TransformOptions` | — | Additional stream options |
|
|
138
|
-
|
|
139
|
-
## Security Notes
|
|
32
|
+
## Environment Variables
|
|
140
33
|
|
|
141
|
-
|
|
142
|
-
- For PGP keys, store them in secure secret management (e.g., Kubernetes Secrets, AWS Secrets Manager).
|
|
143
|
-
- 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.
|
|
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.
|
|
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.
|
|
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.
|
|
3
|
+
"version": "11.0.50",
|
|
4
4
|
"description": "Encrypt Modules",
|
|
5
5
|
"packageScope": "@edirect",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@nestjs/common": "^11.1.
|
|
21
|
+
"@nestjs/common": "^11.1.16",
|
|
22
22
|
"archiver": "7.0.1",
|
|
23
23
|
"archiver-zip-encrypted": "^2.0.0",
|
|
24
24
|
"node-rsa": "1.1.1",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@nestjs/cli": "^11.0.16",
|
|
31
31
|
"@types/archiver": "^7.0.0",
|
|
32
|
-
"@types/node": "^25.
|
|
32
|
+
"@types/node": "^25.4.0",
|
|
33
33
|
"@types/node-rsa": "^1.1.4",
|
|
34
34
|
"@types/stream-buffers": "^3.0.8"
|
|
35
35
|
},
|
|
@@ -50,4 +50,4 @@
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|