Skip to content

Commit e71a608

Browse files
committed
https://tools.simonwillison.net/bluesky-resolve
https://gist.github.com/simonw/ab7280cc31a92aab3f68e6ad69cfd17a
1 parent b8bb678 commit e71a608

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ This collection is partly **an experiment** in how much it's possible to get don
4242
- [Arena animated](https://tools.simonwillison.net/arena-animated) animates the progression of the LMSYS Chatbot Arena, inspired by [this visualization](https://public.flourish.studio/visualisation/17992181/) by [Peter Gostev](https://www.linkedin.com/posts/peter-gostev_how-companies-llms-compare-over-the-course-activity-7196899934615257090-zilk) (via [Time-Winter-4319 on Reddit](https://www.reddit.com/r/LocalLLaMA/comments/1bp4j19/gpt4_is_no_longer_the_top_dog_timelapse_of/))
4343
- [California Clock Change](https://tools.simonwillison.net/california-clock-change) - shows when the clocks will next change for daylight saving time in California
4444
- [Bluesky WebSocket Firehose](https://tools.simonwillison.net/bluesky-firehose) showing a live firehose of Bluesky activity, [described here](https://simonwillison.net/2024/Nov/20/bluesky-websocket-firehose/)
45+
- [Bluesky resolve DID](https://tools.simonwillison.net/bluesky-resolve) turns a Bluesky ID such as `simonwillison.net` into a DID
4546
- [Prompts.js](https://tools.simonwillison.net/prompts-js) small JavaScript library enabling `await Prompts.alert("hi")` and `await Prompts.confirm("Continue?")` and `await Prompts.prompt("Enter your name")`
4647

4748
## On Observable

bluesky-resolve.html

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
* {
6+
box-sizing: border-box;
7+
}
8+
9+
body {
10+
font-family: Helvetica, Arial, sans-serif;
11+
max-width: 800px;
12+
margin: 20px auto;
13+
padding: 0 20px;
14+
}
15+
16+
input {
17+
display: block;
18+
width: 100%;
19+
padding: 8px;
20+
margin: 8px 0;
21+
font-size: 16px;
22+
border: 1px solid #ccc;
23+
border-radius: 4px;
24+
}
25+
26+
button {
27+
background: #0070ff;
28+
color: white;
29+
border: none;
30+
padding: 8px 16px;
31+
border-radius: 4px;
32+
cursor: pointer;
33+
}
34+
35+
button:hover {
36+
background: #0060df;
37+
}
38+
39+
#result {
40+
margin-top: 20px;
41+
padding: 16px;
42+
background: #f5f5f5;
43+
border-radius: 4px;
44+
word-break: break-all;
45+
}
46+
47+
.error {
48+
color: #d00;
49+
}
50+
</style>
51+
</head>
52+
<body>
53+
<h1>Resolve Bluesky handle to DID</h1>
54+
55+
<form id="resolve-form">
56+
<input type="text" id="handle" name="handle" placeholder="Enter Bluesky handle (e.g. jay.bsky.social)" required>
57+
<button type="submit">Resolve</button>
58+
</form>
59+
60+
<div id="result"></div>
61+
62+
<script type="module">
63+
const BSKY_URL = 'https://bsky.social/xrpc/com.atproto.identity.resolveHandle'
64+
const form = document.getElementById('resolve-form')
65+
const result = document.getElementById('result')
66+
67+
async function resolveDid(event) {
68+
if (!event?.target?.tagName === 'FORM') return
69+
event.preventDefault()
70+
71+
const handle = event.target.handle.value.trim()
72+
73+
try {
74+
const response = await fetch(`${BSKY_URL}?handle=${encodeURIComponent(handle)}`)
75+
if (!response.ok) throw new Error('Handle not found')
76+
const data = await response.json()
77+
result.textContent = data.did
78+
} catch (err) {
79+
result.innerHTML = `<span class="error">Error: ${err.message}</span>`
80+
}
81+
return false
82+
}
83+
84+
form.addEventListener('submit', resolveDid)
85+
</script>
86+
</body>
87+
</html>

0 commit comments

Comments
 (0)