@aiconnect/confidant 1.1.0 → 1.3.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/README.md +18 -6
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/request.d.ts.map +1 -1
- package/dist/commands/request.js +2 -0
- package/dist/commands/request.js.map +1 -1
- package/dist/commands/serve-request.d.ts.map +1 -1
- package/dist/commands/serve-request.js +2 -0
- package/dist/commands/serve-request.js.map +1 -1
- package/dist/crypto.d.ts +1 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +2 -6
- package/dist/crypto.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +4 -6
- package/dist/registry.js.map +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +11 -400
- package/dist/routes.js.map +1 -1
- package/dist/storage.d.ts +14 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +32 -10
- package/dist/storage.js.map +1 -1
- package/dist/templates/request-form.d.ts +15 -0
- package/dist/templates/request-form.d.ts.map +1 -0
- package/dist/templates/request-form.js +533 -0
- package/dist/templates/request-form.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimalist HTML templates for Confidant web forms
|
|
3
|
+
* Following PromptSafe-inspired design
|
|
4
|
+
*/
|
|
5
|
+
export interface RequestFormOptions {
|
|
6
|
+
hash: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
expiresAt: Date;
|
|
9
|
+
type: 'form' | 'not-found' | 'expired' | 'completed';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generate minimalist HTML for secret request form
|
|
13
|
+
*/
|
|
14
|
+
export declare function getRequestFormHtml(options: RequestFormOptions): string;
|
|
15
|
+
//# sourceMappingURL=request-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-form.d.ts","sourceRoot":"","sources":["../../src/templates/request-form.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;CACtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAgBtE"}
|
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimalist HTML templates for Confidant web forms
|
|
3
|
+
* Following PromptSafe-inspired design
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate minimalist HTML for secret request form
|
|
7
|
+
*/
|
|
8
|
+
export function getRequestFormHtml(options) {
|
|
9
|
+
const { hash, label, expiresAt, type } = options;
|
|
10
|
+
if (type === 'not-found') {
|
|
11
|
+
return getNotFoundHtml();
|
|
12
|
+
}
|
|
13
|
+
if (type === 'expired') {
|
|
14
|
+
return getExpiredHtml();
|
|
15
|
+
}
|
|
16
|
+
if (type === 'completed') {
|
|
17
|
+
return getCompletedHtml();
|
|
18
|
+
}
|
|
19
|
+
return getFormHtml(hash, label, expiresAt);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Not found page
|
|
23
|
+
*/
|
|
24
|
+
function getNotFoundHtml() {
|
|
25
|
+
return `
|
|
26
|
+
<!DOCTYPE html>
|
|
27
|
+
<html lang="en">
|
|
28
|
+
<head>
|
|
29
|
+
<meta charset="UTF-8">
|
|
30
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
31
|
+
<title>Request Not Found - Confidant</title>
|
|
32
|
+
<style>
|
|
33
|
+
:root {
|
|
34
|
+
--bg-primary: #f8fafc;
|
|
35
|
+
--bg-card: #ffffff;
|
|
36
|
+
--text-primary: #1a202c;
|
|
37
|
+
--text-secondary: #64748b;
|
|
38
|
+
--text-muted: #94a3b8;
|
|
39
|
+
--border-color: #e2e8f0;
|
|
40
|
+
--accent: #1e293b;
|
|
41
|
+
--accent-hover: #334155;
|
|
42
|
+
--success: #10b981;
|
|
43
|
+
--error: #ef4444;
|
|
44
|
+
--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
45
|
+
}
|
|
46
|
+
* {
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: 0;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
}
|
|
51
|
+
body {
|
|
52
|
+
font-family: var(--font-family);
|
|
53
|
+
background: var(--bg-primary);
|
|
54
|
+
min-height: 100vh;
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
padding: 48px 24px;
|
|
59
|
+
}
|
|
60
|
+
.container {
|
|
61
|
+
max-width: 480px;
|
|
62
|
+
width: 100%;
|
|
63
|
+
text-align: center;
|
|
64
|
+
}
|
|
65
|
+
header {
|
|
66
|
+
margin-bottom: 32px;
|
|
67
|
+
}
|
|
68
|
+
.logo {
|
|
69
|
+
font-size: 32px;
|
|
70
|
+
display: block;
|
|
71
|
+
margin-bottom: 8px;
|
|
72
|
+
}
|
|
73
|
+
h1 {
|
|
74
|
+
font-size: 24px;
|
|
75
|
+
font-weight: 700;
|
|
76
|
+
color: var(--text-primary);
|
|
77
|
+
margin-bottom: 0;
|
|
78
|
+
}
|
|
79
|
+
p {
|
|
80
|
+
color: var(--text-secondary);
|
|
81
|
+
font-size: 16px;
|
|
82
|
+
line-height: 1.5;
|
|
83
|
+
}
|
|
84
|
+
@media (max-width: 640px) {
|
|
85
|
+
body {
|
|
86
|
+
padding: 24px 16px;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
90
|
+
</head>
|
|
91
|
+
<body>
|
|
92
|
+
<div class="container">
|
|
93
|
+
<header>
|
|
94
|
+
<span class="logo">🔐</span>
|
|
95
|
+
<h1>Confidant</h1>
|
|
96
|
+
</header>
|
|
97
|
+
<p>The secret request you're looking for doesn't exist or has been removed.</p>
|
|
98
|
+
</div>
|
|
99
|
+
</body>
|
|
100
|
+
</html>`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Expired page
|
|
104
|
+
*/
|
|
105
|
+
function getExpiredHtml() {
|
|
106
|
+
return `
|
|
107
|
+
<!DOCTYPE html>
|
|
108
|
+
<html lang="en">
|
|
109
|
+
<head>
|
|
110
|
+
<meta charset="UTF-8">
|
|
111
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
112
|
+
<title>Request Expired - Confidant</title>
|
|
113
|
+
<style>
|
|
114
|
+
:root {
|
|
115
|
+
--bg-primary: #f8fafc;
|
|
116
|
+
--bg-card: #ffffff;
|
|
117
|
+
--text-primary: #1a202c;
|
|
118
|
+
--text-secondary: #64748b;
|
|
119
|
+
--text-muted: #94a3b8;
|
|
120
|
+
--border-color: #e2e8f0;
|
|
121
|
+
--accent: #1e293b;
|
|
122
|
+
--accent-hover: #334155;
|
|
123
|
+
--success: #10b981;
|
|
124
|
+
--error: #ef4444;
|
|
125
|
+
--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
126
|
+
}
|
|
127
|
+
* {
|
|
128
|
+
margin: 0;
|
|
129
|
+
padding: 0;
|
|
130
|
+
box-sizing: border-box;
|
|
131
|
+
}
|
|
132
|
+
body {
|
|
133
|
+
font-family: var(--font-family);
|
|
134
|
+
background: var(--bg-primary);
|
|
135
|
+
min-height: 100vh;
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
padding: 48px 24px;
|
|
140
|
+
}
|
|
141
|
+
.container {
|
|
142
|
+
max-width: 480px;
|
|
143
|
+
width: 100%;
|
|
144
|
+
text-align: center;
|
|
145
|
+
}
|
|
146
|
+
header {
|
|
147
|
+
margin-bottom: 32px;
|
|
148
|
+
}
|
|
149
|
+
.logo {
|
|
150
|
+
font-size: 32px;
|
|
151
|
+
display: block;
|
|
152
|
+
margin-bottom: 8px;
|
|
153
|
+
}
|
|
154
|
+
h1 {
|
|
155
|
+
font-size: 24px;
|
|
156
|
+
font-weight: 700;
|
|
157
|
+
color: var(--text-primary);
|
|
158
|
+
margin-bottom: 0;
|
|
159
|
+
}
|
|
160
|
+
p {
|
|
161
|
+
color: var(--text-secondary);
|
|
162
|
+
font-size: 16px;
|
|
163
|
+
line-height: 1.5;
|
|
164
|
+
}
|
|
165
|
+
@media (max-width: 640px) {
|
|
166
|
+
body {
|
|
167
|
+
padding: 24px 16px;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
</style>
|
|
171
|
+
</head>
|
|
172
|
+
<body>
|
|
173
|
+
<div class="container">
|
|
174
|
+
<header>
|
|
175
|
+
<span class="logo">🔐</span>
|
|
176
|
+
<h1>Confidant</h1>
|
|
177
|
+
</header>
|
|
178
|
+
<p>This secret request has expired and is no longer available.</p>
|
|
179
|
+
</div>
|
|
180
|
+
</body>
|
|
181
|
+
</html>`;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Completed page
|
|
185
|
+
*/
|
|
186
|
+
function getCompletedHtml() {
|
|
187
|
+
return `
|
|
188
|
+
<!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>Secret Already Submitted - Confidant</title>
|
|
194
|
+
<style>
|
|
195
|
+
:root {
|
|
196
|
+
--bg-primary: #f8fafc;
|
|
197
|
+
--bg-card: #ffffff;
|
|
198
|
+
--text-primary: #1a202c;
|
|
199
|
+
--text-secondary: #64748b;
|
|
200
|
+
--text-muted: #94a3b8;
|
|
201
|
+
--border-color: #e2e8f0;
|
|
202
|
+
--accent: #1e293b;
|
|
203
|
+
--accent-hover: #334155;
|
|
204
|
+
--success: #10b981;
|
|
205
|
+
--error: #ef4444;
|
|
206
|
+
--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
207
|
+
}
|
|
208
|
+
* {
|
|
209
|
+
margin: 0;
|
|
210
|
+
padding: 0;
|
|
211
|
+
box-sizing: border-box;
|
|
212
|
+
}
|
|
213
|
+
body {
|
|
214
|
+
font-family: var(--font-family);
|
|
215
|
+
background: var(--bg-primary);
|
|
216
|
+
min-height: 100vh;
|
|
217
|
+
display: flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
justify-content: center;
|
|
220
|
+
padding: 48px 24px;
|
|
221
|
+
}
|
|
222
|
+
.container {
|
|
223
|
+
max-width: 480px;
|
|
224
|
+
width: 100%;
|
|
225
|
+
text-align: center;
|
|
226
|
+
}
|
|
227
|
+
header {
|
|
228
|
+
margin-bottom: 32px;
|
|
229
|
+
}
|
|
230
|
+
.logo {
|
|
231
|
+
font-size: 32px;
|
|
232
|
+
display: block;
|
|
233
|
+
margin-bottom: 8px;
|
|
234
|
+
}
|
|
235
|
+
h1 {
|
|
236
|
+
font-size: 24px;
|
|
237
|
+
font-weight: 700;
|
|
238
|
+
color: var(--text-primary);
|
|
239
|
+
margin-bottom: 0;
|
|
240
|
+
}
|
|
241
|
+
p {
|
|
242
|
+
color: var(--text-secondary);
|
|
243
|
+
font-size: 16px;
|
|
244
|
+
line-height: 1.5;
|
|
245
|
+
}
|
|
246
|
+
@media (max-width: 640px) {
|
|
247
|
+
body {
|
|
248
|
+
padding: 24px 16px;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
</style>
|
|
252
|
+
</head>
|
|
253
|
+
<body>
|
|
254
|
+
<div class="container">
|
|
255
|
+
<header>
|
|
256
|
+
<span class="logo">🔐</span>
|
|
257
|
+
<h1>Confidant</h1>
|
|
258
|
+
</header>
|
|
259
|
+
<p>This request has already been completed and secret has been retrieved.</p>
|
|
260
|
+
</div>
|
|
261
|
+
</body>
|
|
262
|
+
</html>`;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Form page
|
|
266
|
+
*/
|
|
267
|
+
function getFormHtml(hash, label, expiresAt) {
|
|
268
|
+
const labelHtml = label ? `<p class="label">${escapeHtml(label)}</p>` : '';
|
|
269
|
+
return `
|
|
270
|
+
<!DOCTYPE html>
|
|
271
|
+
<html lang="en">
|
|
272
|
+
<head>
|
|
273
|
+
<meta charset="UTF-8">
|
|
274
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
275
|
+
<title>Submit Secret - Confidant</title>
|
|
276
|
+
<style>
|
|
277
|
+
:root {
|
|
278
|
+
--bg-primary: #f8fafc;
|
|
279
|
+
--bg-card: #ffffff;
|
|
280
|
+
--text-primary: #1a202c;
|
|
281
|
+
--text-secondary: #64748b;
|
|
282
|
+
--text-muted: #94a3b8;
|
|
283
|
+
--border-color: #e2e8f0;
|
|
284
|
+
--accent: #1e293b;
|
|
285
|
+
--accent-hover: #334155;
|
|
286
|
+
--success: #10b981;
|
|
287
|
+
--error: #ef4444;
|
|
288
|
+
--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
289
|
+
}
|
|
290
|
+
* {
|
|
291
|
+
margin: 0;
|
|
292
|
+
padding: 0;
|
|
293
|
+
box-sizing: border-box;
|
|
294
|
+
}
|
|
295
|
+
body {
|
|
296
|
+
font-family: var(--font-family);
|
|
297
|
+
background: var(--bg-primary);
|
|
298
|
+
min-height: 100vh;
|
|
299
|
+
display: flex;
|
|
300
|
+
flex-direction: column;
|
|
301
|
+
justify-content: center;
|
|
302
|
+
padding: 48px 24px;
|
|
303
|
+
}
|
|
304
|
+
.container {
|
|
305
|
+
max-width: 480px;
|
|
306
|
+
margin: 0 auto;
|
|
307
|
+
width: 100%;
|
|
308
|
+
}
|
|
309
|
+
header {
|
|
310
|
+
text-align: center;
|
|
311
|
+
margin-bottom: 32px;
|
|
312
|
+
}
|
|
313
|
+
.logo {
|
|
314
|
+
font-size: 32px;
|
|
315
|
+
display: block;
|
|
316
|
+
margin-bottom: 8px;
|
|
317
|
+
}
|
|
318
|
+
h1 {
|
|
319
|
+
font-size: 24px;
|
|
320
|
+
font-weight: 700;
|
|
321
|
+
color: var(--text-primary);
|
|
322
|
+
margin-bottom: 0;
|
|
323
|
+
}
|
|
324
|
+
.label {
|
|
325
|
+
font-size: 16px;
|
|
326
|
+
color: var(--text-secondary);
|
|
327
|
+
text-align: center;
|
|
328
|
+
margin-bottom: 24px;
|
|
329
|
+
font-weight: 500;
|
|
330
|
+
word-wrap: break-word;
|
|
331
|
+
}
|
|
332
|
+
textarea {
|
|
333
|
+
width: 100%;
|
|
334
|
+
min-height: 160px;
|
|
335
|
+
padding: 16px;
|
|
336
|
+
border: 1px solid var(--border-color);
|
|
337
|
+
border-radius: 8px;
|
|
338
|
+
font-size: 16px;
|
|
339
|
+
font-family: inherit;
|
|
340
|
+
resize: vertical;
|
|
341
|
+
outline: none;
|
|
342
|
+
transition: border-color 0.2s;
|
|
343
|
+
}
|
|
344
|
+
textarea:focus {
|
|
345
|
+
border-color: var(--accent);
|
|
346
|
+
}
|
|
347
|
+
button {
|
|
348
|
+
width: 100%;
|
|
349
|
+
padding: 14px 24px;
|
|
350
|
+
background: var(--accent);
|
|
351
|
+
color: white;
|
|
352
|
+
border: none;
|
|
353
|
+
border-radius: 8px;
|
|
354
|
+
font-size: 16px;
|
|
355
|
+
font-weight: 600;
|
|
356
|
+
cursor: pointer;
|
|
357
|
+
margin-top: 16px;
|
|
358
|
+
transition: background-color 0.2s;
|
|
359
|
+
}
|
|
360
|
+
button:hover {
|
|
361
|
+
background: var(--accent-hover);
|
|
362
|
+
}
|
|
363
|
+
button:disabled {
|
|
364
|
+
opacity: 0.5;
|
|
365
|
+
cursor: not-allowed;
|
|
366
|
+
}
|
|
367
|
+
footer {
|
|
368
|
+
text-align: center;
|
|
369
|
+
margin-top: 24px;
|
|
370
|
+
font-size: 14px;
|
|
371
|
+
color: var(--text-muted);
|
|
372
|
+
}
|
|
373
|
+
.message {
|
|
374
|
+
margin-top: 20px;
|
|
375
|
+
padding: 16px;
|
|
376
|
+
border-radius: 8px;
|
|
377
|
+
text-align: center;
|
|
378
|
+
font-weight: 500;
|
|
379
|
+
display: none;
|
|
380
|
+
}
|
|
381
|
+
.message.success {
|
|
382
|
+
display: block;
|
|
383
|
+
background: var(--success);
|
|
384
|
+
color: white;
|
|
385
|
+
}
|
|
386
|
+
.message.error {
|
|
387
|
+
display: block;
|
|
388
|
+
background: var(--error);
|
|
389
|
+
color: white;
|
|
390
|
+
}
|
|
391
|
+
@media (max-width: 640px) {
|
|
392
|
+
body {
|
|
393
|
+
padding: 24px 16px;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
</style>
|
|
397
|
+
</head>
|
|
398
|
+
<body>
|
|
399
|
+
<div class="container">
|
|
400
|
+
<header>
|
|
401
|
+
<span class="logo">🔐</span>
|
|
402
|
+
<h1>Confidant</h1>
|
|
403
|
+
</header>
|
|
404
|
+
|
|
405
|
+
${labelHtml}
|
|
406
|
+
|
|
407
|
+
<form id="secretForm">
|
|
408
|
+
<textarea
|
|
409
|
+
id="secret"
|
|
410
|
+
name="secret"
|
|
411
|
+
required
|
|
412
|
+
placeholder="Enter your secret..."
|
|
413
|
+
maxlength="65536"
|
|
414
|
+
></textarea>
|
|
415
|
+
|
|
416
|
+
<button type="submit" id="submitBtn">Submit Secret</button>
|
|
417
|
+
</form>
|
|
418
|
+
|
|
419
|
+
<footer>
|
|
420
|
+
<span class="timer">⏱️ Expires in <span id="timeRemaining">calculating...</span></span>
|
|
421
|
+
</footer>
|
|
422
|
+
|
|
423
|
+
<div id="message" class="message"></div>
|
|
424
|
+
</div>
|
|
425
|
+
|
|
426
|
+
<script>
|
|
427
|
+
const API_URL = window.location.origin;
|
|
428
|
+
const hash = '${hash}';
|
|
429
|
+
const expiresAt = new Date('${expiresAt.toISOString()}');
|
|
430
|
+
|
|
431
|
+
// Update timer
|
|
432
|
+
function updateTimer() {
|
|
433
|
+
const now = new Date();
|
|
434
|
+
const diff = expiresAt - now;
|
|
435
|
+
|
|
436
|
+
if (diff <= 0) {
|
|
437
|
+
document.getElementById('timeRemaining').textContent = 'expired';
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const hours = Math.floor(diff / (1000 * 60 * 60));
|
|
442
|
+
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
|
|
443
|
+
const seconds = Math.floor((diff % (1000 * 60)) / 1000);
|
|
444
|
+
|
|
445
|
+
let timeStr = '';
|
|
446
|
+
if (hours > 0) {
|
|
447
|
+
timeStr += \`\${hours}h \`;
|
|
448
|
+
}
|
|
449
|
+
if (minutes > 0 || hours > 0) {
|
|
450
|
+
timeStr += \`\${minutes}m \`;
|
|
451
|
+
}
|
|
452
|
+
timeStr += \`\${seconds}s\`;
|
|
453
|
+
|
|
454
|
+
document.getElementById('timeRemaining').textContent = timeStr;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
updateTimer();
|
|
458
|
+
setInterval(updateTimer, 1000);
|
|
459
|
+
|
|
460
|
+
// Form submission
|
|
461
|
+
document.getElementById('secretForm').addEventListener('submit', async (e) => {
|
|
462
|
+
e.preventDefault();
|
|
463
|
+
|
|
464
|
+
const secret = document.getElementById('secret').value.trim();
|
|
465
|
+
const submitBtn = document.getElementById('submitBtn');
|
|
466
|
+
const messageDiv = document.getElementById('message');
|
|
467
|
+
|
|
468
|
+
if (!secret) {
|
|
469
|
+
showMessage('Please enter a secret.', 'error');
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (secret.length > 65536) {
|
|
474
|
+
showMessage('Secret is too large (max 64KB).', 'error');
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
submitBtn.disabled = true;
|
|
479
|
+
submitBtn.textContent = 'Submitting...';
|
|
480
|
+
|
|
481
|
+
try {
|
|
482
|
+
const response = await fetch(\`\${API_URL}/requests/\${hash}\`, {
|
|
483
|
+
method: 'POST',
|
|
484
|
+
headers: {
|
|
485
|
+
'Content-Type': 'application/json'
|
|
486
|
+
},
|
|
487
|
+
body: JSON.stringify({ secret })
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
const data = await response.json();
|
|
491
|
+
|
|
492
|
+
if (response.status === 200) {
|
|
493
|
+
showMessage('Secret submitted successfully!', 'success');
|
|
494
|
+
document.getElementById('secret').value = '';
|
|
495
|
+
submitBtn.style.display = 'none';
|
|
496
|
+
} else if (response.status === 409) {
|
|
497
|
+
showMessage('This request has already been completed.', 'error');
|
|
498
|
+
} else if (response.status === 410) {
|
|
499
|
+
showMessage('This request has expired.', 'error');
|
|
500
|
+
} else {
|
|
501
|
+
showMessage(data.error || 'Failed to submit secret. Please try again.', 'error');
|
|
502
|
+
}
|
|
503
|
+
} catch (error) {
|
|
504
|
+
showMessage('Network error. Please check your connection and try again.', 'error');
|
|
505
|
+
} finally {
|
|
506
|
+
if (submitBtn.style.display !== 'none') {
|
|
507
|
+
submitBtn.disabled = false;
|
|
508
|
+
submitBtn.textContent = 'Submit Secret';
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
function showMessage(text, type) {
|
|
514
|
+
const messageDiv = document.getElementById('message');
|
|
515
|
+
messageDiv.textContent = text;
|
|
516
|
+
messageDiv.className = \`message \${type}\`;
|
|
517
|
+
}
|
|
518
|
+
</script>
|
|
519
|
+
</body>
|
|
520
|
+
</html>`;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Escape HTML to prevent XSS
|
|
524
|
+
*/
|
|
525
|
+
function escapeHtml(text) {
|
|
526
|
+
return text
|
|
527
|
+
.replace(/&/g, '&')
|
|
528
|
+
.replace(/</g, '<')
|
|
529
|
+
.replace(/>/g, '>')
|
|
530
|
+
.replace(/"/g, '"')
|
|
531
|
+
.replace(/'/g, ''');
|
|
532
|
+
}
|
|
533
|
+
//# sourceMappingURL=request-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-form.js","sourceRoot":"","sources":["../../src/templates/request-form.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA2B;IAC5D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,OAAO,eAAe,EAAE,CAAC;IAC3B,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC;IAED,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,OAAO,gBAAgB,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2ED,CAAC;AACT,CAAC;AAED;;GAEG;AACH,SAAS,cAAc;IACrB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2ED,CAAC;AACT,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB;IACvB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2ED,CAAC;AACT,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY,EAAE,KAAyB,EAAE,SAAe;IAC3E,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwIH,SAAS;;;;;;;;;;;;;;;;;;;;;;;oBAuBK,IAAI;kCACU,SAAS,CAAC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2FjD,CAAC;AACT,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
|