@aimeloic/monkey-tester 4.0.10 → 5.0.1
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/htmlTemplate.js +16 -5
- package/package.json +1 -1
package/htmlTemplate.js
CHANGED
|
@@ -6,19 +6,31 @@
|
|
|
6
6
|
// const endpointsJsonB64 = encodePayload(endpointsData);
|
|
7
7
|
//
|
|
8
8
|
function encodePayload(obj) {
|
|
9
|
-
|
|
9
|
+
const jsonStr = JSON.stringify(obj);
|
|
10
|
+
// Convert string to UTF-8 bytes
|
|
11
|
+
const bytes = new TextEncoder().encode(jsonStr);
|
|
12
|
+
// Convert bytes to binary string for btoa
|
|
13
|
+
const binStr = Array.from(bytes, byte => String.fromCharCode(byte)).join('');
|
|
14
|
+
return btoa(binStr);
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
// The reciprocal decode runs inside each HTML template (see _decode below).
|
|
13
18
|
// It is injected as a one-liner so every template is self-contained.
|
|
14
|
-
|
|
19
|
+
|
|
20
|
+
const _decode = `function _decode(b64){return JSON.parse(decodeURIComponent(escape(atob(b64.replace(/\s+/g,'')))));}`;
|
|
15
21
|
|
|
16
22
|
// ─── Runtime sandbox (injected into tester page) ─────────────────────────────
|
|
17
23
|
function runtimeClientSandbox() {
|
|
18
24
|
// Unicode-safe decode (whitespace-stripped for safety)
|
|
19
25
|
function _decode(b64) {
|
|
20
|
-
|
|
26
|
+
const binStr = atob(b64.replace(/\s+/g, ''));
|
|
27
|
+
const bytes = new Uint8Array(binStr.length);
|
|
28
|
+
for (let i = 0; i < binStr.length; i++) {
|
|
29
|
+
bytes[i] = binStr.charCodeAt(i);
|
|
21
30
|
}
|
|
31
|
+
const jsonStr = new TextDecoder().decode(bytes);
|
|
32
|
+
return JSON.parse(jsonStr);
|
|
33
|
+
}
|
|
22
34
|
|
|
23
35
|
const ENDPOINTS = _decode(
|
|
24
36
|
document.getElementById('__monkey_data__').getAttribute('data-payload')
|
|
@@ -441,8 +453,7 @@ async function handleRegister() {
|
|
|
441
453
|
<script>
|
|
442
454
|
// ── Unicode-safe decode ──────────────────────────────────────────────────────
|
|
443
455
|
function _decode(b64) {
|
|
444
|
-
|
|
445
|
-
return JSON.parse(decodeURIComponent(escape(atob(b64.replace(/\s+/g, '')))));
|
|
456
|
+
return JSON.parse(decodeURIComponent(escape(atob(b64.replace(/\s+/g, '')))));
|
|
446
457
|
}
|
|
447
458
|
|
|
448
459
|
const ENDPOINTS = _decode(
|