claudeunmask 1.0.20 → 1.0.21
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 +3 -3
- package/index.min.js +3 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* v 1.0.
|
|
1
|
+
/* v 1.0.21 */
|
|
2
2
|
function getMessageEncoding(message) {
|
|
3
3
|
return new TextEncoder().encode(message);
|
|
4
4
|
}
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
async function decryptData(inData, decryptionKey) {
|
|
65
65
|
var retVal = [];
|
|
66
66
|
var enc = new TextEncoder();
|
|
67
|
-
var [
|
|
68
|
-
|
|
67
|
+
var [tmpPassword, salt, theIV] = decryptionKey.split("-");
|
|
68
|
+
const password = tmpPassword.slice(2);
|
|
69
69
|
for (const curRec of inData) {
|
|
70
70
|
var tmpRec = {}
|
|
71
71
|
for (const [key, value] of Object.entries(curRec)) {
|
package/index.min.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
function getMessageEncoding(message){return new TextEncoder().encode(message);}
|
|
2
2
|
function getMessageDecoding(buffer){return new TextDecoder().decode(buffer);}
|
|
3
|
-
function base64ToBytes(base64){const binary=atob(base64);const bytes=new Uint8Array(binary.length);for(let i=0;i<binary.length;i++){bytes[i]=binary.charCodeAt(i);}
|
|
4
|
-
return bytes;}
|
|
3
|
+
function base64ToBytes(base64){const binary=atob(base64);const bytes=new Uint8Array(binary.length);for(let i=0;i<binary.length;i++){bytes[i]=binary.charCodeAt(i);}return bytes;}
|
|
5
4
|
function bytesToBase64(bytes){const binary=String.fromCharCode(...bytes);return btoa(binary);}
|
|
6
5
|
async function deriveKeyFromPassword(password,salt){const pwUtf8=getMessageEncoding(password);const keyMaterial=await crypto.subtle.importKey('raw',pwUtf8,'PBKDF2',false,['deriveKey']);const derivedKey=await crypto.subtle.deriveKey({name:'PBKDF2',salt:salt,iterations:100000,hash:'SHA-256',},keyMaterial,{name:'AES-GCM',length:256},true,['encrypt','decrypt']);return derivedKey;}
|
|
7
|
-
async function decryptThisData(ciphertext,key,iv){try{const plaintextBuffer=await crypto.subtle.decrypt({name:'AES-GCM',iv},key,ciphertext);return getMessageDecoding(new Uint8Array(plaintextBuffer));}catch(error){console.log("failed",key,ciphertext);return"Failed to decrypt";}
|
|
8
|
-
|
|
9
|
-
async function decryptData(inData,decryptionKey){var retVal=[];var enc=new TextEncoder();var[password,salt,theIV]=decryptionKey.split("-");for(const curRec of inData){var tmpRec={}
|
|
10
|
-
for(const[key,value]of Object.entries(curRec)){try{if(typeof value==="string"&&value.includes("m$k_")){var theData=base64ToBytes(curRec.secret_column.replace("m$k_",""));const encryptionKey=await deriveKeyFromPassword(password,base64ToBytes(salt));tmpRec[key]=await decryptThisData(theData,encryptionKey,base64ToBytes(theIV));}else{tmpRec[key]=value;}}catch(error){tmpRec[key]="failed";}}
|
|
11
|
-
retVal.push(tmpRec);}
|
|
12
|
-
return retVal;}
|
|
6
|
+
async function decryptThisData(ciphertext,key,iv){try{const plaintextBuffer=await crypto.subtle.decrypt({name:'AES-GCM',iv},key,ciphertext);return getMessageDecoding(new Uint8Array(plaintextBuffer));}catch(error){console.log("failed",key,ciphertext);return"Failed to decrypt";}return"";}
|
|
7
|
+
async function decryptData(inData,decryptionKey){var retVal=[];var enc=new TextEncoder();var[tmpPassword,salt,theIV]=decryptionKey.split("-");const password=tmpPassword.slice(2);for(const curRec of inData){var tmpRec={}for(const[key,value]of Object.entries(curRec)){try{if(typeof value==="string"&&value.includes("m$k_")){var theData=base64ToBytes(curRec.secret_column.replace("m$k_",""));const encryptionKey=await deriveKeyFromPassword(password,base64ToBytes(salt));tmpRec[key]=await decryptThisData(theData,encryptionKey,base64ToBytes(theIV));}else{tmpRec[key]=value;}}catch(error){tmpRec[key]="failed";}}retVal.push(tmpRec);}return retVal;}
|