@delicious233/codex-browser-bridge 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/checksums.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": "v1.5.3",
3
+ "files": {
4
+ "codex-browser-bridge-arm64.exe": "f6b7ccca507b896ab404f92b867260316ebdc589ab575bc7f6d3b02265cf562b",
5
+ "codex-browser-bridge.exe": "7a9361bc414a9f46627866030b87d6ac2dc6713060718fa3a8f84c6dc42a80a4"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@delicious233/codex-browser-bridge",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "private": false,
5
5
  "description": "MCP server that exposes Codex Desktop's Chrome browser bridge for Claude Code and other agents.",
6
6
  "bin": {
7
7
  "codex-browser-bridge": "bin/codex-browser-bridge.js"
8
8
  },
9
9
  "scripts": {
10
+ "test": "node scripts/install.test.js",
10
11
  "postinstall": "node scripts/install.js"
11
12
  },
12
13
  "files": [
13
14
  "bin/codex-browser-bridge.js",
15
+ "checksums.json",
14
16
  "scripts/install.js"
15
17
  ],
16
18
  "repository": {
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const fs = require("fs");
4
- const os = require("os");
5
4
  const path = require("path");
6
5
  const crypto = require("crypto");
7
6
  const https = require("https");
8
7
 
9
- const repo = process.env.CODEX_BRIDGE_REPO || "DeliciousBuding/codex-browser-bridge";
8
+ const defaultRepo = "DeliciousBuding/codex-browser-bridge";
10
9
  const binDir = path.join(__dirname, "..", "bin");
11
10
  const packageJson = require("../package.json");
12
11
 
@@ -42,6 +41,26 @@ function parseChecksumLine(line) {
42
41
  };
43
42
  }
44
43
 
44
+ function findChecksum(text, asset) {
45
+ return text
46
+ .split(/\r?\n/)
47
+ .map(parseChecksumLine)
48
+ .find((entry) => entry && entry.file === asset);
49
+ }
50
+
51
+ function embeddedChecksum(asset) {
52
+ const file = path.join(__dirname, "..", "checksums.json");
53
+ if (!fs.existsSync(file)) return null;
54
+ const checksums = JSON.parse(fs.readFileSync(file, "utf8"));
55
+ if (!checksums || !checksums.files || typeof checksums.files[asset] !== "string") {
56
+ return null;
57
+ }
58
+ return {
59
+ hash: checksums.files[asset].toLowerCase(),
60
+ file: asset,
61
+ };
62
+ }
63
+
45
64
  async function main() {
46
65
  if (process.platform !== "win32") {
47
66
  console.error("codex-browser-bridge only supports Windows (requires named pipes).");
@@ -61,22 +80,23 @@ async function main() {
61
80
  process.exit(1);
62
81
  }
63
82
 
64
- const tag = process.env.CODEX_BRIDGE_TAG || `v${packageJson.version}`;
83
+ const devDownloads = process.env.CODEX_BRIDGE_ALLOW_DEV_DOWNLOADS === "1";
84
+ const repo = devDownloads && process.env.CODEX_BRIDGE_REPO ? process.env.CODEX_BRIDGE_REPO : defaultRepo;
85
+ const tag = devDownloads && process.env.CODEX_BRIDGE_TAG ? process.env.CODEX_BRIDGE_TAG : `v${packageJson.version}`;
65
86
  const exeName = "codex-browser-bridge.exe";
66
87
  const asset = arch === "arm64" ? "codex-browser-bridge-arm64.exe" : "codex-browser-bridge.exe";
67
88
 
68
89
  const base = `https://github.com/${repo}/releases/download/${tag}`;
69
90
 
70
- // Download checksums
71
- const checksumsURL = `${base}/checksums.txt`;
72
- const checksums = await requestBuffer(checksumsURL).catch((err) => {
73
- throw new Error(`could not download checksums for ${tag}: ${err.message}`);
74
- });
75
- const checksum = checksums.toString("utf8")
76
- .split(/\r?\n/)
77
- .map(parseChecksumLine)
78
- .find((entry) => entry && entry.file === asset);
79
- if (!checksum) throw new Error(`checksum not found for ${asset} in ${checksumsURL}`);
91
+ let checksum = embeddedChecksum(asset);
92
+ if (!checksum) {
93
+ const checksumsURL = `${base}/checksums.txt`;
94
+ const checksums = await requestBuffer(checksumsURL).catch((err) => {
95
+ throw new Error(`could not download checksums for ${tag}: ${err.message}`);
96
+ });
97
+ checksum = findChecksum(checksums.toString("utf8"), asset);
98
+ if (!checksum) throw new Error(`checksum not found for ${asset} in ${checksumsURL}`);
99
+ }
80
100
 
81
101
  // Download binary
82
102
  console.log(`Downloading codex-browser-bridge ${tag} (${arch})...`);
@@ -93,7 +113,16 @@ async function main() {
93
113
  console.log(`Installed: ${target}`);
94
114
  }
95
115
 
96
- main().catch((err) => {
97
- console.error(`install failed: ${err.message}`);
98
- process.exit(1);
99
- });
116
+ if (require.main === module) {
117
+ main().catch((err) => {
118
+ console.error(`install failed: ${err.message}`);
119
+ process.exit(1);
120
+ });
121
+ }
122
+
123
+ module.exports = {
124
+ embeddedChecksum,
125
+ findChecksum,
126
+ parseChecksumLine,
127
+ sha256,
128
+ };