Skip to content

Commit ac13c78

Browse files
Merge pull request #30 from BitGo/WP-000000/qol-api-specs
feat(mbe): add unified api spec for mbe
2 parents 99eff9f + 92a45c4 commit ac13c78

5 files changed

Lines changed: 371 additions & 4 deletions

File tree

masterBitgoExpress.json

Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
{
2+
"openapi": "3.0.3",
3+
"info": {
4+
"title": "@bitgo/master-bitgo-express",
5+
"version": "1.0.0",
6+
"description": "BitGo Enclaved Express - Secure enclave for BitGo signing operations with mTLS"
7+
},
8+
"paths": {
9+
"/api/{coin}/wallet/{walletId}/sendMany": {
10+
"post": {
11+
"parameters": [
12+
{
13+
"name": "walletId",
14+
"in": "path",
15+
"required": true,
16+
"schema": {
17+
"type": "string"
18+
}
19+
},
20+
{
21+
"name": "coin",
22+
"in": "path",
23+
"required": true,
24+
"schema": {
25+
"type": "string"
26+
}
27+
}
28+
],
29+
"requestBody": {
30+
"content": {
31+
"application/json": {
32+
"schema": {
33+
"type": "object",
34+
"properties": {
35+
"pubkey": {
36+
"type": "string"
37+
},
38+
"source": {
39+
"type": "string",
40+
"enum": [
41+
"user",
42+
"backup"
43+
]
44+
},
45+
"recipients": {
46+
"type": "array",
47+
"items": {}
48+
},
49+
"numBlocks": {
50+
"type": "number"
51+
},
52+
"feeRate": {
53+
"type": "number"
54+
},
55+
"feeMultiplier": {
56+
"type": "number"
57+
},
58+
"maxFeeRate": {
59+
"type": "number"
60+
},
61+
"minConfirms": {
62+
"type": "number"
63+
},
64+
"enforceMinConfirmsForChange": {
65+
"type": "boolean"
66+
},
67+
"targetWalletUnspents": {
68+
"type": "number"
69+
},
70+
"message": {
71+
"type": "string"
72+
},
73+
"minValue": {
74+
"oneOf": [
75+
{
76+
"type": "number"
77+
},
78+
{
79+
"type": "string"
80+
}
81+
]
82+
},
83+
"maxValue": {
84+
"oneOf": [
85+
{
86+
"type": "number"
87+
},
88+
{
89+
"type": "string"
90+
}
91+
]
92+
},
93+
"sequenceId": {
94+
"type": "string"
95+
},
96+
"lastLedgerSequence": {
97+
"type": "number"
98+
},
99+
"ledgerSequenceDelta": {
100+
"type": "number"
101+
},
102+
"gasPrice": {
103+
"type": "number"
104+
},
105+
"noSplitChange": {
106+
"type": "boolean"
107+
},
108+
"unspents": {
109+
"type": "array",
110+
"items": {
111+
"type": "string"
112+
}
113+
},
114+
"comment": {
115+
"type": "string"
116+
},
117+
"otp": {
118+
"type": "string"
119+
},
120+
"changeAddress": {
121+
"type": "string"
122+
},
123+
"allowExternalChangeAddress": {
124+
"type": "boolean"
125+
},
126+
"instant": {
127+
"type": "boolean"
128+
},
129+
"memo": {
130+
"type": "string"
131+
},
132+
"transferId": {
133+
"type": "number"
134+
},
135+
"eip1559": {},
136+
"gasLimit": {
137+
"type": "number"
138+
},
139+
"custodianTransactionId": {
140+
"type": "string"
141+
}
142+
},
143+
"required": [
144+
"pubkey",
145+
"source",
146+
"recipients"
147+
]
148+
}
149+
}
150+
}
151+
},
152+
"responses": {
153+
"200": {
154+
"description": "OK",
155+
"content": {
156+
"application/json": {
157+
"schema": {}
158+
}
159+
}
160+
},
161+
"500": {
162+
"description": "Internal Server Error",
163+
"content": {
164+
"application/json": {
165+
"schema": {
166+
"type": "object",
167+
"properties": {
168+
"error": {
169+
"type": "string"
170+
},
171+
"details": {
172+
"type": "string"
173+
}
174+
},
175+
"required": [
176+
"error",
177+
"details"
178+
]
179+
}
180+
}
181+
}
182+
}
183+
}
184+
}
185+
},
186+
"/api/{coin}/wallet/generate": {
187+
"post": {
188+
"parameters": [
189+
{
190+
"name": "coin",
191+
"in": "path",
192+
"required": true,
193+
"schema": {
194+
"type": "string"
195+
}
196+
}
197+
],
198+
"requestBody": {
199+
"content": {
200+
"application/json": {
201+
"schema": {
202+
"type": "object",
203+
"properties": {
204+
"label": {
205+
"type": "string"
206+
},
207+
"multisigType": {
208+
"type": "string",
209+
"enum": [
210+
"onchain",
211+
"tss"
212+
]
213+
},
214+
"enterprise": {
215+
"type": "string"
216+
},
217+
"disableTransactionNotifications": {
218+
"type": "boolean"
219+
},
220+
"isDistributedCustody": {
221+
"type": "boolean"
222+
}
223+
},
224+
"required": [
225+
"label",
226+
"enterprise"
227+
]
228+
}
229+
}
230+
}
231+
},
232+
"responses": {
233+
"200": {
234+
"description": "OK",
235+
"content": {
236+
"application/json": {
237+
"schema": {}
238+
}
239+
}
240+
},
241+
"500": {
242+
"description": "Internal Server Error",
243+
"content": {
244+
"application/json": {
245+
"schema": {
246+
"type": "object",
247+
"properties": {
248+
"error": {
249+
"type": "string"
250+
},
251+
"details": {
252+
"type": "string"
253+
}
254+
},
255+
"required": [
256+
"error",
257+
"details"
258+
]
259+
}
260+
}
261+
}
262+
}
263+
}
264+
}
265+
},
266+
"/ping": {
267+
"post": {
268+
"parameters": [],
269+
"responses": {
270+
"200": {
271+
"description": "OK",
272+
"content": {
273+
"application/json": {
274+
"schema": {
275+
"type": "object",
276+
"properties": {
277+
"status": {
278+
"type": "string"
279+
},
280+
"timestamp": {
281+
"type": "string"
282+
}
283+
},
284+
"required": [
285+
"status",
286+
"timestamp"
287+
]
288+
}
289+
}
290+
}
291+
}
292+
}
293+
}
294+
},
295+
"/version": {
296+
"get": {
297+
"parameters": [],
298+
"responses": {
299+
"200": {
300+
"description": "OK",
301+
"content": {
302+
"application/json": {
303+
"schema": {
304+
"type": "object",
305+
"properties": {
306+
"version": {
307+
"type": "string"
308+
},
309+
"name": {
310+
"type": "string"
311+
}
312+
},
313+
"required": [
314+
"version",
315+
"name"
316+
]
317+
}
318+
}
319+
}
320+
}
321+
}
322+
}
323+
}
324+
},
325+
"components": {
326+
"schemas": {}
327+
}
328+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"test:watch": "mocha --require ts-node/register --watch 'src/**/__tests__/**/*.test.ts'",
1515
"test:coverage": "nyc mocha --require ts-node/register 'src/**/__tests__/**/*.test.ts'",
1616
"lint": "eslint --quiet .",
17-
"generate-test-ssl": "openssl req -x509 -newkey rsa:2048 -keyout test-ssl-key.pem -out test-ssl-cert.pem -days 365 -nodes -subj '/CN=localhost'"
17+
"generate-test-ssl": "openssl req -x509 -newkey rsa:2048 -keyout test-ssl-key.pem -out test-ssl-cert.pem -days 365 -nodes -subj '/CN=localhost'",
18+
"generate:openapi:masterExpress": "npx @api-ts/openapi-generator --name @bitgo/master-bitgo-express ./src/masterBitgoExpress/routers/index.ts > masterBitgoExpress.json"
1819
},
1920
"dependencies": {
2021
"@api-ts/io-ts-http": "^3.2.1",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { apiSpec } from '@api-ts/io-ts-http';
2+
import { HealthCheckApiSpec } from './healthCheck';
3+
import { MasterApiSpec } from './masterApiSpec';
4+
5+
// Combine all API specifications
6+
const combinedSpec = apiSpec({
7+
...HealthCheckApiSpec,
8+
...MasterApiSpec,
9+
});
10+
11+
// Export the OpenAPI specification
12+
export default {
13+
openapi: '3.1.0',
14+
info: {
15+
title: '@bitgo/master-bitgo-express',
16+
version: '0.0.1',
17+
description: 'BitGo Master Express - Gateway for on Prem BitGo services',
18+
},
19+
...combinedSpec,
20+
components: {
21+
securitySchemes: {
22+
bearerAuth: {
23+
type: 'http',
24+
scheme: 'bearer',
25+
bearerFormat: 'JWT',
26+
description: 'Enter your Bearer token in the format "Bearer {token}"',
27+
},
28+
},
29+
},
30+
security: [
31+
{
32+
bearerAuth: [],
33+
},
34+
],
35+
};
36+
37+
// Also export the combined API spec for internal use
38+
export const FullApiSpec = combinedSpec;

src/masterBitgoExpress/routers/masterApiSpec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const MasterApiSpec = apiSpec({
9090
'v1.wallet.generate': {
9191
post: httpRoute({
9292
method: 'POST' as const,
93-
path: '/{coin}/wallet/generate',
93+
path: '/api/{coin}/wallet/generate',
9494
request: httpRequest({
9595
params: {
9696
coin: t.string,
@@ -104,7 +104,7 @@ export const MasterApiSpec = apiSpec({
104104
'v1.wallet.sendMany': {
105105
post: httpRoute({
106106
method: 'POST',
107-
path: '/{coin}/wallet/{walletId}/sendMany',
107+
path: '/api/{coin}/wallet/{walletId}/sendMany',
108108
request: httpRequest({
109109
params: {
110110
walletId: t.string,

0 commit comments

Comments
 (0)