@appconda/nextjs 1.0.89 → 1.0.90
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/lib/crypto.js +2 -1
- package/package.json +1 -1
- package/src/lib/crypto.ts +3 -1
package/dist/lib/crypto.js
CHANGED
@@ -4,7 +4,6 @@ import { getEnv } from "./env";
|
|
4
4
|
const ALGORITHM = "aes256";
|
5
5
|
const INPUT_ENCODING = "utf8";
|
6
6
|
const OUTPUT_ENCODING = "hex";
|
7
|
-
const BUFFER_ENCODING = getEnv().ENCRYPTION_KEY.length === 32 ? "latin1" : "hex";
|
8
7
|
const IV_LENGTH = 16; // AES blocksize
|
9
8
|
/**
|
10
9
|
*
|
@@ -14,6 +13,7 @@ const IV_LENGTH = 16; // AES blocksize
|
|
14
13
|
* @returns Encrypted value using key
|
15
14
|
*/
|
16
15
|
export const symmetricEncrypt = (text, key) => {
|
16
|
+
const BUFFER_ENCODING = getEnv().ENCRYPTION_KEY.length === 32 ? "latin1" : "hex";
|
17
17
|
const _key = Buffer.from(key, BUFFER_ENCODING);
|
18
18
|
const iv = crypto.randomBytes(IV_LENGTH);
|
19
19
|
// @ts-ignore -- the package needs to be built
|
@@ -29,6 +29,7 @@ export const symmetricEncrypt = (text, key) => {
|
|
29
29
|
* @param key Key used to decrypt value must be 32 bytes for AES256 encryption algorithm
|
30
30
|
*/
|
31
31
|
export const symmetricDecrypt = (text, key) => {
|
32
|
+
const BUFFER_ENCODING = getEnv().ENCRYPTION_KEY.length === 32 ? "latin1" : "hex";
|
32
33
|
const _key = Buffer.from(key, BUFFER_ENCODING);
|
33
34
|
const components = text.split(":");
|
34
35
|
const iv_from_ciphertext = Buffer.from(components.shift() || "", OUTPUT_ENCODING);
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@appconda/nextjs",
|
3
3
|
"homepage": "https://appconda.io/support",
|
4
4
|
"description": "Appconda is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
5
|
-
"version": "1.0.
|
5
|
+
"version": "1.0.90",
|
6
6
|
"license": "BSD-3-Clause",
|
7
7
|
"main": "dist/index.js",
|
8
8
|
"types": "dist/index.d.ts",
|
package/src/lib/crypto.ts
CHANGED
@@ -6,7 +6,7 @@ import { getEnv } from "./env";
|
|
6
6
|
const ALGORITHM = "aes256";
|
7
7
|
const INPUT_ENCODING = "utf8";
|
8
8
|
const OUTPUT_ENCODING = "hex";
|
9
|
-
|
9
|
+
|
10
10
|
const IV_LENGTH = 16; // AES blocksize
|
11
11
|
|
12
12
|
/**
|
@@ -17,6 +17,7 @@ const IV_LENGTH = 16; // AES blocksize
|
|
17
17
|
* @returns Encrypted value using key
|
18
18
|
*/
|
19
19
|
export const symmetricEncrypt = (text: string, key: string) => {
|
20
|
+
const BUFFER_ENCODING = getEnv().ENCRYPTION_KEY!.length === 32 ? "latin1" : "hex";
|
20
21
|
const _key = Buffer.from(key, BUFFER_ENCODING);
|
21
22
|
const iv = crypto.randomBytes(IV_LENGTH);
|
22
23
|
|
@@ -35,6 +36,7 @@ export const symmetricEncrypt = (text: string, key: string) => {
|
|
35
36
|
* @param key Key used to decrypt value must be 32 bytes for AES256 encryption algorithm
|
36
37
|
*/
|
37
38
|
export const symmetricDecrypt = (text: string, key: string) => {
|
39
|
+
const BUFFER_ENCODING = getEnv().ENCRYPTION_KEY!.length === 32 ? "latin1" : "hex";
|
38
40
|
const _key = Buffer.from(key, BUFFER_ENCODING);
|
39
41
|
|
40
42
|
const components = text.split(":");
|