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.
Files changed (2) hide show
  1. package/index.js +23 -19
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* v 1.0.16 */
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
- const plaintextBuffer = await crypto.subtle.decrypt(
53
- { name: 'AES-GCM', iv },
54
- key,
55
- ciphertext
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 getMessageDecoding(new Uint8Array(plaintextBuffer));
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
- console.log ("Key, value", key, value);
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
- if (typeof value === "string" && value.includes("m$k_")) {
72
- const tmpData = curRec.secret_column.replace ("m$k_", "");
73
- const theData = base64ToBytes(tmpData.split('-')[0]);
74
- const encryptionKey = await deriveKeyFromPassword(password, base64ToBytes(salt));
75
-
76
- tmpRec[key] = await decryptThisData (theData, encryptionKey, theIV);
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudeunmask",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "claude unmask test",
5
5
  "main": "index.js",
6
6
  "scripts": {