claudeunmask 1.0.1 → 1.0.3
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 - Copy.js +19 -0
- package/index.js +76 -12
- package/notes.txt +1 -0
- package/package.json +5 -2
package/index - Copy.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
function unmask (theData) {
|
|
3
|
+
var retVal = [];
|
|
4
|
+
for (curRow of theData) {
|
|
5
|
+
var retRow = {};
|
|
6
|
+
for (const [key, value] of Object.entries(curRow)) {
|
|
7
|
+
let newValue = value;
|
|
8
|
+
|
|
9
|
+
if (newValue.startsWith ("m$k_")) {
|
|
10
|
+
newValue = newValue.replace ("m$k_","");
|
|
11
|
+
newValue = newValue.split('').reverse().join('');
|
|
12
|
+
}
|
|
13
|
+
retRow[key] = newValue;
|
|
14
|
+
}
|
|
15
|
+
retVal.push (retRow);
|
|
16
|
+
}
|
|
17
|
+
console.log ("hello from unmask", retVal);
|
|
18
|
+
return retVal;
|
|
19
|
+
}
|
package/index.js
CHANGED
|
@@ -1,19 +1,83 @@
|
|
|
1
|
+
function getMessageEncoding(message) {
|
|
2
|
+
return new TextEncoder().encode(message);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function getMessageDecoding(buffer) {
|
|
6
|
+
return new TextDecoder().decode(buffer);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function base64ToBytes(base64) {
|
|
10
|
+
const binary = atob(base64);
|
|
11
|
+
const bytes = new Uint8Array(binary.length);
|
|
12
|
+
for (let i = 0; i < binary.length; i++) {
|
|
13
|
+
bytes[i] = binary.charCodeAt(i);
|
|
14
|
+
}
|
|
15
|
+
return bytes;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function bytesToBase64(bytes) {
|
|
19
|
+
const binary = String.fromCharCode(...bytes);
|
|
20
|
+
return btoa(binary);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function deriveKeyFromPassword(password, salt) {
|
|
24
|
+
const pwUtf8 = getMessageEncoding(password);
|
|
1
25
|
|
|
2
|
-
|
|
26
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
27
|
+
'raw',
|
|
28
|
+
pwUtf8,
|
|
29
|
+
'PBKDF2',
|
|
30
|
+
false,
|
|
31
|
+
['deriveKey']
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const derivedKey = await crypto.subtle.deriveKey(
|
|
35
|
+
{
|
|
36
|
+
name: 'PBKDF2',
|
|
37
|
+
salt: salt,
|
|
38
|
+
iterations: 100000,
|
|
39
|
+
hash: 'SHA-256',
|
|
40
|
+
},
|
|
41
|
+
keyMaterial,
|
|
42
|
+
{ name: 'AES-GCM', length: 256 },
|
|
43
|
+
true,
|
|
44
|
+
['encrypt', 'decrypt']
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return derivedKey;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function decryptThisData(ciphertext, key, iv) {
|
|
51
|
+
const plaintextBuffer = await crypto.subtle.decrypt(
|
|
52
|
+
{ name: 'AES-GCM', iv },
|
|
53
|
+
key,
|
|
54
|
+
ciphertext
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return getMessageDecoding(new Uint8Array(plaintextBuffer));
|
|
58
|
+
}
|
|
59
|
+
async function decryptData(inData) {
|
|
60
|
+
console.log ("hello from decryptData!");
|
|
3
61
|
var retVal = [];
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
62
|
+
var enc = new TextEncoder();
|
|
63
|
+
const password = "a-strong-password-123";
|
|
64
|
+
|
|
65
|
+
for (const curRec of inData) {
|
|
66
|
+
var tmpRec = {}
|
|
67
|
+
for (const [key, value] of Object.entries(curRec)) {
|
|
68
|
+
if (value.includes("m$k_")) {
|
|
69
|
+
const tmpData = curRec.secret_column.replace ("m$k_", "");
|
|
70
|
+
const theData = base64ToBytes(tmpData.split('-')[0]);
|
|
71
|
+
const theIV = base64ToBytes(tmpData.split('-')[1]);
|
|
72
|
+
const salt = base64ToBytes(tmpData.split('-')[2]);
|
|
73
|
+
const encryptionKey = await deriveKeyFromPassword(password, salt);
|
|
74
|
+
|
|
75
|
+
tmpRec[key] = await decryptThisData (theData, encryptionKey, theIV);
|
|
76
|
+
} else {
|
|
77
|
+
tmpRec[key] = value;
|
|
12
78
|
}
|
|
13
|
-
retRow[key] = newValue;
|
|
14
79
|
}
|
|
15
|
-
retVal.push
|
|
80
|
+
retVal.push(tmpRec);
|
|
16
81
|
}
|
|
17
|
-
console.log ("hello from unmask", retVal);
|
|
18
82
|
return retVal;
|
|
19
83
|
}
|
package/notes.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ECHO is on.
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudeunmask",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "claude unmask test",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"author": "me",
|
|
10
|
-
"license": "ISC"
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"crypto-js": "^4.2.0"
|
|
13
|
+
}
|
|
11
14
|
}
|