@voiceflow/encryption 0.4.2 → 0.5.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.
- package/package.json +6 -6
- package/build/cjs/aes-256-gcm.d.ts +0 -49
- package/build/cjs/aes-256-gcm.d.ts.map +0 -1
- package/build/cjs/aes-256-gcm.js +0 -34
- package/build/cjs/aes-256-gcm.js.map +0 -1
- package/build/cjs/aes-256-gcm.test.d.ts +0 -2
- package/build/cjs/aes-256-gcm.test.d.ts.map +0 -1
- package/build/cjs/aes-256-gcm.test.js +0 -43
- package/build/cjs/aes-256-gcm.test.js.map +0 -1
- package/build/cjs/encryption.const.d.ts +0 -2
- package/build/cjs/encryption.const.d.ts.map +0 -1
- package/build/cjs/encryption.const.js +0 -5
- package/build/cjs/encryption.const.js.map +0 -1
- package/build/cjs/encryption.interface.d.ts +0 -9
- package/build/cjs/encryption.interface.d.ts.map +0 -1
- package/build/cjs/encryption.interface.js +0 -3
- package/build/cjs/encryption.interface.js.map +0 -1
- package/build/cjs/encryption.module.d.ts +0 -7
- package/build/cjs/encryption.module.d.ts.map +0 -1
- package/build/cjs/encryption.module.js +0 -95
- package/build/cjs/encryption.module.js.map +0 -1
- package/build/cjs/encryption.service.d.ts +0 -10
- package/build/cjs/encryption.service.d.ts.map +0 -1
- package/build/cjs/encryption.service.js +0 -73
- package/build/cjs/encryption.service.js.map +0 -1
- package/build/cjs/encryption.service.test.d.ts +0 -2
- package/build/cjs/encryption.service.test.d.ts.map +0 -1
- package/build/cjs/encryption.service.test.js +0 -77
- package/build/cjs/encryption.service.test.js.map +0 -1
- package/build/cjs/main.d.ts +0 -7
- package/build/cjs/main.d.ts.map +0 -1
- package/build/cjs/main.js +0 -16
- package/build/cjs/main.js.map +0 -1
- package/build/cjs/package.json +0 -1
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voiceflow/encryption",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Voiceflow encryption library",
|
|
5
5
|
"license": "ISC",
|
|
6
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "build/esm/main.js",
|
|
7
8
|
"module": "build/esm/main.js",
|
|
8
|
-
"types": "build/
|
|
9
|
+
"types": "build/esm/main.d.ts",
|
|
9
10
|
"files": [
|
|
10
11
|
"build"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "yarn g:turbo run build:cmd --filter=@voiceflow/encryption...",
|
|
14
|
-
"build:
|
|
15
|
-
"build:cmd": "yarn g:run-p build:cjs build:esm",
|
|
15
|
+
"build:cmd": "yarn build:esm",
|
|
16
16
|
"build:esm": "yarn g:build:pkg esm",
|
|
17
17
|
"clean": "yarn g:rimraf build",
|
|
18
18
|
"lint": "yarn g:run-p -c lint:eslint lint:prettier",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "c88cb20155e489c081e5f29079b1ad4727903e17"
|
|
44
44
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file implements AES 256 Galois/counter (GCM) encryption. The AES algorithm
|
|
3
|
-
* is a symmetric-key block cipher that is considered to be a highly secure algorithm
|
|
4
|
-
* (as of 30 Sep 2024).
|
|
5
|
-
*
|
|
6
|
-
* For this implementation, we will use AES-256 with 256-bit keys, which provides the
|
|
7
|
-
* strongest security of all AES variants.
|
|
8
|
-
*
|
|
9
|
-
* GCM mode is the usual recommended mode of operation for encryption. AES 256 features
|
|
10
|
-
* a variety of modes of operation, such as ECB, CBC, CTR, and GCM. To understand why
|
|
11
|
-
* GCM is a good choice, we will discuss the weaknesses of each method mentioned.
|
|
12
|
-
*
|
|
13
|
-
* 1. ECB is considered insecure as it does not sufficiently scramble patterns in the
|
|
14
|
-
* original data, e.g, see the Tux image in
|
|
15
|
-
* https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_codebook_(ECB)
|
|
16
|
-
*
|
|
17
|
-
* 2. CBC is stronger than ECB but operates on fixed-length blocks of plaintext, so
|
|
18
|
-
* plaintext that does not conform to these requirements require *padding*. The use of
|
|
19
|
-
* padding opens CBC to "padding oracle attacks" which allows attackers to decrypt the
|
|
20
|
-
* ciphertext without knowing the symmetric key.
|
|
21
|
-
*
|
|
22
|
-
* 3. CTR does not suffer from padding oracle attacks as it does not require padding.
|
|
23
|
-
* However, it and other methods are vulnerable to attacks on data integrity such as
|
|
24
|
-
* "malleability attacks" which allows an attacker to manipulate the ciphertext to
|
|
25
|
-
* inject malicious data without knowing the symmetric key.
|
|
26
|
-
*
|
|
27
|
-
* GCM uses CTR under the hood, but adds a "message authenticate code" (MAC) to each ciphertext
|
|
28
|
-
* created. A trusted sender computes a MAC on some text, using the symmetric key. A trusted
|
|
29
|
-
* receiver will verify the MAC using the symmetric key to ensure that no attacker intercepted
|
|
30
|
-
* the message and tampered with its underlying contents. This is similar to the concept of
|
|
31
|
-
* "digital signatures" that is also used in cryptography.
|
|
32
|
-
*
|
|
33
|
-
* The MAC guards against malleability attacks, as a symmetric key is required to compute the
|
|
34
|
-
* exact MAC corresponding to the protected ciphertext. Manipulating the ciphertext without
|
|
35
|
-
* making the corresponding change in the MAC causes a mismatch which is flagged as an integrity
|
|
36
|
-
* violation.
|
|
37
|
-
*
|
|
38
|
-
* NOTE: While GCM is one of the more secure modes of operation, it is by no means perfect
|
|
39
|
-
* and requires careful adherence to best practice, e.g, AES-256 should ideally be used
|
|
40
|
-
* with 96-bit cryptographically secure pseudorandom initialization vectors.
|
|
41
|
-
*/
|
|
42
|
-
export interface GCMEncryptedData {
|
|
43
|
-
value: string;
|
|
44
|
-
iv: string;
|
|
45
|
-
mac: string;
|
|
46
|
-
}
|
|
47
|
-
export declare function encryptAes256Gcm(plaintext: string, symmetricKey: string): GCMEncryptedData;
|
|
48
|
-
export declare function decryptAes256Gcm(data: GCMEncryptedData, symmetricKey: string): string;
|
|
49
|
-
//# sourceMappingURL=aes-256-gcm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aes-256-gcm.d.ts","sourceRoot":"","sources":["../../src/aes-256-gcm.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAYD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAa1F;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAU5E"}
|
package/build/cjs/aes-256-gcm.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.encryptAes256Gcm = encryptAes256Gcm;
|
|
7
|
-
exports.decryptAes256Gcm = decryptAes256Gcm;
|
|
8
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
9
|
-
const mode = 'aes-256-gcm';
|
|
10
|
-
// 96-bit IV is recommended by section 5.2.1.1 in
|
|
11
|
-
// https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
|
|
12
|
-
const ivLengthBytes = 12;
|
|
13
|
-
const dbEncoding = 'base64';
|
|
14
|
-
const plaintextEncoding = 'utf8';
|
|
15
|
-
function encryptAes256Gcm(plaintext, symmetricKey) {
|
|
16
|
-
const key = Buffer.from(symmetricKey, dbEncoding);
|
|
17
|
-
const iv = node_crypto_1.default.randomBytes(ivLengthBytes);
|
|
18
|
-
const cipher = node_crypto_1.default.createCipheriv(mode, key, iv);
|
|
19
|
-
const ciphertext = cipher.update(plaintext, plaintextEncoding, dbEncoding) + cipher.final(dbEncoding);
|
|
20
|
-
return {
|
|
21
|
-
value: ciphertext,
|
|
22
|
-
iv: iv.toString(dbEncoding),
|
|
23
|
-
mac: cipher.getAuthTag().toString(dbEncoding),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function decryptAes256Gcm(data, symmetricKey) {
|
|
27
|
-
const key = Buffer.from(symmetricKey, dbEncoding);
|
|
28
|
-
const iv = Buffer.from(data.iv, dbEncoding);
|
|
29
|
-
const decipher = node_crypto_1.default.createDecipheriv(mode, key, iv);
|
|
30
|
-
const mac = Buffer.from(data.mac, dbEncoding);
|
|
31
|
-
decipher.setAuthTag(mac);
|
|
32
|
-
return decipher.update(data.value, dbEncoding, plaintextEncoding) + decipher.final(plaintextEncoding);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=aes-256-gcm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aes-256-gcm.js","sourceRoot":"","sources":["../../src/aes-256-gcm.ts"],"names":[],"mappings":";;;;;AA4DA,4CAaC;AAED,4CAUC;AArFD,8DAAiC;AAkDjC,MAAM,IAAI,GAAG,aAAa,CAAC;AAE3B,iDAAiD;AACjD,gFAAgF;AAChF,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,UAAU,GAAG,QAAQ,CAAC;AAE5B,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,SAAgB,gBAAgB,CAAC,SAAiB,EAAE,YAAoB;IACtE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAElD,MAAM,EAAE,GAAG,qBAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,qBAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAEpD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAEtG,OAAO;QACL,KAAK,EAAE,UAAU;QACjB,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3B,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,IAAsB,EAAE,YAAoB;IAC3E,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAElD,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,qBAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAExD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC9C,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAEzB,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACxG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aes-256-gcm.test.d.ts","sourceRoot":"","sources":["../../src/aes-256-gcm.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
7
|
-
const vitest_1 = require("vitest");
|
|
8
|
-
const aes_256_gcm_1 = require("./aes-256-gcm");
|
|
9
|
-
(0, vitest_1.describe)('AES-256 GCM', async () => {
|
|
10
|
-
const createAES256Key = () => new Promise((resolve) => {
|
|
11
|
-
crypto_1.default.generateKey('aes', { length: 256 }, (err, key) => {
|
|
12
|
-
if (err)
|
|
13
|
-
throw err;
|
|
14
|
-
resolve(key.export().toString('base64'));
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
const testKey = await createAES256Key();
|
|
18
|
-
(0, vitest_1.test)('successfully encrypts then decrypts', async () => {
|
|
19
|
-
const plaintext = 'hello, world!';
|
|
20
|
-
const cipherdata = await (0, aes_256_gcm_1.encryptAes256Gcm)(plaintext, testKey);
|
|
21
|
-
const deciphertext = await (0, aes_256_gcm_1.decryptAes256Gcm)(cipherdata, testKey);
|
|
22
|
-
(0, vitest_1.expect)(deciphertext).to.eq(plaintext);
|
|
23
|
-
});
|
|
24
|
-
(0, vitest_1.test)('throws error if decrypted with wrong key', async () => {
|
|
25
|
-
const plaintext = 'hello, world!';
|
|
26
|
-
const wrongKey = await createAES256Key();
|
|
27
|
-
const cipherdata = await (0, aes_256_gcm_1.encryptAes256Gcm)(plaintext, testKey);
|
|
28
|
-
const decipher = () => (0, aes_256_gcm_1.decryptAes256Gcm)(cipherdata, wrongKey);
|
|
29
|
-
await (0, vitest_1.expect)(decipher).to.throw('Unsupported state or unable to authenticate data');
|
|
30
|
-
});
|
|
31
|
-
(0, vitest_1.test)('throws error if ciphertext is not validated by the mac', async () => {
|
|
32
|
-
const plaintext = 'hello, world!';
|
|
33
|
-
const trueCipherdata = await (0, aes_256_gcm_1.encryptAes256Gcm)(plaintext, testKey);
|
|
34
|
-
const data = await (0, aes_256_gcm_1.encryptAes256Gcm)('malicious payload', testKey);
|
|
35
|
-
const forgedCipherdata = {
|
|
36
|
-
...trueCipherdata,
|
|
37
|
-
value: data.value,
|
|
38
|
-
};
|
|
39
|
-
const decipher = () => (0, aes_256_gcm_1.decryptAes256Gcm)(forgedCipherdata, testKey);
|
|
40
|
-
await (0, vitest_1.expect)(decipher).to.throw('Unsupported state or unable to authenticate data');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=aes-256-gcm.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aes-256-gcm.test.js","sourceRoot":"","sources":["../../src/aes-256-gcm.test.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,mCAAgD;AAEhD,+CAAmE;AAEnE,IAAA,iBAAQ,EAAC,aAAa,EAAE,KAAK,IAAI,EAAE;IACjC,MAAM,eAAe,GAAG,GAAG,EAAE,CAC3B,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;QAC9B,gBAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACtD,IAAI,GAAG;gBAAE,MAAM,GAAG,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACL,MAAM,OAAO,GAAG,MAAM,eAAe,EAAE,CAAC;IAExC,IAAA,aAAI,EAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,SAAS,GAAG,eAAe,CAAC;QAElC,MAAM,UAAU,GAAG,MAAM,IAAA,8BAAgB,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAEj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[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,8BAA8B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.const.js","sourceRoot":"","sources":["../../src/encryption.const.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG,2BAA2B,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ModuleMetadata } from '@nestjs/common';
|
|
2
|
-
export interface EncryptionModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
3
|
-
useFactory: (...args: any[]) => Promise<EncryptionModuleOptions> | EncryptionModuleOptions;
|
|
4
|
-
inject?: any[];
|
|
5
|
-
}
|
|
6
|
-
export interface EncryptionModuleOptions {
|
|
7
|
-
encryptionKey?: string | null;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=encryption.interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.interface.d.ts","sourceRoot":"","sources":["../../src/encryption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC;IACnF,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,uBAAuB,CAAC,GAAG,uBAAuB,CAAC;IAC3F,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.interface.js","sourceRoot":"","sources":["../../src/encryption.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { EncryptionModuleAsyncOptions, EncryptionModuleOptions } from './encryption.interface';
|
|
3
|
-
export declare class EncryptionModule {
|
|
4
|
-
static register(options: EncryptionModuleOptions): DynamicModule;
|
|
5
|
-
static registerAsync(options: EncryptionModuleAsyncOptions): DynamicModule;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=encryption.module.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.module.d.ts","sourceRoot":"","sources":["../../src/encryption.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAG/F,qBACa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa;IAahE,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,4BAA4B,GAAG,aAAa;CAqB3E"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.EncryptionModule = void 0;
|
|
41
|
-
const common_1 = require("@nestjs/common");
|
|
42
|
-
const encryption_const_1 = require("./encryption.const");
|
|
43
|
-
const encryption_service_1 = __importDefault(require("./encryption.service"));
|
|
44
|
-
let EncryptionModule = (() => {
|
|
45
|
-
let _classDecorators = [(0, common_1.Module)({})];
|
|
46
|
-
let _classDescriptor;
|
|
47
|
-
let _classExtraInitializers = [];
|
|
48
|
-
let _classThis;
|
|
49
|
-
var EncryptionModule = class {
|
|
50
|
-
static { _classThis = this; }
|
|
51
|
-
static {
|
|
52
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
53
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
54
|
-
EncryptionModule = _classThis = _classDescriptor.value;
|
|
55
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
56
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
57
|
-
}
|
|
58
|
-
static register(options) {
|
|
59
|
-
return {
|
|
60
|
-
module: EncryptionModule,
|
|
61
|
-
providers: [
|
|
62
|
-
{
|
|
63
|
-
provide: encryption_service_1.default,
|
|
64
|
-
useValue: new encryption_service_1.default(options.encryptionKey),
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
exports: [encryption_service_1.default],
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
static registerAsync(options) {
|
|
71
|
-
return {
|
|
72
|
-
module: EncryptionModule,
|
|
73
|
-
imports: options.imports || [],
|
|
74
|
-
providers: [
|
|
75
|
-
{
|
|
76
|
-
provide: encryption_const_1.EncryptionModuleOptionsProvide,
|
|
77
|
-
useFactory: options.useFactory,
|
|
78
|
-
inject: options.inject || [],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
provide: encryption_service_1.default,
|
|
82
|
-
useFactory: (moduleOptions) => {
|
|
83
|
-
return new encryption_service_1.default(moduleOptions.encryptionKey);
|
|
84
|
-
},
|
|
85
|
-
inject: [encryption_const_1.EncryptionModuleOptionsProvide],
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
exports: [encryption_service_1.default],
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
return EncryptionModule = _classThis;
|
|
93
|
-
})();
|
|
94
|
-
exports.EncryptionModule = EncryptionModule;
|
|
95
|
-
//# sourceMappingURL=encryption.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.module.js","sourceRoot":"","sources":["../../src/encryption.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAuD;AAEvD,yDAAoE;AAEpE,8EAAqD;IAGxC,gBAAgB;4BAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;;;;;;;;YACX,6KAmCC;;;YAnCY,uDAAgB;;QAC3B,MAAM,CAAC,QAAQ,CAAC,OAAgC;YAC9C,OAAO;gBACL,MAAM,EAAE,gBAAgB;gBACxB,SAAS,EAAE;oBACT;wBACE,OAAO,EAAE,4BAAiB;wBAC1B,QAAQ,EAAE,IAAI,4BAAiB,CAAC,OAAO,CAAC,aAAa,CAAC;qBACvD;iBACF;gBACD,OAAO,EAAE,CAAC,4BAAiB,CAAC;aAC7B,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,aAAa,CAAC,OAAqC;YACxD,OAAO;gBACL,MAAM,EAAE,gBAAgB;gBACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;gBAC9B,SAAS,EAAE;oBACT;wBACE,OAAO,EAAE,iDAA8B;wBACvC,UAAU,EAAE,OAAO,CAAC,UAAU;wBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;qBAC7B;oBACD;wBACE,OAAO,EAAE,4BAAiB;wBAC1B,UAAU,EAAE,CAAC,aAAsC,EAAE,EAAE;4BACrD,OAAO,IAAI,4BAAiB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;wBAC5D,CAAC;wBACD,MAAM,EAAE,CAAC,iDAA8B,CAAC;qBACzC;iBACF;gBACD,OAAO,EAAE,CAAC,4BAAiB,CAAC;aAC7B,CAAC;QACJ,CAAC;;;;AAlCU,4CAAgB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { GCMEncryptedData } from './aes-256-gcm';
|
|
2
|
-
declare class EncryptionService {
|
|
3
|
-
private readonly _encryptionKey?;
|
|
4
|
-
constructor(_encryptionKey?: string | null | undefined);
|
|
5
|
-
private get encryptionKey();
|
|
6
|
-
encrypt(plaintext: string): GCMEncryptedData;
|
|
7
|
-
decrypt(data: GCMEncryptedData): string;
|
|
8
|
-
}
|
|
9
|
-
export default EncryptionService;
|
|
10
|
-
//# sourceMappingURL=encryption.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.service.d.ts","sourceRoot":"","sources":["../../src/encryption.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,cACM,iBAAiB;IACT,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;gBAAf,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,YAAA;IAE3D,OAAO,KAAK,aAAa,GAMxB;IAEM,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB;IAI5C,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM;CAG/C;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
const common_1 = require("@nestjs/common");
|
|
38
|
-
const aes_256_gcm_1 = require("./aes-256-gcm");
|
|
39
|
-
let EncryptionService = (() => {
|
|
40
|
-
let _classDecorators = [(0, common_1.Injectable)()];
|
|
41
|
-
let _classDescriptor;
|
|
42
|
-
let _classExtraInitializers = [];
|
|
43
|
-
let _classThis;
|
|
44
|
-
var EncryptionService = class {
|
|
45
|
-
static { _classThis = this; }
|
|
46
|
-
static {
|
|
47
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
48
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
49
|
-
EncryptionService = _classThis = _classDescriptor.value;
|
|
50
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
51
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
52
|
-
}
|
|
53
|
-
_encryptionKey;
|
|
54
|
-
constructor(_encryptionKey) {
|
|
55
|
-
this._encryptionKey = _encryptionKey;
|
|
56
|
-
}
|
|
57
|
-
get encryptionKey() {
|
|
58
|
-
if (!this._encryptionKey) {
|
|
59
|
-
throw new Error('Encryption key is required');
|
|
60
|
-
}
|
|
61
|
-
return this._encryptionKey;
|
|
62
|
-
}
|
|
63
|
-
encrypt(plaintext) {
|
|
64
|
-
return (0, aes_256_gcm_1.encryptAes256Gcm)(plaintext, this.encryptionKey);
|
|
65
|
-
}
|
|
66
|
-
decrypt(data) {
|
|
67
|
-
return (0, aes_256_gcm_1.decryptAes256Gcm)(data, this.encryptionKey);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
return EncryptionService = _classThis;
|
|
71
|
-
})();
|
|
72
|
-
exports.default = EncryptionService;
|
|
73
|
-
//# sourceMappingURL=encryption.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.service.js","sourceRoot":"","sources":["../../src/encryption.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAG5C,+CAAmE;IAG7D,iBAAiB;4BADtB,IAAA,mBAAU,GAAE;;;;;;;;YACb,6KAkBC;;;YAlBK,uDAAiB;;QACQ,cAAc;QAA3C,YAA6B,cAA8B;YAA9B,mBAAc,GAAd,cAAc,CAAgB;QAAG,CAAC;QAE/D,IAAY,aAAa;YACvB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAChD,CAAC;YAED,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;QAEM,OAAO,CAAC,SAAiB;YAC9B,OAAO,IAAA,8BAAgB,EAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,CAAC;QAEM,OAAO,CAAC,IAAsB;YACnC,OAAO,IAAA,8BAAgB,EAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACpD,CAAC;;;;AAGH,kBAAe,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.service.test.d.ts","sourceRoot":"","sources":["../../src/encryption.service.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const vitest_1 = require("vitest");
|
|
7
|
-
const aes_256_gcm_1 = require("./aes-256-gcm");
|
|
8
|
-
const encryption_service_1 = __importDefault(require("./encryption.service"));
|
|
9
|
-
(0, vitest_1.describe)('EncryptionService', () => {
|
|
10
|
-
// 32-byte key (256 bits) required for AES-256
|
|
11
|
-
const MOCK_KEY = Buffer.from('0123456789abcdef0123456789abcdef').toString('base64');
|
|
12
|
-
(0, vitest_1.describe)('constructor', () => {
|
|
13
|
-
(0, vitest_1.it)('creates instance with valid encryption key', () => {
|
|
14
|
-
(0, vitest_1.expect)(() => new encryption_service_1.default(MOCK_KEY)).not.toThrow();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
(0, vitest_1.describe)('encrypt', () => {
|
|
18
|
-
let service;
|
|
19
|
-
(0, vitest_1.beforeEach)(() => {
|
|
20
|
-
service = new encryption_service_1.default(MOCK_KEY);
|
|
21
|
-
});
|
|
22
|
-
(0, vitest_1.it)('encrypts plaintext string', () => {
|
|
23
|
-
const plaintext = 'test-data';
|
|
24
|
-
const encrypted = service.encrypt(plaintext);
|
|
25
|
-
(0, vitest_1.expect)(encrypted).toBeDefined();
|
|
26
|
-
(0, vitest_1.expect)(encrypted.iv).toBeDefined();
|
|
27
|
-
(0, vitest_1.expect)(encrypted.mac).toBeDefined();
|
|
28
|
-
(0, vitest_1.expect)(encrypted.value).toBeDefined();
|
|
29
|
-
(0, vitest_1.expect)(encrypted.value).not.toBe(plaintext);
|
|
30
|
-
// Verify we can decrypt it back
|
|
31
|
-
const decrypted = service.decrypt(encrypted);
|
|
32
|
-
(0, vitest_1.expect)(decrypted).toBe(plaintext);
|
|
33
|
-
});
|
|
34
|
-
(0, vitest_1.it)('produces different ciphertext for same plaintext', () => {
|
|
35
|
-
const plaintext = 'test-data';
|
|
36
|
-
const encrypted1 = service.encrypt(plaintext);
|
|
37
|
-
const encrypted2 = service.encrypt(plaintext);
|
|
38
|
-
// Should have different IVs
|
|
39
|
-
(0, vitest_1.expect)(encrypted1.iv).not.toBe(encrypted2.iv);
|
|
40
|
-
// Should have different ciphertext
|
|
41
|
-
(0, vitest_1.expect)(encrypted1.value).not.toBe(encrypted2.value);
|
|
42
|
-
// But both should decrypt to the same plaintext
|
|
43
|
-
(0, vitest_1.expect)(service.decrypt(encrypted1)).toBe(service.decrypt(encrypted2));
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
(0, vitest_1.describe)('decrypt', () => {
|
|
47
|
-
let service;
|
|
48
|
-
(0, vitest_1.beforeEach)(() => {
|
|
49
|
-
service = new encryption_service_1.default(MOCK_KEY);
|
|
50
|
-
});
|
|
51
|
-
(0, vitest_1.it)('decrypts valid encrypted data', () => {
|
|
52
|
-
const plaintext = 'test-data';
|
|
53
|
-
const encrypted = (0, aes_256_gcm_1.encryptAes256Gcm)(plaintext, MOCK_KEY);
|
|
54
|
-
const decrypted = service.decrypt(encrypted);
|
|
55
|
-
(0, vitest_1.expect)(decrypted).toBe(plaintext);
|
|
56
|
-
});
|
|
57
|
-
(0, vitest_1.it)('throws error for invalid encrypted data', () => {
|
|
58
|
-
const invalidData = {
|
|
59
|
-
iv: 'invalid',
|
|
60
|
-
mac: 'invalid',
|
|
61
|
-
value: 'invalid',
|
|
62
|
-
};
|
|
63
|
-
(0, vitest_1.expect)(() => service.decrypt(invalidData)).toThrow();
|
|
64
|
-
});
|
|
65
|
-
(0, vitest_1.it)('throws error for tampered encrypted data', () => {
|
|
66
|
-
const plaintext = 'test-data';
|
|
67
|
-
const encrypted = service.encrypt(plaintext);
|
|
68
|
-
// Tamper with the encrypted data
|
|
69
|
-
const tampered = {
|
|
70
|
-
...encrypted,
|
|
71
|
-
value: `${encrypted.value}tampered`,
|
|
72
|
-
};
|
|
73
|
-
(0, vitest_1.expect)(() => service.decrypt(tampered)).toThrow();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=encryption.service.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.service.test.js","sourceRoot":"","sources":["../../src/encryption.service.test.ts"],"names":[],"mappings":";;;;;AAAA,mCAA0D;AAG1D,+CAAiD;AACjD,8EAAqD;AAErD,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,8CAA8C;IAE9C,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEpF,IAAA,iBAAQ,EAAC,aAAa,EAAE,GAAG,EAAE;QAC3B,IAAA,WAAE,EAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,IAAI,4BAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAC9D,CAA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AG,EAAE;YAClD,MAAM,SAAS,GAAG,WAAW,CAAC;YAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAE7C,iCAAiC;YACjC,MAAM,QAAQ,GAAqB;gBACjC,GAAG,SAAS;gBACZ,KAAK,EAAE,GAAG,SAAS,CAAC,KAAK,UAAU;aACpC,CAAC;YAEF,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/build/cjs/main.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { GCMEncryptedData } from './aes-256-gcm';
|
|
2
|
-
export { decryptAes256Gcm, encryptAes256Gcm } from './aes-256-gcm';
|
|
3
|
-
export { EncryptionModuleOptionsProvide } from './encryption.const';
|
|
4
|
-
export type { EncryptionModuleAsyncOptions, EncryptionModuleOptions } from './encryption.interface';
|
|
5
|
-
export { EncryptionModule } from './encryption.module';
|
|
6
|
-
export { default as EncryptionService } from './encryption.service';
|
|
7
|
-
//# sourceMappingURL=main.d.ts.map
|
package/build/cjs/main.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,YAAY,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/build/cjs/main.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EncryptionService = exports.EncryptionModule = exports.EncryptionModuleOptionsProvide = exports.encryptAes256Gcm = exports.decryptAes256Gcm = void 0;
|
|
7
|
-
var aes_256_gcm_1 = require("./aes-256-gcm");
|
|
8
|
-
Object.defineProperty(exports, "decryptAes256Gcm", { enumerable: true, get: function () { return aes_256_gcm_1.decryptAes256Gcm; } });
|
|
9
|
-
Object.defineProperty(exports, "encryptAes256Gcm", { enumerable: true, get: function () { return aes_256_gcm_1.encryptAes256Gcm; } });
|
|
10
|
-
var encryption_const_1 = require("./encryption.const");
|
|
11
|
-
Object.defineProperty(exports, "EncryptionModuleOptionsProvide", { enumerable: true, get: function () { return encryption_const_1.EncryptionModuleOptionsProvide; } });
|
|
12
|
-
var encryption_module_1 = require("./encryption.module");
|
|
13
|
-
Object.defineProperty(exports, "EncryptionModule", { enumerable: true, get: function () { return encryption_module_1.EncryptionModule; } });
|
|
14
|
-
var encryption_service_1 = require("./encryption.service");
|
|
15
|
-
Object.defineProperty(exports, "EncryptionService", { enumerable: true, get: function () { return __importDefault(encryption_service_1).default; } });
|
|
16
|
-
//# sourceMappingURL=main.js.map
|
package/build/cjs/main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;;;;AACA,6CAAmE;AAA1D,+GAAA,gBAAgB,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AAC3C,uDAAoE;AAA3D,kIAAA,8BAA8B,OAAA;AAEvC,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,2DAAoE;AAA3D,wIAAA,OAAO,OAAqB"}
|
package/build/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "type": "commonjs" }
|