A desktop browser with x402 built in: when a page asks for payment, it pays in stablecoins and shows the content.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-browser.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-browser.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-browser.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 site icons (favicons) in tabs, address bar suggestions and the bookmarks panel 7249579 15 hours, 56 minutes ago History
example.mjs · 1.8 KB · 24 lines
1// The example caller (examples/caller-network-client.mjs), run for real as a separate process against the browser.
2import { execFile } from "node:child_process";
3import { fileURLToPath } from "node:url";
4
5export default async function (ctx) {
6 const { check, base, controlUrl, controlToken } = ctx;
7 const client = fileURLToPath(new URL("../../examples/caller-network-client.mjs", import.meta.url));
8 const UA = "ExampleCaller/1.0 (+https://caller.example/about)";
9 const run = (extra) => new Promise((resolve) => {
10 execFile(process.execPath, [client, "--url", base + "/free", "--user-agent", UA, "--settle-timeout", "15000", ...extra], { env: { ...process.env, DBB_URL: controlUrl, DBB_TOKEN: controlToken }, timeout: 60000 }, (err, stdout, stderr) => {
11 let verdict = null;
12 try { verdict = JSON.parse(stdout); } catch {}
13 resolve({ code: err ? (err.code ?? 1) : 0, verdict, stderr });
14 });
15 });
16
17 let r = await run([]);
18 check(r.code === 3 && r.verdict?.failure?.kind === "blocked" && r.verdict?.failure?.source === "caller", "by default it refuses a loopback/private address, as the caller, with a reason", JSON.stringify(r.verdict?.failure));
19 r = await run(["--allow-private", "--min-gap-ms", "0"]);
20 check(r.code === 0 && r.verdict?.settled && r.verdict?.outcome === "ok" && r.verdict?.status === 200, "with --allow-private it loads the page and exits 0", `${r.verdict?.outcome} ${r.verdict?.status}`);
21 r = await run(["--allow-private", "--min-gap-ms", "0", "--max-bytes", "100"]);
22 check(r.code === 3 && r.verdict?.failure?.source === "caller", "a response over the size limit is refused, not handed over", JSON.stringify(r.verdict?.failure));
23 check((await ctx.call("net.provider")).enabled === false, "and it turns the caller network off again when done");
24}