claudeunmask 1.0.30 → 1.0.31

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.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ // index.d.ts
2
+ export interface UnmaskResult {
3
+ data: any[];
4
+ errorCount: number;
5
+ unmaskCount: number;
6
+ }
7
+
8
+ export function unmaskData(
9
+ inData: any[],
10
+ decryptionKey: string,
11
+ dailyKey: string
12
+ ): Promise<UnmaskResult>;
13
+
14
+ export function deriveKeyFromPassword(
15
+ password: string,
16
+ salt: Uint8Array
17
+ ): Promise<CryptoKey>;
18
+
19
+ export function decryptThisData(
20
+ ciphertext: Uint8Array,
21
+ key: CryptoKey,
22
+ iv: Uint8Array
23
+ ): Promise<string>;
24
+
25
+ export function base64ToBytes(base64: string): Uint8Array;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* v 1.0.30 */
1
+ /* v 1.0.31 */
2
2
  // claudeunmask/index.js (or index.mjs)
3
3
  const crypto = typeof window !== 'undefined'
4
4
  ? window.crypto
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudeunmask",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "claude unmask test",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,5 +10,11 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "crypto-js": "^4.2.0"
13
- }
13
+ },
14
+ "types": "index.d.ts",
15
+ "files": [
16
+ "index.js",
17
+ "index.min.js",
18
+ "index.d.ts"
19
+ ]
14
20
  }
package/fromClaude.txt DELETED
@@ -1,127 +0,0 @@
1
- // claudeunmask/index.js (or index.mjs)
2
- const crypto = typeof window !== 'undefined'
3
- ? window.crypto
4
- : require('crypto').webcrypto;
5
-
6
- function base64ToBytes(base64) {
7
- if (typeof Buffer !== 'undefined') {
8
- // Node.js
9
- return new Uint8Array(Buffer.from(base64, 'base64'));
10
- } else {
11
- // Browser
12
- const binary = atob(base64);
13
- const bytes = new Uint8Array(binary.length);
14
- for (let i = 0; i < binary.length; i++) {
15
- bytes[i] = binary.charCodeAt(i);
16
- }
17
- return bytes;
18
- }
19
- }
20
-
21
- async function deriveKeyFromPassword(password, salt) {
22
- const encoder = new TextEncoder();
23
- const pwUtf8 = encoder.encode(password);
24
-
25
- const keyMaterial = await crypto.subtle.importKey(
26
- 'raw',
27
- pwUtf8,
28
- 'PBKDF2',
29
- false,
30
- ['deriveKey']
31
- );
32
-
33
- return await crypto.subtle.deriveKey(
34
- {
35
- name: 'PBKDF2',
36
- salt: salt,
37
- iterations: 100000,
38
- hash: 'SHA-256',
39
- },
40
- keyMaterial,
41
- { name: 'AES-GCM', length: 256 },
42
- true,
43
- ['encrypt', 'decrypt']
44
- );
45
- }
46
-
47
- async function decryptData(ciphertext, key, iv) {
48
- const decoder = new TextDecoder();
49
- const plaintextBuffer = await crypto.subtle.decrypt(
50
- { name: 'AES-GCM', iv },
51
- key,
52
- ciphertext
53
- );
54
- return decoder.decode(new Uint8Array(plaintextBuffer));
55
- }
56
-
57
- async function unmask(theData, encryptKey, dailyKey) {
58
- const retVal = {
59
- data: [],
60
- errorCount: 0,
61
- unmaskCount: 0
62
- };
63
-
64
- let [tmpPassword, salt, theIV] = encryptKey.split("-");
65
-
66
- // Try to decrypt the daily key (add padding if needed)
67
- let decryptedPassword = null;
68
- for (let ii = 0; ii <= 2; ii++) {
69
- try {
70
- const dailyKeyBinary = await deriveKeyFromPassword(
71
- dailyKey,
72
- base64ToBytes(salt)
73
- );
74
- decryptedPassword = await decryptData(
75
- base64ToBytes(tmpPassword),
76
- dailyKeyBinary,
77
- base64ToBytes(theIV)
78
- );
79
- break;
80
- } catch (error) {
81
- if (ii < 2) {
82
- dailyKey = dailyKey + '=';
83
- } else {
84
- throw new Error("Failed to decrypt the key");
85
- }
86
- }
87
- }
88
-
89
- const encryptionKey = await deriveKeyFromPassword(
90
- decryptedPassword,
91
- base64ToBytes(salt)
92
- );
93
-
94
- for (const curRec of theData) {
95
- const tmpRec = {};
96
- for (const [key, value] of Object.entries(curRec)) {
97
- try {
98
- if (typeof value === "string" && value.includes("m$k_")) {
99
- retVal.unmaskCount++;
100
- const tmpData = base64ToBytes(value.replace("m$k_", ""));
101
- tmpRec[key] = await decryptData(
102
- tmpData,
103
- encryptionKey,
104
- base64ToBytes(theIV)
105
- );
106
- } else {
107
- tmpRec[key] = value;
108
- }
109
- } catch (error) {
110
- tmpRec[key] = "failed";
111
- retVal.errorCount++;
112
- }
113
- }
114
- retVal.data.push(tmpRec);
115
- }
116
-
117
- return retVal;
118
- }
119
-
120
- // Export for both Node.js and browser
121
- if (typeof module !== 'undefined' && module.exports) {
122
- // Node.js
123
- module.exports = { unmask, deriveKeyFromPassword, decryptData, base64ToBytes };
124
- } else {
125
- // Browser
126
- window.claudeUnmask = { unmask, deriveKeyFromPassword, decryptData, base64ToBytes };
127
- }
package/notes.txt DELETED
@@ -1 +0,0 @@
1
- ECHO is on.