@aimeloic/monkey-tester 4.0.3 → 4.0.5

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/html.backup.js CHANGED
@@ -1,103 +1,8 @@
1
1
  'use strict';
2
2
 
3
- function getHtmlTemplate(endpoints) {
4
- const safeJsonString = Buffer.from(JSON.stringify(endpoints)).toString('base64');
5
-
6
- return `<!DOCTYPE html>
7
- <html lang="en">
8
- <head>
9
- <meta charset="UTF-8">
10
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
11
- <title>Endtester — API Environment</title>
12
- <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500&display=swap" rel="stylesheet">
13
- <style>
14
- :root {
15
- --bg: #0e0c09; --surface: #181510; --surface2: #221d14; --border: #3a3020;
16
- --accent: #e8a838; --accent2: #c47a1e; --text: #f0e8d8; --text-dim: #9a8c78;
17
- --red: #d45c3c; --green: #6ba05a; --blue: #5a86c0; --radius: 8px;
18
- }
19
- * { box-sizing: border-box; margin: 0; padding: 0; }
20
- body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; height: 100vh; overflow: hidden; background-image: radial-gradient(ellipse 80% 60% at 50% -20%, #3a2a0a22 0%, transparent 70%); }
21
- header { border-bottom: 1px solid var(--border); padding: 16px 32px; display: flex; align-items: center; gap: 20px; background: #0e0c09ee; backdrop-filter: blur(8px); height: 65px; }
22
- .logo { font-family: 'Playfair Display', serif; font-size: 20px; color: var(--accent); letter-spacing: 0.02em; }
23
- .logo span { color: var(--text-dim); font-size: 11px; font-family: 'DM Mono', monospace; display: inline-block; margin-left: 8px; font-weight: 400; }
24
- .header-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
25
- .jwt-wrap, .base-url-wrap { display: flex; align-items: center; gap: 8px; }
26
- .jwt-wrap label, .base-url-wrap label { color: var(--text-dim); font-size: 11px; font-family: 'DM Mono', monospace; letter-spacing: 0.05em; }
27
- #jwt-input, #base-url { background: var(--surface2); border: 1px solid var(--border); color: var(--text); font-family: 'DM Mono', monospace; font-size: 12px; padding: 6px 12px; border-radius: var(--radius); width: 220px; outline: none; }
28
- .layout { display: grid; grid-template-columns: 280px 1fr 450px; height: calc(100vh - 65px); overflow: hidden; }
29
- aside { border-right: 1px solid var(--border); overflow-y: auto; padding: 16px 0; background: #0b0907; }
30
- .section-label { font-size: 10px; font-family: 'DM Mono', monospace; color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase; padding: 12px 18px 6px; }
31
- .nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 18px; cursor: pointer; border-left: 2px solid transparent; color: var(--text-dim); transition: all 0.2s; }
32
- .nav-item:hover { background: var(--surface); color: var(--text); }
33
- .nav-item.active { border-left-color: var(--accent); background: var(--surface); color: var(--accent); }
34
- .method-badge { font-family: 'DM Mono', monospace; font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 4px; min-width: 52px; text-align: center; text-transform: uppercase; }
35
- .GET { background: #1a3a22; color: #6ba05a; } .POST { background: #1a2e3a; color: #5a86c0; } .PUT, .PATCH { background: #3a2e10; color: #e8a838; } .DELETE { background: #3a1a14; color: #d45c3c; }
36
- .nav-label { font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
37
- main { overflow-y: auto; padding: 32px; background: #0e0c09; }
38
- .endpoint-title { font-family: 'Playfair Display', serif; font-size: 24px; color: var(--accent); margin-bottom: 8px; }
39
- .endpoint-path { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text-dim); margin-bottom: 24px; display: flex; align-items: center; gap: 8px; }
40
- .endpoint-desc { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin-bottom: 24px; border-left: 2px solid var(--border); padding-left: 12px; }
41
- .form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
42
- .form-section-title { font-size: 11px; font-family: 'DM Mono', monospace; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
43
- .field-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 16px; margin-bottom: 14px; }
44
- .field-label { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text-dim); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
45
- input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], input[type=email], select { background: var(--surface2); border: 1px solid var(--border); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px; padding: 8px 12px; border-radius: var(--radius); width: 100%; outline: none; transition: border-color 0.2s; }
46
- input:focus { border-color: var(--accent); }
47
- .btn-row { margin-top: 24px; display: flex; gap: 12px; }
48
- .btn { background: var(--accent); color: #0e0c09; border: none; padding: 10px 24px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color 0.2s; }
49
- .btn:hover { background: #f0b850; } .btn-secondary { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); } .btn-secondary:hover { color: var(--text); background: var(--surface); }
50
- .response-panel { border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; background: #110e0a; }
51
- .response-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; background: var(--surface); height: 50px; }
52
- .response-header-title { font-size: 11px; font-family: 'DM Mono', monospace; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
53
- .status-badge { font-family: 'DM Mono', monospace; font-size: 12px; margin-left: auto; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
54
- .status-ok { background: #1a3a22; color: #6ba05a; } .status-err { background: #3a1a14; color: #d45c3c; } .status-idle { background: var(--surface2); color: var(--text-dim); }
55
- .response-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0; background: #0d0b08; }
56
- .response-body.empty { color: var(--text-dim); display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; font-size: 13px; }
57
- .json-render-block { display: block; padding: 20px; margin: 0; font-family: 'DM Mono', monospace; font-size: 12px; line-height: 1.5; white-space: pre; overflow-x: auto; word-break: normal; word-wrap: normal; }
58
- .json-key { color: #e8a838; } .json-str { color: #9ab878; } .json-num { color: #5a86c0; } .json-bool { color: #c47a1e; } .json-null { color: var(--text-dim); }
59
- #toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface2); border: 1px solid var(--border); padding: 10px 18px; border-radius: var(--radius); opacity: 0; transition: all .25s; z-index: 1000; font-family: 'DM Mono', monospace; font-size: 12px; color: var(--accent); }
60
- #toast.show { opacity: 1; }
61
- .empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
62
- .empty-state .monkey { font-size: 48px; margin-bottom: 16px; }
63
- .empty-state h2 { color: var(--text); font-family: 'Playfair Display', serif; margin-bottom: 8px; }
64
- </style>
65
- </head>
66
- <body>
67
-
68
- <div id="__monkey_data__" data-payload="${safeJsonString}" style="display:none;"></div>
69
-
70
- <header>
71
- <div class="logo">🐒 Endtester <span>Application Runtime Sandbox</span></div>
72
- <div class="header-right">
73
- <div class="base-url-wrap">
74
- <label>TARGET HOST</label>
75
- <input id="base-url" type="text" value="">
76
- </div>
77
- <div class="jwt-wrap">
78
- <label>BEARER AUTH</label>
79
- <input id="jwt-input" type="text" placeholder="Token value...">
80
- </div>
81
- </div>
82
- </header>
83
-
84
- <div class="layout">
85
- <aside id="sidebar-nav">
86
- <div class="section-label">Discovered Endpoints</div>
87
- </aside>
88
- <main id="main-panel"></main>
89
- <div class="response-panel">
90
- <div class="response-header">
91
- <span class="response-header-title">Response Output</span>
92
- <span id="status-badge" class="status-badge status-idle">—</span>
93
- </div>
94
- <div class="response-body empty" id="response-body">Execute a request row to generate feedback data</div>
95
- </div>
96
- </div>
97
-
98
- <div id="toast"></div>
99
-
100
- <script>
3
+ // ─── BROWSER RUNTIME ENGINE ──────────────────────────────────────────────────
4
+ // This function is stringified safely to eliminate string template syntax bugs
5
+ function runtimeClientSandbox() {
101
6
  const ENDPOINTS = JSON.parse(atob(document.getElementById('__monkey_data__').getAttribute('data-payload')));
102
7
  let currentKey = null;
103
8
 
@@ -170,11 +75,14 @@ function getHtmlTemplate(endpoints) {
170
75
 
171
76
  html +=
172
77
  '<div class="btn-row">' +
173
- '<button class="btn" onclick="sendRequest()">Execute Route</button>' +
174
- '<button class="btn btn-secondary" onclick="clearResponse()">Clear Context</button>' +
78
+ '<button class="btn" id="_exec_btn">Execute Route</button>' +
79
+ '<button class="btn btn-secondary" id="_clear_btn">Clear Context</button>' +
175
80
  '</div>';
176
81
 
177
82
  main.innerHTML = html;
83
+
84
+ document.getElementById('_exec_btn').addEventListener('click', sendRequest);
85
+ document.getElementById('_clear_btn').addEventListener('click', clearResponse);
178
86
  }
179
87
 
180
88
  async function sendRequest() {
@@ -271,9 +179,109 @@ function getHtmlTemplate(endpoints) {
271
179
  }
272
180
 
273
181
  buildSidebar();
182
+ }
183
+
184
+ // ─── BACKEND HTML GENERATOR ──────────────────────────────────────────────────
185
+ function getHtmlTemplate(endpoints) {
186
+ const safeJsonString = Buffer.from(JSON.stringify(endpoints)).toString('base64');
187
+
188
+ return `<!DOCTYPE html>
189
+ <html lang="en">
190
+ <head>
191
+ <meta charset="UTF-8">
192
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
193
+ <title>Endtester — API Environment</title>
194
+ <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500&display=swap" rel="stylesheet">
195
+ <style>
196
+ :root {
197
+ --bg: #0e0c09; --surface: #181510; --surface2: #221d14; --border: #3a3020;
198
+ --accent: #e8a838; --accent2: #c47a1e; --text: #f0e8d8; --text-dim: #9a8c78;
199
+ --red: #d45c3c; --green: #6ba05a; --blue: #5a86c0; --radius: 8px;
200
+ }
201
+ * { box-sizing: border-box; margin: 0; padding: 0; }
202
+ body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; height: 100vh; overflow: hidden; background-image: radial-gradient(ellipse 80% 60% at 50% -20%, #3a2a0a22 0%, transparent 70%); }
203
+ header { border-bottom: 1px solid var(--border); padding: 16px 32px; display: flex; align-items: center; gap: 20px; background: #0e0c09ee; backdrop-filter: blur(8px); height: 65px; }
204
+ .logo { font-family: 'Playfair Display', serif; font-size: 20px; color: var(--accent); letter-spacing: 0.02em; }
205
+ .logo span { color: var(--text-dim); font-size: 11px; font-family: 'DM Mono', monospace; display: inline-block; margin-left: 8px; font-weight: 400; }
206
+ .header-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
207
+ .jwt-wrap, .base-url-wrap { display: flex; align-items: center; gap: 8px; }
208
+ .jwt-wrap label, .base-url-wrap label { color: var(--text-dim); font-size: 11px; font-family: 'DM Mono', monospace; letter-spacing: 0.05em; }
209
+ #jwt-input, #base-url { background: var(--surface2); border: 1px solid var(--border); color: var(--text); font-family: 'DM Mono', monospace; font-size: 12px; padding: 6px 12px; border-radius: var(--radius); width: 220px; outline: none; }
210
+ .layout { display: grid; grid-template-columns: 280px 1fr 450px; height: calc(100vh - 65px); overflow: hidden; }
211
+ aside { border-right: 1px solid var(--border); overflow-y: auto; padding: 16px 0; background: #0b0907; }
212
+ .section-label { font-size: 10px; font-family: 'DM Mono', monospace; color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase; padding: 12px 18px 6px; }
213
+ .nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 18px; cursor: pointer; border-left: 2px solid transparent; color: var(--text-dim); transition: all 0.2s; }
214
+ .nav-item:hover { background: var(--surface); color: var(--text); }
215
+ .nav-item.active { border-left-color: var(--accent); background: var(--surface); color: var(--accent); }
216
+ .method-badge { font-family: 'DM Mono', monospace; font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 4px; min-width: 52px; text-align: center; text-transform: uppercase; }
217
+ .GET { background: #1a3a22; color: #6ba05a; } .POST { background: #1a2e3a; color: #5a86c0; } .PUT, .PATCH { background: #3a2e10; color: #e8a838; } .DELETE { background: #3a1a14; color: #d45c3c; }
218
+ .nav-label { font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
219
+ main { overflow-y: auto; padding: 32px; background: #0e0c09; }
220
+ .endpoint-title { font-family: 'Playfair Display', serif; font-size: 24px; color: var(--accent); margin-bottom: 8px; }
221
+ .endpoint-path { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text-dim); margin-bottom: 24px; display: flex; align-items: center; gap: 8px; }
222
+ .endpoint-desc { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin-bottom: 24px; border-left: 2px solid var(--border); padding-left: 12px; }
223
+ .form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
224
+ .form-section-title { font-size: 11px; font-family: 'DM Mono', monospace; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
225
+ .field-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 16px; margin-bottom: 14px; }
226
+ .field-label { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text-dim); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
227
+ input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], input[type=email], select { background: var(--surface2); border: 1px solid var(--border); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px; padding: 8px 12px; border-radius: var(--radius); width: 100%; outline: none; transition: border-color 0.2s; }
228
+ input:focus { border-color: var(--accent); }
229
+ .btn-row { margin-top: 24px; display: flex; gap: 12px; }
230
+ .btn { background: var(--accent); color: #0e0c09; border: none; padding: 10px 24px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color 0.2s; }
231
+ .btn:hover { background: #f0b850; } .btn-secondary { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); } .btn-secondary:hover { color: var(--text); background: var(--surface); }
232
+ .response-panel { border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; background: #110e0a; }
233
+ .response-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; background: var(--surface); height: 50px; }
234
+ .response-header-title { font-size: 11px; font-family: 'DM Mono', monospace; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
235
+ .status-badge { font-family: 'DM Mono', monospace; font-size: 12px; margin-left: auto; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
236
+ .status-ok { background: #1a3a22; color: #6ba05a; } .status-err { background: #3a1a14; color: #d45c3c; } .status-idle { background: var(--surface2); color: var(--text-dim); }
237
+ .response-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0; background: #0d0b08; }
238
+ .response-body.empty { color: var(--text-dim); display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; font-size: 13px; }
239
+ .json-render-block { display: block; padding: 20px; margin: 0; font-family: 'DM Mono', monospace; font-size: 12px; line-height: 1.5; white-space: pre; overflow-x: auto; word-break: normal; word-wrap: normal; }
240
+ .json-key { color: #e8a838; } .json-str { color: #9ab878; } .json-num { color: #5a86c0; } .json-bool { color: #c47a1e; } .json-null { color: var(--text-dim); }
241
+ #toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface2); border: 1px solid var(--border); padding: 10px 18px; border-radius: var(--radius); opacity: 0; transition: all .25s; z-index: 1000; font-family: 'DM Mono', monospace; font-size: 12px; color: var(--accent); }
242
+ #toast.show { opacity: 1; }
243
+ </style>
244
+ </head>
245
+ <body>
246
+
247
+ <div id="__monkey_data__" data-payload="${safeJsonString}" style="display:none;"></div>
248
+
249
+ <header>
250
+ <div class="logo">🐒 Endtester <span>Application Runtime Sandbox</span></div>
251
+ <div class="header-right">
252
+ <div class="base-url-wrap">
253
+ <label>TARGET HOST</label>
254
+ <input id="base-url" type="text" value="">
255
+ </div>
256
+ <div class="jwt-wrap">
257
+ <label>BEARER AUTH</label>
258
+ <input id="jwt-input" type="text" placeholder="Token value...">
259
+ </div>
260
+ </div>
261
+ </header>
262
+
263
+ <div class="layout">
264
+ <aside id="sidebar-nav">
265
+ <div class="section-label">Discovered Endpoints</div>
266
+ </aside>
267
+ <main id="main-panel"></main>
268
+ <div class="response-panel">
269
+ <div class="response-header">
270
+ <span class="response-header-title">Response Output</span>
271
+ <span id="status-badge" class="status-badge status-idle">—</span>
272
+ </div>
273
+ <div class="response-body empty" id="response-body">Execute a request row to generate feedback data</div>
274
+ </div>
275
+ </div>
276
+
277
+ <div id="toast"></div>
278
+
279
+ <script>
280
+ // Clean, flawless evaluation structure
281
+ (${runtimeClientSandbox.toString()})();
274
282
  </script>
275
283
  </body>
276
284
  </html>`;
277
285
  }
278
286
 
279
- module.exports = { getHtmlTemplate };
287
+ export { getHtmlTemplate };