@edirect/encrypt-modules 11.0.62-beta.0 → 11.0.62-beta.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 (52) hide show
  1. package/dist/README.md +149 -0
  2. package/dist/package.json +35 -0
  3. package/dist/src/aes-encrypt/aes-encrypt.interface.d.ts +23 -0
  4. package/dist/src/aes-encrypt/aes-encrypt.interface.d.ts.map +1 -0
  5. package/dist/src/aes-encrypt/aes-encrypt.interface.js +2 -0
  6. package/dist/src/aes-encrypt/aes-encrypt.module.d.ts +3 -0
  7. package/dist/src/aes-encrypt/aes-encrypt.module.d.ts.map +1 -0
  8. package/dist/src/aes-encrypt/aes-encrypt.module.js +15 -0
  9. package/dist/src/aes-encrypt/aes-encrypt.service.d.ts +7 -0
  10. package/dist/src/aes-encrypt/aes-encrypt.service.d.ts.map +1 -0
  11. package/dist/src/aes-encrypt/aes-encrypt.service.js +42 -0
  12. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.interface.d.ts +5 -0
  13. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.interface.d.ts.map +1 -0
  14. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.interface.js +2 -0
  15. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.module.d.ts +3 -0
  16. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.module.d.ts.map +1 -0
  17. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.module.js +15 -0
  18. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.service.d.ts +6 -0
  19. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.service.d.ts.map +1 -0
  20. package/dist/src/bin-pgp-encrypt/bin-pgp-encrypt.service.js +64 -0
  21. package/dist/src/index.d.ts +11 -0
  22. package/dist/src/index.d.ts.map +1 -0
  23. package/dist/src/index.js +23 -0
  24. package/dist/src/pgp-encrypt/pgp-encrypt.interface.d.ts +5 -0
  25. package/dist/src/pgp-encrypt/pgp-encrypt.interface.d.ts.map +1 -0
  26. package/dist/src/pgp-encrypt/pgp-encrypt.interface.js +2 -0
  27. package/dist/src/pgp-encrypt/pgp-encrypt.module.d.ts +3 -0
  28. package/dist/src/pgp-encrypt/pgp-encrypt.module.d.ts.map +1 -0
  29. package/dist/src/pgp-encrypt/pgp-encrypt.module.js +15 -0
  30. package/dist/src/pgp-encrypt/pgp-encrypt.service.d.ts +6 -0
  31. package/dist/src/pgp-encrypt/pgp-encrypt.service.d.ts.map +1 -0
  32. package/dist/src/pgp-encrypt/pgp-encrypt.service.js +68 -0
  33. package/dist/src/rsa-encrypt/rsa-encrypt.interface.d.ts +6 -0
  34. package/dist/src/rsa-encrypt/rsa-encrypt.interface.d.ts.map +1 -0
  35. package/dist/src/rsa-encrypt/rsa-encrypt.interface.js +2 -0
  36. package/dist/src/rsa-encrypt/rsa-encrypt.module.d.ts +3 -0
  37. package/dist/src/rsa-encrypt/rsa-encrypt.module.d.ts.map +1 -0
  38. package/dist/src/rsa-encrypt/rsa-encrypt.module.js +15 -0
  39. package/dist/src/rsa-encrypt/rsa-encrypt.service.d.ts +7 -0
  40. package/dist/src/rsa-encrypt/rsa-encrypt.service.d.ts.map +1 -0
  41. package/dist/src/rsa-encrypt/rsa-encrypt.service.js +22 -0
  42. package/dist/src/zip-encrypt/zipencrypt.interface.d.ts +10 -0
  43. package/dist/src/zip-encrypt/zipencrypt.interface.d.ts.map +1 -0
  44. package/dist/src/zip-encrypt/zipencrypt.interface.js +2 -0
  45. package/dist/src/zip-encrypt/zipencrypt.module.d.ts +3 -0
  46. package/dist/src/zip-encrypt/zipencrypt.module.d.ts.map +1 -0
  47. package/dist/src/zip-encrypt/zipencrypt.module.js +15 -0
  48. package/dist/src/zip-encrypt/zipencrypt.service.d.ts +5 -0
  49. package/dist/src/zip-encrypt/zipencrypt.service.d.ts.map +1 -0
  50. package/dist/src/zip-encrypt/zipencrypt.service.js +34 -0
  51. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  52. package/package.json +20 -2
