devanvil 0.0.0-stage → 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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.ar.md +113 -0
  3. package/README.md +272 -2
  4. package/SECURITY.md +49 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +664 -0
  7. package/dist/core/contract-drift.d.ts +49 -0
  8. package/dist/core/contract-drift.js +312 -0
  9. package/dist/core/converters.d.ts +18 -0
  10. package/dist/core/converters.js +989 -0
  11. package/dist/core/cron.d.ts +33 -0
  12. package/dist/core/cron.js +309 -0
  13. package/dist/core/crypto.d.ts +59 -0
  14. package/dist/core/crypto.js +260 -0
  15. package/dist/core/curl.d.ts +17 -0
  16. package/dist/core/curl.js +174 -0
  17. package/dist/core/diff.d.ts +36 -0
  18. package/dist/core/diff.js +148 -0
  19. package/dist/core/encoding.d.ts +3 -0
  20. package/dist/core/encoding.js +143 -0
  21. package/dist/core/importers.d.ts +65 -0
  22. package/dist/core/importers.js +361 -0
  23. package/dist/core/jwt.d.ts +39 -0
  24. package/dist/core/jwt.js +269 -0
  25. package/dist/core/llm-tokens.d.ts +38 -0
  26. package/dist/core/llm-tokens.js +125 -0
  27. package/dist/core/log-analyzer.d.ts +30 -0
  28. package/dist/core/log-analyzer.js +155 -0
  29. package/dist/core/network.d.ts +72 -0
  30. package/dist/core/network.js +185 -0
  31. package/dist/core/oauth-protobuf.d.ts +74 -0
  32. package/dist/core/oauth-protobuf.js +396 -0
  33. package/dist/core/openapi.d.ts +27 -0
  34. package/dist/core/openapi.js +257 -0
  35. package/dist/core/pipeline.d.ts +28 -0
  36. package/dist/core/pipeline.js +154 -0
  37. package/dist/core/regex.d.ts +50 -0
  38. package/dist/core/regex.js +360 -0
  39. package/dist/core/runner.d.ts +53 -0
  40. package/dist/core/runner.js +250 -0
  41. package/dist/core/secrets.d.ts +87 -0
  42. package/dist/core/secrets.js +603 -0
  43. package/dist/core/security.d.ts +34 -0
  44. package/dist/core/security.js +301 -0
  45. package/dist/core/sql-explain.d.ts +50 -0
  46. package/dist/core/sql-explain.js +259 -0
  47. package/dist/core/tls.d.ts +44 -0
  48. package/dist/core/tls.js +169 -0
  49. package/dist/index.d.ts +31 -0
  50. package/dist/index.js +31 -0
  51. package/dist/server/app.d.ts +31 -0
  52. package/dist/server/app.js +359 -0
  53. package/dist/server/http-proxy.d.ts +55 -0
  54. package/dist/server/http-proxy.js +373 -0
  55. package/dist/server/http-utils.d.ts +28 -0
  56. package/dist/server/http-utils.js +118 -0
  57. package/dist/server/load-tester.d.ts +53 -0
  58. package/dist/server/load-tester.js +137 -0
  59. package/dist/server/mcp.d.ts +35 -0
  60. package/dist/server/mcp.js +470 -0
  61. package/dist/server/mock-store.d.ts +38 -0
  62. package/dist/server/mock-store.js +238 -0
  63. package/dist/server/plugin-loader.d.ts +61 -0
  64. package/dist/server/plugin-loader.js +305 -0
  65. package/dist/server/recorder-store.d.ts +35 -0
  66. package/dist/server/recorder-store.js +147 -0
  67. package/dist/server/routes/network-routes.d.ts +3 -0
  68. package/dist/server/routes/network-routes.js +441 -0
  69. package/dist/server/routes/tools-routes.d.ts +3 -0
  70. package/dist/server/routes/tools-routes.js +299 -0
  71. package/dist/server/routes/workspace-routes.d.ts +3 -0
  72. package/dist/server/routes/workspace-routes.js +262 -0
  73. package/dist/server/webhook-store.d.ts +29 -0
  74. package/dist/server/webhook-store.js +100 -0
  75. package/dist/server/workspace-store.d.ts +91 -0
  76. package/dist/server/workspace-store.js +448 -0
  77. package/dist/server/ws-probe.d.ts +34 -0
  78. package/dist/server/ws-probe.js +291 -0
  79. package/dist/ui/app.js +290 -0
  80. package/dist/ui/favicon.svg +14 -0
  81. package/dist/ui/index.html +83 -0
  82. package/dist/ui/logo.png +0 -0
  83. package/dist/ui/styles.css +694 -0
  84. package/dist/ui/tools-data.js +719 -0
  85. package/dist/ui/tools-network.js +769 -0
  86. package/dist/ui/tools-ops.js +299 -0
  87. package/dist/ui/tools-pro.js +500 -0
  88. package/dist/ui/tools-security.js +397 -0
  89. package/dist/ui/tools-v12.js +765 -0
  90. package/dist/ui/tools-v13.js +321 -0
  91. package/dist/ui/tools-v20.js +563 -0
  92. package/dist/ui/tools-v21.js +411 -0
  93. package/package.json +75 -4
