react-native-inapp-inspector 2.3.6 → 2.3.7

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.
@@ -1,7 +1,3 @@
1
- export declare const ENC_MID = "029e338afbbf509e97b2ea5b";
2
- export declare const ENC_MID_IV = "9a6d6b4d732f07bedbe40229";
3
- export declare const ENC_MID_TAG = "e545372ce1ad53c593394a2c0281c75d";
4
- export declare const ENC_SEC = "7e95ab688f1b37f9b72d3ab70c9d92105e5bd7046e84";
5
- export declare const ENC_SEC_IV = "64a3aa1ee24005449e885c08";
6
- export declare const ENC_SEC_TAG = "007ce86e096dfb0ed902678902754f71";
1
+ export declare const ENC_MID = "df8ace0290a695bd05986213";
2
+ export declare const ENC_SEC = "db93cb0186b1f7bb0ba63a0d0a64997586849455ce37";
7
3
  export declare const TELEMETRY_SALT = "rn-inapp-inspector-telemetry-v1";
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TELEMETRY_SALT = exports.ENC_SEC_TAG = exports.ENC_SEC_IV = exports.ENC_SEC = exports.ENC_MID_TAG = exports.ENC_MID_IV = exports.ENC_MID = void 0;
4
- exports.ENC_MID = '029e338afbbf509e97b2ea5b';
5
- exports.ENC_MID_IV = '9a6d6b4d732f07bedbe40229';
6
- exports.ENC_MID_TAG = 'e545372ce1ad53c593394a2c0281c75d';
7
- exports.ENC_SEC = '7e95ab688f1b37f9b72d3ab70c9d92105e5bd7046e84';
8
- exports.ENC_SEC_IV = '64a3aa1ee24005449e885c08';
9
- exports.ENC_SEC_TAG = '007ce86e096dfb0ed902678902754f71';
3
+ exports.TELEMETRY_SALT = exports.ENC_SEC = exports.ENC_MID = void 0;
4
+ exports.ENC_MID = 'df8ace0290a695bd05986213';
5
+ exports.ENC_SEC = 'db93cb0186b1f7bb0ba63a0d0a64997586849455ce37';
10
6
  exports.TELEMETRY_SALT = 'rn-inapp-inspector-telemetry-v1';
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "2.3.6";
1
+ export declare const LIB_VERSION = "2.3.7";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIB_VERSION = void 0;
4
- exports.LIB_VERSION = '2.3.6';
4
+ exports.LIB_VERSION = '2.3.7';
@@ -7,197 +7,33 @@ const version_1 = require("../constants/version");
7
7
  const settingsStore_1 = require("./settingsStore");
8
8
  const telemetryConfig_1 = require("../constants/telemetryConfig");
9
9
  const PKG_NAME = 'react-native-inapp-inspector';
10
- const PKG_REPO = 'git+https://github.com/vengatmacuser/react-native-inapp-inspector.git';
11
- function sha256Hex(input) {
12
- const K = [
13
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
14
- 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
15
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
16
- 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
17
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
18
- 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
19
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
20
- 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
21
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
22
- 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
23
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
24
- ];
25
- function rr(n, x) {
26
- return ((n >>> x) | (n << (32 - x))) >>> 0;
27
- }
28
- const bytes = [];
29
- for (let i = 0; i < input.length; i++) {
30
- const c = input.charCodeAt(i);
31
- if (c < 0x80)
32
- bytes.push(c);
33
- else if (c < 0x800) {
34
- bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
35
- }
36
- else {
37
- bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
38
- }
39
- }
40
- const bitLen = bytes.length * 8;
41
- bytes.push(0x80);
42
- while (bytes.length % 64 !== 56)
43
- bytes.push(0);
44
- for (let i = 56; i >= 0; i -= 8) {
45
- bytes.push((bitLen >>> i) & 0xff);
46
- }
47
- let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a;
48
- let h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
49
- for (let offset = 0; offset < bytes.length; offset += 64) {
50
- const w = new Array(64);
51
- for (let i = 0; i < 16; i++) {
52
- w[i] = ((bytes[offset + i * 4] << 24) | (bytes[offset + i * 4 + 1] << 16) |
53
- (bytes[offset + i * 4 + 2] << 8) | bytes[offset + i * 4 + 3]) >>> 0;
54
- }
55
- for (let i = 16; i < 64; i++) {
56
- const s0 = rr(w[i - 15], 7) ^ rr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
57
- const s1 = rr(w[i - 2], 17) ^ rr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
58
- w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
59
- }
60
- let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
61
- for (let i = 0; i < 64; i++) {
62
- const S1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25);
63
- const ch = (e & f) ^ (~e & g);
64
- const temp1 = (h + S1 + ch + K[i] + w[i]) >>> 0;
65
- const S0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22);
66
- const maj = (a & b) ^ (a & c) ^ (b & c);
67
- const temp2 = (S0 + maj) >>> 0;
68
- h = g;
69
- g = f;
70
- f = e;
71
- e = (d + temp1) >>> 0;
72
- d = c;
73
- c = b;
74
- b = a;
75
- a = (temp1 + temp2) >>> 0;
76
- }
77
- h0 = (h0 + a) >>> 0;
78
- h1 = (h1 + b) >>> 0;
79
- h2 = (h2 + c) >>> 0;
80
- h3 = (h3 + d) >>> 0;
81
- h4 = (h4 + e) >>> 0;
82
- h5 = (h5 + f) >>> 0;
83
- h6 = (h6 + g) >>> 0;
84
- h7 = (h7 + h) >>> 0;
85
- }
86
- function toHex(n) {
87
- return ('00000000' + n.toString(16)).slice(-8);
88
- }
89
- return toHex(h0) + toHex(h1) + toHex(h2) + toHex(h3) + toHex(h4) + toHex(h5) + toHex(h6) + toHex(h7);
10
+ const KEY_MATERIAL = `${PKG_NAME}::${telemetryConfig_1.TELEMETRY_SALT}`;
11
+ function getKeystream(material, length) {
12
+ const stream = [];
13
+ let acc = 0x5a827999;
14
+ for (let i = 0; i < length; i++) {
15
+ const charCode = material.charCodeAt(i % material.length);
16
+ acc = ((acc * 31 + charCode * 17 + i * 13) ^ (acc >>> 7)) & 0xffffffff;
17
+ stream.push((acc >>> (i % 24)) & 0xff);
18
+ }
19
+ return stream;
90
20
  }
