claudeunmask 1.0.23 → 1.0.25
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 +44 -6
- package/index.min.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* v 1.0.
|
|
1
|
+
/* v 1.0.25 */
|
|
2
2
|
function getMessageEncoding(message) {
|
|
3
3
|
return new TextEncoder().encode(message);
|
|
4
4
|
}
|
|
@@ -56,29 +56,67 @@
|
|
|
56
56
|
);
|
|
57
57
|
return getMessageDecoding(new Uint8Array(plaintextBuffer));
|
|
58
58
|
} catch (error) {
|
|
59
|
-
console.log ("failed", key, ciphertext);
|
|
59
|
+
console.log ("failed", key, ciphertext, error);
|
|
60
60
|
return "Failed to decrypt";
|
|
61
61
|
}
|
|
62
62
|
return "";
|
|
63
63
|
}
|
|
64
|
-
async function
|
|
64
|
+
async function decrypt(inData, decryptionKey) {
|
|
65
|
+
var dailyKey = await window.prompt("Enter the daily key","crazy_string");
|
|
66
|
+
console.log ("daily key", dailyKey);
|
|
65
67
|
var retVal = [];
|
|
66
68
|
var enc = new TextEncoder();
|
|
67
69
|
var [tmpPassword, salt, theIV] = decryptionKey.split("-");
|
|
68
|
-
|
|
70
|
+
console.log ("from MCP", decryptionKey, tmpPassword, salt, theIV);
|
|
71
|
+
const dailyKeyBinary = await deriveKeyFromPassword(dailyKey, base64ToBytes(salt));
|
|
72
|
+
tmpPassword = await decryptThisData (base64ToBytes(tmpPassword), dailyKeyBinary, base64ToBytes(theIV));
|
|
73
|
+
console.log ("secret:", tmpPassword);
|
|
74
|
+
const password = tmpPassword;
|
|
69
75
|
for (const curRec of inData) {
|
|
70
76
|
var tmpRec = {};
|
|
71
77
|
for (const [key, value] of Object.entries(curRec)) {
|
|
72
78
|
try {
|
|
73
79
|
if (typeof value === "string" && value.includes("m$k_")) {
|
|
74
|
-
|
|
80
|
+
console.log ("masked", value, curRec[key]);
|
|
81
|
+
var theData = base64ToBytes(curRec[key].replace ("m$k_", ""));
|
|
82
|
+
const encryptionKey = await deriveKeyFromPassword(password, base64ToBytes(salt));
|
|
83
|
+
tmpRec[key] = await decryptThisData (theData, encryptionKey, base64ToBytes(theIV));
|
|
84
|
+
} else {
|
|
85
|
+
tmpRec[key] = value;
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.log ("error", error);
|
|
89
|
+
tmpRec[key] = "failed";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
retVal.push(tmpRec);
|
|
93
|
+
}
|
|
94
|
+
return retVal;
|
|
95
|
+
}
|
|
96
|
+
async function unmask (inData, decryptionKey, dailyKey) {
|
|
97
|
+
console.log ("daily key", dailyKey);
|
|
98
|
+
var retVal = [];
|
|
99
|
+
var enc = new TextEncoder();
|
|
100
|
+
var [tmpPassword, salt, theIV] = decryptionKey.split("-");
|
|
101
|
+
console.log ("from MCP", decryptionKey, tmpPassword, salt, theIV);
|
|
102
|
+
const dailyKeyBinary = await deriveKeyFromPassword(dailyKey, base64ToBytes(salt));
|
|
103
|
+
tmpPassword = await decryptThisData (base64ToBytes(tmpPassword), dailyKeyBinary, base64ToBytes(theIV));
|
|
104
|
+
console.log ("secret:", tmpPassword);
|
|
105
|
+
const password = tmpPassword;
|
|
106
|
+
for (const curRec of inData) {
|
|
107
|
+
var tmpRec = {};
|
|
108
|
+
for (const [key, value] of Object.entries(curRec)) {
|
|
109
|
+
try {
|
|
110
|
+
if (typeof value === "string" && value.includes("m$k_")) {
|
|
111
|
+
console.log ("masked", value, curRec[key]);
|
|
112
|
+
var theData = base64ToBytes(curRec[key].replace ("m$k_", ""));
|
|
75
113
|
const encryptionKey = await deriveKeyFromPassword(password, base64ToBytes(salt));
|
|
76
|
-
|
|
77
114
|
tmpRec[key] = await decryptThisData (theData, encryptionKey, base64ToBytes(theIV));
|
|
78
115
|
} else {
|
|
79
116
|
tmpRec[key] = value;
|
|
80
117
|
}
|
|
81
118
|
} catch (error) {
|
|
119
|
+
console.log ("error", error);
|
|
82
120
|
tmpRec[key] = "failed";
|
|
83
121
|
}
|
|
84
122
|
}
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function getMessageEncoding(e){return new TextEncoder().encode(e)}function getMessageDecoding(e){return new TextDecoder().decode(e)}function base64ToBytes(e){let t=atob(e),
|
|
1
|
+
function getMessageEncoding(e){return new TextEncoder().encode(e)}function getMessageDecoding(e){return new TextDecoder().decode(e)}function base64ToBytes(e){let t=atob(e),a=new Uint8Array(t.length);for(let r=0;r<t.length;r++)a[r]=t.charCodeAt(r);return a}function bytesToBase64(e){let t=String.fromCharCode(...e);return btoa(t)}async function deriveKeyFromPassword(e,t){let a=getMessageEncoding(e),r=await crypto.subtle.importKey("raw",a,"PBKDF2",!1,["deriveKey"]),s=await crypto.subtle.deriveKey({name:"PBKDF2",salt:t,iterations:1e5,hash:"SHA-256"},r,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return s}async function decryptThisData(e,t,a){try{let r=await crypto.subtle.decrypt({name:"AES-GCM",iv:a},t,e);return getMessageDecoding(new Uint8Array(r))}catch(s){return console.log("failed",t,e,s),"Failed to decrypt"}return""}async function decrypt(e,t){var a=await window.prompt("Enter the daily key","crazy_string");console.log("daily key",a);var r=[];new TextEncoder;var[s,o,n]=t.split("-");console.log("from MCP",t,s,o,n);let i=await deriveKeyFromPassword(a,base64ToBytes(o));s=await decryptThisData(base64ToBytes(s),i,base64ToBytes(n)),console.log("secret:",s);let l=s;for(let y of e){var c={};for(let[d,g]of Object.entries(y))try{if("string"==typeof g&&g.includes("m$k_")){console.log("masked",g,y[d]);var f=base64ToBytes(y[d].replace("m$k_",""));let u=await deriveKeyFromPassword(l,base64ToBytes(o));c[d]=await decryptThisData(f,u,base64ToBytes(n))}else c[d]=g}catch(w){console.log("error",w),c[d]="failed"}r.push(c)}return r}async function unmask(e,t,a){console.log("daily key",a);var r=[];new TextEncoder;var[s,o,n]=t.split("-");console.log("from MCP",t,s,o,n);let i=await deriveKeyFromPassword(a,base64ToBytes(o));s=await decryptThisData(base64ToBytes(s),i,base64ToBytes(n)),console.log("secret:",s);let l=s;for(let y of e){var c={};for(let[d,g]of Object.entries(y))try{if("string"==typeof g&&g.includes("m$k_")){console.log("masked",g,y[d]);var f=base64ToBytes(y[d].replace("m$k_",""));let u=await deriveKeyFromPassword(l,base64ToBytes(o));c[d]=await decryptThisData(f,u,base64ToBytes(n))}else c[d]=g}catch(w){console.log("error",w),c[d]="failed"}r.push(c)}return r}
|