devanvil 2.1.0 → 2.1.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.
Files changed (41) hide show
  1. package/SECURITY.md +4 -4
  2. package/dist/cli.js +6 -1
  3. package/dist/core/contract-drift.js +15 -5
  4. package/dist/core/converters.js +25 -17
  5. package/dist/core/cron.js +6 -3
  6. package/dist/core/crypto.js +11 -1
  7. package/dist/core/curl.js +5 -1
  8. package/dist/core/diff.js +2 -2
  9. package/dist/core/encoding.js +1 -1
  10. package/dist/core/jwt.js +21 -8
  11. package/dist/core/oauth-protobuf.js +16 -10
  12. package/dist/core/regex.js +13 -4
  13. package/dist/core/secrets.js +11 -7
  14. package/dist/core/security.js +20 -3
  15. package/dist/core/tls.js +5 -2
  16. package/dist/server/app.d.ts +1 -1
  17. package/dist/server/app.js +17 -6
  18. package/dist/server/http-proxy.js +19 -10
  19. package/dist/server/http-utils.js +15 -3
  20. package/dist/server/load-tester.js +3 -0
  21. package/dist/server/mcp.d.ts +1 -1
  22. package/dist/server/mcp.js +8 -4
  23. package/dist/server/mock-store.js +54 -13
  24. package/dist/server/plugin-loader.d.ts +2 -1
  25. package/dist/server/plugin-loader.js +21 -1
  26. package/dist/server/recorder-store.js +2 -1
  27. package/dist/server/routes/network-routes.js +54 -4
  28. package/dist/server/routes/tools-routes.js +9 -2
  29. package/dist/server/routes/workspace-routes.js +26 -4
  30. package/dist/server/webhook-store.js +12 -2
  31. package/dist/server/workspace-store.js +4 -3
  32. package/dist/server/ws-probe.js +8 -0
  33. package/dist/ui/app.js +20 -4
  34. package/dist/ui/styles.css +2 -2
  35. package/dist/ui/tools-data.js +42 -27
  36. package/dist/ui/tools-network.js +70 -28
  37. package/dist/ui/tools-ops.js +16 -12
  38. package/dist/ui/tools-security.js +30 -22
  39. package/dist/ui/tools-v12.js +34 -14
  40. package/dist/ui/tools-v21.js +26 -10
  41. package/package.json +1 -1