91
- function hexToBytes(hex) {
21
+ function deobfuscate(hexStr) {
22
+ if (!hexStr)
23
+ return '';
92
24
  const bytes = [];
93
- for (let i = 0; i < hex.length; i += 2) {
94
- bytes.push(parseInt(hex.substring(i, i + 2), 16));
95
- }
96
- return bytes;
97
- }
98
- function aesGcmDecrypt(ctHex, ivHex, _tagHex, keyHex) {
99
- const keyBytes = hexToBytes(keyHex);
100
- const ivBytes = hexToBytes(ivHex);
101
- const ctBytes = hexToBytes(ctHex);
102
- const Sbox = [
103
- 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
104
- 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
105
- 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
106
- 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
107
- 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
108
- 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
109
- 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
110
- 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
111
- 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
112
- 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
113
- 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
114
- 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
115
- 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
116
- 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
117
- 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
118
- 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16,
119
- ];
120
- const Rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
121
- const Nk = 8, Nr = 14;
122
- const expandedKey = new Uint8Array(4 * 4 * (Nr + 1));
123
- for (let i = 0; i < 32; i++)
124
- expandedKey[i] = keyBytes[i];
125
- for (let i = Nk; i < 4 * (Nr + 1); i++) {
126
- const t = expandedKey.slice((i - 1) * 4, i * 4);
127
- if (i % Nk === 0) {
128
- const tmp = t[0];
129
- t[0] = Sbox[t[1]] ^ Rcon[i / Nk - 1];
130
- t[1] = Sbox[t[2]];
131
- t[2] = Sbox[t[3]];
132
- t[3] = Sbox[tmp];
133
- }
134
- else if (Nk > 6 && i % Nk === 4) {
135
- t[0] = Sbox[t[0]];
136
- t[1] = Sbox[t[1]];
137
- t[2] = Sbox[t[2]];
138
- t[3] = Sbox[t[3]];
139
- }
140
- for (let j = 0; j < 4; j++) {
141
- expandedKey[i * 4 + j] = expandedKey[(i - Nk) * 4 + j] ^ t[j];
142
- }
143
- }
144
- function aesEncryptBlock(block) {
145
- const state = new Uint8Array(16);
146
- for (let i = 0; i < 16; i++)
147
- state[i] = block[i] ^ expandedKey[i];
148
- for (let round = 1; round <= Nr; round++) {
149
- for (let i = 0; i < 16; i++)
150
- state[i] = Sbox[state[i]];
151
- let t = state[1];
152
- state[1] = state[5];
153
- state[5] = state[9];
154
- state[9] = state[13];
155
- state[13] = t;
156
- t = state[2];
157
- state[2] = state[10];
158
- state[10] = t;
159
- t = state[6];
160
- state[6] = state[14];
161
- state[14] = t;
162
- t = state[15];
163
- state[15] = state[11];
164
- state[11] = state[7];
165
- state[7] = state[3];
166
- state[3] = t;
167
- if (round < Nr) {
168
- for (let c = 0; c < 4; c++) {
169
- const s0 = state[c * 4], s1 = state[c * 4 + 1], s2 = state[c * 4 + 2], s3 = state[c * 4 + 3];
170
- const xtime = (v) => ((v << 1) ^ ((v & 0x80) ? 0x1b : 0)) & 0xff;
171
- state[c * 4] = xtime(s0) ^ xtime(s1) ^ s1 ^ s2 ^ s3;
172
- state[c * 4 + 1] = s0 ^ xtime(s1) ^ xtime(s2) ^ s2 ^ s3;
173
- state[c * 4 + 2] = s0 ^ s1 ^ xtime(s2) ^ xtime(s3) ^ s3;
174
- state[c * 4 + 3] = xtime(s0) ^ s0 ^ s1 ^ s2 ^ xtime(s3);
175
- }
176
- }
177
- const rkOffset = round * 16;
178
- for (let i = 0; i < 16; i++)
179
- state[i] ^= expandedKey[rkOffset + i];
180
- }
181
- return state;
182
- }
183
- const result = [];
184
- let counter = 2;
185
- for (let i = 0; i < ctBytes.length; i += 16) {
186
- const counterBlock = new Uint8Array(16);
187
- for (let j = 0; j < 12; j++)
188
- counterBlock[j] = ivBytes[j];
189
- counterBlock[12] = (counter >>> 24) & 0xff;
190
- counterBlock[13] = (counter >>> 16) & 0xff;
191
- counterBlock[14] = (counter >>> 8) & 0xff;
192
- counterBlock[15] = counter & 0xff;
193
- counter++;
194
- const keystream = aesEncryptBlock(counterBlock);
195
- const blockLen = Math.min(16, ctBytes.length - i);
196
- for (let j = 0; j < blockLen; j++) {
197
- result.push(ctBytes[i + j] ^ keystream[j]);
198
- }
199
- }
200
- return String.fromCharCode(...result);
25
+ for (let i = 0; i < hexStr.length; i += 2) {
26
+ bytes.push(parseInt(hexStr.substring(i, i + 2), 16));
27
+ }
28
+ const keystream = getKeystream(KEY_MATERIAL, bytes.length);
29
+ const out = [];
30
+ for (let i = 0; i < bytes.length; i++) {
31
+ const k = keystream[i];
32
+ const s = telemetryConfig_1.TELEMETRY_SALT.charCodeAt(i % telemetryConfig_1.TELEMETRY_SALT.length);
33
+ const dec = (bytes[i] ^ k ^ s) & 0xff;
34
+ out.push(String.fromCharCode(dec));
35
+ }
36
+ return out.join('');
201
37
  }
202
38
  let _cachedMid = null;
203
39
  let _cachedSec = null;
@@ -211,10 +47,8 @@ function getCredentials() {
211
47
  return { measurementId: '', apiSecret: '' };
212
48
  }
213
49
  try {
214
- const keyMaterial = `${PKG_NAME}::${telemetryConfig_1.TELEMETRY_SALT}::${PKG_REPO}`;
215
- const keyHex = sha256Hex(keyMaterial);
216
- _cachedMid = aesGcmDecrypt(telemetryConfig_1.ENC_MID, telemetryConfig_1.ENC_MID_IV, telemetryConfig_1.ENC_MID_TAG, keyHex);
217
- _cachedSec = aesGcmDecrypt(telemetryConfig_1.ENC_SEC, telemetryConfig_1.ENC_SEC_IV, telemetryConfig_1.ENC_SEC_TAG, keyHex);
50
+ _cachedMid = deobfuscate(telemetryConfig_1.ENC_MID);
51
+ _cachedSec = deobfuscate(telemetryConfig_1.ENC_SEC);
218
52
  }
219
53
  catch {
220
54
  _cachedMid = '';
@@ -1,7 +1,3 @@
1
- export declare const ENC_MID = "029e338afbbf509e97b2ea5b";
2
- export declare const ENC_MID_IV = "9a6d6b4d732f07bedbe40229";
3
- export declare const ENC_MID_TAG = "e545372ce1ad53c593394a2c0281c75d";
4
- export declare const ENC_SEC = "7e95ab688f1b37f9b72d3ab70c9d92105e5bd7046e84";
5
- export declare const ENC_SEC_IV = "64a3aa1ee24005449e885c08";
6
- export declare const ENC_SEC_TAG = "007ce86e096dfb0ed902678902754f71";
1
+ export declare const ENC_MID = "df8ace0290a695bd05986213";
2
+ export declare const ENC_SEC = "db93cb0186b1f7bb0ba63a0d0a64997586849455ce37";
7
3
  export declare const TELEMETRY_SALT = "rn-inapp-inspector-telemetry-v1";
@@ -1,7 +1,3 @@
1
- export const ENC_MID = '029e338afbbf509e97b2ea5b';
2
- export const ENC_MID_IV = '9a6d6b4d732f07bedbe40229';
3
- export const ENC_MID_TAG = 'e545372ce1ad53c593394a2c0281c75d';
4
- export const ENC_SEC = '7e95ab688f1b37f9b72d3ab70c9d92105e5bd7046e84';
5
- export const ENC_SEC_IV = '64a3aa1ee24005449e885c08';
6
- export const ENC_SEC_TAG = '007ce86e096dfb0ed902678902754f71';
1
+ export const ENC_MID = 'df8ace0290a695bd05986213';
2
+ export const ENC_SEC = 'db93cb0186b1f7bb0ba63a0d0a64997586849455ce37';
7
3
  export const TELEMETRY_SALT = 'rn-inapp-inspector-telemetry-v1';
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "2.3.6";
1
+ export declare const LIB_VERSION = "2.3.7";
@@ -1 +1 @@
1
- export const LIB_VERSION = '2.3.6';
1
+ export const LIB_VERSION = '2.3.7';
@@ -1,199 +1,35 @@
1
1
  import { Platform } from 'react-native';
2
2
  import { LIB_VERSION } from '../constants/version';
3
3
  import { loadSettings, saveSettings } from './settingsStore';
4
- import { ENC_MID, ENC_MID_IV, ENC_MID_TAG, ENC_SEC, ENC_SEC_IV, ENC_SEC_TAG, TELEMETRY_SALT, } from '../constants/telemetryConfig';
4
+ import { ENC_MID, ENC_SEC, TELEMETRY_SALT, } from '../constants/telemetryConfig';
5
5
  const PKG_NAME = 'react-native-inapp-inspector';
6
- const PKG_REPO = 'git+https://github.com/vengatmacuser/react-native-inapp-inspector.git';
7
- function sha256Hex(input) {
8
- const K = [
9
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
10
- 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
11
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
12
- 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
13
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
14
- 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
15
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
16
- 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
17
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
18
- 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
19
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
20
- ];
21
- function rr(n, x) {
22
- return ((n >>> x) | (n << (32 - x))) >>> 0;
23
- }
24
- const bytes = [];
25
- for (let i = 0; i < input.length; i++) {
26
- const c = input.charCodeAt(i);
27
- if (c < 0x80)
28
- bytes.push(c);
29
- else if (c < 0x800) {
30
- bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
31
- }
32
- else {
33
- bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
34
- }
35
- }
36
- const bitLen = bytes.length * 8;
37
- bytes.push(0x80);
38
- while (bytes.length % 64 !== 56)
39
- bytes.push(0);
40
- for (let i = 56; i >= 0; i -= 8) {
41
- bytes.push((bitLen >>> i) & 0xff);
42
- }
43
- let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a;
44
- let h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
45
- for (let offset = 0; offset < bytes.length; offset += 64) {
46
- const w = new Array(64);
47
- for (let i = 0; i < 16; i++) {
48
- w[i] = ((bytes[offset + i * 4] << 24) | (bytes[offset + i * 4 + 1] << 16) |
49
- (bytes[offset + i * 4 + 2] << 8) | bytes[offset + i * 4 + 3]) >>> 0;
50
- }
51
- for (let i = 16; i < 64; i++) {
52
- const s0 = rr(w[i - 15], 7) ^ rr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
53
- const s1 = rr(w[i - 2], 17) ^ rr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
54
- w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
55
- }
56
- let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
57
- for (let i = 0; i < 64; i++) {
58
- const S1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25);
59
- const ch = (e & f) ^ (~e & g);
60
- const temp1 = (h + S1 + ch + K[i] + w[i]) >>> 0;
61
- const S0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22);
62
- const maj = (a & b) ^ (a & c) ^ (b & c);
63
- const temp2 = (S0 + maj) >>> 0;
64
- h = g;
65
- g = f;
66
- f = e;
67
- e = (d + temp1) >>> 0;
68
- d = c;
69
- c = b;
70
- b = a;
71
- a = (temp1 + temp2) >>> 0;
72
- }
73
- h0 = (h0 + a) >>> 0;
74
- h1 = (h1 + b) >>> 0;
75
- h2 = (h2 + c) >>> 0;
76
- h3 = (h3 + d) >>> 0;
77
- h4 = (h4 + e) >>> 0;
78
- h5 = (h5 + f) >>> 0;
79
- h6 = (h6 + g) >>> 0;
80
- h7 = (h7 + h) >>> 0;
81
- }
82
- function toHex(n) {
83
- return ('00000000' + n.toString(16)).slice(-8);
84
- }
85
- return toHex(h0) + toHex(h1) + toHex(h2) + toHex(h3) + toHex(h4) + toHex(h5) + toHex(h6) + toHex(h7);
6
+ const KEY_MATERIAL = `${PKG_NAME}::${TELEMETRY_SALT}`;
7
+ function getKeystream(material, length) {
8
+ const stream = [];
9
+ let acc = 0x5a827999;
10
+ for (let i = 0; i < length; i++) {
11
+ const charCode = material.charCodeAt(i % material.length);
12
+ acc = ((acc * 31 + charCode * 17 + i * 13) ^ (acc >>> 7)) & 0xffffffff;
13
+ stream.push((acc >>> (i % 24)) & 0xff);
14
+ }
15
+ return stream;
86
16
  }
87
- function hexToBytes(hex) {
17
+ function deobfuscate(hexStr) {
18
+ if (!hexStr)
19
+ return '';
88
20
  const bytes = [];
89
- for (let i = 0; i < hex.length; i += 2) {
90
- bytes.push(parseInt(hex.substring(i, i + 2), 16));
91
- }
92
- return bytes;
93
- }
94
- function aesGcmDecrypt(ctHex, ivHex, _tagHex, keyHex) {
95
- const keyBytes = hexToBytes(keyHex);
96
- const ivBytes = hexToBytes(ivHex);
97
- const ctBytes = hexToBytes(ctHex);
98
- const Sbox = [
99
- 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
100
- 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
101
- 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
102
- 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
103
- 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
104
- 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
105
- 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
106
- 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
107
- 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
108
- 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
109
- 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
110
- 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
111
- 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
112
- 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
113
- 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
114
- 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16,
115
- ];
116
- const Rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
117
- const Nk = 8, Nr = 14;
118
- const expandedKey = new Uint8Array(4 * 4 * (Nr + 1));
119
- for (let i = 0; i < 32; i++)
120
- expandedKey[i] = keyBytes[i];
121
- for (let i = Nk; i < 4 * (Nr + 1); i++) {
122
- const t = expandedKey.slice((i - 1) * 4, i * 4);
123
- if (i % Nk === 0) {
124
- const tmp = t[0];
125
- t[0] = Sbox[t[1]] ^ Rcon[i / Nk - 1];
126
- t[1] = Sbox[t[2]];
127
- t[2] = Sbox[t[3]];
128
- t[3] = Sbox[tmp];
129
- }
130
- else if (Nk > 6 && i % Nk === 4) {
131
- t[0] = Sbox[t[0]];
132
- t[1] = Sbox[t[1]];
133
- t[2] = Sbox[t[2]];
134
- t[3] = Sbox[t[3]];
135
- }
136
- for (let j = 0; j < 4; j++) {
137
- expandedKey[i * 4 + j] = expandedKey[(i - Nk) * 4 + j] ^ t[j];
138
- }
139
- }
140
- function aesEncryptBlock(block) {
141
- const state = new Uint8Array(16);
142
- for (let i = 0; i < 16; i++)
143
- state[i] = block[i] ^ expandedKey[i];
144
- for (let round = 1; round <= Nr; round++) {
145
- for (let i = 0; i < 16; i++)
146
- state[i] = Sbox[state[i]];
147
- let t = state[1];
148
- state[1] = state[5];
149
- state[5] = state[9];
150
- state[9] = state[13];
151
- state[13] = t;
152
- t = state[2];
153
- state[2] = state[10];
154
- state[10] = t;
155
- t = state[6];
156
- state[6] = state[14];
157
- state[14] = t;
158
- t = state[15];
159
- state[15] = state[11];
160
- state[11] = state[7];
161
- state[7] = state[3];
162
- state[3] = t;
163
- if (round < Nr) {
164
- for (let c = 0; c < 4; c++) {
165
- const s0 = state[c * 4], s1 = state[c * 4 + 1], s2 = state[c * 4 + 2], s3 = state[c * 4 + 3];
166
- const xtime = (v) => ((v << 1) ^ ((v & 0x80) ? 0x1b : 0)) & 0xff;
167
- state[c * 4] = xtime(s0) ^ xtime(s1) ^ s1 ^ s2 ^ s3;
168
- state[c * 4 + 1] = s0 ^ xtime(s1) ^ xtime(s2) ^ s2 ^ s3;
169
- state[c * 4 + 2] = s0 ^ s1 ^ xtime(s2) ^ xtime(s3) ^ s3;
170
- state[c * 4 + 3] = xtime(s0) ^ s0 ^ s1 ^ s2 ^ xtime(s3);
171
- }
172
- }
173
- const rkOffset = round * 16;
174
- for (let i = 0; i < 16; i++)
175
- state[i] ^= expandedKey[rkOffset + i];
176
- }
177
- return state;
178
- }
179
- const result = [];
180
- let counter = 2;
181
- for (let i = 0; i < ctBytes.length; i += 16) {
182
- const counterBlock = new Uint8Array(16);
183
- for (let j = 0; j < 12; j++)
184
- counterBlock[j] = ivBytes[j];
185
- counterBlock[12] = (counter >>> 24) & 0xff;
186
- counterBlock[13] = (counter >>> 16) & 0xff;
187
- counterBlock[14] = (counter >>> 8) & 0xff;
188
- counterBlock[15] = counter & 0xff;
189
- counter++;
190
- const keystream = aesEncryptBlock(counterBlock);
191
- const blockLen = Math.min(16, ctBytes.length - i);
192
- for (let j = 0; j < blockLen; j++) {
193
- result.push(ctBytes[i + j] ^ keystream[j]);
194
- }
195
- }
196
- return String.fromCharCode(...result);
21
+ for (let i = 0; i < hexStr.length; i += 2) {
22
+ bytes.push(parseInt(hexStr.substring(i, i + 2), 16));
23
+ }
24
+ const keystream = getKeystream(KEY_MATERIAL, bytes.length);
25
+ const out = [];
26
+ for (let i = 0; i < bytes.length; i++) {
27
+ const k = keystream[i];
28
+ const s = TELEMETRY_SALT.charCodeAt(i % TELEMETRY_SALT.length);
29
+ const dec = (bytes[i] ^ k ^ s) & 0xff;
30
+ out.push(String.fromCharCode(dec));
31
+ }
32
+ return out.join('');
197
33
  }
198
34
  let _cachedMid = null;
199
35
  let _cachedSec = null;
@@ -207,10 +43,8 @@ function getCredentials() {
207
43
  return { measurementId: '', apiSecret: '' };
208
44
  }
209
45
  try {
210
- const keyMaterial = `${PKG_NAME}::${TELEMETRY_SALT}::${PKG_REPO}`;
211
- const keyHex = sha256Hex(keyMaterial);
212
- _cachedMid = aesGcmDecrypt(ENC_MID, ENC_MID_IV, ENC_MID_TAG, keyHex);
213
- _cachedSec = aesGcmDecrypt(ENC_SEC, ENC_SEC_IV, ENC_SEC_TAG, keyHex);
46
+ _cachedMid = deobfuscate(ENC_MID);
47
+ _cachedSec = deobfuscate(ENC_SEC);
214
48
  }
215
49
  catch {
216
50
  _cachedMid = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-inapp-inspector",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "description": "The zero-config, all-in-one in-app debugger for React Native & Expo. Inspect Network (fetch/axios), Console logs, Stack Traces, Redux State, Firebase Analytics, and JS Bundle size directly on device.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,16 +1,6 @@
1
1
  // AUTO-GENERATED FILE — do not edit by hand.
2
2
  // Generated by scripts/gen-telemetry.js from .env at build time.
3
- // The .env file is gitignored; this file contains only encrypted payloads.
4
3
 
5
- /** AES-256-GCM encrypted GA4 Measurement ID */
6
- export const ENC_MID = '029e338afbbf509e97b2ea5b';
7
- export const ENC_MID_IV = '9a6d6b4d732f07bedbe40229';
8
- export const ENC_MID_TAG = 'e545372ce1ad53c593394a2c0281c75d';
9
-
10
- /** AES-256-GCM encrypted GA4 API Secret */
11
- export const ENC_SEC = '7e95ab688f1b37f9b72d3ab70c9d92105e5bd7046e84';
12
- export const ENC_SEC_IV = '64a3aa1ee24005449e885c08';
13
- export const ENC_SEC_TAG = '007ce86e096dfb0ed902678902754f71';
14
-
15
- /** Key derivation salt (public, used to reconstruct the key at runtime) */
4
+ export const ENC_MID = 'df8ace0290a695bd05986213';
5
+ export const ENC_SEC = 'db93cb0186b1f7bb0ba63a0d0a64997586849455ce37';
16
6
  export const TELEMETRY_SALT = 'rn-inapp-inspector-telemetry-v1';
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED FILE — do not edit by hand.
2
2
  // Regenerated from package.json on every build by scripts/gen-version.js.
3
- export const LIB_VERSION = '2.3.6';
3
+ export const LIB_VERSION = '2.3.7';
@@ -3,219 +3,41 @@ import {LIB_VERSION} from '../constants/version';
3
3
  import {loadSettings, saveSettings} from './settingsStore';
4
4
  import {
5
5
  ENC_MID,
6
- ENC_MID_IV,
7
- ENC_MID_TAG,
8
6
  ENC_SEC,
9
- ENC_SEC_IV,
10
- ENC_SEC_TAG,
11
7
  TELEMETRY_SALT,
12
8
  } from '../constants/telemetryConfig';
13
9
 
14
- // ─── Runtime AES-256-GCM Decryption ────────────────────────────────────────
15
- // Credentials are encrypted at build time by scripts/gen-telemetry.js.
16
- // The key is derived from public package metadata + salt using SHA-256.
17
- // This prevents plain-text secrets from appearing in source code or npm tarball.
10
+ // ─── Runtime Keystream Deobfuscation ────────────────────────────────────────
18
11
 
19
12
  const PKG_NAME = 'react-native-inapp-inspector';
20
- const PKG_REPO = 'git+https://github.com/vengatmacuser/react-native-inapp-inspector.git';
21
-
22
- /**
23
- * SHA-256 hash (returns hex string). Works in React Native / Hermes
24
- * via a lightweight iterative implementation (no native crypto needed).
25
- */
26
- function sha256Hex(input: string): string {
27
- // Lightweight SHA-256 for runtime key derivation.
28
- // Adapted from a minimal pure-JS implementation.
29
- const K = [
30
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
31
- 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
32
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
33
- 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
34
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
35
- 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
36
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
37
- 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
38
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
39
- 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
40
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
41
- ];
42
-
43
- function rr(n: number, x: number) {
44
- return ((n >>> x) | (n << (32 - x))) >>> 0;
13
+ const KEY_MATERIAL = `${PKG_NAME}::${TELEMETRY_SALT}`;
14
+
15
+ function getKeystream(material: string, length: number): number[] {
16
+ const stream: number[] = [];
17
+ let acc = 0x5a827999;
18
+ for (let i = 0; i < length; i++) {
19
+ const charCode = material.charCodeAt(i % material.length);
20
+ acc = ((acc * 31 + charCode * 17 + i * 13) ^ (acc >>> 7)) & 0xffffffff;
21
+ stream.push((acc >>> (i % 24)) & 0xff);
45
22
  }
46
-
47
- // Convert string to UTF-8 bytes
48
- const bytes: number[] = [];
49
- for (let i = 0; i < input.length; i++) {
50
- const c = input.charCodeAt(i);
51
- if (c < 0x80) bytes.push(c);
52
- else if (c < 0x800) {
53
- bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
54
- } else {
55
- bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
56
- }
57
- }
58
-
59
- // Pre-processing: padding
60
- const bitLen = bytes.length * 8;
61
- bytes.push(0x80);
62
- while (bytes.length % 64 !== 56) bytes.push(0);
63
- // Append original length in bits as 64-bit big-endian
64
- for (let i = 56; i >= 0; i -= 8) {
65
- bytes.push((bitLen >>> i) & 0xff);
66
- }
67
-
68
- let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a;
69
- let h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
70
-
71
- for (let offset = 0; offset < bytes.length; offset += 64) {
72
- const w = new Array(64);
73
- for (let i = 0; i < 16; i++) {
74
- w[i] = ((bytes[offset + i * 4] << 24) | (bytes[offset + i * 4 + 1] << 16) |
75
- (bytes[offset + i * 4 + 2] << 8) | bytes[offset + i * 4 + 3]) >>> 0;
76
- }
77
- for (let i = 16; i < 64; i++) {
78
- const s0 = rr(w[i - 15], 7) ^ rr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
79
- const s1 = rr(w[i - 2], 17) ^ rr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
80
- w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
81
- }
82
- let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
83
- for (let i = 0; i < 64; i++) {
84
- const S1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25);
85
- const ch = (e & f) ^ (~e & g);
86
- const temp1 = (h + S1 + ch + K[i] + w[i]) >>> 0;
87
- const S0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22);
88
- const maj = (a & b) ^ (a & c) ^ (b & c);
89
- const temp2 = (S0 + maj) >>> 0;
90
- h = g; g = f; f = e; e = (d + temp1) >>> 0;
91
- d = c; c = b; b = a; a = (temp1 + temp2) >>> 0;
92
- }
93
- h0 = (h0 + a) >>> 0; h1 = (h1 + b) >>> 0; h2 = (h2 + c) >>> 0; h3 = (h3 + d) >>> 0;
94
- h4 = (h4 + e) >>> 0; h5 = (h5 + f) >>> 0; h6 = (h6 + g) >>> 0; h7 = (h7 + h) >>> 0;
95
- }
96
-
97
- function toHex(n: number) {
98
- return ('00000000' + n.toString(16)).slice(-8);
99
- }
100
- return toHex(h0) + toHex(h1) + toHex(h2) + toHex(h3) + toHex(h4) + toHex(h5) + toHex(h6) + toHex(h7);
23
+ return stream;
101
24
  }
102
25
 
103
- function hexToBytes(hex: string): number[] {
26
+ function deobfuscate(hexStr: string): string {
27
+ if (!hexStr) return '';
104
28
  const bytes: number[] = [];
105
- for (let i = 0; i < hex.length; i += 2) {
106
- bytes.push(parseInt(hex.substring(i, i + 2), 16));
107
- }
108
- return bytes;
109
- }
110
-
111
- /**
112
- * AES-256-GCM decryption (pure JS for React Native / Hermes compatibility).
113
- * Uses a lightweight AES + GCM implementation that runs without native crypto.
114
- */
115
- function aesGcmDecrypt(ctHex: string, ivHex: string, _tagHex: string, keyHex: string): string {
116
- // For React Native runtime where SubtleCrypto is unavailable,
117
- // we use AES-CTR mode (GCM's encryption layer) for decryption.
118
- // The auth tag was verified at build time; runtime skips tag verification
119
- // since we control both the encryption and decryption.
120
- const keyBytes = hexToBytes(keyHex);
121
- const ivBytes = hexToBytes(ivHex);
122
- const ctBytes = hexToBytes(ctHex);
123
-
124
- // ─── AES key expansion ───
125
- const Sbox = [
126
- 0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
127
- 0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
128
- 0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
129
- 0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
130
- 0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
131
- 0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
132
- 0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
133
- 0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
134
- 0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
135
- 0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
136
- 0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
137
- 0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
138
- 0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
139
- 0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
140
- 0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
141
- 0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16,
142
- ];
143
-
144
- const Rcon = [0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36];
145
-
146
- // Key schedule for AES-256
147
- const Nk = 8, Nr = 14;
148
- const expandedKey = new Uint8Array(4 * 4 * (Nr + 1));
149
- for (let i = 0; i < 32; i++) expandedKey[i] = keyBytes[i];
150
-
151
- for (let i = Nk; i < 4 * (Nr + 1); i++) {
152
- const t = expandedKey.slice((i - 1) * 4, i * 4);
153
- if (i % Nk === 0) {
154
- const tmp = t[0];
155
- t[0] = Sbox[t[1]] ^ Rcon[i / Nk - 1];
156
- t[1] = Sbox[t[2]];
157
- t[2] = Sbox[t[3]];
158
- t[3] = Sbox[tmp];
159
- } else if (Nk > 6 && i % Nk === 4) {
160
- t[0] = Sbox[t[0]]; t[1] = Sbox[t[1]]; t[2] = Sbox[t[2]]; t[3] = Sbox[t[3]];
161
- }
162
- for (let j = 0; j < 4; j++) {
163
- expandedKey[i * 4 + j] = expandedKey[(i - Nk) * 4 + j] ^ t[j];
164
- }
29
+ for (let i = 0; i < hexStr.length; i += 2) {
30
+ bytes.push(parseInt(hexStr.substring(i, i + 2), 16));
165
31
  }
166
-
167
- // AES single-block encryption (for CTR mode counter blocks)
168
- function aesEncryptBlock(block: Uint8Array): Uint8Array {
169
- const state = new Uint8Array(16);
170
- for (let i = 0; i < 16; i++) state[i] = block[i] ^ expandedKey[i];
171
-
172
- for (let round = 1; round <= Nr; round++) {
173
- // SubBytes
174
- for (let i = 0; i < 16; i++) state[i] = Sbox[state[i]];
175
- // ShiftRows
176
- let t = state[1]; state[1] = state[5]; state[5] = state[9]; state[9] = state[13]; state[13] = t;
177
- t = state[2]; state[2] = state[10]; state[10] = t; t = state[6]; state[6] = state[14]; state[14] = t;
178
- t = state[15]; state[15] = state[11]; state[11] = state[7]; state[7] = state[3]; state[3] = t;
179
- // MixColumns (skip on last round)
180
- if (round < Nr) {
181
- for (let c = 0; c < 4; c++) {
182
- const s0 = state[c*4], s1 = state[c*4+1], s2 = state[c*4+2], s3 = state[c*4+3];
183
- const xtime = (v: number) => ((v << 1) ^ ((v & 0x80) ? 0x1b : 0)) & 0xff;
184
- state[c*4] = xtime(s0) ^ xtime(s1) ^ s1 ^ s2 ^ s3;
185
- state[c*4+1] = s0 ^ xtime(s1) ^ xtime(s2) ^ s2 ^ s3;
186
- state[c*4+2] = s0 ^ s1 ^ xtime(s2) ^ xtime(s3) ^ s3;
187
- state[c*4+3] = xtime(s0) ^ s0 ^ s1 ^ s2 ^ xtime(s3);
188
- }
189
- }
190
- // AddRoundKey
191
- const rkOffset = round * 16;
192
- for (let i = 0; i < 16; i++) state[i] ^= expandedKey[rkOffset + i];
193
- }
194
- return state;
195
- }
196
-
197
- // ─── AES-CTR decryption (GCM uses CTR internally) ───
198
- // Build initial counter block: IV (12 bytes) + counter (4 bytes, starts at 2 for GCM)
199
- const result: number[] = [];
200
- let counter = 2; // GCM starts CTR at 2 for ciphertext (1 is used for tag)
201
-
202
- for (let i = 0; i < ctBytes.length; i += 16) {
203
- const counterBlock = new Uint8Array(16);
204
- for (let j = 0; j < 12; j++) counterBlock[j] = ivBytes[j];
205
- counterBlock[12] = (counter >>> 24) & 0xff;
206
- counterBlock[13] = (counter >>> 16) & 0xff;
207
- counterBlock[14] = (counter >>> 8) & 0xff;
208
- counterBlock[15] = counter & 0xff;
209
- counter++;
210
-
211
- const keystream = aesEncryptBlock(counterBlock);
212
- const blockLen = Math.min(16, ctBytes.length - i);
213
- for (let j = 0; j < blockLen; j++) {
214
- result.push(ctBytes[i + j] ^ keystream[j]);
215
- }
32
+ const keystream = getKeystream(KEY_MATERIAL, bytes.length);
33
+ const out: string[] = [];
34
+ for (let i = 0; i < bytes.length; i++) {
35
+ const k = keystream[i];
36
+ const s = TELEMETRY_SALT.charCodeAt(i % TELEMETRY_SALT.length);
37
+ const dec = (bytes[i] ^ k ^ s) & 0xff;
38
+ out.push(String.fromCharCode(dec));
216
39
  }
217
-
218
- return String.fromCharCode(...result);
40
+ return out.join('');
219
41
  }
220
42
 
221
43
  // ─── Lazy-initialized credentials ──────────────────────────────────────────
@@ -234,10 +56,8 @@ function getCredentials(): {measurementId: string; apiSecret: string} {
234
56
  }
235
57
 
236
58
  try {
237
- const keyMaterial = `${PKG_NAME}::${TELEMETRY_SALT}::${PKG_REPO}`;
238
- const keyHex = sha256Hex(keyMaterial);
239
- _cachedMid = aesGcmDecrypt(ENC_MID, ENC_MID_IV, ENC_MID_TAG, keyHex);
240
- _cachedSec = aesGcmDecrypt(ENC_SEC, ENC_SEC_IV, ENC_SEC_TAG, keyHex);
59
+ _cachedMid = deobfuscate(ENC_MID);
60
+ _cachedSec = deobfuscate(ENC_SEC);
241
61
  } catch {
242
62
  _cachedMid = '';
243
63
  _cachedSec = '';
@@ -252,7 +72,7 @@ function getCollectUrl(): string {
252
72
  return `https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`;
253
73
  }
254
74
 
255
- // ─── Telemetry State ────────────────────────────────────────────────────────
75
+ // ─── Telemetry State & Heartbeat ───────────────────────────────────────────
256
76
 
257
77
  const PING_INTERVAL_MS = 24 * 60 * 60 * 1000;
258
78