@@ -0,0 +1,397 @@
1
+ (function () {
2
+ 'use strict';
3
+ const { h, api, toast, copyText, registerTool } = window.DevAnvil;
4
+
5
+ // ───────────────────────────────────────────────────────────────────────────
6
+ // 3. JWT Studio (Decode, Security Audit, Sign & Verify)
7
+ // ───────────────────────────────────────────────────────────────────────────
8
+ registerTool({
9
+ id: 'jwt-studio',
10
+ group: 'Security & Identity',
11
+ name: 'JWT Studio',
12
+ icon: '🔐',
13
+ subtitle: 'Inspect, security-audit, sign & verify HS256/384/512 and RS256/ES256 JWTs',
14
+ keywords: ['jwt', 'token', 'oauth', 'auth', 'hs256', 'rs256', 'es256', 'verify', 'sign'],
15
+ render(root) {
16
+ const tokenInput = h('textarea', { rows: 4, placeholder: 'Paste JWT (header.payload.signature) or generate one below…' });
17
+ const algSel = h(
18
+ 'select',
19
+ { style: { width: '120px' } },
20
+ ['HS256', 'HS384', 'HS512', 'RS256', 'ES256'].map((a) => h('option', { value: a }, a)),
21
+ );
22
+ const secretInput = h('textarea', {
23
+ rows: 3,
24
+ value: 'devanvil-super-secret-signing-key-2026',
25
+ placeholder: 'HMAC secret or PEM private/public key',
26
+ });
27
+ const payloadInput = h('textarea', {
28
+ rows: 6,
29
+ value: JSON.stringify({ sub: 'usr_019374f1', name: 'Ada Lovelace', role: 'admin', scope: 'read:api write:api' }, null, 2),
30
+ });
31
+ const ttlInput = h('input', { type: 'number', value: '3600', min: '0', style: { width: '110px' } });
32
+
33
+ const verifyBanner = h('div', {});
34
+ const auditBox = h('div', { class: 'stack' });
35
+ const headerPre = h('pre', { class: 'code-box' }, '{}');
36
+ const payloadPre = h('pre', { class: 'code-box' }, '{}');
37
+
38
+ function renderDecoded(decoded) {
39
+ headerPre.textContent = JSON.stringify(decoded.header, null, 2);
40
+ payloadPre.textContent = JSON.stringify({ ...decoded.payload, _timestamps: decoded.timestamps }, null, 2);
41
+ auditBox.textContent = '';
42
+ for (const f of decoded.audit || []) {
43
+ auditBox.appendChild(
44
+ h(
45
+ 'div',
46
+ { class: `finding ${f.severity}` },
47
+ h('span', { class: 'mono', style: { fontWeight: '700' } }, `[${f.code}]`),
48
+ h('span', {}, f.message),
49
+ ),
50
+ );
51
+ }
52
+ }
53
+
54
+ async function doDecode() {
55
+ try {
56
+ const decoded = await api('/api/jwt/decode', { body: { token: tokenInput.value } });
57
+ renderDecoded(decoded);
58
+ verifyBanner.textContent = '';
59
+ } catch (err) {
60
+ toast(err.message, 'err');
61
+ }
62
+ }
63
+
64
+ async function doSign() {
65
+ try {
66
+ const payload = JSON.parse(payloadInput.value);
67
+ const res = await api('/api/jwt/sign', {
68
+ body: {
69
+ payload,
70
+ secret: secretInput.value,
71
+ alg: algSel.value,
72
+ expiresInSeconds: Number(ttlInput.value) || undefined,
73
+ },
74
+ });
75
+ tokenInput.value = res.token;
76
+ renderDecoded(res.decoded);
77
+ verifyBanner.textContent = '';
78
+ verifyBanner.appendChild(h('div', { class: 'finding pass' }, `Signed valid ${algSel.value} JWT`));
79
+ toast(`Signed ${algSel.value} JWT`, 'ok');
80
+ } catch (err) {
81
+ toast(err.message, 'err');
82
+ }
83
+ }
84
+
85
+ async function doVerify() {
86
+ try {
87
+ const res = await api('/api/jwt/verify', {
88
+ body: { token: tokenInput.value, secret: secretInput.value },
89
+ });
90
+ renderDecoded(res.decoded);
91
+ verifyBanner.textContent = '';
92
+ if (res.valid) {
93
+ verifyBanner.appendChild(h('div', { class: 'finding pass' }, 'Signature & claims verified cryptographically (VALID)'));
94
+ } else {
95
+ verifyBanner.appendChild(h('div', { class: 'finding critical' }, `Verification FAILED: ${res.reason || 'Invalid token'}`));
96
+ }
97
+ } catch (err) {
98
+ verifyBanner.textContent = '';
99
+ verifyBanner.appendChild(h('div', { class: 'finding critical' }, err.message));
100
+ }
101
+ }
102
+
103
+ async function genKeyPair(type) {
104
+ try {
105
+ const kp = await api('/api/jwt/keypair', { body: { type } });
106
+ algSel.value = kp.algorithmHint;
107
+ secretInput.value = kp.privateKeyPem;
108
+ toast(`Generated ${kp.algorithmHint} keypair! Public key copied to clipboard.`, 'ok');
109
+ await copyText(kp.publicKeyPem, `Generated ${kp.algorithmHint} keypair (Public PEM copied)`);
110
+ } catch (err) {
111
+ toast(err.message, 'err');
112
+ }
113
+ }
114
+
115
+ const layout = h(
116
+ 'div',
117
+ { class: 'stack' },
118
+ h(
119
+ 'div',
120
+ { class: 'card' },
121
+ h(
122
+ 'div',
123
+ { class: 'row-between' },
124
+ h('h2', { class: 'card-title' }, 'Encoded JWT'),
125
+ h(
126
+ 'div',
127
+ { class: 'row' },
128
+ h('button', { type: 'button', class: 'btn btn-sm', onClick: doDecode }, 'Decode & Audit'),
129
+ h('button', { type: 'button', class: 'btn btn-primary btn-sm', onClick: doVerify }, 'Verify Signature'),
130
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => copyText(tokenInput.value) }, 'Copy Token'),
131
+ ),
132
+ ),
133
+ tokenInput,
134
+ verifyBanner,
135
+ ),
136
+ h(
137
+ 'div',
138
+ { class: 'grid-2' },
139
+ h(
140
+ 'div',
141
+ { class: 'card' },
142
+ h('h2', { class: 'card-title' }, 'Sign / Generate JWT'),
143
+ h(
144
+ 'div',
145
+ { class: 'row' },
146
+ h('div', {}, h('label', { class: 'field-label' }, 'Algorithm'), algSel),
147
+ h('div', {}, h('label', { class: 'field-label' }, 'Expires In (sec)'), ttlInput),
148
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', style: { marginTop: '18px' }, onClick: () => genKeyPair('ec') }, 'Gen ES256 Keys'),
149
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', style: { marginTop: '18px' }, onClick: () => genKeyPair('rsa') }, 'Gen RS256 Keys'),
150
+ ),
151
+ h('div', {}, h('label', { class: 'field-label' }, 'Secret / Private or Public PEM Key'), secretInput),
152
+ h('div', {}, h('label', { class: 'field-label' }, 'Payload JSON'), payloadInput),
153
+ h('div', { class: 'row' }, h('button', { type: 'button', class: 'btn btn-primary', onClick: doSign }, 'Sign New Token')),
154
+ ),
155
+ h(
156
+ 'div',
157
+ { class: 'stack' },
158
+ h('div', { class: 'card' }, h('h2', { class: 'card-title' }, 'Security Audit Findings'), auditBox),
159
+ h('div', { class: 'card' }, h('h2', { class: 'card-title' }, 'Decoded Header'), headerPre),
160
+ h('div', { class: 'card' }, h('h2', { class: 'card-title' }, 'Decoded Payload & Timestamps'), payloadPre),
161
+ ),
162
+ ),
163
+ );
164
+
165
+ root.appendChild(layout);
166
+ void doSign();
167
+ },
168
+ });
169
+
170
+ // ───────────────────────────────────────────────────────────────────────────
171
+ // 4. Crypto, Hashing, Encoders & Identity Studio
172
+ // ───────────────────────────────────────────────────────────────────────────
173
+ registerTool({
174
+ id: 'crypto-studio',
175
+ group: 'Security & Identity',
176
+ name: 'Crypto, Encode & IDs',
177
+ icon: '🔑',
178
+ subtitle: 'AES-256-GCM encryption, SHA/BLAKE2b/HMAC, Password entropy, UUIDv7/ULID & Multi-Codec Encoder',
179
+ keywords: ['crypto', 'aes', 'sha256', 'hmac', 'password', 'uuid', 'uuidv7', 'ulid', 'nanoid', 'base64', 'hex', 'gzip', 'encode'],
180
+ render(root) {
181
+ // --- Panel A: Multi-Codec Encoder/Decoder ---
182
+ const codecSel = h(
183
+ 'select',
184
+ { style: { width: '165px' } },
185
+ [
186
+ ['base64', 'Base64'],
187
+ ['base64url', 'Base64URL'],
188
+ ['hex', 'Hexadecimal'],
189
+ ['url', 'URL Percent'],
190
+ ['html', 'HTML Entities'],
191
+ ['unicode', 'Unicode \\uXXXX'],
192
+ ['gzip-base64', 'Gzip + Base64'],
193
+ ['deflate-base64', 'Deflate + Base64'],
194
+ ['binary', 'Binary (8-bit)'],
195
+ ['rot13', 'ROT13'],
196
+ ].map(([v, label]) => h('option', { value: v }, label)),
197
+ );
198
+ const encIn = h('textarea', { rows: 3, value: 'DevAnvil — Zero-dependency offline developer workbench!' });
199
+ const encOut = h('pre', { class: 'code-box' }, '');
200
+
201
+ async function runCodec(mode) {
202
+ try {
203
+ const res = await api('/api/encode', { body: { mode, codec: codecSel.value, input: encIn.value } });
204
+ encOut.textContent = res.output;
205
+ } catch (err) {
206
+ toast(err.message, 'err');
207
+ }
208
+ }
209
+
210
+ // --- Panel B: Hash & HMAC ---
211
+ const hashAlgo = h(
212
+ 'select',
213
+ { style: { width: '140px' } },
214
+ ['sha256', 'sha512', 'sha384', 'blake2b512', 'blake2s256', 'sha1', 'md5'].map((a) => h('option', { value: a }, a.toUpperCase())),
215
+ );
216
+ const hashInput = h('textarea', { rows: 2, value: 'hello devanvil' });
217
+ const hmacSecret = h('input', { type: 'text', placeholder: 'Optional HMAC secret key…' });
218
+ const hashOut = h('pre', { class: 'code-box' }, '');
219
+
220
+ async function runHash() {
221
+ try {
222
+ const res = await api('/api/crypto/hash', {
223
+ body: { input: hashInput.value, algorithm: hashAlgo.value, hmacSecret: hmacSecret.value || undefined },
224
+ });
225
+ hashOut.textContent = [
226
+ `Algorithm: ${res.algorithm.toUpperCase()} (${res.bits}-bit)`,
227
+ `HEX: ${res.hex}`,
228
+ `Base64: ${res.base64}`,
229
+ ...(res.warning ? [`\nWARNING: ${res.warning}`] : []),
230
+ ].join('\n');
231
+ } catch (err) {
232
+ toast(err.message, 'err');
233
+ }
234
+ }
235
+
236
+ // --- Panel C: AES-256-GCM Authenticated Encryption ---
237
+ const aesPass = h('input', { type: 'password', value: 'correct-horse-battery-staple', placeholder: 'Passphrase (scrypt KDF)' });
238
+ const aesIn = h('textarea', { rows: 3, value: 'Top-secret API config payload' });
239
+ const aesOut = h('pre', { class: 'code-box' }, '');
240
+
241
+ async function runAes(mode) {
242
+ try {
243
+ const res = await api('/api/crypto/aes', { body: { mode, input: aesIn.value, passphrase: aesPass.value } });
244
+ aesOut.textContent = res.output;
245
+ toast(mode === 'encrypt' ? 'Encrypted with AES-256-GCM' : 'Decrypted & authenticated!', 'ok');
246
+ } catch (err) {
247
+ toast(err.message, 'err');
248
+ }
249
+ }
250
+
251
+ // --- Panel D: CSPRNG Password & IDs ---
252
+ const pwLen = h('input', { type: 'number', value: '24', min: '8', max: '128', style: { width: '80px' } });
253
+ const pwSym = h('input', { type: 'checkbox', checked: true });
254
+ const pwAmb = h('input', { type: 'checkbox', checked: true });
255
+ const pwOut = h('div', { class: 'stack' });
256
+
257
+ async function genPasswords() {
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(
265
+ h(
266
+ 'div',
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
+ ),
280
+ ),
281
+ );
282
+ }
283
+ } catch (err) {
284
+ toast(err.message, 'err');
285
+ }
286
+ }
287
+
288
+ const idKind = h(
289
+ 'select',
290
+ { style: { width: '140px' } },
291
+ [
292
+ ['uuidv7', 'UUID v7 (Sortable)'],
293
+ ['uuidv4', 'UUID v4 (Random)'],
294
+ ['ulid', 'ULID (26-char)'],
295
+ ['nanoid', 'NanoID (21-char)'],
296
+ ['apikey', 'API Key Token'],
297
+ ].map(([v, l]) => h('option', { value: v }, l)),
298
+ );
299
+ const idOut = h('pre', { class: 'code-box' }, '');
300
+
301
+ async function genIds() {
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
+ }
308
+ }
309
+
310
+ const layout = h(
311
+ 'div',
312
+ { class: 'grid-2' },
313
+ h(
314
+ 'div',
315
+ { class: 'card' },
316
+ h('div', { class: 'row-between' }, h('h2', { class: 'card-title' }, 'Multi-Codec Encoder / Decoder'), codecSel),
317
+ encIn,
318
+ h(
319
+ 'div',
320
+ { class: 'row' },
321
+ h('button', { type: 'button', class: 'btn btn-primary btn-sm', onClick: () => runCodec('encode') }, 'Encode'),
322
+ h('button', { type: 'button', class: 'btn btn-sm', onClick: () => runCodec('decode') }, 'Decode'),
323
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => { encIn.value = encOut.textContent; } }, 'Swap -> Input'),
324
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => copyText(encOut.textContent) }, 'Copy'),
325
+ ),
326
+ encOut,
327
+ ),
328
+ h(
329
+ 'div',
330
+ { class: 'card' },
331
+ h('div', { class: 'row-between' }, h('h2', { class: 'card-title' }, 'Hash & HMAC Generator'), hashAlgo),
332
+ hashInput,
333
+ hmacSecret,
334
+ h(
335
+ 'div',
336
+ { class: 'row' },
337
+ h('button', { type: 'button', class: 'btn btn-primary btn-sm', onClick: runHash }, 'Compute Digest'),
338
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => copyText(hashOut.textContent) }, 'Copy'),
339
+ ),
340
+ hashOut,
341
+ ),
342
+ h(
343
+ 'div',
344
+ { class: 'card' },
345
+ h('h2', { class: 'card-title' }, 'AES-256-GCM Authenticated Encryption'),
346
+ h('div', {}, h('label', { class: 'field-label' }, 'Passphrase (scrypt + random salt & 96-bit IV)'), aesPass),
347
+ aesIn,
348
+ h(
349
+ 'div',
350
+ { class: 'row' },
351
+ h('button', { type: 'button', class: 'btn btn-primary btn-sm', onClick: () => runAes('encrypt') }, 'Encrypt'),
352
+ h('button', { type: 'button', class: 'btn btn-sm', onClick: () => runAes('decrypt') }, 'Decrypt'),
353
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => { aesIn.value = aesOut.textContent; } }, 'Use Output as Input'),
354
+ h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => copyText(aesOut.textContent) }, 'Copy'),
355
+ ),
356
+ aesOut,
357
+ ),
358
+ h(
359
+ 'div',
360
+ { class: 'stack' },
361
+ h(
362
+ 'div',
363
+ { class: 'card' },
364
+ h('h2', { class: 'card-title' }, 'CSPRNG Password & Entropy Studio'),
365
+ h(
366
+ 'div',
367
+ { class: 'row' },
368
+ h('span', { style: { fontSize: '12px', color: 'var(--text-muted)' } }, 'Length:'),
369
+ pwLen,
370
+ h('label', { class: 'row', style: { fontSize: '12px' } }, pwSym, 'Symbols'),
371
+ h('label', { class: 'row', style: { fontSize: '12px' } }, pwAmb, 'No Ambiguous'),
372
+ h('button', { type: 'button', class: 'btn btn-primary btn-sm', onClick: genPasswords }, 'Generate'),
373
+ ),
374
+ pwOut,
375
+ ),
376
+ h(
377
+ 'div',
378
+ { class: 'card' },
379
+ h(
380
+ 'div',
381
+ { class: 'row-between' },
382
+ h('h2', { class: 'card-title' }, 'ID & Token Batch Generator'),
383
+ h('div', { class: 'row' }, idKind, h('button', { type: 'button', class: 'btn btn-primary btn-sm', onClick: genIds }, 'Generate'), h('button', { type: 'button', class: 'btn btn-ghost btn-sm', onClick: () => copyText(idOut.textContent) }, 'Copy All')),
384
+ ),
385
+ idOut,
386
+ ),
387
+ ),
388
+ );
389
+
390
+ root.appendChild(layout);
391
+ void runCodec('encode');
392
+ void runHash();
393
+ void genPasswords();
394
+ void genIds();
395
+ },
396
+ });
397
+ })();