hostdb 0.29.0 → 0.31.0

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # hostdb
2
2
 
3
- Pre-built database binaries for all major platforms, distributed via GitHub Releases.
3
+ Pre-built database binaries for all major platforms, distributed via Cloudflare R2 (mirrored from GitHub Releases). Also a **typed npm package** (`hostdb`) that bundles the registry offline so consumers can resolve versions and download URLs without a network round-trip to `registry.layerbase.host`.
4
4
 
5
- **Primary consumer:** [SpinDB](https://github.com/robertjbass/spindb) - a CLI tool for spinning up local database instances
5
+ **Primary consumer:** [SpinDB](https://github.com/robertjbass/spindb) a CLI tool for spinning up local database instances. SpinDB depends on `hostdb` as a pinned npm dependency; bumping `hostdb` is how SpinDB picks up new database versions.
6
6
 
7
7
  ## Philosophy
8
8
 
@@ -51,20 +51,52 @@ pnpm dbs
51
51
 
52
52
  ## Querying Available Binaries
53
53
 
54
- SpinDB (or any consumer) can fetch `releases.json` for available binaries:
54
+ ### As an npm package (recommended)
55
55
 
56
56
  ```bash
57
- curl https://raw.githubusercontent.com/robertjbass/hostdb/main/releases.json
57
+ pnpm add hostdb # or: npm install hostdb / yarn add hostdb
58
+ ```
59
+
60
+ ```ts
61
+ import {
62
+ resolveVersion,
63
+ getReleaseInfo,
64
+ listEngines,
65
+ } from 'hostdb'
66
+
67
+ // Short-form version → full pinned version (LTS-aware via the defaults block)
68
+ resolveVersion('postgresql', '17') // '17.10.0'
69
+ resolveVersion('mongodb', '8') // '8.0.23' (LTS pick, not the highest 8.x)
70
+ resolveVersion('mysql', '8') // '8.4.9' (LTS, not the 9.x latest)
71
+
72
+ // Find the R2 download URL + sha256 for a specific platform
73
+ getReleaseInfo('postgresql', '17.10.0', 'linux-x64')
74
+ // → { url: 'https://registry.layerbase.host/...', sha256: '...', size: 165123456 }
75
+
76
+ // All bundled engines
77
+ listEngines() // ['clickhouse', 'cockroachdb', ..., 'weaviate']
78
+ ```
79
+
80
+ The published tarball ships `databases.json`, `releases.json`, and `downloads.json` baked in. No runtime network calls. Pin to an exact version (e.g., `"hostdb": "0.31.0"` — no caret, no tilde) so the snapshot is deterministic for any given consumer release.
81
+
82
+ Full API surface is locked in `tests/api-shape.test.ts` (currently 19 exported names).
83
+
84
+ ### As raw JSON
85
+
86
+ ```bash
87
+ curl https://registry.layerbase.host/releases.json
58
88
  ```
59
89
 
60
90
  **Download URL pattern:**
61
91
  ```
62
- https://github.com/robertjbass/hostdb/releases/download/{tag}/{filename}
92
+ https://registry.layerbase.host/{tag}/{filename}
63
93
 
64
94
  # Example:
65
- https://github.com/robertjbass/hostdb/releases/download/mysql-8.4.3/mysql-8.4.3-darwin-arm64.tar.gz
95
+ https://registry.layerbase.host/mysql-8.4.3/mysql-8.4.3-darwin-arm64.tar.gz
66
96
  ```
67
97
 
98
+ GitHub Releases (`https://github.com/robertjbass/hostdb/releases/download/...`) are the upstream source; R2 is the canonical mirror.
99
+
68
100
  ## Configuration Files
69
101
 
70
102
  | File | Purpose |
package/databases.json CHANGED
@@ -12,14 +12,25 @@
12
12
  "hostedServiceAllowed": true,
13
13
  "protocol": null,
14
14
  "note": "Windows binaries unavailable. Require WSL.",
15
+ "defaults": {
16
+ "25": "25.12.3.21"
17
+ },
15
18
  "versions": {
16
19
  "25.12.3.21": true
17
20
  },
18
- "platforms": ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64"],
21
+ "platforms": [
22
+ "linux-x64",
23
+ "linux-arm64",
24
+ "darwin-x64",
25
+ "darwin-arm64"
26
+ ],
19
27
  "cliTools": {
20
28
  "server": "clickhouse-server",
21
29
  "client": "clickhouse-client",
22
- "utilities": ["clickhouse-local", "clickhouse-benchmark"],
30
+ "utilities": [
31
+ "clickhouse-local",
32
+ "clickhouse-benchmark"
33
+ ],
23
34
  "enhanced": []
24
35
  },
25
36
  "connection": {
@@ -42,6 +53,9 @@
42
53
  "hostedServiceAllowed": false,
43
54
  "protocol": "postgresql",
44
55
  "note": "CockroachDB Software License restricts competing cloud services; fine for local dev",
56
+ "defaults": {
57
+ "25": "25.4.2"
58
+ },
45
59
  "versions": {
46
60
  "25.4.2": true
47
61
  },
@@ -56,7 +70,10 @@
56
70
  "server": "cockroach",
57
71
  "client": "cockroach",
58
72
  "utilities": [],
59
- "enhanced": ["pgcli", "usql"],
73
+ "enhanced": [
74
+ "pgcli",
75
+ "usql"
76
+ ],
60
77
  "note": "Single binary; use 'cockroach start-single-node' for server, 'cockroach sql' for client"
61
78
  },
62
79
  "connection": {
@@ -79,6 +96,9 @@
79
96
  "hostedServiceAllowed": true,
80
97
  "protocol": null,
81
98
  "note": "",
99
+ "defaults": {
100
+ "3": "3.5.1"
101
+ },
82
102
  "versions": {
83
103
  "3.5.1": true
84
104
  },
@@ -116,7 +136,11 @@
116
136
  "hostedServiceAllowed": true,
117
137
  "protocol": null,
118
138
  "note": "",
139
+ "defaults": {
140
+ "1": "1.4.4"
141
+ },
119
142
  "versions": {
143
+ "1.4.4": true,
120
144
  "1.4.3": true
121
145
  },
122
146
  "platforms": [
@@ -130,7 +154,9 @@
130
154
  "server": null,
131
155
  "client": "duckdb",
132
156
  "utilities": [],
133
- "enhanced": ["usql"]
157
+ "enhanced": [
158
+ "usql"
159
+ ]
134
160
  },
135
161
  "connection": {
136
162
  "runtime": "embedded",
@@ -152,6 +178,10 @@
152
178
  "hostedServiceAllowed": true,
153
179
  "protocol": "mongodb",
154
180
  "note": "FerretDB v2 requires PostgreSQL-DocumentDB; v1 uses plain PostgreSQL",
181
+ "defaults": {
182
+ "1": "1.24.2",
183
+ "2": "2.7.0"
184
+ },
155
185
  "versions": {
156
186
  "2.7.0": {
157
187
  "platforms": [
@@ -188,7 +218,10 @@
188
218
  "cliTools": {
189
219
  "server": "ferretdb",
190
220
  "client": "mongosh",
191
- "utilities": ["mongodump", "mongorestore"],
221
+ "utilities": [
222
+ "mongodump",
223
+ "mongorestore"
224
+ ],
192
225
  "enhanced": []
193
226
  },
194
227
  "connection": {
@@ -211,6 +244,9 @@
211
244
  "hostedServiceAllowed": true,
212
245
  "protocol": null,
213
246
  "note": "v3.0 is a Rust rewrite using Apache Arrow/DataFusion. Single binary with bundled Python runtime for plugin system. Most popular time-series database by adoption.",
247
+ "defaults": {
248
+ "3": "3.8.0"
249
+ },
214
250
  "versions": {
215
251
  "3.8.0": true
216
252
  },
@@ -238,6 +274,48 @@
238
274
  },
239
275
  "spindbStatus": "completed"
240
276
  },
277
+ "libsql": {
278
+ "displayName": "libSQL",
279
+ "description": "SQLite fork by Turso with server mode (sqld), HTTP API, replication, and embedded replica support",
280
+ "type": "Embedded SQL",
281
+ "sourceRepo": "https://github.com/tursodatabase/libsql",
282
+ "license": "MIT",
283
+ "commercialUse": true,
284
+ "hostedServiceAllowed": true,
285
+ "protocol": "sqlite",
286
+ "note": "Windows binaries unavailable. Require WSL.",
287
+ "defaults": {
288
+ "0": "0.24.32"
289
+ },
290
+ "versions": {
291
+ "0.24.32": true
292
+ },
293
+ "platforms": [
294
+ "linux-x64",
295
+ "linux-arm64",
296
+ "darwin-x64",
297
+ "darwin-arm64"
298
+ ],
299
+ "cliTools": {
300
+ "server": "sqld",
301
+ "client": null,
302
+ "utilities": [],
303
+ "enhanced": [
304
+ "litecli",
305
+ "usql"
306
+ ],
307
+ "note": "HTTP API; use Turso client SDKs or any libSQL/SQLite client"
308
+ },
309
+ "connection": {
310
+ "runtime": "server",
311
+ "defaultPort": 8080,
312
+ "scheme": "http",
313
+ "defaultDatabase": null,
314
+ "defaultUser": null,
315
+ "queryLanguage": "SQL"
316
+ },
317
+ "spindbStatus": "in-progress"
318
+ },
241
319
  "mariadb": {
242
320
  "displayName": "MariaDB",
243
321
  "description": "Community-developed fork of MySQL with enhanced performance, storage engines, and features",
@@ -248,9 +326,16 @@
248
326
  "hostedServiceAllowed": true,
249
327
  "protocol": null,
250
328
  "note": "",
329
+ "defaults": {
330
+ "10": "10.11.16",
331
+ "11": "11.8.6"
332
+ },
251
333
  "versions": {
334
+ "11.8.6": true,
252
335
  "11.8.5": true,
336
+ "11.4.10": true,
253
337
  "11.4.5": true,
338
+ "10.11.16": true,
254
339
  "10.11.15": true
255
340
  },
256
341
  "platforms": [
@@ -263,8 +348,15 @@
263
348
  "cliTools": {
264
349
  "server": "mariadbd",
265
350
  "client": "mariadb",
266
- "utilities": ["mariadb-dump", "mariadb-import", "mariadb-admin"],
267
- "enhanced": ["mycli", "usql"]
351
+ "utilities": [
352
+ "mariadb-dump",
353
+ "mariadb-import",
354
+ "mariadb-admin"
355
+ ],
356
+ "enhanced": [
357
+ "mycli",
358
+ "usql"
359
+ ]
268
360
  },
269
361
  "connection": {
270
362
  "runtime": "server",
@@ -286,7 +378,11 @@
286
378
  "hostedServiceAllowed": true,
287
379
  "protocol": null,
288
380
  "note": "",
381
+ "defaults": {
382
+ "1": "1.43.1"
383
+ },
289
384
  "versions": {
385
+ "1.43.1": true,
290
386
  "1.33.1": true
291
387
  },
292
388
  "platforms": [
@@ -323,9 +419,16 @@
323
419
  "hostedServiceAllowed": false,
324
420
  "protocol": null,
325
421
  "note": "SSPL restricts offering MongoDB as a competing managed database service (i.e., MongoDB Atlas competitors). Commercial use in applications, local dev, and internal use is fine. FerretDB available as fully open-source alternative.",
422
+ "defaults": {
423
+ "7": "7.0.34",
424
+ "8": "8.0.23"
425
+ },
326
426
  "versions": {
427
+ "8.2.9": true,
327
428
  "8.2.3": true,
429
+ "8.0.23": true,
328
430
  "8.0.17": true,
431
+ "7.0.34": true,
329
432
  "7.0.28": true
330
433
  },
331
434
  "platforms": [
@@ -366,15 +469,72 @@
366
469
  "hostedServiceAllowed": true,
367
470
  "protocol": null,
368
471
  "note": "",
472
+ "defaults": {
473
+ "8": "8.4.9",
474
+ "9": "9.6.0"
475
+ },
369
476
  "versions": {
370
- "9.6.0": true,
477
+ "9.6.0": {
478
+ "note": "mysqlpump removed in MySQL 9.0; 9.x uses mysqldump only",
479
+ "cliTools": {
480
+ "server": "mysqld",
481
+ "client": "mysql",
482
+ "utilities": [
483
+ "mysqldump",
484
+ "mysqladmin"
485
+ ],
486
+ "enhanced": [
487
+ "mycli",
488
+ "usql"
489
+ ]
490
+ }
491
+ },
371
492
  "9.5.0": {
372
493
  "deprecated": true,
373
- "note": "Deprecated; superseded by 9.6.0"
494
+ "note": "Deprecated; superseded by 9.6.0. mysqlpump removed in MySQL 9.0.",
495
+ "cliTools": {
496
+ "server": "mysqld",
497
+ "client": "mysql",
498
+ "utilities": [
499
+ "mysqldump",
500
+ "mysqladmin"
501
+ ],
502
+ "enhanced": [
503
+ "mycli",
504
+ "usql"
505
+ ]
506
+ }
374
507
  },
375
508
  "9.1.0": {
376
509
  "deprecated": true,
377
- "note": "Deprecated; superseded by 9.6.0"
510
+ "note": "Deprecated; superseded by 9.6.0. mysqlpump removed in MySQL 9.0.",
511
+ "cliTools": {
512
+ "server": "mysqld",
513
+ "client": "mysql",
514
+ "utilities": [
515
+ "mysqldump",
516
+ "mysqladmin"
517
+ ],
518
+ "enhanced": [
519
+ "mycli",
520
+ "usql"
521
+ ]
522
+ }
523
+ },
524
+ "8.4.9": {
525
+ "note": "mysqlpump removed in 8.4.9",
526
+ "cliTools": {
527
+ "server": "mysqld",
528
+ "client": "mysql",
529
+ "utilities": [
530
+ "mysqldump",
531
+ "mysqladmin"
532
+ ],
533
+ "enhanced": [
534
+ "mycli",
535
+ "usql"
536
+ ]
537
+ }
378
538
  },
379
539
  "8.4.3": true,
380
540
  "8.0.40": {
@@ -392,8 +552,15 @@
392
552
  "cliTools": {
393
553
  "server": "mysqld",
394
554
  "client": "mysql",
395
- "utilities": ["mysqldump", "mysqlpump", "mysqladmin"],
396
- "enhanced": ["mycli", "usql"]
555
+ "utilities": [
556
+ "mysqldump",
557
+ "mysqlpump",
558
+ "mysqladmin"
559
+ ],
560
+ "enhanced": [
561
+ "mycli",
562
+ "usql"
563
+ ]
397
564
  },
398
565
  "connection": {
399
566
  "runtime": "server",
@@ -415,10 +582,20 @@
415
582
  "hostedServiceAllowed": true,
416
583
  "protocol": null,
417
584
  "note": "",
585
+ "defaults": {
586
+ "15": "15.18.0",
587
+ "16": "16.14.0",
588
+ "17": "17.10.0",
589
+ "18": "18.4.0"
590
+ },
418
591
  "versions": {
592
+ "18.4.0": true,
419
593
  "18.1.0": true,
594
+ "17.10.0": true,
420
595
  "17.7.0": true,
596
+ "16.14.0": true,
421
597
  "16.11.0": true,
598
+ "15.18.0": true,
422
599
  "15.15.0": true
423
600
  },
424
601
  "platforms": [
@@ -438,7 +615,10 @@
438
615
  "createdb",
439
616
  "dropdb"
440
617
  ],
441
- "enhanced": ["pgcli", "usql"]
618
+ "enhanced": [
619
+ "pgcli",
620
+ "usql"
621
+ ]
442
622
  },
443
623
  "connection": {
444
624
  "runtime": "server",
@@ -460,15 +640,30 @@
460
640
  "hostedServiceAllowed": true,
461
641
  "protocol": "postgresql",
462
642
  "note": "Backend for FerretDB v2 only; includes pg_cron, pgvector, PostGIS, rum extensions. Not available on Windows.",
643
+ "defaults": {
644
+ "17": "17-0.107.0"
645
+ },
463
646
  "versions": {
464
647
  "17-0.107.0": true
465
648
  },
466
- "platforms": ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64"],
649
+ "platforms": [
650
+ "linux-x64",
651
+ "linux-arm64",
652
+ "darwin-x64",
653
+ "darwin-arm64"
654
+ ],
467
655
  "cliTools": {
468
656
  "server": "postgres",
469
657
  "client": "psql",
470
- "utilities": ["pg_dump", "pg_restore", "initdb", "pg_ctl"],
471
- "enhanced": ["pgcli"]
658
+ "utilities": [
659
+ "pg_dump",
660
+ "pg_restore",
661
+ "initdb",
662
+ "pg_ctl"
663
+ ],
664
+ "enhanced": [
665
+ "pgcli"
666
+ ]
472
667
  },
473
668
  "connection": {
474
669
  "runtime": "server",
@@ -490,6 +685,9 @@
490
685
  "hostedServiceAllowed": true,
491
686
  "protocol": null,
492
687
  "note": "",
688
+ "defaults": {
689
+ "1": "1.16.3"
690
+ },
493
691
  "versions": {
494
692
  "1.16.3": true
495
693
  },
@@ -534,6 +732,9 @@
534
732
  "note": "QuestDB uses PostgreSQL client tools (psql, pgcli) for its wire protocol; PostgreSQL remains installed as a standalone database when QuestDB is removed"
535
733
  }
536
734
  ],
735
+ "defaults": {
736
+ "9": "9.2.3"
737
+ },
537
738
  "versions": {
538
739
  "9.2.3": true
539
740
  },
@@ -548,7 +749,10 @@
548
749
  "server": "questdb",
549
750
  "client": "psql",
550
751
  "utilities": [],
551
- "enhanced": ["pgcli", "usql"],
752
+ "enhanced": [
753
+ "pgcli",
754
+ "usql"
755
+ ],
552
756
  "note": "PostgreSQL wire protocol; use psql or pgcli"
553
757
  },
554
758
  "connection": {
@@ -571,8 +775,13 @@
571
775
  "hostedServiceAllowed": false,
572
776
  "protocol": null,
573
777
  "note": "RSALv2 restricts building competing products to Redis itself. AGPL-3.0 (8.0+) requires source disclosure if you modify Redis and offer it as a network service. Commercial use in applications, local dev, and internal use is fine. Valkey available as BSD-licensed drop-in alternative.",
778
+ "defaults": {
779
+ "7": "7.4.9",
780
+ "8": "8.4.0"
781
+ },
574
782
  "versions": {
575
783
  "8.4.0": true,
784
+ "7.4.9": true,
576
785
  "7.4.7": true
577
786
  },
578
787
  "platforms": [
@@ -585,8 +794,14 @@
585
794
  "cliTools": {
586
795
  "server": "redis-server",
587
796
  "client": "redis-cli",
588
- "utilities": ["redis-benchmark", "redis-check-aof", "redis-check-rdb"],
589
- "enhanced": ["iredis"]
797
+ "utilities": [
798
+ "redis-benchmark",
799
+ "redis-check-aof",
800
+ "redis-check-rdb"
801
+ ],
802
+ "enhanced": [
803
+ "iredis"
804
+ ]
590
805
  },
591
806
  "connection": {
592
807
  "runtime": "server",
@@ -608,7 +823,11 @@
608
823
  "hostedServiceAllowed": true,
609
824
  "protocol": null,
610
825
  "note": "",
826
+ "defaults": {
827
+ "3": "3.53.1"
828
+ },
611
829
  "versions": {
830
+ "3.53.1": true,
612
831
  "3.51.2": true
613
832
  },
614
833
  "platforms": [
@@ -622,7 +841,10 @@
622
841
  "server": null,
623
842
  "client": "sqlite3",
624
843
  "utilities": [],
625
- "enhanced": ["litecli", "usql"]
844
+ "enhanced": [
845
+ "litecli",
846
+ "usql"
847
+ ]
626
848
  },
627
849
  "connection": {
628
850
  "runtime": "embedded",
@@ -644,6 +866,9 @@
644
866
  "hostedServiceAllowed": false,
645
867
  "protocol": null,
646
868
  "note": "Rust-based; single binary. License is BSL-1.1 (not Apache-2.0); prohibits competing DBaaS offerings. Converts to Apache-2.0 after 4 years per release. Fine for local dev and internal use.",
869
+ "defaults": {
870
+ "2": "2.3.2"
871
+ },
647
872
  "versions": {
648
873
  "2.3.2": true
649
874
  },
@@ -681,6 +906,9 @@
681
906
  "hostedServiceAllowed": true,
682
907
  "protocol": null,
683
908
  "note": "Written in Zig; single binary with built-in REPL client. Uses a custom binary protocol (not HTTP/SQL). macOS uses a universal (fat) binary for both x64 and arm64.",
909
+ "defaults": {
910
+ "0": "0.16.70"
911
+ },
684
912
  "versions": {
685
913
  "0.16.70": true
686
914
  },
@@ -718,6 +946,9 @@
718
946
  "hostedServiceAllowed": true,
719
947
  "protocol": null,
720
948
  "note": "Rewritten from Java to Rust in v3.0 (Dec 2024). Binaries distributed via Cloudsmith and GitHub Releases.",
949
+ "defaults": {
950
+ "3": "3.8.0"
951
+ },
721
952
  "versions": {
722
953
  "3.8.0": true
723
954
  },
@@ -755,8 +986,14 @@
755
986
  "hostedServiceAllowed": true,
756
987
  "protocol": "redis",
757
988
  "note": "",
989
+ "defaults": {
990
+ "8": "8.0.9",
991
+ "9": "9.0.4"
992
+ },
758
993
  "versions": {
994
+ "9.0.4": true,
759
995
  "9.0.1": true,
996
+ "8.0.9": true,
760
997
  "8.0.6": true
761
998
  },
762
999
  "platforms": [
@@ -769,8 +1006,12 @@
769
1006
  "cliTools": {
770
1007
  "server": "valkey-server",
771
1008
  "client": "valkey-cli",
772
- "utilities": ["valkey-benchmark"],
773
- "enhanced": ["iredis"]
1009
+ "utilities": [
1010
+ "valkey-benchmark"
1011
+ ],
1012
+ "enhanced": [
1013
+ "iredis"
1014
+ ]
774
1015
  },
775
1016
  "connection": {
776
1017
  "runtime": "server",
@@ -792,6 +1033,9 @@
792
1033
  "hostedServiceAllowed": true,
793
1034
  "protocol": null,
794
1035
  "note": "Go-based single binary (CGO_ENABLED=0). Linux from official releases; macOS/Windows cross-compiled from source.",
1036
+ "defaults": {
1037
+ "1": "1.35.7"
1038
+ },
795
1039
  "versions": {
796
1040
  "1.35.7": true
797
1041
  },
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shared checksum utilities for fetching and parsing checksums.txt files
3
+ */
4
+ /**
5
+ * Parse checksums.txt content into a record of filename -> hash
6
+ */
7
+ export declare function parseChecksums(content: string): Record<string, string>;
8
+ /**
9
+ * Fetch checksums.txt from a GitHub release using the API (avoids CDN caching issues)
10
+ *
11
+ * @param repo - Repository in "owner/repo" format
12
+ * @param tag - Release tag name
13
+ * @returns Record of filename -> SHA256 hash, or empty object if not found
14
+ */
15
+ export declare function fetchChecksums(repo: string, tag: string): Promise<Record<string, string>>;
16
+ //# sourceMappingURL=checksums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checksums.d.ts","sourceRoot":"","sources":["../lib/checksums.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYtE;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAwDjC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Shared checksum utilities for fetching and parsing checksums.txt files
3
+ */
4
+ /**
5
+ * Parse checksums.txt content into a record of filename -> hash
6
+ */
7
+ export function parseChecksums(content) {
8
+ const checksums = {};
9
+ for (const line of content.split('\n')) {
10
+ // Format: "hash filename" or "hash *filename" (binary mode)
11
+ const match = line.match(/^([a-f0-9]{64})\s+\*?(.+)$/);
12
+ if (match) {
13
+ checksums[match[2]] = match[1];
14
+ }
15
+ }
16
+ return checksums;
17
+ }
18
+ /**
19
+ * Fetch checksums.txt from a GitHub release using the API (avoids CDN caching issues)
20
+ *
21
+ * @param repo - Repository in "owner/repo" format
22
+ * @param tag - Release tag name
23
+ * @returns Record of filename -> SHA256 hash, or empty object if not found
24
+ */
25
+ export async function fetchChecksums(repo, tag) {
26
+ // First try to get the asset URL from the API
27
+ const apiUrl = `https://api.github.com/repos/${repo}/releases/tags/${tag}`;
28
+ const apiResponse = await fetch(apiUrl, {
29
+ headers: {
30
+ Accept: 'application/vnd.github.v3+json',
31
+ 'User-Agent': 'hostdb-checksums',
32
+ ...(process.env.GITHUB_TOKEN
33
+ ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` }
34
+ : {}),
35
+ },
36
+ });
37
+ if (!apiResponse.ok) {
38
+ return {};
39
+ }
40
+ const release = (await apiResponse.json());
41
+ const checksumAsset = release.assets.find((a) => a.name === 'checksums.txt');
42
+ if (!checksumAsset) {
43
+ return {};
44
+ }
45
+ // Use API asset download (works for both private and public repos)
46
+ const assetApiUrl = `https://api.github.com/repos/${repo}/releases/assets/${checksumAsset.id}`;
47
+ const assetApiResponse = await fetch(assetApiUrl, {
48
+ headers: {
49
+ Accept: 'application/octet-stream',
50
+ 'User-Agent': 'hostdb-checksums',
51
+ ...(process.env.GITHUB_TOKEN
52
+ ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` }
53
+ : {}),
54
+ },
55
+ redirect: 'follow',
56
+ });
57
+ if (assetApiResponse.ok) {
58
+ const content = await assetApiResponse.text();
59
+ return parseChecksums(content);
60
+ }
61
+ // Fallback: try browser_download_url (only works for public repos)
62
+ if (!process.env.GITHUB_TOKEN) {
63
+ const browserResponse = await fetch(checksumAsset.browser_download_url, {
64
+ headers: { 'User-Agent': 'hostdb-checksums' },
65
+ redirect: 'follow',
66
+ });
67
+ if (browserResponse.ok) {
68
+ const content = await browserResponse.text();
69
+ return parseChecksums(content);
70
+ }
71
+ }
72
+ return {};
73
+ }
74
+ //# sourceMappingURL=checksums.js.map