@opencode/browse 0.0.18-dev.192 → 0.0.18-dev.198

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.
Files changed (41) hide show
  1. package/dist/cli.mjs +62 -107
  2. package/package.json +13 -33
  3. package/dist/Runtime-tvxdkp60.mjs +0 -16
  4. package/dist/THIRD_PARTY_NOTICES.txt +0 -310
  5. package/dist/Undici-xgvbtsb1.mjs +0 -25295
  6. package/dist/cli-54nftqxr.mjs +0 -5939
  7. package/dist/coreBundle-mbshhes2.mjs +0 -8
  8. package/dist/helpers-yksnc17b.mjs +0 -70
  9. package/dist/index-kmxtpxxk.mjs +0 -13
  10. package/dist/legacy-runtime-e6y2jnc6.mjs +0 -134
  11. package/dist/main-4fw36c57.mjs +0 -160
  12. package/dist/main-4wycvga6.mjs +0 -797
  13. package/dist/main-c9qxrdzn.mjs +0 -73
  14. package/dist/main-d1th6z2h.mjs +0 -5395
  15. package/dist/main-de0xhbg0.mjs +0 -1269
  16. package/dist/main-dyya6jpy.mjs +0 -140
  17. package/dist/main-gexpjhk5.mjs +0 -32
  18. package/dist/main-h65pjrag.mjs +0 -11403
  19. package/dist/main-hh16893t.mjs +0 -5358
  20. package/dist/main-j98fzrvv.mjs +0 -68
  21. package/dist/main-jtgan144.mjs +0 -327
  22. package/dist/main-p44hff2a.mjs +0 -213
  23. package/dist/main-p8jk5985.mjs +0 -1750
  24. package/dist/main-p8q3wrpd.mjs +0 -342
  25. package/dist/main-pmfd055v.mjs +0 -63
  26. package/dist/main-q5w61fgh.mjs +0 -17
  27. package/dist/main-t8hspw29.mjs +0 -922
  28. package/dist/main-t8xtycpr.mjs +0 -227
  29. package/dist/main-tk4axre7.mjs +0 -39
  30. package/dist/main-w6180mxa.mjs +0 -161
  31. package/dist/main-wds0wcmt.mjs +0 -4
  32. package/dist/main-z4c819pg.mjs +0 -5512
  33. package/dist/main-zrjcdksk.mjs +0 -62
  34. package/dist/mcp-a2jkny55.mjs +0 -9466
  35. package/dist/migrate-p84kbr3y.mjs +0 -353
  36. package/dist/relay-e9q9hfc3.mjs +0 -18369
  37. package/dist/remove-stored-secrets-c90a5h72.mjs +0 -6
  38. package/dist/runtime-update-jj6pa7vd.mjs +0 -244
  39. package/dist/setup-p86ywb7k.mjs +0 -1051
  40. package/dist/update-rh24h3m1.mjs +0 -17
  41. package/dist/version-1p8wpyzk.mjs +0 -8
@@ -1,73 +0,0 @@
1
- import {
2
- ensurePrivateDirectorySync
3
- } from "./main-t8hspw29.mjs";
4
- import {
5
- dataRoot
6
- } from "./main-dyya6jpy.mjs";
7
-
8
- // src/relay/secrets.ts
9
- import crypto from "node:crypto";
10
- import fs from "node:fs";
11
- import path from "node:path";
12
- var relayTokenQueryParam = "opencodeBrowserToken";
13
- var tokenPattern = /^[A-Za-z0-9_-]{43}$/;
14
- function relayTokenPath(root = dataRoot()) {
15
- return path.join(root, "relay-token");
16
- }
17
- function relayToken(root = dataRoot()) {
18
- return readOrCreateSecret(relayTokenPath(root), () => crypto.randomBytes(32).toString("base64url"), (value) => tokenPattern.test(value));
19
- }
20
- function relayAuthorization(root = dataRoot()) {
21
- return `Bearer ${relayToken(root)}`;
22
- }
23
- function secretsEqual(expected, actual) {
24
- if (actual === undefined)
25
- return false;
26
- const a = crypto.createHash("sha256").update(expected).digest();
27
- const b = crypto.createHash("sha256").update(actual).digest();
28
- return crypto.timingSafeEqual(a, b) && expected.length === actual.length;
29
- }
30
- function readOrCreateSecret(file, generate, valid) {
31
- const existing = readSecret(file);
32
- if (existing !== undefined && valid(existing))
33
- return existing;
34
- ensurePrivateDirectory(path.dirname(file));
35
- const temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
36
- fs.writeFileSync(temporary, `${generate()}
37
- `, { mode: 384 });
38
- try {
39
- if (existing === undefined) {
40
- try {
41
- fs.linkSync(temporary, file);
42
- } catch (error) {
43
- if (error.code !== "EEXIST")
44
- throw error;
45
- }
46
- } else {
47
- fs.renameSync(temporary, file);
48
- }
49
- } finally {
50
- fs.rmSync(temporary, { force: true });
51
- }
52
- const created = readSecret(file);
53
- if (created === undefined || !valid(created))
54
- throw new Error(`Could not create ${file}`);
55
- return created;
56
- }
57
- function readSecret(file) {
58
- try {
59
- const stat = fs.statSync(file);
60
- if (process.platform !== "win32" && (stat.mode & 63) !== 0)
61
- fs.chmodSync(file, 384);
62
- return fs.readFileSync(file, "utf8").trim();
63
- } catch (error) {
64
- if (error.code === "ENOENT")
65
- return;
66
- throw error;
67
- }
68
- }
69
- function ensurePrivateDirectory(directory = dataRoot()) {
70
- ensurePrivateDirectorySync(directory);
71
- }
72
-
73
- export { relayTokenQueryParam, relayToken, relayAuthorization, secretsEqual, ensurePrivateDirectory };