Skip to content

Commit 2f8c22d

Browse files
committed
feat: auth-eth-bun
1 parent 5e41faf commit 2f8c22d

File tree

8 files changed

+1467
-0
lines changed

8 files changed

+1467
-0
lines changed

kms/auth-eth-bun/.oxlintrc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/crates/oxc_linter/src/config/schema.json",
3+
"rules": {
4+
"typescript": "warn",
5+
"unicorn": "warn",
6+
"react": "off",
7+
"jsx-a11y": "off",
8+
"nextjs": "off"
9+
},
10+
"env": {
11+
"node": true,
12+
"es2022": true
13+
},
14+
"globals": {
15+
"globalThis": "readonly",
16+
"console": "readonly"
17+
},
18+
"ignore_patterns": [
19+
"node_modules/**",
20+
"dist/**",
21+
"build/**",
22+
"coverage/**",
23+
"*.min.js",
24+
"*.d.ts",
25+
"*.test.ts"
26+
]
27+
}

kms/auth-eth-bun/README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# dstack KMS auth-eth-bun
2+
3+
a single-file implementation of the dstack KMS ethereum backend using bun + hono + zod.
4+
5+
## features
6+
7+
- 🚀 fast and lightweight with bun runtime
8+
- 🔧 modern web framework with hono.js
9+
- ✅ type-safe validation with zod.js
10+
- 📦 single file implementation
11+
- 🔐 ethereum smart contract integration with viem
12+
13+
## installation
14+
15+
```bash
16+
# install dependencies
17+
bun install
18+
```
19+
20+
## usage
21+
22+
### development
23+
```bash
24+
# run with hot reload
25+
bun run dev
26+
```
27+
28+
### production
29+
```bash
30+
# run directly
31+
bun run start
32+
33+
# or build first
34+
bun run build
35+
```
36+
37+
### testing
38+
```bash
39+
# run tests (watch mode)
40+
bun run test
41+
42+
# run tests once
43+
bun run test:run
44+
```
45+
46+
### code quality
47+
```bash
48+
# run linter
49+
bun run lint
50+
51+
# run linter and fix issues
52+
bun run lint:fix
53+
54+
# format code
55+
bun run format
56+
57+
# run full check (lint + tests)
58+
bun run check
59+
```
60+
61+
## environment variables
62+
63+
- `ETH_RPC_URL` - ethereum RPC endpoint (default: http://localhost:8545)
64+
- `KMS_CONTRACT_ADDR` - KMS contract address (default: 0x0000000000000000000000000000000000000000)
65+
- `PORT` - server port (default: 3000)
66+
67+
## API endpoints
68+
69+
### GET /
70+
health check and system information
71+
72+
### POST /bootAuth/app
73+
application boot authentication
74+
75+
### POST /bootAuth/kms
76+
KMS boot authentication
77+
78+
## request format
79+
80+
```json
81+
{
82+
"tcbStatus": "string",
83+
"advisoryIds": ["string"],
84+
"mrAggregated": "string",
85+
"mrSystem": "string",
86+
"osImageHash": "string",
87+
"appId": "string",
88+
"composeHash": "string",
89+
"instanceId": "string",
90+
"deviceId": "string"
91+
}
92+
```
93+
94+
## response format
95+
96+
```json
97+
{
98+
"isAllowed": boolean,
99+
"reason": "string",
100+
"gatewayAppId": "string"
101+
}
102+
```
103+
104+
## API compatibility
105+
106+
this implementation is fully compatible with the original fastify + ethers version:
107+
108+
- **request/response schemas**: identical to original API
109+
- **OpenAPI specification**: available in `openapi.json`
110+
- **comprehensive testing**: vitest test suite validates compatibility
111+
- **backward compatibility**: supports both minimal and full BootInfo formats
112+
113+
### OpenAPI specification
114+
115+
the complete API specification is available in `openapi.json` and includes:
116+
- detailed schema definitions
117+
- request/response examples
118+
- compatibility notes
119+
120+
### compatibility testing
121+
122+
the test suite (`index.test.ts`) validates:
123+
- ✅ request/response format compatibility
124+
- ✅ schema validation using OpenAPI spec
125+
- ✅ error handling behavior
126+
- ✅ hex encoding/decoding compatibility
127+
- ✅ optional field handling

kms/auth-eth-bun/bun.lock

Lines changed: 378 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)