| 1 | // Enable only base Git hosting on an isolated, owned benchmark tenant. |
| 2 | import { finalizeEvent } from "nostr-tools/pure" ; |
| 3 | import { getToken } from "nostr-tools/nip98" ; |
| 4 | |
| 5 | const url = process.argv[2] || "http://127.0.0.1:17447" ; |
| 6 | const privateRepos = process.argv.includes("--private" ); |
| 7 | const secret = Uint8Array.from(Buffer.from("fc1d06a0fd5e622dcf448d0b3c2fccc891a5ecf74546a7675460d92441fecfdd" , "hex" )); |
| 8 | async function rpc(method, params = []) { |
| 9 | const payload = {method, params}; |
| 10 | const token = await getToken(url, "POST" , event => finalizeEvent(event, secret), true, payload); |
| 11 | const response = await fetch(url, {method: "POST" , headers: { |
| 12 | "Content-Type" : "application/nostr+json+rpc" , Authorization: token, |
| 13 | }, body: JSON.stringify(payload)}); |
| 14 | const result = await response.json(); |
| 15 | if (!response.ok || result.error) throw Error(JSON.stringify(result)); |
| 16 | return result.result; |
| 17 | } |
| 18 | const policy = await rpc("getpolicy" ); |
| 19 | policy.features = {...policy.features, grasp: true, grasp02: false, grasp03: false, grasp05: false, grasp06: false, grasp08: privateRepos}; |
| 20 | if (privateRepos) policy.reads = "members" ; |
| 21 | console.log(JSON.stringify(await rpc("setpolicy" , [policy]))); |