Skip to content

Commit 2a1c514

Browse files
committed
imp: more configurable for auth-mock
1 parent 1c2d7c3 commit 2a1c514

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed

kms/auth-mock/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ bun run check
6868

6969
## environment variables
7070

71-
- `KMS_CONTRACT_ADDR` - mock contract address (default: 0xmockcontract1234567890123456789012345678)
7271
- `PORT` - server port (default: 3000)
72+
- `MOCK_GATEWAY_APP_ID` - mock gateway app ID (default: 0xmockgateway1234567890123456789012345678)
73+
- `MOCK_CHAIN_ID` - mock blockchain chain ID (default: 1337)
74+
- `MOCK_APP_IMPLEMENTATION` - mock app implementation address (default: 0xmockapp9876543210987654321098765432109)
7375

7476
## API endpoints
7577

kms/auth-mock/bun.lock

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
"": {
55
"name": "auth-mock",
66
"dependencies": {
7-
"@hono/zod-validator": "^0.2.0",
8-
"hono": "^4.0.0",
9-
"zod": "^3.22.0",
7+
"@hono/zod-validator": "0.2.2",
8+
"hono": "4.8.5",
9+
"zod": "3.25.76",
1010
},
1111
"devDependencies": {
12-
"@types/bun": "latest",
13-
"@vitest/ui": "^1.0.0",
14-
"openapi-types": "^12.1.0",
15-
"oxlint": "^0.9.0",
16-
"typescript": "^5.3.3",
17-
"vitest": "^1.0.0",
12+
"@types/bun": "1.2.18",
13+
"@types/node": "22.10.8",
14+
"@vitest/ui": "1.6.1",
15+
"openapi-types": "12.1.3",
16+
"oxlint": "0.9.10",
17+
"typescript": "5.8.3",
18+
"vitest": "1.6.1",
1819
},
1920
},
2021
},
@@ -141,7 +142,7 @@
141142

142143
"@types/estree": ["@types/[email protected]", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
143144

144-
"@types/node": ["@types/node@24.0.14", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw=="],
145+
"@types/node": ["@types/node@22.10.8", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-rk+QvAEGsbX/ZPiiyel6hJHNUS9cnSbPWVaZLvE+Er3tLqQFzWMz9JOfWW7XUmKvRPfxJfbl3qYWve+RGXncFw=="],
145146

146147
"@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g=="],
147148

@@ -321,7 +322,7 @@
321322

322323
"ufo": ["[email protected]", "", {}, "sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA=="],
323324

324-
"undici-types": ["undici-types@7.8.0", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
325+
"undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
325326

326327
"vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["@types/node", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": { "vite": "bin/vite.js" } }, "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA=="],
327328

@@ -337,10 +338,14 @@
337338

338339
"zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
339340

341+
"bun-types/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw=="],
342+
340343
"mlly/pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
341344

342345
"npm-run-path/path-key": ["[email protected]", "", {}, "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="],
343346

344347
"pkg-types/pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
348+
349+
"bun-types/@types/node/undici-types": ["[email protected]", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
345350
}
346351
}

kms/auth-mock/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ describe('Mock Backend Tests', () => {
3636
note: 'this is a mock backend - all authentications will succeed'
3737
});
3838

39-
// Verify mock values
40-
expect(data.gatewayAppId).toBe('0xmockgateway1234567890123456789012345678');
41-
expect(data.chainId).toBe(1337);
42-
expect(data.appImplementation).toBe('0xmockapp9876543210987654321098765432109');
39+
// Verify mock values (using same defaults as implementation)
40+
expect(data.gatewayAppId).toBe(process.env.MOCK_GATEWAY_APP_ID || '0xmockgateway1234567890123456789012345678');
41+
expect(data.chainId).toBe(parseInt(process.env.MOCK_CHAIN_ID || '1337'));
42+
expect(data.appImplementation).toBe(process.env.MOCK_APP_IMPLEMENTATION || '0xmockapp9876543210987654321098765432109');
4343

4444
// Verify response structure matches OpenAPI spec
4545
const systemInfoSchema = openApiSpec.components.schemas.MockSystemInfo;
@@ -76,7 +76,7 @@ describe('Mock Backend Tests', () => {
7676
expect(data).toMatchObject({
7777
isAllowed: true,
7878
reason: 'mock app always allowed',
79-
gatewayAppId: '0xmockgateway1234567890123456789012345678',
79+
gatewayAppId: process.env.MOCK_GATEWAY_APP_ID || '0xmockgateway1234567890123456789012345678',
8080
});
8181

8282
// Verify console log was called
@@ -181,7 +181,7 @@ describe('Mock Backend Tests', () => {
181181
expect(data).toMatchObject({
182182
isAllowed: true,
183183
reason: 'mock KMS always allowed',
184-
gatewayAppId: '0xmockgateway1234567890123456789012345678',
184+
gatewayAppId: process.env.MOCK_GATEWAY_APP_ID || '0xmockgateway1234567890123456789012345678',
185185
});
186186

187187
// Verify console log was called

kms/auth-mock/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class MockBackend {
3333
private mockAppImplementation: string;
3434

3535
constructor() {
36-
// mock values for consistent responses
37-
this.mockGatewayAppId = '0xmockgateway1234567890123456789012345678';
38-
this.mockChainId = 1337; // mock chain ID
39-
this.mockAppImplementation = '0xmockapp9876543210987654321098765432109';
36+
// mock values - configurable via environment variables
37+
this.mockGatewayAppId = process.env.MOCK_GATEWAY_APP_ID || '0xmockgateway1234567890123456789012345678';
38+
this.mockChainId = parseInt(process.env.MOCK_CHAIN_ID || '1337');
39+
this.mockAppImplementation = process.env.MOCK_APP_IMPLEMENTATION || '0xmockapp9876543210987654321098765432109';
4040
}
4141

4242
async checkBoot(bootInfo: BootInfo, isKms: boolean): Promise<BootResponse> {

kms/auth-mock/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
},
2222
"devDependencies": {
2323
"@types/bun": "1.2.18",
24-
"typescript": "5.8.3",
25-
"vitest": "1.6.1",
24+
"@types/node": "22.10.8",
2625
"@vitest/ui": "1.6.1",
2726
"openapi-types": "12.1.3",
28-
"oxlint": "0.9.10"
27+
"oxlint": "0.9.10",
28+
"typescript": "5.8.3",
29+
"vitest": "1.6.1"
2930
},
3031
"type": "module"
3132
}

0 commit comments

Comments
 (0)