@meebon/meebon-crypto 1.2.13 → 1.2.15
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressEncryptionMiddleware.d.ts","sourceRoot":"","sources":["../lib/ExpressEncryptionMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;GAKG;AACH,iBAAS,oBAAoB,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"ExpressEncryptionMiddleware.d.ts","sourceRoot":"","sources":["../lib/ExpressEncryptionMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;GAKG;AACH,iBAAS,oBAAoB,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,cAAc,CAsC5F;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -83,9 +83,11 @@ function EncryptionMiddleware({ privateKey, publicKey }) {
|
|
|
83
83
|
return (req, res, next) => {
|
|
84
84
|
if (req.body && req.body.data) {
|
|
85
85
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (req.body.data) {
|
|
87
|
+
const plainText = JSON.stringify(req.body.data);
|
|
88
|
+
const encrypted = MeebonCrypto.encryptData(plainText, publicKey);
|
|
89
|
+
req.body.data = encrypted;
|
|
90
|
+
}
|
|
89
91
|
} catch (error) {
|
|
90
92
|
return next(new Error(error?.message || "Encryption failed."));
|
|
91
93
|
}
|
|
@@ -94,11 +96,13 @@ function EncryptionMiddleware({ privateKey, publicKey }) {
|
|
|
94
96
|
res.send = (body) => {
|
|
95
97
|
try {
|
|
96
98
|
if (typeof body === "string") {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if (body) {
|
|
100
|
+
const decrypted = MeebonCrypto.decryptData(body, privateKey);
|
|
101
|
+
try {
|
|
102
|
+
body = JSON.parse(decrypted);
|
|
103
|
+
} catch {
|
|
104
|
+
body = decrypted;
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meebon/meebon-crypto",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "kajalanS <103587022+kajalanS@users.noreply.github.com>",
|
|
6
6
|
"homepage": "https://github.com/KsoftmHub/meebon-crypto?tab=readme-ov-file#getting-started",
|