tangled
alpha
login
or
join now
l4.pm
/
atvouch
7
fork
atom
dev vouch dev on at. thats about it
atvouch.dev
7
fork
atom
overview
issues
pulls
pipelines
use did as rkey
l4.pm
6 days ago
38cae5ff
102548f7
+3
-27
2 changed files
expand all
collapse all
unified
split
frontend
src
api.ts
lexicons
dev
atvouch
graph
vouch.json
+2
-26
frontend/src/api.ts
···
58
58
});
59
59
const subjectDid = (resolveResp.data as unknown as { did: string }).did;
60
60
61
61
-
// Check if already vouched
62
62
-
const existing = await listMyVouches(agent);
63
63
-
if (existing.includes(subjectDid)) {
64
64
-
throw new Error(`You have already vouched for ${handle}`);
65
65
-
}
66
66
-
67
67
-
// Generate TID (timestamp-based ID)
68
68
-
const tid = generateTID();
69
69
-
70
70
-
// Create vouch record
61
61
+
// Create vouch record (rkey is the subject DID, so duplicates are impossible)
71
62
const createResp = await rpc.call("com.atproto.repo.createRecord", {
72
63
data: {
73
64
repo: agent.sub,
74
65
collection: "dev.atvouch.graph.vouch",
75
75
-
rkey: tid,
66
66
+
rkey: subjectDid,
76
67
record: {
77
68
$type: "dev.atvouch.graph.vouch",
78
69
subject: subjectDid,
···
265
256
return { targetDID, directVouch: false, paths, handleMap };
266
257
}
267
258
268
268
-
// Generate a TID (Timestamp ID) matching AT Protocol spec
269
269
-
function generateTID(): string {
270
270
-
const now = BigInt(Date.now()) * 1000n;
271
271
-
const clockId = BigInt(Math.floor(Math.random() * 1024));
272
272
-
const tid = (now << 10n) | clockId;
273
273
-
274
274
-
const chars = "234567abcdefghijklmnopqrstuvwxyz";
275
275
-
let result = "";
276
276
-
let val = tid;
277
277
-
for (let i = 0; i < 13; i++) {
278
278
-
result = chars[Number(val & 31n)] + result;
279
279
-
val >>= 5n;
280
280
-
}
281
281
-
return result;
282
282
-
}
+1
-1
lexicons/dev/atvouch/graph/vouch.json
···
5
5
"main": {
6
6
"type": "record",
7
7
"description": "a vouch",
8
8
-
"key": "tid",
8
8
+
"key": "any",
9
9
"record": {
10
10
"type": "object",
11
11
"required": ["subject", "createdAt"],