+32
-1
scripts/setup.js
+32
-1
scripts/setup.js
···
338
return true
339
}
340
341
+
// === PDS INITIALIZATION ===
342
+
343
+
async function initializePds(pdsUrl, did, privateKeyHex, handle) {
344
+
const url = `${pdsUrl}/init?did=${encodeURIComponent(did)}`
345
+
346
+
const response = await fetch(url, {
347
+
method: 'POST',
348
+
headers: {
349
+
'Content-Type': 'application/json'
350
+
},
351
+
body: JSON.stringify({
352
+
did,
353
+
privateKey: privateKeyHex,
354
+
handle
355
+
})
356
+
})
357
+
358
+
if (!response.ok) {
359
+
const text = await response.text()
360
+
throw new Error(`PDS initialization failed: ${response.status} ${text}`)
361
+
}
362
+
363
+
return response.json()
364
+
}
365
+
366
// === MAIN ===
367
368
async function main() {
···
400
console.log(' Registered successfully!')
401
console.log('')
402
403
+
// Step 4: Initialize PDS
404
+
console.log(`Initializing PDS at ${opts.pds}...`)
405
+
const privateKeyHex = bytesToHex(keyPair.privateKey)
406
+
await initializePds(opts.pds, did, privateKeyHex, fullHandle)
407
+
console.log(' PDS initialized!')
408
+
console.log('')
409
+
410
// TODO: Notify relay
411
}
412