@aimeloic/monkey-tester 1.0.2 → 1.0.4
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 +13 -9
- package/package.json +1 -1
package/htmlTemplate.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export function getHtmlTemplate(endpoints) {
|
|
2
|
+
// Safe stringification for HTML attribute encoding
|
|
3
|
+
const safeJsonString = Buffer.from(JSON.stringify(endpoints)).toString('base64');
|
|
4
|
+
|
|
2
5
|
return `
|
|
3
6
|
<!DOCTYPE html>
|
|
4
7
|
<html lang="en">
|
|
@@ -79,6 +82,8 @@ export function getHtmlTemplate(endpoints) {
|
|
|
79
82
|
</head>
|
|
80
83
|
<body>
|
|
81
84
|
|
|
85
|
+
<div id="endtester-data-vault" data-payload="${safeJsonString}" style="display: none;"></div>
|
|
86
|
+
|
|
82
87
|
<header>
|
|
83
88
|
<div class="logo">Endtester <span>Application Runtime Sandbox</span></div>
|
|
84
89
|
<div class="header-right">
|
|
@@ -96,7 +101,7 @@ export function getHtmlTemplate(endpoints) {
|
|
|
96
101
|
<div class="layout">
|
|
97
102
|
<aside id="sidebar-nav">
|
|
98
103
|
<div class="section-label">Discovered Endpoints</div>
|
|
99
|
-
|
|
104
|
+
</aside>
|
|
100
105
|
|
|
101
106
|
<main id="main-panel"></main>
|
|
102
107
|
|
|
@@ -112,12 +117,11 @@ export function getHtmlTemplate(endpoints) {
|
|
|
112
117
|
<div id="toast"></div>
|
|
113
118
|
|
|
114
119
|
<script>
|
|
115
|
-
|
|
116
|
-
const ENDPOINTS =
|
|
120
|
+
const rawPayload = document.getElementById('endtester-data-vault').getAttribute('data-payload');
|
|
121
|
+
const ENDPOINTS = JSON.parse(atob(rawPayload));
|
|
117
122
|
|
|
118
123
|
let currentEp = '';
|
|
119
124
|
|
|
120
|
-
// Setup host variables contextually on layout initialization
|
|
121
125
|
document.getElementById('base-url').value = window.location.origin;
|
|
122
126
|
|
|
123
127
|
function buildSidebar() {
|
|
@@ -146,7 +150,6 @@ function buildSidebar() {
|
|
|
146
150
|
sidebar.appendChild(div);
|
|
147
151
|
});
|
|
148
152
|
|
|
149
|
-
// Render first item initially
|
|
150
153
|
if(keys.length > 0) renderPanel(keys[0]);
|
|
151
154
|
}
|
|
152
155
|
|
|
@@ -168,7 +171,7 @@ function renderPanel(epKey) {
|
|
|
168
171
|
ep.params.forEach(p => {
|
|
169
172
|
html += '<div class="field-row">' +
|
|
170
173
|
'<label class="field-label">' + p.label + '</label>' +
|
|
171
|
-
|
|
174
|
+
<input type="text" id="param-' + p.name + '" placeholder="' + p.placeholder + '" />' +
|
|
172
175
|
'</div>';
|
|
173
176
|
});
|
|
174
177
|
html += '</div>';
|
|
@@ -205,10 +208,12 @@ async function sendRequest() {
|
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
|
|
208
|
-
|
|
211
|
+
// FIXED: Reading from the actual layout elements directly
|
|
212
|
+
const baseUrl = document.getElementById('base-url').value.replace(/\\/+$/, '');
|
|
213
|
+
const url = baseUrl + path;
|
|
209
214
|
const headers = { 'Content-Type': 'application/json' };
|
|
210
215
|
|
|
211
|
-
const jwt =
|
|
216
|
+
const jwt = document.getElementById('jwt-input').value.trim();
|
|
212
217
|
if (jwt) headers['Authorization'] = 'Bearer ' + jwt;
|
|
213
218
|
|
|
214
219
|
let body = undefined;
|
|
@@ -281,7 +286,6 @@ function showToast(msg) {
|
|
|
281
286
|
setTimeout(() => t.classList.remove('show'), 2500);
|
|
282
287
|
}
|
|
283
288
|
|
|
284
|
-
// Initial script activation
|
|
285
289
|
buildSidebar();
|
|
286
290
|
</script>
|
|
287
291
|
</body>
|