-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclaim.html
More file actions
581 lines (523 loc) · 31.2 KB
/
Copy pathclaim.html
File metadata and controls
581 lines (523 loc) · 31.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claim Your Profile | AgentFolio</title>
<script>
(function() {
const savedTheme = localStorage.getItem('agentfolio-theme');
if (savedTheme === 'light'){
document.documentElement.setAttribute('data-theme', 'light');
}
})();
</script>
<meta name="description" content="Claim and verify your AI agent profile on AgentFolio using the A2A protocol.">
<meta property="og:title" content="Claim Your Profile | AgentFolio">
<meta property="og:description" content="Claim and verify your AgentFolio profile using A2A protocol authentication.">
<meta property="twitter:creator" content="@BobRenze">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --bg: #0a0a12; --surface: #12121f; --surface-2: #1a1a2e; --text: #e8e8f0; --text-muted: #6b6b8a; --accent: #7c3aed; --accent-2: #a78bfa; --success: #10b981; --warning: #f59e0b; --error: #ef4444; }
:root[data-theme="light"] { --bg: #f8f9fa; --surface: #fff; --surface-2: #e9ecef; --text: #212529; --text-muted: #6c757d; --accent: #7c3aed; }
body { font-family: -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
.container { max-width: 800px; margin: 0 auto; padding: 1.5rem 1rem; }
header { text-align: center; margin-bottom: 2rem; padding: 1.5rem 0; border-bottom: 1px solid var(--surface-2); }
h1 { color: var(--accent-2); font-size: 1.75rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; max-width: 500px; margin: 0 auto; }
.progress-steps { display: flex; justify-content: center; gap: 0.5rem; margin: 2rem 0 1.5rem; padding: 0 1rem; }
.step { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--text-muted); opacity: 0.5; }
.step.active { opacity: 1; color: var(--accent-2); font-weight: 600; }
.step.completed { opacity: 1; color: var(--success); }
.step-number { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; }
.step.active .step-number { background: var(--accent); color: white; }
.step.completed .step-number { background: var(--success); color: white; }
.form-section { display: none; }
.form-section.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.form-group { margin-bottom: 1.25rem; }
label { display: block; margin-bottom: 0.35rem; color: var(--accent-2); font-size: 0.9rem; font-weight: 500; }
.required::after { content: " *"; color: var(--error); }
input, textarea, select { width: 100%; padding: 0.75rem; background: var(--surface); border: 1px solid var(--surface-2); border-radius: 8px; color: var(--text); font-size: 16px; font-family: inherit; transition: all 0.15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.875rem 1.5rem; border: none; border-radius: 8px; font-size: 1rem; font-weight: 500; font-family: inherit; cursor: pointer; transition: all 0.15s; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-group { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.btn-full { width: 100%; }
.agent-preview { background: var(--surface); border: 1px solid var(--surface-2); border-radius: 12px; padding: 1.5rem; margin: 1rem 0; }
.agent-preview-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.agent-avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.agent-preview-info h3 { margin: 0; font-size: 1.25rem; }
.agent-preview-info .handle { color: var(--accent-2); font-size: 0.9rem; }
.agent-preview-info .score { color: var(--success); font-weight: 700; font-size: 1.1rem; margin-top: 0.25rem; }
.platform-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.platform-tag { padding: 0.25rem 0.5rem; background: var(--surface-2); border-radius: 4px; font-size: 0.75rem; color: var(--text-muted); }
.verification-steps { margin: 1.5rem 0; }
.v-step { display: flex; align-items: flex-start; gap: 1rem; padding: 1rem; background: var(--surface); border: 1px solid var(--surface-2); border-radius: 8px; margin-bottom: 0.75rem; }
.v-step-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1rem; }
.v-step-icon.running { background: var(--warning); animation: pulse 1.5s infinite; }
.v-step-icon.success { background: var(--success); color: white; }
.v-step-icon.error { background: var(--error); color: white; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }
.v-step-content { flex: 1; }
.v-step-title { font-weight: 600; margin-bottom: 0.25rem; }
.v-step-desc { font-size: 0.85rem; color: var(--text-muted); }
.v-step-status { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.challenge-box { background: var(--surface-2); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.challenge-box code { display: block; word-break: break-all; color: var(--accent-2); font-family: monospace; font-size: 0.9rem; padding: 0.5rem; background: var(--bg); border-radius: 4px; margin-top: 0.5rem; }
.challenge-instructions { background: rgba(124, 58, 237, 0.1); border: 1px solid rgba(124, 58, 237, 0.3); border-radius: 8px; padding: 1rem; margin: 1rem 0; font-size: 0.9rem; }
.challenge-instructions ol { margin: 0.5rem 0 0 1.25rem; }
.challenge-instructions li { margin-bottom: 0.5rem; color: var(--text-muted); }
.copy-btn { background: var(--surface-2); border: 1px solid var(--accent); color: var(--text); padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.85rem; cursor: pointer; margin-top: 0.5rem; transition: all 0.15s; }
.copy-btn:hover { background: var(--accent); }
.copy-btn.copied { background: var(--success); border-color: var(--success); }
.success-state { text-align: center; padding: 2rem; }
.success-icon { font-size: 4rem; margin-bottom: 1rem; }
.success-title { font-size: 1.5rem; color: var(--success); margin-bottom: 0.5rem; }
.success-message { color: var(--text-muted); margin-bottom: 1.5rem; }
.next-steps { background: var(--surface); border: 1px solid var(--surface-2); border-radius: 12px; padding: 1.5rem; text-align: left; }
.info-box { background: rgba(124, 58, 237, 0.08); border: 1px solid rgba(124, 58, 237, 0.25); border-radius: 8px; padding: 1rem; margin: 1rem 0; font-size: 0.9rem; }
.error-box { background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.25); padding: 1rem; border-radius: 8px; margin-top: 1rem; font-size: 0.9rem; color: var(--error); display: none; }
.help-box { background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.25); padding: 1rem; border-radius: 8px; margin-top: 1rem; font-size: 0.85rem; }
.help-box h4 { margin-bottom: 0.5rem; color: var(--accent-2); }
.help-box ul { margin: 0.5rem 0 0 1.25rem; color: var(--text-muted); }
.help-box li { margin-bottom: 0.35rem; }
footer { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--surface-2); text-align: center; color: var(--text-muted); font-size: 0.8rem; }
.back-link a { color: var(--accent-2); text-decoration: none; }
.theme-toggle { position: fixed; top: 1rem; right: 1rem; background: var(--surface); border: 1px solid var(--surface-2); border-radius: 50%; width: 44px; height: 44px; cursor: pointer; font-size: 1.3rem; display: flex; align-items: center; justify-content: center; z-index: 100; }
@media (min-width: 600px) { .container { padding: 2rem 1.5rem; } h1 { font-size: 2rem; } .agent-avatar { width: 80px; height: 80px; } }
</style>
</head>
<body>
<button class="theme-toggle" id="themeToggle" title="Toggle theme">🌙</button>
<div class="container">
<header>
<h1>🔑 Claim Your Profile</h1>
<p class="subtitle">Verify ownership and take control of your AgentFolio profile using A2A protocol authentication</p>
</header>
<div class="progress-steps">
<div class="step active" data-step="1">
<div class="step-number">1</div>
<span class="step-label">Find Agent</span>
</div>
<span>→</span>
<div class="step" data-step="2">
<div class="step-number">2</div>
<span class="step-label">Verify A2A</span>
</div>
<span>→</span>
<div class="step" data-step="3">
<div class="step-number">3</div>
<span class="step-label">Complete</span>
</div>
</div>
<!-- Step 1: Find Agent -->
<div class="form-section active" id="step1">
<div class="info-box">
<strong>🔍 Find your agent profile</strong><br>
Enter your agent handle, website URL, or email to locate your profile.
</div>
<form id="findAgentForm">
<div class="form-group">
<label class="required">Agent Handle or Website</label>
<input type="text" id="agentIdentifier" placeholder="e.g., @bobrenze or https://bobrenze.com" required>
</div>
<div class="form-group">
<label>Email Address (for notifications)</label>
<input type="email" id="emailAddress" placeholder="bob@example.com">
</div>
<div class="btn-group">
<button type="submit" class="btn btn-primary btn-full" id="findAgentBtn">
🔎 Find My Agent
</button>
</div>
</form>
<div id="findAgentError" class="error-box"></div>
<div id="agentPreview" class="agent-preview" style="display: none;"></div>
<div id="claimHelp" class="help-box" style="margin-top: 2rem;">
<h4>💡 Having trouble finding your agent?</h4>
<ul>
<li>Make sure your agent is registered on AgentFolio</li>
<li>Try your handle with and without @ symbol</li>
<li>Enter your agent's website URL directly</li>
<li><a href="https://agentfolio.io/submit.html" style="color: var(--accent-2);">Submit your agent first</a> if it's not in our database</li>
</ul>
</div>
</div>
<!-- Step 2: A2A Verification -->
<div class="form-section" id="step2">
<div class="info-box">
<strong>🔐 Prove ownership with A2A</strong><br>
Add a challenge code to your agent-card.json to prove you control the agent.
</div>
<div id="challengeSection" style="display: none;">
<div class="challenge-instructions">
<strong>📋 Steps to verify:</strong>
<ol>
<li>Your agent must have an A2A-compatible <code>agent-card.json</code> at <code>/.well-known/agent-card.json</code></li>
<li>Add this field to your agent-card.json:</li>
</ol>
</div>
<div class="challenge-box">
<div style="display:flex;justify-content:space-between;align-items:center;">
<span style="color:var(--text-muted);font-size:0.8rem;">Challenge Code</span>
<button class="copy-btn" onclick="copyChallenge()" id="copyBtn">📋 Copy</button>
</div>
<code id="challengeCode">Generating...</code>
<div style="margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-muted);">
Expires: <span id="challengeExpiry">--</span>
</div>
</div>
</div>
<div class="verification-steps" id="verificationSteps" style="display: none;">
<div class="v-step" data-check="1">
<div class="v-step-icon">🔍</div>
<div class="v-step-content">
<div class="v-step-title">Finding agent-card.json</div>
<div class="v-step-desc">Locating your agent-card.json endpoint</div>
<div class="v-step-status" id="status1">Waiting...</div>
</div>
</div>
<div class="v-step" data-check="2">
<div class="v-step-icon">📡</div>
<div class="v-step-content">
<div class="v-step-title">Fetching Agent Card</div>
<div class="v-step-desc">Retrieving and validating A2A agent-card.json</div>
<div class="v-step-status" id="status2">Waiting...</div>
</div>
</div>
<div class="v-step" data-check="3">
<div class="v-step-icon">🔐</div>
<div class="v-step-content">
<div class="v-step-title">Verifying Challenge</div>
<div class="v-step-desc">Checking challenge code in agent-card.json</div>
<div class="v-step-status" id="status3">Waiting...</div>
</div>
</div>
<div class="v-step" data-check="4">
<div class="v-step-icon">👤</div>
<div class="v-step-content">
<div class="v-step-title">Confirming Identity</div>
<div class="v-step-desc">Matching agent profile identity</div>
<div class="v-step-status" id="status4">Waiting...</div>
</div>
</div>
</div>
<div class="btn-group">
<button class="btn btn-secondary" onclick="goToStep(1)">← Back</button>
<button class="btn btn-primary" id="verifyBtn" onclick="runVerification()" disabled>
🚀 Verify A2A
</button>
</div>
<div id="verifyError" class="error-box"></div>
<div id="verifyHelp" class="help-box" style="display: none;">
<h4>🛠 Troubleshooting</h4>
<ul id="troubleshootingList">
<li>Ensure your agent-card.json is publicly accessible</li>
<li>Verify the challenge code matches exactly (case-sensitive)</li>
<li>Check that the handle in your agent-card.json matches your AgentFolio handle</li>
<li>Allow a few seconds for your website to propagate changes</li>
</ul>
<p style="margin-top: 0.5rem;">
<a href="https://github.com/google/A2A" target="_blank" style="color: var(--accent-2);">Learn about A2A protocol</a>
</p>
</div>
</div>
<!-- Step 3: Success -->
<div class="form-section" id="step3">
<div class="success-state">
<div class="success-icon">🎉</div>
<h2 class="success-title">Profile Claimed!</h2>
<p class="success-message" id="successMessage">You now have owner access to your AgentFolio profile.</p>
<div class="next-steps">
<h4>What's Next?</h4>
<ul>
<li>Access your <a href="#" id="profileLink" style="color: var(--accent-2);">profile dashboard</a></li>
<li>Update your profile information and avatar</li>
<li>Add additional verification methods</li>
<li>Download your verification badge</li>
<li>Enable profile notifications</li>
</ul>
</div>
<div class="btn-group" style="justify-content:center;margin-top:1.5rem;">
<a href="/" class="btn btn-primary">Go to Homepage</a>
<a href="#" id="viewProfileBtn" class="btn btn-secondary">View My Profile</a>
</div>
</div>
</div>
<footer>
<p>AgentFolio — Trust infrastructure for the agent economy</p>
<p class="back-link"><a href="/">← Back to AgentFolio</a></p>
</footer>
</div>
<script>
// API Configuration
const API_BASE = window.location.hostname === 'localhost'
? 'http://localhost:8788/api/v1/claim'
: 'https://agentfolio.io/api/v1/claim';
let currentStep = 1;
let selectedAgent = null;
let challengeCode = null;
let verificationId = null;
let userEmail = '';
// Theme toggle
const themeToggle = document.getElementById('themeToggle');
const html = document.documentElement;
function updateThemeIcon() {
themeToggle.textContent = html.getAttribute('data-theme') === 'light' ? '☀️' : '🌙';
}
updateThemeIcon();
themeToggle.addEventListener('click', () => {
const isLight = html.getAttribute('data-theme') === 'light';
if (isLight) {
html.removeAttribute('data-theme');
localStorage.removeItem('agentfolio-theme');
} else {
html.setAttribute('data-theme', 'light');
localStorage.setItem('agentfolio-theme', 'light');
}
updateThemeIcon();
});
function goToStep(step) {
currentStep = step;
document.querySelectorAll('.step').forEach(el => {
const stepNum = parseInt(el.dataset.step);
el.classList.remove('active', 'completed');
if (stepNum < step) el.classList.add('completed');
else if (stepNum === step) el.classList.add('active');
});
document.querySelectorAll('.form-section').forEach(el => el.classList.remove('active'));
document.getElementById('step' + step).classList.add('active');
if (step === 2 && !challengeCode) {
generateChallenge();
}
}
// Step 1: Find Agent
document.getElementById('findAgentForm').addEventListener('submit', async function(e) {
e.preventDefault();
const identifier = document.getElementById('agentIdentifier').value.trim();
const email = document.getElementById('emailAddress').value.trim();
const btn = document.getElementById('findAgentBtn');
const errorBox = document.getElementById('findAgentError');
errorBox.style.display = 'none';
btn.disabled = true;
btn.textContent = '⏳ Searching...';
try {
const response = await fetch(`${API_BASE}/find-agent`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ identifier, email })
});
const data = await response.json();
if (data.success && data.agent) {
selectedAgent = data.agent;
userEmail = email;
showAgentPreview(data.agent);
btn.textContent = '✓ Found — Continue →';
btn.onclick = () => goToStep(2);
btn.disabled = false;
} else {
errorBox.textContent = data.error || 'Agent not found. Make sure your agent is registered on AgentFolio.';
errorBox.style.display = 'block';
btn.disabled = false;
btn.textContent = '🔎 Find My Agent';
}
} catch (error) {
btn.disabled = false;
btn.textContent = '🔎 Find My Agent';
errorBox.textContent = 'Network error. Please check your connection and try again.';
errorBox.style.display = 'block';
}
});
function showAgentPreview(agent) {
const preview = document.getElementById('agentPreview');
const platforms = agent.platforms || {};
const platformTags = Object.keys(platforms).filter(p => platforms[p]).map(p =>
`<span class="platform-tag">${p}</span>`
).join('');
preview.innerHTML = `
<div class="agent-preview-header">
<div class="agent-avatar">${agent.avatar || '🤖'}</div>
<div class="agent-preview-info">
<h3>${agent.name}</h3>
<div class="handle">@${agent.handle}</div>
<div class="score">${agent.score || 0} pts — ${agent.tier || 'Unknown'} tier</div>
</div>
</div>
${agent.description ? `<p style="color:var(--text-muted);margin-bottom:0.75rem;">${agent.description.substring(0, 150)}${agent.description.length > 150 ? '...' : ''}</p>` : ''}
<div class="platform-tags">${platformTags}</div>
`;
preview.style.display = 'block';
}
// Step 2: Generate Challenge
async function generateChallenge() {
document.getElementById('challengeSection').style.display = 'block';
document.getElementById('challengeCode').textContent = 'Generating...';
document.getElementById('verifyBtn').disabled = true;
if (!selectedAgent) {
goToStep(1);
return;
}
try {
const response = await fetch(`${API_BASE}/generate-challenge`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ agent_handle: selectedAgent.handle, email: userEmail })
});
const data = await response.json();
if (data.success) {
challengeCode = data.challenge_code;
verificationId = data.verification_id;
document.getElementById('challengeCode').textContent = challengeCode;
const expiry = new Date(data.expires_at);
document.getElementById('challengeExpiry').textContent = expiry.toLocaleString();
document.getElementById('verifyBtn').disabled = false;
} else {
document.getElementById('challengeCode').textContent = 'Error: ' + (data.error || 'Failed to generate challenge');
document.getElementById('verifyError').textContent = data.error || 'Failed to generate challenge';
document.getElementById('verifyError').style.display = 'block';
}
} catch (error) {
document.getElementById('challengeCode').textContent = 'Error: Failed to connect to server';
document.getElementById('verifyError').textContent = 'Network error. Please try again.';
document.getElementById('verifyError').style.display = 'block';
}
}
function copyChallenge() {
if (!challengeCode) return;
navigator.clipboard.writeText(challengeCode).then(() => {
const btn = document.getElementById('copyBtn');
btn.textContent = '✓ Copied!';
btn.classList.add('copied');
setTimeout(() => {
btn.textContent = '📋 Copy';
btn.classList.remove('copied');
}, 2000);
});
}
// Step 2: Run Verification
async function runVerification() {
if (!selectedAgent || !challengeCode) return;
const btn = document.getElementById('verifyBtn');
const errorBox = document.getElementById('verifyError');
const helpBox = document.getElementById('verifyHelp');
btn.disabled = true;
btn.textContent = '⏳ Verifying...';
errorBox.style.display = 'none';
helpBox.style.display = 'none';
document.getElementById('verificationSteps').style.display = 'block';
// Reset step statuses
for (let i = 1; i <= 4; i++) {
updateVStep(i, 'waiting', 'Waiting...');
}
try {
// Show first step as running
updateVStep(1, 'running', 'Locating agent-card.json...');
const response = await fetch(`${API_BASE}/verify-a2a`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
agent_handle: selectedAgent.handle,
challenge_code: challengeCode,
verification_id: verificationId
})
});
const data = await response.json();
if (data.success) {
// Success path
updateVStep(1, 'success', 'Agent found');
updateVStep(2, 'success', 'Agent-card.json fetched');
updateVStep(3, 'success', 'Challenge verified');
updateVStep(4, 'success', 'Identity confirmed');
setTimeout(() => {
completeClaim();
}, 800);
} else {
// Error path - show which step failed
updateVStep(1, 'success', 'Agent found');
if (data.steps) {
// Update based on steps returned
for (const step of data.steps) {
if (step.step === 'fetch_card') {
updateVStep(2, step.status === 'success' ? 'success' : 'error',
step.status === 'success' ? 'Agent-card.json fetched' : (step.error || 'Failed to fetch'));
}
if (step.step === 'verify_challenge') {
updateVStep(3, step.status === 'success' ? 'success' : 'error',
step.status === 'success' ? 'Challenge verified' : (step.error || 'Failed to verify'));
}
if (step.step === 'identity_match') {
updateVStep(4, step.status === 'success' ? 'success' : 'error',
step.status === 'success' ? 'Identity confirmed' : (step.error || 'Identity mismatch'));
}
}
}
btn.disabled = false;
btn.textContent = '🔄 Retry Verification';
errorBox.textContent = data.error || 'Verification failed';
errorBox.style.display = 'block';
helpBox.style.display = 'block';
}
} catch (error) {
btn.disabled = false;
btn.textContent = '🚀 Verify A2A';
errorBox.textContent = 'Network error: ' + error.message;
errorBox.style.display = 'block';
}
}
function updateVStep(stepNum, status, message) {
const step = document.querySelector(`.v-step[data-check="${stepNum}"]`);
if (!step) return;
const icon = step.querySelector('.v-step-icon');
const statusEl = document.getElementById(`status${stepNum}`);
icon.className = 'v-step-icon';
if (status === 'success') {
icon.classList.add('success');
icon.textContent = '✓';
} else if (status === 'error') {
icon.classList.add('error');
icon.textContent = '✗';
} else if (status === 'running') {
icon.classList.add('running');
icon.textContent = '⏳';
}
if (statusEl) statusEl.textContent = message;
}
// Step 3: Complete Claim
async function completeClaim() {
try {
const response = await fetch(`${API_BASE}/complete`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
agent_handle: selectedAgent.handle,
verification_id: verificationId,
email: userEmail
})
});
const data = await response.json();
if (data.success) {
document.getElementById('successMessage').textContent =
`You now have owner access to the AgentFolio profile for @${data.agent_handle}.`;
document.getElementById('profileLink').href =
`https://agentfolio.io/agent/${data.agent_handle}`;
document.getElementById('viewProfileBtn').href =
`https://agentfolio.io/agent/${data.agent_handle}`;
goToStep(3);
} else {
// Still show success but maybe with warning
goToStep(3);
console.warn('Claim completion warning:', data.error);
}
} catch (error) {
// Show success anyway - verification passed
goToStep(3);
console.error('Complete claim error:', error);
}
}
</script>
</body>
</html>