claudeunmask 1.0.16 → 1.0.18
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/index.js +23 -19
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* v 1.0.
|
|
1
|
+
/* v 1.0.18 */
|
|
2
2
|
function getMessageEncoding(message) {
|
|
3
3
|
return new TextEncoder().encode(message);
|
|
4
4
|
}
|
|
@@ -49,13 +49,18 @@
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async function decryptThisData(ciphertext, key, iv) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
try {
|
|
53
|
+
const plaintextBuffer = await crypto.subtle.decrypt(
|
|
54
|
+
{ name: 'AES-GCM', iv },
|
|
55
|
+
key,
|
|
56
|
+
ciphertext
|
|
57
|
+
);
|
|
58
|
+
return getMessageDecoding(new Uint8Array(plaintextBuffer));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return "Failed to decrypt";
|
|
61
|
+
}
|
|
57
62
|
|
|
58
|
-
return
|
|
63
|
+
return "";
|
|
59
64
|
}
|
|
60
65
|
async function decryptData(inData, decryptionKey) {
|
|
61
66
|
var retVal = [];
|
|
@@ -64,22 +69,21 @@
|
|
|
64
69
|
|
|
65
70
|
for (const curRec of inData) {
|
|
66
71
|
var tmpRec = {}
|
|
67
|
-
console.log ("curRec", curRec);
|
|
68
72
|
for (const [key, value] of Object.entries(curRec)) {
|
|
69
|
-
|
|
73
|
+
try {
|
|
74
|
+
if (typeof value === "string" && value.includes("m$k_")) {
|
|
75
|
+
const theData = curRec.secret_column.replace ("m$k_", "");
|
|
76
|
+
const encryptionKey = await deriveKeyFromPassword(password, base64ToBytes(salt));
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
tmpRec[key] =
|
|
77
|
-
} else {
|
|
78
|
-
tmpRec[key] = value;
|
|
78
|
+
tmpRec[key] = await decryptThisData (theData, encryptionKey, base64ToBytes(theIV));
|
|
79
|
+
} else {
|
|
80
|
+
tmpRec[key] = value;
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {
|
|
83
|
+
tmpRec[key] = "failed";
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
retVal.push(tmpRec);
|
|
82
87
|
}
|
|
83
|
-
console.log ("retVal", JSON.stringify(retVal));
|
|
84
88
|
return retVal;
|
|
85
|
-
}
|
|
89
|
+
}
|