-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathbluesky-resolve.html
87 lines (74 loc) · 1.76 KB
/
bluesky-resolve.html
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
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Helvetica, Arial, sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 0 20px;
}
input {
display: block;
width: 100%;
padding: 8px;
margin: 8px 0;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background: #0070ff;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background: #0060df;
}
#result {
margin-top: 20px;
padding: 16px;
background: #f5f5f5;
border-radius: 4px;
word-break: break-all;
}
.error {
color: #d00;
}
</style>
</head>
<body>
<h1>Resolve Bluesky handle to DID</h1>
<form id="resolve-form">
<input type="text" id="handle" name="handle" placeholder="Enter Bluesky handle (e.g. jay.bsky.social)" required>
<button type="submit">Resolve</button>
</form>
<div id="result"></div>
<script type="module">
const BSKY_URL = 'https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle'
const form = document.getElementById('resolve-form')
const result = document.getElementById('result')
async function resolveDid(event) {
if (!event?.target?.tagName === 'FORM') return
event.preventDefault()
const handle = event.target.handle.value.trim()
try {
const response = await fetch(`${BSKY_URL}?handle=${encodeURIComponent(handle)}`)
if (!response.ok) throw new Error('Handle not found')
const data = await response.json()
result.textContent = data.did
} catch (err) {
result.innerHTML = `<span class="error">Error: ${err.message}</span>`
}
return false
}
form.addEventListener('submit', resolveDid)
</script>
</body>
</html>