most-box 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MOST.BOX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # MostBox
2
+
3
+ P2P 文件分享应用。基于 Hyperswarm/Hyperdrive 的去中心化文件分发。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm i -g most-box
9
+ ```
10
+
11
+ ## 运行
12
+
13
+ ```bash
14
+ most-box
15
+ ```
16
+
17
+ 浏览器访问 `http://127.0.0.1:1976`
18
+
19
+ ## 开发
20
+
21
+ ```bash
22
+ git clone https://github.com/your-username/most.git
23
+ cd most
24
+ npm install
25
+ npm run dev
26
+ ```
27
+
28
+ ## 三种访问场景
29
+
30
+ | 场景 | 启动方式 | 访问地址 |
31
+ |------|----------|----------|
32
+ | 本地 | `most-box` | `http://127.0.0.1:1976` |
33
+ | 内网 | `set MOSTBOX_HOST=0.0.0.0 && most-box` | `http://<IP>:1976` |
34
+ | 外网 | Caddy 反向代理 | `https://your-domain.com` |
35
+
36
+ ### 内网访问
37
+
38
+ ```bash
39
+ set MOSTBOX_HOST=0.0.0.0
40
+ most-box
41
+ ```
42
+
43
+ ### 外网访问(Caddy)
44
+
45
+ ```caddy
46
+ mostbox.example.com {
47
+ reverse_proxy localhost:1976
48
+ }
49
+ ```
50
+
51
+ ## 核心功能
52
+
53
+ 1. **确定性 P2P 文件发布**
54
+ - 采用标准 IPFS UnixFS Chunking 算法计算 CID v1
55
+ - 相同文件生成一致的 CID 链接
56
+
57
+ 2. **大文件流式传输**
58
+ - 支持 GB 级别超大文件的发布与下载
59
+
60
+ 3. **完整性校验**
61
+ - 下载完成后自动验证 CID,防止数据篡改
62
+
63
+ ## 技术栈
64
+
65
+ - **Hyperswarm** — P2P 网络发现与连接
66
+ - **Hyperdrive** — 分布式文件存储
67
+ - **Corestore** — Hypercore 存储管理
68
+ - **IPFS UnixFS Importer** — CID 计算
69
+ - **Node.js HTTP** — 零依赖的 HTTP + WebSocket 服务
70
+
71
+ ## 许可证
72
+
73
+ MIT
package/build.mjs ADDED
@@ -0,0 +1,40 @@
1
+ import * as esbuild from 'esbuild'
2
+ import fs from 'fs'
3
+ import path from 'path'
4
+ import { fileURLToPath } from 'url'
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
+ const publicDir = path.join(__dirname, 'public')
8
+ const outFile = path.join(publicDir, 'bundle.js')
9
+
10
+ const isWatch = process.argv.includes('--watch')
11
+ const isDev = process.argv.includes('--dev')
12
+
13
+ const buildOptions = {
14
+ entryPoints: [path.join(publicDir, 'index.jsx')],
15
+ bundle: true,
16
+ outfile: outFile,
17
+ format: 'esm',
18
+ jsx: 'automatic',
19
+ jsxImportSource: 'react',
20
+ loader: {
21
+ '.js': 'jsx',
22
+ '.jsx': 'jsx',
23
+ },
24
+ define: {
25
+ 'process.env.NODE_ENV': isDev ? '"development"' : '"production"'
26
+ },
27
+ minify: !isDev,
28
+ sourcemap: isDev,
29
+ target: ['es2020'],
30
+ logLevel: 'info',
31
+ }
32
+
33
+ if (isWatch) {
34
+ const ctx = await esbuild.context(buildOptions)
35
+ await ctx.watch()
36
+ console.log('[Build] Watching for changes...')
37
+ } else {
38
+ await esbuild.build(buildOptions)
39
+ console.log('[Build] Done.')
40
+ }
package/cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './server.js';
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "most-box",
3
+ "version": "0.0.1",
4
+ "description": "MostBox - P2P file sharing application",
5
+ "type": "module",
6
+ "main": "server.js",
7
+ "bin": {
8
+ "most-box": "./cli.js"
9
+ },
10
+ "files": [
11
+ "public",
12
+ "src",
13
+ "server.js",
14
+ "build.mjs",
15
+ "cli.js"
16
+ ],
17
+ "scripts": {
18
+ "start": "npm run build && node server.js",
19
+ "dev": "npm run build -- --dev --watch & node --watch server.js",
20
+ "build": "node build.mjs"
21
+ },
22
+ "keywords": [
23
+ "p2p",
24
+ "file-sharing",
25
+ "hyperswarm",
26
+ "hyperdrive"
27
+ ],
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "b4a": "^1.8.0",
31
+ "corestore": "^7.9.2",
32
+ "eventemitter3": "^5.0.4",
33
+ "hyperdrive": "^13.3.1",
34
+ "hyperswarm": "^4.17.0",
35
+ "ipfs-unixfs-importer": "^16.1.4",
36
+ "lucide-react": "^1.7.0",
37
+ "multiformats": "^13.4.2",
38
+ "react": "^19.2.4",
39
+ "react-dom": "^19.2.4"
40
+ },
41
+ "devDependencies": {
42
+ "esbuild": "^0.27.4"
43
+ }
44
+ }