package/dist/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # @edirect/encrypt-modules
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.
4
+
5
+ ## Features
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
13
+
14
+ ## Installation
15
+
16
+ ```sh
17
+ pnpm add @edirect/encrypt-modules
18
+ # or
19
+ npm install @edirect/encrypt-modules
20
+ ```
21
+
22
+ ## Available Modules
23
+
24
+ ### PGP Encryption (`PgpEncryptModule`)
25
+
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';
40
+ import { PgpEncryptService } from '@edirect/encrypt-modules';
41
+
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(
87
+ encrypted,
88
+ 'my-32-char-passphrase-here!!!!!'
89
+ );
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
+ ```
98
+
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
146
+
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.
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@edirect/encrypt-modules",
3
+ "version": "11.0.62-beta.2",
4
+ "description": "Encrypt Modules",
5
+ "main": "./dist/src/index.js",
6
+ "types": "./dist/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/src/index.js",
10
+ "default": "./dist/src/index.js",
11
+ "require": "./dist/src/index.js",
12
+ "types": "./dist/src/index.d.ts"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@nestjs/common": "^11.1.19",
21
+ "archiver": "8.0.0",
22
+ "archiver-zip-encrypted": "^2.0.0",
23
+ "node-rsa": "1.1.1",
24
+ "openpgp": "^6.3.0",
25
+ "stream-buffers": "^3.0.3",
26
+ "tslib": "^2.8.1"
27
+ },
28
+ "devDependencies": {
29
+ "@types/archiver": "^7.0.0",
30
+ "@types/node": "^25.6.2",
31
+ "@types/node-rsa": "^1.1.4",
32
+ "@types/stream-buffers": "^3.0.8"
33
+ },
34
+ "type": "commonjs"
35
+ }
@@ -0,0 +1,23 @@
1
+ import { BinaryLike, CipherCCMTypes, CipherKey, Encoding } from 'crypto';
2
+ import { TransformOptions } from 'stream';
3
+ type encryptionMethods = CipherCCMTypes | 'aes-256-cbc';
4
+ export interface IaesEncryptOptionalParameters {
5
+ iv?: BinaryLike;
6
+ encryptionMethod?: encryptionMethods;
7
+ inputEncoding?: Encoding;
8
+ outputEncoding?: Encoding;
9
+ options?: TransformOptions;
10
+ }
11
+ export interface IaesDecryptOptionalParameters {
12
+ iv?: BinaryLike;
13
+ encryptionMethod?: encryptionMethods;
14
+ inputEncoding?: Encoding;
15
+ outputEncoding?: Encoding;
16
+ options?: TransformOptions;
17
+ }
18
+ export interface AesEncryptInterface {
19
+ encrypt(message: string, passphrase: CipherKey, optionalParameters?: IaesEncryptOptionalParameters): string;
20
+ decrypt(encryptedMessage: string, passphrase: BinaryLike, optionalParameters?: IaesDecryptOptionalParameters): string;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=aes-encrypt.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes-encrypt.interface.d.ts","sourceRoot":"","sources":["../../../src/aes-encrypt/aes-encrypt.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE1C,KAAK,iBAAiB,GAAG,cAAc,GAAG,aAAa,CAAC;AAExD,MAAM,WAAW,6BAA6B;IAC5C,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,6BAA6B;IAC5C,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CACL,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,SAAS,EACrB,kBAAkB,CAAC,EAAE,6BAA6B,GACjD,MAAM,CAAC;IAEV,OAAO,CACL,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,UAAU,EACtB,kBAAkB,CAAC,EAAE,6BAA6B,GACjD,MAAM,CAAC;CACX"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare class AesEncryptModule {
2
+ }
3
+ //# sourceMappingURL=aes-encrypt.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes-encrypt.module.d.ts","sourceRoot":"","sources":["../../../src/aes-encrypt/aes-encrypt.module.ts"],"names":[],"mappings":"AAGA,qBAIa,gBAAgB;CAAG"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AesEncryptModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const aes_encrypt_service_1 = require("./aes-encrypt.service");
7
+ let AesEncryptModule = class AesEncryptModule {
8
+ };
9
+ exports.AesEncryptModule = AesEncryptModule;
10
+ exports.AesEncryptModule = AesEncryptModule = tslib_1.__decorate([
11
+ (0, common_1.Module)({
12
+ providers: [aes_encrypt_service_1.AesEncryptService],
13
+ exports: [aes_encrypt_service_1.AesEncryptService],
14
+ })
15
+ ], AesEncryptModule);
@@ -0,0 +1,7 @@
1
+ import { BinaryLike, CipherKey } from 'crypto';
2
+ import { AesEncryptInterface, IaesDecryptOptionalParameters, IaesEncryptOptionalParameters } from './aes-encrypt.interface';
3
+ export declare class AesEncryptService implements AesEncryptInterface {
4
+ encrypt(message: string, passphrase: CipherKey, optionalParameters?: IaesEncryptOptionalParameters): string;
5
+ decrypt(encryptedMessage: string, passphrase: BinaryLike, optionalParameters?: IaesDecryptOptionalParameters): string;
6
+ }
7
+ //# sourceMappingURL=aes-encrypt.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes-encrypt.service.d.ts","sourceRoot":"","sources":["../../../src/aes-encrypt/aes-encrypt.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,yBAAyB,CAAC;AAEjC,qBACa,iBAAkB,YAAW,mBAAmB;IACpD,OAAO,CACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,SAAS,EACrB,kBAAkB,GAAE,6BAAkC,GACrD,MAAM;IAyBF,OAAO,CACZ,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,UAAU,EACtB,kBAAkB,GAAE,6BAAkC,GACrD,MAAM;CAwBV"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AesEncryptService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const crypto_1 = require("crypto");
7
+ let AesEncryptService = class AesEncryptService {
8
+ encrypt(message, passphrase, optionalParameters = {}) {
9
+ optionalParameters = {
10
+ ...{
11
+ iv: Buffer.alloc(16).fill(0),
12
+ encryptionMethod: 'aes-256-cbc',
13
+ inputEncoding: 'utf8',
14
+ outputEncoding: 'hex',
15
+ },
16
+ ...optionalParameters,
17
+ };
18
+ const cipher = (0, crypto_1.createCipheriv)(optionalParameters.encryptionMethod, passphrase, optionalParameters.iv, optionalParameters.options);
19
+ let result = cipher.update(message, optionalParameters.inputEncoding, optionalParameters.outputEncoding);
20
+ result += cipher.final(optionalParameters.outputEncoding);
21
+ return result;
22
+ }
23
+ decrypt(encryptedMessage, passphrase, optionalParameters = {}) {
24
+ optionalParameters = {
25
+ ...{
26
+ encryptionMethod: 'aes-256-cbc',
27
+ iv: Buffer.alloc(16).fill(0),
28
+ inputEncoding: 'hex',
29
+ outputEncoding: 'utf8',
30
+ },
31
+ ...optionalParameters,
32
+ };
33
+ const decipher = (0, crypto_1.createDecipheriv)(optionalParameters.encryptionMethod, passphrase, optionalParameters.iv, optionalParameters.options);
34
+ let result = decipher.update(encryptedMessage, optionalParameters.inputEncoding, optionalParameters.outputEncoding);
35
+ result += decipher.final(optionalParameters.outputEncoding);
36
+ return result;
37
+ }
38
+ };
39
+ exports.AesEncryptService = AesEncryptService;
40
+ exports.AesEncryptService = AesEncryptService = tslib_1.__decorate([
41
+ (0, common_1.Injectable)()
42
+ ], AesEncryptService);
@@ -0,0 +1,5 @@
1
+ export interface IBinPgpEncryptModuleInterface {
2
+ encrypt(pgpKey: string, dataToEncrypt: unknown): Promise<string>;
3
+ decrypt(pgpKey: string, encryptedData: Buffer | Uint8Array | string, passphrase?: string): Promise<string>;
4
+ }
5
+ //# sourceMappingURL=bin-pgp-encrypt.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin-pgp-encrypt.interface.d.ts","sourceRoot":"","sources":["../../../src/bin-pgp-encrypt/bin-pgp-encrypt.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjE,OAAO,CACL,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,EAC3C,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare class BinPgpEncryptModule {
2
+ }
3
+ //# sourceMappingURL=bin-pgp-encrypt.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin-pgp-encrypt.module.d.ts","sourceRoot":"","sources":["../../../src/bin-pgp-encrypt/bin-pgp-encrypt.module.ts"],"names":[],"mappings":"AAGA,qBAIa,mBAAmB;CAAG"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BinPgpEncryptModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const bin_pgp_encrypt_service_1 = require("./bin-pgp-encrypt.service");
7
+ let BinPgpEncryptModule = class BinPgpEncryptModule {
8
+ };
9
+ exports.BinPgpEncryptModule = BinPgpEncryptModule;
10
+ exports.BinPgpEncryptModule = BinPgpEncryptModule = tslib_1.__decorate([
11
+ (0, common_1.Module)({
12
+ providers: [bin_pgp_encrypt_service_1.BinPgpEncryptService],
13
+ exports: [bin_pgp_encrypt_service_1.BinPgpEncryptService],
14
+ })
15
+ ], BinPgpEncryptModule);
@@ -0,0 +1,6 @@
1
+ import { IBinPgpEncryptModuleInterface } from './bin-pgp-encrypt.interface';
2
+ export declare class BinPgpEncryptService implements IBinPgpEncryptModuleInterface {
3
+ encrypt(pgpKey: string, dataToEncrypt: any): Promise<string>;
4
+ decrypt(pgpKey: string, encryptedData: Buffer | Uint8Array | string, passphrase?: string): Promise<string>;
5
+ }
6
+ //# sourceMappingURL=bin-pgp-encrypt.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin-pgp-encrypt.service.d.ts","sourceRoot":"","sources":["../../../src/bin-pgp-encrypt/bin-pgp-encrypt.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAE5E,qBACa,oBAAqB,YAAW,6BAA6B;IAC3D,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAiB5D,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,EAC3C,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;CA4CnB"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BinPgpEncryptService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ let BinPgpEncryptService = class BinPgpEncryptService {
7
+ async encrypt(pgpKey, dataToEncrypt) {
8
+ try {
9
+ const openpgp = await import('openpgp');
10
+ const publicKey = await openpgp.readKey({
11
+ armoredKey: pgpKey,
12
+ });
13
+ const encrypted = await openpgp.encrypt({
14
+ message: await openpgp.createMessage({ text: dataToEncrypt }),
15
+ encryptionKeys: publicKey,
16
+ format: 'binary',
17
+ });
18
+ return encrypted.toString();
19
+ }
20
+ catch (error) {
21
+ throw new Error(`File encryption error: \n ${error}`);
22
+ }
23
+ }
24
+ async decrypt(pgpKey, encryptedData, passphrase) {
25
+ try {
26
+ const openpgp = await import('openpgp');
27
+ const openpgpPrivatekey = await openpgp.readPrivateKey({
28
+ armoredKey: pgpKey,
29
+ });
30
+ const decryptKeyOptions = {
31
+ privateKey: openpgpPrivatekey,
32
+ config: {
33
+ allowInsecureDecryptionWithSigningKeys: true,
34
+ allowUnauthenticatedMessages: true,
35
+ },
36
+ };
37
+ let privateKey = openpgpPrivatekey;
38
+ if (passphrase) {
39
+ decryptKeyOptions.passphrase = passphrase;
40
+ privateKey = await openpgp.decryptKey(decryptKeyOptions);
41
+ }
42
+ const message = await openpgp.readMessage({
43
+ binaryMessage: encryptedData,
44
+ });
45
+ const { data: decryptedData } = await openpgp.decrypt({
46
+ message,
47
+ decryptionKeys: privateKey,
48
+ format: 'utf8',
49
+ config: {
50
+ allowInsecureDecryptionWithSigningKeys: true,
51
+ allowUnauthenticatedMessages: true,
52
+ },
53
+ });
54
+ return decryptedData.toString();
55
+ }
56
+ catch (error) {
57
+ throw new Error(`File decryption error: \n ${error}`);
58
+ }
59
+ }
60
+ };
61
+ exports.BinPgpEncryptService = BinPgpEncryptService;
62
+ exports.BinPgpEncryptService = BinPgpEncryptService = tslib_1.__decorate([
63
+ (0, common_1.Injectable)()
64
+ ], BinPgpEncryptService);
@@ -0,0 +1,11 @@
1
+ export { AesEncryptModule } from './aes-encrypt/aes-encrypt.module';
2
+ export { AesEncryptService } from './aes-encrypt/aes-encrypt.service';
3
+ export { RsaEncryptModule } from './rsa-encrypt/rsa-encrypt.module';
4
+ export { RsaEncryptService } from './rsa-encrypt/rsa-encrypt.service';
5
+ export { PgpEncryptModule } from './pgp-encrypt/pgp-encrypt.module';
6
+ export { PgpEncryptService } from './pgp-encrypt/pgp-encrypt.service';
7
+ export { BinPgpEncryptModule } from './bin-pgp-encrypt/bin-pgp-encrypt.module';
8
+ export { BinPgpEncryptService } from './bin-pgp-encrypt/bin-pgp-encrypt.service';
9
+ export { ZipEncryptModule } from './zip-encrypt/zipencrypt.module';
10
+ export { ZipEncryptService } from './zip-encrypt/zipencrypt.service';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZipEncryptService = exports.ZipEncryptModule = exports.BinPgpEncryptService = exports.BinPgpEncryptModule = exports.PgpEncryptService = exports.PgpEncryptModule = exports.RsaEncryptService = exports.RsaEncryptModule = exports.AesEncryptService = exports.AesEncryptModule = void 0;
4
+ var aes_encrypt_module_1 = require("./aes-encrypt/aes-encrypt.module");
5
+ Object.defineProperty(exports, "AesEncryptModule", { enumerable: true, get: function () { return aes_encrypt_module_1.AesEncryptModule; } });
6
+ var aes_encrypt_service_1 = require("./aes-encrypt/aes-encrypt.service");
7
+ Object.defineProperty(exports, "AesEncryptService", { enumerable: true, get: function () { return aes_encrypt_service_1.AesEncryptService; } });
8
+ var rsa_encrypt_module_1 = require("./rsa-encrypt/rsa-encrypt.module");
9
+ Object.defineProperty(exports, "RsaEncryptModule", { enumerable: true, get: function () { return rsa_encrypt_module_1.RsaEncryptModule; } });
10
+ var rsa_encrypt_service_1 = require("./rsa-encrypt/rsa-encrypt.service");
11
+ Object.defineProperty(exports, "RsaEncryptService", { enumerable: true, get: function () { return rsa_encrypt_service_1.RsaEncryptService; } });
12
+ var pgp_encrypt_module_1 = require("./pgp-encrypt/pgp-encrypt.module");
13
+ Object.defineProperty(exports, "PgpEncryptModule", { enumerable: true, get: function () { return pgp_encrypt_module_1.PgpEncryptModule; } });
14
+ var pgp_encrypt_service_1 = require("./pgp-encrypt/pgp-encrypt.service");
15
+ Object.defineProperty(exports, "PgpEncryptService", { enumerable: true, get: function () { return pgp_encrypt_service_1.PgpEncryptService; } });
16
+ var bin_pgp_encrypt_module_1 = require("./bin-pgp-encrypt/bin-pgp-encrypt.module");
17
+ Object.defineProperty(exports, "BinPgpEncryptModule", { enumerable: true, get: function () { return bin_pgp_encrypt_module_1.BinPgpEncryptModule; } });
18
+ var bin_pgp_encrypt_service_1 = require("./bin-pgp-encrypt/bin-pgp-encrypt.service");
19
+ Object.defineProperty(exports, "BinPgpEncryptService", { enumerable: true, get: function () { return bin_pgp_encrypt_service_1.BinPgpEncryptService; } });
20
+ var zipencrypt_module_1 = require("./zip-encrypt/zipencrypt.module");
21
+ Object.defineProperty(exports, "ZipEncryptModule", { enumerable: true, get: function () { return zipencrypt_module_1.ZipEncryptModule; } });
22
+ var zipencrypt_service_1 = require("./zip-encrypt/zipencrypt.service");
23
+ Object.defineProperty(exports, "ZipEncryptService", { enumerable: true, get: function () { return zipencrypt_service_1.ZipEncryptService; } });
@@ -0,0 +1,5 @@
1
+ export interface IPgpEncryptModuleInterface {
2
+ encrypt(pgpKey: any, dataToEncrypt: any): Promise<string>;
3
+ decrypt(pgpKey: any, encryptedData: any, passphrase?: string): Promise<string>;
4
+ }
5
+ //# sourceMappingURL=pgp-encrypt.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgp-encrypt.interface.d.ts","sourceRoot":"","sources":["../../../src/pgp-encrypt/pgp-encrypt.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,CACL,MAAM,EAAE,GAAG,EACX,aAAa,EAAE,GAAG,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare class PgpEncryptModule {
2
+ }
3
+ //# sourceMappingURL=pgp-encrypt.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgp-encrypt.module.d.ts","sourceRoot":"","sources":["../../../src/pgp-encrypt/pgp-encrypt.module.ts"],"names":[],"mappings":"AAGA,qBAIa,gBAAgB;CAAG"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PgpEncryptModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const pgp_encrypt_service_1 = require("./pgp-encrypt.service");
7
+ let PgpEncryptModule = class PgpEncryptModule {
8
+ };
9
+ exports.PgpEncryptModule = PgpEncryptModule;
10
+ exports.PgpEncryptModule = PgpEncryptModule = tslib_1.__decorate([
11
+ (0, common_1.Module)({
12
+ providers: [pgp_encrypt_service_1.PgpEncryptService],
13
+ exports: [pgp_encrypt_service_1.PgpEncryptService],
14
+ })
15
+ ], PgpEncryptModule);
@@ -0,0 +1,6 @@
1
+ import { IPgpEncryptModuleInterface } from './pgp-encrypt.interface';
2
+ export declare class PgpEncryptService implements IPgpEncryptModuleInterface {
3
+ encrypt(pgpKey: any, dataToEncrypt: any): Promise<string>;
4
+ decrypt(pgpKey: any, encryptedData: any, passphrase?: string): Promise<string>;
5
+ }
6
+ //# sourceMappingURL=pgp-encrypt.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgp-encrypt.service.d.ts","sourceRoot":"","sources":["../../../src/pgp-encrypt/pgp-encrypt.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAErE,qBACa,iBAAkB,YAAW,0BAA0B;IACrD,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBzD,OAAO,CAClB,MAAM,EAAE,GAAG,EACX,aAAa,EAAE,GAAG,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;CAkDnB"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PgpEncryptService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ let PgpEncryptService = class PgpEncryptService {
7
+ async encrypt(pgpKey, dataToEncrypt) {
8
+ try {
9
+ const openpgp = await import('openpgp');
10
+ const publicKey = await openpgp.readKey({
11
+ armoredKey: pgpKey,
12
+ });
13
+ const encrypted = await openpgp.encrypt({
14
+ message: await openpgp.createMessage({ text: dataToEncrypt }),
15
+ encryptionKeys: publicKey,
16
+ format: 'armored',
17
+ });
18
+ return encrypted.toString();
19
+ }
20
+ catch (error) {
21
+ throw new Error(`File encryption error: \n ${error}`);
22
+ }
23
+ }
24
+ async decrypt(pgpKey, encryptedData, passphrase) {
25
+ try {
26
+ const openpgp = await import('openpgp');
27
+ const openpgpPrivatekey = await openpgp.readPrivateKey({
28
+ armoredKey: pgpKey,
29
+ });
30
+ const decryptKeyOptions = {
31
+ privateKey: openpgpPrivatekey,
32
+ config: {
33
+ allowInsecureDecryptionWithSigningKeys: true,
34
+ allowUnauthenticatedMessages: true,
35
+ },
36
+ };
37
+ let privateKey = openpgpPrivatekey;
38
+ if (passphrase) {
39
+ decryptKeyOptions.passphrase = passphrase;
40
+ privateKey = await openpgp.decryptKey(decryptKeyOptions);
41
+ }
42
+ const armoredMessage = (await openpgp.createMessage({
43
+ text: encryptedData,
44
+ format: 'utf8',
45
+ })).getText();
46
+ const message = await openpgp.readMessage({
47
+ armoredMessage,
48
+ });
49
+ const { data: decryptedData } = await openpgp.decrypt({
50
+ message,
51
+ decryptionKeys: privateKey,
52
+ format: 'utf8',
53
+ config: {
54
+ allowInsecureDecryptionWithSigningKeys: true,
55
+ allowUnauthenticatedMessages: true,
56
+ },
57
+ });
58
+ return decryptedData.toString();
59
+ }
60
+ catch (error) {
61
+ throw new Error(`File decryption error: \n ${error}`);
62
+ }
63
+ }
64
+ };
65
+ exports.PgpEncryptService = PgpEncryptService;
66
+ exports.PgpEncryptService = PgpEncryptService = tslib_1.__decorate([
67
+ (0, common_1.Injectable)()
68
+ ], PgpEncryptService);
@@ -0,0 +1,6 @@
1
+ import * as NodeRSA from 'node-rsa';
2
+ export interface RsaEncryptInterface {
3
+ encrypt(message: NodeRSA.Data, key: NodeRSA.KeyBits, messageEncoding: NodeRSA.Encoding): string;
4
+ decrypt(message: string | Buffer, key: NodeRSA.Key, messageEncoding: NodeRSA.Encoding): string;
5
+ }
6
+ //# sourceMappingURL=rsa-encrypt.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsa-encrypt.interface.d.ts","sourceRoot":"","sources":["../../../src/rsa-encrypt/rsa-encrypt.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,UAAU,CAAC;AAEpC,MAAM,WAAW,mBAAmB;IAClC,OAAO,CACL,OAAO,EAAE,OAAO,CAAC,IAAI,EACrB,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,eAAe,EAAE,OAAO,CAAC,QAAQ,GAChC,MAAM,CAAC;IAEV,OAAO,CACL,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,GAAG,EAAE,OAAO,CAAC,GAAG,EAChB,eAAe,EAAE,OAAO,CAAC,QAAQ,GAChC,MAAM,CAAC;CACX"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare class RsaEncryptModule {
2
+ }
3
+ //# sourceMappingURL=rsa-encrypt.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsa-encrypt.module.d.ts","sourceRoot":"","sources":["../../../src/rsa-encrypt/rsa-encrypt.module.ts"],"names":[],"mappings":"AAGA,qBAIa,gBAAgB;CAAG"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RsaEncryptModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const rsa_encrypt_service_1 = require("./rsa-encrypt.service");
7
+ let RsaEncryptModule = class RsaEncryptModule {
8
+ };
9
+ exports.RsaEncryptModule = RsaEncryptModule;
10
+ exports.RsaEncryptModule = RsaEncryptModule = tslib_1.__decorate([
11
+ (0, common_1.Module)({
12
+ providers: [rsa_encrypt_service_1.RsaEncryptService],
13
+ exports: [rsa_encrypt_service_1.RsaEncryptService],
14
+ })
15
+ ], RsaEncryptModule);
@@ -0,0 +1,7 @@
1
+ import NodeRSA from 'node-rsa';
2
+ import { RsaEncryptInterface } from './rsa-encrypt.interface';
3
+ export declare class RsaEncryptService implements RsaEncryptInterface {
4
+ encrypt(message: NodeRSA.Data, key: NodeRSA.KeyBits, messageEncoding?: NodeRSA.Encoding): string;
5
+ decrypt(message: string | Buffer, key: NodeRSA.Key, messageEncoding?: NodeRSA.Encoding): string;
6
+ }
7
+ //# sourceMappingURL=rsa-encrypt.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsa-encrypt.service.d.ts","sourceRoot":"","sources":["../../../src/rsa-encrypt/rsa-encrypt.service.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,qBACa,iBAAkB,YAAW,mBAAmB;IACpD,OAAO,CACZ,OAAO,EAAE,OAAO,CAAC,IAAI,EACrB,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,eAAe,GAAE,OAAO,CAAC,QAAmB,GAC3C,MAAM;IAMF,OAAO,CACZ,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,GAAG,EAAE,OAAO,CAAC,GAAG,EAChB,eAAe,GAAE,OAAO,CAAC,QAAmB,GAC3C,MAAM;CAKV"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RsaEncryptService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const node_rsa_1 = tslib_1.__importDefault(require("node-rsa"));
7
+ let RsaEncryptService = class RsaEncryptService {
8
+ encrypt(message, key, messageEncoding = 'base64') {
9
+ const rsa = new node_rsa_1.default(key);
10
+ const encryptedData = rsa.encrypt(message, messageEncoding);
11
+ return encryptedData;
12
+ }
13
+ decrypt(message, key, messageEncoding = 'buffer') {
14
+ const rsa = new node_rsa_1.default(key);
15
+ const decrypt = rsa.decrypt(message, messageEncoding).toString();
16
+ return decrypt;
17
+ }
18
+ };
19
+ exports.RsaEncryptService = RsaEncryptService;
20
+ exports.RsaEncryptService = RsaEncryptService = tslib_1.__decorate([
21
+ (0, common_1.Injectable)()
22
+ ], RsaEncryptService);
@@ -0,0 +1,10 @@
1
+ import { ArchiverOptions } from 'archiver';
2
+ export type encryptionMethodType = 'zip20' | 'aes256';
3
+ export type archiverOptionsZipEncrypted = ArchiverOptions & {
4
+ encryptionMethod: encryptionMethodType;
5
+ };
6
+ export interface FileFormat {
7
+ content: any;
8
+ filename: string;
9
+ }
10
+ //# sourceMappingURL=zipencrypt.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zipencrypt.interface.d.ts","sourceRoot":"","sources":["../../../src/zip-encrypt/zipencrypt.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtD,MAAM,MAAM,2BAA2B,GAAG,eAAe,GAAG;IAC1D,gBAAgB,EAAE,oBAAoB,CAAC;CACxC,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare class ZipEncryptModule {
2
+ }
3
+ //# sourceMappingURL=zipencrypt.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zipencrypt.module.d.ts","sourceRoot":"","sources":["../../../src/zip-encrypt/zipencrypt.module.ts"],"names":[],"mappings":"AAGA,qBAIa,gBAAgB;CAAG"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZipEncryptModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const zipencrypt_service_1 = require("./zipencrypt.service");
7
+ let ZipEncryptModule = class ZipEncryptModule {
8
+ };
9
+ exports.ZipEncryptModule = ZipEncryptModule;
10
+ exports.ZipEncryptModule = ZipEncryptModule = tslib_1.__decorate([
11
+ (0, common_1.Module)({
12
+ providers: [zipencrypt_service_1.ZipEncryptService],
13
+ exports: [zipencrypt_service_1.ZipEncryptService],
14
+ })
15
+ ], ZipEncryptModule);
@@ -0,0 +1,5 @@
1
+ import { encryptionMethodType, FileFormat } from './zipencrypt.interface';
2
+ export declare class ZipEncryptService {
3
+ encryptFiles(files: FileFormat[], password: string, encryptionMethod?: encryptionMethodType): Promise<Buffer | false>;
4
+ }
5
+ //# sourceMappingURL=zipencrypt.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zipencrypt.service.d.ts","sourceRoot":"","sources":["../../../src/zip-encrypt/zipencrypt.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,oBAAoB,EACpB,UAAU,EACX,MAAM,wBAAwB,CAAC;AAEhC,qBACa,iBAAiB;IACf,YAAY,CACvB,KAAK,EAAE,UAAU,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,GAAE,oBAA8B,GAC/C,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;CA0B3B"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZipEncryptService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const archiver_1 = require("archiver");
7
+ const stream_buffers_1 = require("stream-buffers");
8
+ let ZipEncryptService = class ZipEncryptService {
9
+ async encryptFiles(files, password, encryptionMethod = 'zip20') {
10
+ const output = new stream_buffers_1.WritableStreamBuffer({
11
+ initialSize: 1000,
12
+ incrementAmount: 1000,
13
+ });
14
+ if (!(0, archiver_1.isRegisteredFormat)('zip-encrypted')) {
15
+ (0, archiver_1.registerFormat)('zip-encrypted', require('archiver-zip-encrypted'));
16
+ }
17
+ const archive = (0, archiver_1.create)('zip-encrypted', {
18
+ zlib: { level: 8 },
19
+ encryptionMethod,
20
+ password,
21
+ });
22
+ archive.pipe(output);
23
+ files.map((file) => {
24
+ archive.append(file.content, { name: file.filename });
25
+ });
26
+ await archive.finalize();
27
+ output.end();
28
+ return output.getContents();
29
+ }
30
+ };
31
+ exports.ZipEncryptService = ZipEncryptService;
32
+ exports.ZipEncryptService = ZipEncryptService = tslib_1.__decorate([
33
+ (0, common_1.Injectable)()
34
+ ], ZipEncryptService);
@@ -0,0 +1 @@
1
+ {"version":"5.9.3"}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@edirect/encrypt-modules",
3
- "version": "11.0.62-beta.0",
3
+ "version": "11.0.62-beta.2",
4
4
  "description": "Encrypt Modules",
5
+ "packageScope": "@edirect",
5
6
  "main": "./dist/src/index.js",
6
7
  "types": "./dist/src/index.d.ts",
7
8
  "exports": {
@@ -26,10 +27,27 @@
26
27
  "tslib": "^2.8.1"
27
28
  },
28
29
  "devDependencies": {
30
+ "@nestjs/cli": "^11.0.21",
29
31
  "@types/archiver": "^7.0.0",
30
32
  "@types/node": "^25.6.2",
31
33
  "@types/node-rsa": "^1.1.4",
32
34
  "@types/stream-buffers": "^3.0.8"
33
35
  },
34
- "type": "commonjs"
36
+ "nx": {
37
+ "name": "@edirect/encrypt-modules",
38
+ "targets": {
39
+ "build": {
40
+ "executor": "@nx/js:tsc",
41
+ "options": {
42
+ "main": "{workspaceRoot}/packages/edirect-encrypt-modules/src/index.ts",
43
+ "tsConfig": "{workspaceRoot}/packages/edirect-encrypt-modules/tsconfig.lib.json",
44
+ "outputPath": "{workspaceRoot}/packages/edirect-encrypt-modules/dist",
45
+ "assets": [
46
+ "{workspaceRoot}/packages/edirect-encrypt-modules/package.json",
47
+ "{workspaceRoot}/packages/edirect-encrypt-modules/README.md"
48
+ ]
49
+ }
50
+ }
51
+ }
52
+ }
35
53
  }