MCPcopy Index your code
hub / github.com/anomalyco/opencode / sign

Function sign

packages/desktop/scripts/finalize-latest-json.ts:113–133  ·  view source on GitHub ↗
(url: string, key: string)

Source from the content-addressed store, hash-verified

111}
112
113async function sign(url: string, key: string) {
114 const name = decodeURIComponent(new URL(url).pathname.split("/").pop() ?? key)
115 const asset = amap.get(name)
116 const res = await fetch(asset?.url ?? url, {
117 headers: {
118 Authorization: `token ${token}`,
119 ...(asset ? { Accept: "application/octet-stream" } : {}),
120 },
121 })
122 if (!res.ok) {
123 throw new Error(`Failed to fetch file ${name}: ${res.status} ${res.statusText} (${asset?.url ?? url})`)
124 }
125
126 const tmp = process.env.RUNNER_TEMP ?? "/tmp"
127 const file = path.join(tmp, name)
128 await Bun.write(file, await res.arrayBuffer())
129 await $`bunx @tauri-apps/cli signer sign ${file}`
130 const sigFile = Bun.file(`${file}.sig`)
131 if (!(await sigFile.exists())) throw new Error(`Signature file not found for ${name}`)
132 return (await sigFile.text()).trim()
133}
134
135const add = async (data: Record<string, { url: string; signature: string }>, key: string, raw: string | undefined) => {
136 if (!raw) return

Callers 1

addFunction · 0.85

Calls 7

writeMethod · 0.80
fileMethod · 0.80
getMethod · 0.65
arrayBufferMethod · 0.65
textMethod · 0.65
fetchFunction · 0.50
existsMethod · 0.45

Tested by

no test coverage detected