@aimeloic/monkey-tester 5.0.0 → 5.0.2

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.
Files changed (2) hide show
  1. package/htmlTemplate.js +20 -5
  2. package/package.json +1 -1
package/htmlTemplate.js CHANGED
@@ -6,7 +6,12 @@
6
6
  // const endpointsJsonB64 = encodePayload(endpointsData);
7
7
  //
8
8
  function encodePayload(obj) {
9
- return btoa(unescape(encodeURIComponent(JSON.stringify(obj))));
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).
@@ -18,8 +23,14 @@ const _decode = `function _decode(b64){return JSON.parse(decodeURIComponent(esca
18
23
  function runtimeClientSandbox() {
19
24
  // Unicode-safe decode (whitespace-stripped for safety)
20
25
  function _decode(b64) {
21
- return JSON.parse(decodeURIComponent(escape(atob(b64.replace(/\s+/g, '')))));
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);
22
30
  }
31
+ const jsonStr = new TextDecoder().decode(bytes);
32
+ return JSON.parse(jsonStr);
33
+ }
23
34
 
24
35
  const ENDPOINTS = _decode(
25
36
  document.getElementById('__monkey_data__').getAttribute('data-payload')
@@ -249,7 +260,8 @@ const UI = {
249
260
  </style>
250
261
  </head>
251
262
  <body>
252
- <div id="__monkey_data__" data-payload="${endpointsJsonB64}" style="display:none;"></div>
263
+ <!-- Replace the old hidden div with this -->
264
+ <script id="__monkey_data__" type="text/plain">${endpointsJsonB64}</script>
253
265
  <header>
254
266
  <div class="logo">🐒 Endtester <span>Interactive API Hub</span></div>
255
267
  <div class="header-right">
@@ -409,7 +421,8 @@ async function handleRegister() {
409
421
  </style>
410
422
  </head>
411
423
  <body>
412
- <div id="__monkey_data__" data-payload="${endpointsJsonB64}" style="display:none;"></div>
424
+ <!-- Replace the old hidden div with this -->
425
+ <script id="__monkey_data__" type="text/plain">${endpointsJsonB64}</script>
413
426
 
414
427
  <header>
415
428
  <h1>Universal Management Dashboard</h1>
@@ -445,8 +458,10 @@ function _decode(b64) {
445
458
  return JSON.parse(decodeURIComponent(escape(atob(b64.replace(/\s+/g, '')))));
446
459
  }
447
460
 
461
+ // BEFORE (Broken)
462
+ // AFTER (Safe from HTML parsing artifacts)
448
463
  const ENDPOINTS = _decode(
449
- document.getElementById('__monkey_data__').getAttribute('data-payload')
464
+ document.getElementById('__monkey_data__').textContent.trim()
450
465
  );
451
466
 
452
467
  const token = localStorage.getItem('__auth_token__');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aimeloic/monkey-tester",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "Auto route scanning visual runner dashboard.",
5
5
  "main": "index.js",
6
6
  "type": "module",