mirror of
https://gitlab.com/vyla-entertainment/live.git
synced 2026-11-20 00:57:26 -05:00
Sync project files
This commit is contained in:
20
src/sources/goat/lock.js
Normal file
20
src/sources/goat/lock.js
Normal 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)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user