Sync project files

This commit is contained in:
2026-08-12 19:36:39 -07:00
commit 06f7e76d94
36 changed files with 1456 additions and 0 deletions

20
src/sources/goat/lock.js Normal file
View File

@@ -0,0 +1,20 @@
import { Worker } from 'node:worker_threads'
const workerUrl = new URL('./lock-worker.js', import.meta.url)
export function unlock(slot, goat, body) {
return new Promise((resolve, reject) => {
const worker = new Worker(workerUrl, {
workerData: { slot, goat, bodyHex: body.toString('hex') },
})
worker.once('message', (msg) => {
worker.terminate().catch(() => {})
if (msg.ok) resolve(msg.url)
else reject(new Error(msg.error || 'lock decrypt failed'))
})
worker.once('error', (err) => {
worker.terminate().catch(() => {})
reject(err)
})
})
}