@@ -85,6 +85,9 @@ export async function executeWebSocketProbe(input, options = {}) {
85
85
  if (parsed.protocol !== 'ws:' && parsed.protocol !== 'wss:') {
86
86
  throw new Error(`Unsupported WebSocket protocol "${parsed.protocol}". Use ws:// or wss://`);
87
87
  }
88
+ if (parsed.username || parsed.password) {
89
+ throw new Error('Embedded URL credentials are not permitted in WebSocket URL; use headers instead');
90
+ }
88
91
  const isTls = parsed.protocol === 'wss:';
89
92
  const port = parsed.port ? Number(parsed.port) : isTls ? 443 : 80;
90
93
  const httpEquivalent = `${isTls ? 'https' : 'http'}://${parsed.host}${parsed.pathname}${parsed.search}`;
@@ -174,9 +177,14 @@ export async function executeWebSocketProbe(input, options = {}) {
174
177
  socket.once('secureConnect', onConnected);
175
178
  else
176
179
  socket.once('connect', onConnected);
180
+ const MAX_WS_BUFFER_BYTES = 2 * 1024 * 1024;
177
181
  socket.on('data', (chunk) => {
178
182
  if (settled)
179
183
  return;
184
+ if (rawBuf.length + chunk.length > MAX_WS_BUFFER_BYTES) {
185
+ fail(new Error('WebSocket receive buffer exceeded 2 MB safety limit'));
186
+ return;
187
+ }
180
188
  rawBuf = Buffer.concat([rawBuf, chunk]);
181
189
  if (!upgraded) {
182
190
  const headerEnd = rawBuf.indexOf('\r\n\r\n');
package/dist/ui/app.js CHANGED
@@ -1,8 +1,24 @@
1
1
  (function () {
2
2
  'use strict';
3
3
 
4
+ function safeStorageGet(key, fallback) {
5
+ try {
6
+ return localStorage.getItem(key) || fallback;
7
+ } catch {
8
+ return fallback;
9
+ }
10
+ }
11
+
12
+ function safeStorageSet(key, val) {
13
+ try {
14
+ localStorage.setItem(key, val);
15
+ } catch {
16
+ // Ignore storage errors in sandboxed iframes or strict privacy modes
17
+ }
18
+ }
19
+
4
20
  const tools = [];
5
- let activeToolId = localStorage.getItem('devanvil.activeTool') || 'api-studio';
21
+ let activeToolId = safeStorageGet('devanvil.activeTool', 'api-studio');
6
22
  let activeCleanup = null;
7
23
 
8
24
  function h(tag, attrs = {}, ...children) {
@@ -109,7 +125,7 @@
109
125
  }
110
126
 
111
127
  activeToolId = found.id;
112
- localStorage.setItem('devanvil.activeTool', activeToolId);
128
+ safeStorageSet('devanvil.activeTool', activeToolId);
113
129
  document.getElementById('toolTitle').textContent = found.name;
114
130
  document.getElementById('toolSubtitle').textContent = found.subtitle;
115
131
  document.getElementById('sidebar').classList.remove('open');
@@ -124,7 +140,7 @@
124
140
  // Theme switcher
125
141
  function applyTheme(theme) {
126
142
  document.documentElement.setAttribute('data-theme', theme);
127
- localStorage.setItem('devanvil.theme', theme);
143
+ safeStorageSet('devanvil.theme', theme);
128
144
  const btn = document.getElementById('themeToggleBtn');
129
145
  btn.textContent = theme === 'dark' ? '☀ Light' : '☾ Dark';
130
146
  }
@@ -199,7 +215,7 @@
199
215
  }
200
216
 
201
217
  function boot() {
202
- applyTheme(localStorage.getItem('devanvil.theme') || 'dark');
218
+ applyTheme(safeStorageGet('devanvil.theme', 'dark'));
203
219
 
204
220
  document.getElementById('themeToggleBtn').addEventListener('click', () => {
205
221
  const cur = document.documentElement.getAttribute('data-theme') || 'dark';
@@ -477,8 +477,8 @@ input:focus, select:focus, textarea:focus {
477
477
  font-size: 12.5px;
478
478
  border: 1px solid var(--border);
479
479
  }
480
- .finding.critical { background: var(--err-soft); border-color: rgba(244, 63, 94, 0.35); color: var(--err); }
481
- .finding.warning { background: var(--warn-soft); border-color: rgba(245, 158, 11, 0.35); color: var(--warn); }
480
+ .finding.critical, .finding.fail { background: var(--err-soft); border-color: rgba(244, 63, 94, 0.35); color: var(--err); }
481
+ .finding.warning, .finding.warn { background: var(--warn-soft); border-color: rgba(245, 158, 11, 0.35); color: var(--warn); }
482
482
  .finding.pass { background: var(--ok-soft); border-color: rgba(16, 185, 129, 0.3); color: var(--ok); }
483
483
  .finding.info { background: var(--info-soft); border-color: rgba(56, 189, 248, 0.3); color: var(--info); }
484
484
 
@@ -87,6 +87,9 @@
87
87
  const treeBox = h('div', { class: 'json-tree' });
88
88
 
89
89
  function buildTreeNode(keyLabel, val, jsonPath, depth, filter) {
90
+ if (depth > 16) {
91
+ return h('div', { class: 'tree-leaf' }, h('span', { class: 'tree-key' }, keyLabel), h('span', { class: 'tree-val' }, ': [Max tree depth reached]'));
92
+ }
90
93
  const isObj = val !== null && typeof val === 'object';
91
94
  if (!isObj) {
92
95
  const valStr = JSON.stringify(val);
@@ -139,8 +142,12 @@
139
142
  });
140
143
  const sqlOut = h('pre', { class: 'code-box' }, '');
141
144
  async function runSql() {
142
- const res = await api('/api/sql/format', { body: { sql: sqlIn.value } });
143
- sqlOut.textContent = res.formatted;
145
+ try {
146
+ const res = await api('/api/sql/format', { body: { sql: sqlIn.value } });
147
+ sqlOut.textContent = res.formatted;
148
+ } catch (err) {
149
+ toast(err.message, 'err');
150
+ }
144
151
  }
145
152
 
146
153
  const layout = h(
@@ -411,25 +418,29 @@
411
418
  }
412
419
 
413
420
  async function loadPresets() {
414
- const { presets } = await api('/api/regex/presets');
415
- presetRow.textContent = '';
416
- for (const p of presets) {
417
- presetRow.appendChild(
418
- h(
419
- 'button',
420
- {
421
- type: 'button',
422
- class: 'btn btn-ghost btn-xs',
423
- onClick: () => {
424
- patternIn.value = p.pattern;
425
- flagsIn.value = p.flags;
426
- textIn.value = p.sample;
427
- void runRegex();
421
+ try {
422
+ const { presets } = await api('/api/regex/presets');
423
+ presetRow.textContent = '';
424
+ for (const p of presets) {
425
+ presetRow.appendChild(
426
+ h(
427
+ 'button',
428
+ {
429
+ type: 'button',
430
+ class: 'btn btn-ghost btn-xs',
431
+ onClick: () => {
432
+ patternIn.value = p.pattern;
433
+ flagsIn.value = p.flags;
434
+ textIn.value = p.sample;
435
+ void runRegex();
436
+ },
428
437
  },
429
- },
430
- p.name,
431
- ),
432
- );
438
+ p.name,
439
+ ),
440
+ );
441
+ }
442
+ } catch (err) {
443
+ toast(err.message, 'err');
433
444
  }
434
445
  }
435
446
 
@@ -597,14 +608,18 @@
597
608
  }
598
609
 
599
610
  async function initOps() {
600
- const { operations } = await api('/api/pipeline/ops');
601
- opsCatalog = operations;
602
- opSelect.textContent = '';
603
- for (const op of operations) {
604
- opSelect.appendChild(h('option', { value: op.id }, `[${op.category}] ${op.label}`));
611
+ try {
612
+ const { operations } = await api('/api/pipeline/ops');
613
+ opsCatalog = operations;
614
+ opSelect.textContent = '';
615
+ for (const op of operations) {
616
+ opSelect.appendChild(h('option', { value: op.id }, `[${op.category}] ${op.label}`));
617
+ }
618
+ renderSteps();
619
+ void executePipeline();
620
+ } catch (err) {
621
+ toast(err.message, 'err');
605
622
  }
606
- renderSteps();
607
- void executePipeline();
608
623
  }
609
624
 
610
625
  const starterRecipes = [
@@ -30,7 +30,11 @@
30
30
  function saveHistory(entry) {
31
31
  const list = loadHistory().filter((x) => !(x.method === entry.method && x.url === entry.url));
32
32
  list.unshift(entry);
33
- localStorage.setItem('devanvil.apiHistory', JSON.stringify(list.slice(0, 12)));
33
+ try {
34
+ localStorage.setItem('devanvil.apiHistory', JSON.stringify(list.slice(0, 12)));
35
+ } catch {
36
+ // Ignore storage quota or sandboxed iframe restrictions
37
+ }
34
38
  renderHistory();
35
39
  }
36
40
 
@@ -51,8 +55,12 @@
51
55
  const recordMockChk = h('input', { type: 'checkbox' });
52
56
  const envSelect = h('select', { style: { width: '160px' }, onChange: async (e) => {
53
57
  if (!e.target.value) return;
54
- await api('/api/workspace/environments/active', { body: { id: e.target.value } });
55
- toast('Active environment switched', 'ok');
58
+ try {
59
+ await api('/api/workspace/environments/active', { body: { id: e.target.value } });
60
+ toast('Active environment switched', 'ok');
61
+ } catch (err) {
62
+ toast(err.message, 'err');
63
+ }
56
64
  } });
57
65
 
58
66
  async function loadEnvironments() {
@@ -87,7 +95,7 @@
87
95
 
88
96
  const initialHeadersText = pending?.headers
89
97
  ? Object.entries(pending.headers).map(([k, v]) => `${k}: ${v}`).join('\n')
90
- : 'Accept: application/json\nUser-Agent: DevAnvil/1.1';
98
+ : 'Accept: application/json\nUser-Agent: DevAnvil/2.1';
91
99
 
92
100
  const headersArea = h('textarea', {
93
101
  rows: 5,
@@ -148,13 +156,20 @@
148
156
  }
149
157
  }
150
158
 
159
+ function utf8ToBase64(str) {
160
+ const bytes = new TextEncoder().encode(str);
161
+ let bin = '';
162
+ for (const b of bytes) bin += String.fromCharCode(b);
163
+ return btoa(bin);
164
+ }
165
+
151
166
  function buildEffectiveHeaders() {
152
167
  const hdrs = parseHeadersText(headersArea.value);
153
168
  const aType = authTypeSel.value;
154
169
  const aVal = authValInput.value.trim();
155
170
  if (aType === 'bearer' && aVal) hdrs['Authorization'] = `Bearer ${aVal}`;
156
171
  else if (aType === 'apikey' && aVal) hdrs['X-API-Key'] = aVal;
157
- else if (aType === 'basic' && aVal) hdrs['Authorization'] = `Basic ${btoa(aVal)}`;
172
+ else if (aType === 'basic' && aVal) hdrs['Authorization'] = `Basic ${utf8ToBase64(aVal)}`;
158
173
  return hdrs;
159
174
  }
160
175
 
@@ -485,15 +500,19 @@
485
500
  type: 'button',
486
501
  class: 'btn btn-xs',
487
502
  onClick: async () => {
488
- const testMethod = r.method === 'ANY' ? 'GET' : r.method;
489
- const resp = await fetch(samplePath, {
490
- method: testMethod,
491
- headers: testMethod !== 'GET' && testMethod !== 'HEAD' ? { 'Content-Type': 'application/json' } : {},
492
- body: testMethod !== 'GET' && testMethod !== 'HEAD' ? '{"sample":true}' : undefined,
493
- });
494
- const txt = await resp.text();
495
- mockPreview.textContent = `${testMethod} ${samplePath} -> HTTP ${resp.status}\n\n${txt}`;
496
- await loadMocks();
503
+ try {
504
+ const testMethod = r.method === 'ANY' ? 'GET' : r.method;
505
+ const resp = await fetch(samplePath, {
506
+ method: testMethod,
507
+ headers: testMethod !== 'GET' && testMethod !== 'HEAD' ? { 'Content-Type': 'application/json' } : {},
508
+ body: testMethod !== 'GET' && testMethod !== 'HEAD' ? '{"sample":true}' : undefined,
509
+ });
510
+ const txt = await resp.text();
511
+ mockPreview.textContent = `${testMethod} ${samplePath} -> HTTP ${resp.status}\n\n${txt}`;
512
+ await loadMocks();
513
+ } catch (err) {
514
+ toast(err.message, 'err');
515
+ }
497
516
  },
498
517
  },
499
518
  'Test Live',
@@ -513,9 +532,13 @@
513
532
  type: 'button',
514
533
  class: 'btn btn-danger btn-xs',
515
534
  onClick: async () => {
516
- await api(`/api/mocks/${r.id}`, { method: 'DELETE' });
517
- toast('Mock route removed', 'ok');
518
- await loadMocks();
535
+ try {
536
+ await api(`/api/mocks/${encodeURIComponent(r.id)}`, { method: 'DELETE' });
537
+ toast('Mock route removed', 'ok');
538
+ await loadMocks();
539
+ } catch (err) {
540
+ toast(err.message, 'err');
541
+ }
519
542
  },
520
543
  },
521
544
  'Delete',
@@ -625,8 +648,12 @@
625
648
  sseBadge.className = 'badge badge-ok';
626
649
  });
627
650
  sseSource.addEventListener('webhook', async () => {
628
- const refreshed = await api(`/api/webhooks/${encodeURIComponent(activeChannel)}`);
629
- renderWebhookEvents(refreshed.events || []);
651
+ try {
652
+ const refreshed = await api(`/api/webhooks/${encodeURIComponent(activeChannel)}`);
653
+ renderWebhookEvents(refreshed.events || []);
654
+ } catch {
655
+ // Ignore transient refresh errors while SSE stays active
656
+ }
630
657
  });
631
658
  sseSource.addEventListener('cleared', () => {
632
659
  renderWebhookEvents([]);
@@ -642,12 +669,17 @@
642
669
  }
643
670
 
644
671
  async function sendTestWebhook() {
645
- await fetch(`/hook/${encodeURIComponent(activeChannel)}/stripe-demo?env=staging`, {
646
- method: 'POST',
647
- headers: { 'Content-Type': 'application/json', 'X-Webhook-Signature': 't=1700000000,v1=demo_sig' },
648
- body: JSON.stringify({ event: 'invoice.paid', amount: 4900, currency: 'usd', liveTest: true }),
649
- });
650
- toast('Captured test webhook live!', 'ok');
672
+ try {
673
+ const resp = await fetch(`/hook/${encodeURIComponent(activeChannel)}/stripe-demo?env=staging`, {
674
+ method: 'POST',
675
+ headers: { 'Content-Type': 'application/json', 'X-Webhook-Signature': 't=1700000000,v1=demo_sig' },
676
+ body: JSON.stringify({ event: 'invoice.paid', amount: 4900, currency: 'usd', liveTest: true }),
677
+ });
678
+ if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
679
+ toast('Captured test webhook live!', 'ok');
680
+ } catch (err) {
681
+ toast(err.message, 'err');
682
+ }
651
683
  }
652
684
 
653
685
  const layout = h(
@@ -677,8 +709,12 @@
677
709
  type: 'button',
678
710
  class: 'btn btn-ghost btn-xs',
679
711
  onClick: async () => {
680
- const data = await api('/api/mocks');
681
- await copyText(JSON.stringify(data.routes, null, 2), 'Exported mock routes JSON to clipboard');
712
+ try {
713
+ const data = await api('/api/mocks');
714
+ await copyText(JSON.stringify(data.routes, null, 2), 'Exported mock routes JSON to clipboard');
715
+ } catch (err) {
716
+ toast(err.message, 'err');
717
+ }
682
718
  },
683
719
  },
684
720
  'Export JSON',
@@ -701,7 +737,13 @@
701
737
  channelInput,
702
738
  h('button', { type: 'button', class: 'btn btn-sm', onClick: () => connectChannel(channelInput.value) }, 'Switch Channel'),
703
739
  h('button', { type: 'button', class: 'btn btn-primary btn-sm', onClick: sendTestWebhook }, 'Send Test Webhook'),
704
- h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => api(`/api/webhooks/${encodeURIComponent(activeChannel)}`, { method: 'DELETE' }) }, 'Clear'),
740
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: async () => {
741
+ try {
742
+ await api(`/api/webhooks/${encodeURIComponent(activeChannel)}`, { method: 'DELETE' });
743
+ } catch (err) {
744
+ toast(err.message, 'err');
745
+ }
746
+ } }, 'Clear'),
705
747
  ),
706
748
  h(
707
749
  'div',
@@ -236,18 +236,22 @@
236
236
  const httpList = h('div', { class: 'stack', style: { maxHeight: '260px', overflowY: 'auto' } });
237
237
 
238
238
  async function loadHttpStatuses() {
239
- const res = await api(`/api/utils/http-statuses?q=${encodeURIComponent(httpQuery.value)}`);
240
- httpList.textContent = '';
241
- for (const s of res.statuses) {
242
- const cls = s.code < 200 ? 'badge-info' : s.code < 300 ? 'badge-ok' : s.code < 400 ? 'badge-warn' : 'badge-err';
243
- httpList.appendChild(
244
- h(
245
- 'div',
246
- { class: 'list-item' },
247
- h('div', { class: 'row' }, h('span', { class: `badge ${cls}` }, String(s.code)), h('strong', {}, s.title)),
248
- h('div', { style: { fontSize: '12px', color: 'var(--text-muted)' } }, s.description),
249
- ),
250
- );
239
+ try {
240
+ const res = await api(`/api/utils/http-statuses?q=${encodeURIComponent(httpQuery.value)}`);
241
+ httpList.textContent = '';
242
+ for (const s of res.statuses) {
243
+ const cls = s.code < 200 ? 'badge-info' : s.code < 300 ? 'badge-ok' : s.code < 400 ? 'badge-warn' : 'badge-err';
244
+ httpList.appendChild(
245
+ h(
246
+ 'div',
247
+ { class: 'list-item' },
248
+ h('div', { class: 'row' }, h('span', { class: `badge ${cls}` }, String(s.code)), h('strong', {}, s.title)),
249
+ h('div', { style: { fontSize: '12px', color: 'var(--text-muted)' } }, s.description),
250
+ ),
251
+ );
252
+ }
253
+ } catch (err) {
254
+ toast(err.message, 'err');
251
255
  }
252
256
  }
253
257
 
@@ -255,29 +255,33 @@
255
255
  const pwOut = h('div', { class: 'stack' });
256
256
 
257
257
  async function genPasswords() {
258
- const res = await api('/api/crypto/password', {
259
- body: { length: Number(pwLen.value), symbols: pwSym.checked, excludeAmbiguous: pwAmb.checked, count: 3 },
260
- });
261
- pwOut.textContent = '';
262
- for (const item of res.items) {
263
- pwOut.appendChild(
264
- h(
265
- 'div',
266
- { class: 'list-item' },
267
- h(
268
- 'div',
269
- { class: 'row-between' },
270
- h('code', { class: 'mono', style: { wordBreak: 'break-all', fontWeight: '600' } }, item.password),
271
- h('button', { type: 'button', class: 'btn btn-ghost btn-xs', onClick: () => copyText(item.password, 'Password copied') }, 'Copy'),
272
- ),
258
+ try {
259
+ const res = await api('/api/crypto/password', {
260
+ body: { length: Number(pwLen.value), symbols: pwSym.checked, excludeAmbiguous: pwAmb.checked, count: 3 },
261
+ });
262
+ pwOut.textContent = '';
263
+ for (const item of res.items) {
264
+ pwOut.appendChild(
273
265
  h(
274
266
  'div',
275
- { class: 'row' },
276
- h('span', { class: `badge ${item.strength === 'very-strong' || item.strength === 'strong' ? 'badge-ok' : 'badge-warn'}` }, `${item.entropyBits} bits (${item.strength})`),
277
- h('span', { class: 'badge badge-subtle' }, `Offline crack: ${item.crackTimeEstimate}`),
267
+ { class: 'list-item' },
268
+ h(
269
+ 'div',
270
+ { class: 'row-between' },
271
+ h('code', { class: 'mono', style: { wordBreak: 'break-all', fontWeight: '600' } }, item.password),
272
+ h('button', { type: 'button', class: 'btn btn-ghost btn-xs', onClick: () => copyText(item.password, 'Password copied') }, 'Copy'),
273
+ ),
274
+ h(
275
+ 'div',
276
+ { class: 'row' },
277
+ h('span', { class: `badge ${item.strength === 'very-strong' || item.strength === 'strong' ? 'badge-ok' : 'badge-warn'}` }, `${item.entropyBits} bits (${item.strength})`),
278
+ h('span', { class: 'badge badge-subtle' }, `Offline crack: ${item.crackTimeEstimate}`),
279
+ ),
278
280
  ),
279
- ),
280
- );
281
+ );
282
+ }
283
+ } catch (err) {
284
+ toast(err.message, 'err');
281
285
  }
282
286
  }
283
287
 
@@ -295,8 +299,12 @@
295
299
  const idOut = h('pre', { class: 'code-box' }, '');
296
300
 
297
301
  async function genIds() {
298
- const res = await api('/api/crypto/ids', { body: { kind: idKind.value, count: 6 } });
299
- idOut.textContent = res.ids.join('\n');
302
+ try {
303
+ const res = await api('/api/crypto/ids', { body: { kind: idKind.value, count: 6 } });
304
+ idOut.textContent = res.ids.join('\n');
305
+ } catch (err) {
306
+ toast(err.message, 'err');
307
+ }
300
308
  }
301
309
 
302
310
  const layout = h(
@@ -105,9 +105,13 @@
105
105
  type: 'button',
106
106
  class: 'btn btn-xs btn-primary',
107
107
  onClick: async () => {
108
- await api('/api/workspace/environments/active', { body: { id: env.id } });
109
- toast(`Switched active environment -> ${env.name}`, 'ok');
110
- await refreshWorkspace();
108
+ try {
109
+ await api('/api/workspace/environments/active', { body: { id: env.id } });
110
+ toast(`Switched active environment -> ${env.name}`, 'ok');
111
+ await refreshWorkspace();
112
+ } catch (err) {
113
+ toast(err.message, 'err');
114
+ }
111
115
  },
112
116
  },
113
117
  'Set Active',
@@ -136,9 +140,13 @@
136
140
  type: 'button',
137
141
  class: 'btn btn-xs btn-ghost',
138
142
  onClick: async () => {
139
- await api(`/api/workspace/environments/${encodeURIComponent(env.id)}`, { method: 'DELETE' });
140
- toast(`Deleted environment "${env.name}"`, 'ok');
141
- await refreshWorkspace();
143
+ try {
144
+ await api(`/api/workspace/environments/${encodeURIComponent(env.id)}`, { method: 'DELETE' });
145
+ toast(`Deleted environment "${env.name}"`, 'ok');
146
+ await refreshWorkspace();
147
+ } catch (err) {
148
+ toast(err.message, 'err');
149
+ }
142
150
  },
143
151
  },
144
152
  'Delete',
@@ -289,9 +297,13 @@
289
297
  type: 'button',
290
298
  class: 'btn btn-xs btn-ghost',
291
299
  onClick: async () => {
292
- await api(`/api/workspace/collections/${encodeURIComponent(col.id)}/requests/${encodeURIComponent(req.id)}`, { method: 'DELETE' });
293
- toast(`Deleted request "${req.name}"`, 'ok');
294
- await refreshWorkspace();
300
+ try {
301
+ await api(`/api/workspace/collections/${encodeURIComponent(col.id)}/requests/${encodeURIComponent(req.id)}`, { method: 'DELETE' });
302
+ toast(`Deleted request "${req.name}"`, 'ok');
303
+ await refreshWorkspace();
304
+ } catch (err) {
305
+ toast(err.message, 'err');
306
+ }
295
307
  },
296
308
  },
297
309
  'Delete Request',
@@ -393,9 +405,13 @@
393
405
  type: 'button',
394
406
  class: 'btn btn-xs btn-ghost',
395
407
  onClick: async () => {
396
- await api(`/api/workspace/collections/${encodeURIComponent(col.id)}`, { method: 'DELETE' });
397
- toast(`Deleted collection "${col.name}"`, 'ok');
398
- await refreshWorkspace();
408
+ try {
409
+ await api(`/api/workspace/collections/${encodeURIComponent(col.id)}`, { method: 'DELETE' });
410
+ toast(`Deleted collection "${col.name}"`, 'ok');
411
+ await refreshWorkspace();
412
+ } catch (err) {
413
+ toast(err.message, 'err');
414
+ }
399
415
  },
400
416
  },
401
417
  'Delete',
@@ -429,8 +445,12 @@
429
445
  type: 'button',
430
446
  class: 'btn btn-sm',
431
447
  onClick: async () => {
432
- const data = await api('/api/workspace');
433
- await copyText(JSON.stringify(data.workspace, null, 2), 'Exported devanvil.json to clipboard');
448
+ try {
449
+ const data = await api('/api/workspace');
450
+ await copyText(JSON.stringify(data.workspace, null, 2), 'Exported devanvil.json to clipboard');
451
+ } catch (err) {
452
+ toast(err.message, 'err');
453
+ }
434
454
  },
435
455
  },
436
456
  'Export devanvil.json',
@@ -163,9 +163,13 @@
163
163
  type: 'button',
164
164
  class: 'btn btn-xs btn-primary',
165
165
  onClick: async () => {
166
- const res = await api('/api/recorder/export', { body: { mode: 'openapi' } });
167
- recOut.textContent = JSON.stringify(res.spec, null, 2);
168
- await copyText(recOut.textContent, 'Inferred OpenAPI 3.0.3 copied to clipboard!');
166
+ try {
167
+ const res = await api('/api/recorder/export', { body: { mode: 'openapi' } });
168
+ recOut.textContent = JSON.stringify(res.spec, null, 2);
169
+ await copyText(recOut.textContent, 'Inferred OpenAPI 3.0.3 copied to clipboard!');
170
+ } catch (err) {
171
+ toast(err.message, 'err');
172
+ }
169
173
  },
170
174
  },
171
175
  'Infer OpenAPI 3.0',
@@ -176,8 +180,12 @@
176
180
  type: 'button',
177
181
  class: 'btn btn-xs',
178
182
  onClick: async () => {
179
- const res = await api('/api/recorder/export', { body: { mode: 'mocks' } });
180
- toast(`Mounted ${res.mountedCount} recorded route(s) at /mock/*`, 'ok');
183
+ try {
184
+ const res = await api('/api/recorder/export', { body: { mode: 'mocks' } });
185
+ toast(`Mounted ${res.mountedCount} recorded route(s) at /mock/*`, 'ok');
186
+ } catch (err) {
187
+ toast(err.message, 'err');
188
+ }
181
189
  },
182
190
  },
183
191
  'Mount as Mocks',
@@ -188,8 +196,12 @@
188
196
  type: 'button',
189
197
  class: 'btn btn-xs',
190
198
  onClick: async () => {
191
- const res = await api('/api/recorder/export', { body: { mode: 'collection' } });
192
- toast(`Saved ${res.requestCount} recorded request(s) to Workspace Collection`, 'ok');
199
+ try {
200
+ const res = await api('/api/recorder/export', { body: { mode: 'collection' } });
201
+ toast(`Saved ${res.requestCount} recorded request(s) to Workspace Collection`, 'ok');
202
+ } catch (err) {
203
+ toast(err.message, 'err');
204
+ }
193
205
  },
194
206
  },
195
207
  'Save Collection',
@@ -200,9 +212,13 @@
200
212
  type: 'button',
201
213
  class: 'btn btn-xs btn-ghost',
202
214
  onClick: async () => {
203
- await api('/api/recorder', { method: 'DELETE' });
204
- recOut.textContent = 'Recorder cleared.';
205
- await refreshRecorder();
215
+ try {
216
+ await api('/api/recorder', { method: 'DELETE' });
217
+ recOut.textContent = 'Recorder cleared.';
218
+ await refreshRecorder();
219
+ } catch (err) {
220
+ toast(err.message, 'err');
221
+ }
206
222
  },
207
223
  },
208
224
  'Clear',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devanvil",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Local-first, zero-dependency offline Developer Studio, MCP Server & CLI — 14 local studios: OpenAPI-to-Mock, Workspaces + Postman/HAR Import, Record & Replay, SSE Stream Tester, Secret & .env Guard (SARIF), LLM Token Studio, JWT, Regex/ReDoS & Pipelines.",
5
5
  "keywords": [
6
6
  "developer-tools",