+27
-1
scripts/setup.js
+27
-1
scripts/setup.js
···
317
return result
318
}
319
320
+
// === PLC DIRECTORY REGISTRATION ===
321
+
322
+
async function registerWithPlc(plcUrl, did, operation) {
323
+
const url = `${plcUrl}/${encodeURIComponent(did)}`
324
+
325
+
const response = await fetch(url, {
326
+
method: 'POST',
327
+
headers: {
328
+
'Content-Type': 'application/json'
329
+
},
330
+
body: JSON.stringify(operation)
331
+
})
332
+
333
+
if (!response.ok) {
334
+
const text = await response.text()
335
+
throw new Error(`PLC registration failed: ${response.status} ${text}`)
336
+
}
337
+
338
+
return true
339
+
}
340
+
341
// === MAIN ===
342
343
async function main() {
···
369
console.log(` Handle: ${fullHandle}`)
370
console.log('')
371
372
+
// Step 3: Register with PLC directory
373
+
console.log(`Registering with ${opts.plcUrl}...`)
374
+
await registerWithPlc(opts.plcUrl, did, operation)
375
+
console.log(' Registered successfully!')
376
+
console.log('')
377
+
378
// TODO: Initialize PDS
379
// TODO: Notify relay
380
}