@maestro-js/crypt 1.0.0-alpha.20 → 1.0.0-alpha.22
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/index.js +8 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -17,10 +17,10 @@ function create(keysetInput) {
|
|
|
17
17
|
const cipher = crypto.createCipheriv("aes-256-gcm", Buffer.from(key.key, "base64"), iv);
|
|
18
18
|
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]).toString("base64");
|
|
19
19
|
const tag = cipher.getAuthTag().toString("base64");
|
|
20
|
-
return [key.id, iv, encrypted, tag].join(".");
|
|
20
|
+
return [key.id, iv.toString("base64"), encrypted, tag].join(".");
|
|
21
21
|
}
|
|
22
22
|
function encryptString(plaintext) {
|
|
23
|
-
const iv = crypto.randomBytes(12)
|
|
23
|
+
const iv = crypto.randomBytes(12);
|
|
24
24
|
return encrypt(primaryKey, iv, plaintext);
|
|
25
25
|
}
|
|
26
26
|
function decryptString(encryptedText) {
|
|
@@ -34,9 +34,13 @@ function create(keysetInput) {
|
|
|
34
34
|
throw new Error(`No key found matching id "${key}"`);
|
|
35
35
|
}
|
|
36
36
|
let err;
|
|
37
|
-
for (
|
|
37
|
+
for (const decipherKey of matchingKeys) {
|
|
38
38
|
try {
|
|
39
|
-
const decipher = crypto.createDecipheriv(
|
|
39
|
+
const decipher = crypto.createDecipheriv(
|
|
40
|
+
"aes-256-gcm",
|
|
41
|
+
Buffer.from(decipherKey.key, "base64"),
|
|
42
|
+
Buffer.from(iv, "base64")
|
|
43
|
+
);
|
|
40
44
|
decipher.setAuthTag(Buffer.from(tag, "base64"));
|
|
41
45
|
let plaintext = decipher.update(encrypted, "base64", "utf8");
|
|
42
46
|
plaintext += decipher.final("utf8");
|
package/package.json
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@maestro-js/service-registry": "1.0.0-alpha.
|
|
12
|
+
"@maestro-js/service-registry": "1.0.0-alpha.22"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^22.9.0"
|
|
16
16
|
},
|
|
17
|
-
"version": "1.0.0-alpha.
|
|
17
|
+
"version": "1.0.0-alpha.22",
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "restricted"
|
|
20
20
|
},
|