Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions modules/express/openapi-generator.rc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* OpenAPI Generator Configuration
* Custom codec handlers for OpenAPI generation
*/

module.exports = (E) => {
return {
'.': {
JsonFromStringifiedJson: () => E.right({ type: 'string' }),
Optional: (args) => E.right({ ...args[0], nullable: true }),
},
'io-ts-types': {
Json: () => E.right({ type: 'object', properties: {}, required: [] }),
NonEmptyString: () => E.right({ type: 'string', minLength: 1 }),
DateFromISOString: () => E.right({ type: 'string', format: 'date-time' }),
BigIntFromString: () => E.right({ type: 'string' }),
},
'io-ts-bigint': {
BigIntFromString: () => E.right({ type: 'string' }),
NegativeBigIntFromString: () => E.right({ type: 'string' }),
PositiveBigIntFromString: () => E.right({ type: 'string' }),
NonZeroBigIntFromString: () => E.right({ type: 'string' }),
NonNegativeBigIntFromString: () => E.right({ type: 'string' }),
},
'io-ts-numbers': {
NumberFromString: () => E.right({ type: 'string' }),
},
};
};
1 change: 1 addition & 0 deletions modules/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"description": "Local signing server and proxy for the BitGo platform",
"main": "./dist/src/index.js",
"source": "src/typedRoutes/api/index.ts",
"types": "./dist/src/index.d.ts",
"bin": {
"bitgo-express": "./bin/bitgo-express"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const CalculateMinerFeeInfoResponse = t.type({
* 4. The fee rate (in satoshis per kilobyte)
*
* @operationId express.calculateminerfeeinfo
* @tag express
*/
export const PostCalculateMinerFeeInfo = httpRoute({
path: '/api/v[12]/calculateminerfeeinfo',
Expand Down
1 change: 1 addition & 0 deletions modules/express/src/typedRoutes/api/common/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const DecryptRequestBody = {
* Decrypt
*
* @operationId express.decrypt
* @tag express
*/
export const PostDecrypt = httpRoute({
path: '/api/v[12]/decrypt',
Expand Down
1 change: 1 addition & 0 deletions modules/express/src/typedRoutes/api/common/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const EncryptRequestBody = {
* Encrypt
*
* @operationId express.encrypt
* @tag express
*/
export const PostEncrypt = httpRoute({
path: '/api/v[12]/encrypt',
Expand Down
1 change: 1 addition & 0 deletions modules/express/src/typedRoutes/api/common/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const LoginRequest = {
* Login
*
* @operationId express.login
* @tag express
*/
export const PostLogin = httpRoute({
path: '/api/v[12]/user/login',
Expand Down
1 change: 1 addition & 0 deletions modules/express/src/typedRoutes/api/common/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BitgoExpressError } from '../../schemas/error';
* Ping
*
* @operationId express.ping
* @tag express
*/
export const GetPing = httpRoute({
path: '/api/v[12]/ping',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BitgoExpressError } from '../../schemas/error';
* Ping Express
*
* @operationId express.pingExpress
* @tag express
*/
export const GetPingExpress = httpRoute({
path: '/api/v[12]/pingexpress',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const VerifyAddressBody = {
* Verify Address
*
* @operationId express.verifyaddress
* @tag express
*/
export const PostVerifyAddress = httpRoute({
path: '/api/v[12]/verifyaddress',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v1/acceptShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const AcceptShareRequestBody = {
* When a wallet is shared with a user, they need to accept the share to gain access
* to the wallet according to the permissions granted by the sharing user.
*
* @tag express
* @operationId express.v1.wallet.acceptShare
* @tag express
*/
export const PostAcceptShare = httpRoute({
path: '/api/v1/walletshare/{shareId}/acceptShare',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const ConsolidateUnspentsResponse = t.array(
* multiple inputs to a single output. This is useful for reducing the number of UTXOs in a wallet,
* which can improve performance and reduce transaction fees.
*
* @tag express
* @operationId express.v1.wallet.consolidateunspents
* @tag express
*/
export const PutConsolidateUnspents = httpRoute({
path: '/api/v1/wallet/{id}/consolidateunspents',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export const ConstructPendingApprovalTxResponse = t.type({
* For transaction request type approvals, either a wallet passphrase or xprv must be provided to sign the transaction.
* You can optionally specify fee-related parameters to customize the transaction fee.
*
* @tag express
* @operationId express.v1.pendingapproval.constructTx
* @tag express
*/
export const PutConstructPendingApprovalTx = httpRoute({
path: '/api/v1/pendingapprovals/{id}/constructTx',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const CreateLocalKeyChainResponse = t.type({
* For security reasons, it is highly recommended that you encrypt and destroy
* the original xprv immediately to prevent theft.
*
* @tag express
* @operationId express.v1.keychain.local
* @tag express
*/
export const PostCreateLocalKeyChain = httpRoute({
path: '/api/v1/keychain/local',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const DeriveLocalKeyChainResponse = t.type({
* both the derived xprv and xpub are returned. If xpub is provided, only the
* derived xpub is returned.
*
* @tag express
* @operationId express.v1.keychain.derive
* @tag express
*/
export const PostDeriveLocalKeyChain = httpRoute({
path: '/api/v1/keychain/derive',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v1/fanoutUnspents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export const FanoutUnspentsResponse = t.type({
* multiple inputs to multiple outputs. This is useful for increasing the number of UTXOs
* in a wallet, which can improve transaction parallelization.
*
* @tag express
* @operationId express.v1.wallet.fanoutunspents
* @tag express
*/
export const PutFanoutUnspents = httpRoute({
path: '/api/v1/wallet/{id}/fanoutunspents',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const pendingApprovalRequestBody = {
* Handles various approval scenarios including transaction approvals, policy rule changes,
* and user change requests.
*
* @tag express
* @operationId express.v1.pendingapprovals
* @tag express
*/

export const PutPendingApproval = httpRoute({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const signTransactionRequestBody = {
* signTransaction
* Sign a previously created transaction with a keychain
*
* @tag express
* @operationId express.v1.wallet.signTransaction
* @tag express
*/
export const PostSignTransaction = httpRoute({
path: '/api/v1/wallet/{id}/signtransaction',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v1/simpleCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const SimpleCreateRequestBody = {
* 4. Creates the BitGo key on the service
* 5. Creates the wallet on BitGo with the 3 public keys above
*
* @tag express
* @operationId express.v1.wallet.simplecreate
* @tag express
*/
export const PostSimpleCreate = httpRoute({
path: '/api/v1/wallets/simplecreate',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v2/createAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export const CreateAddressResponse = {
/**
* Create address for a wallet
*
* @tag express
* @operationId express.v2.wallet.createAddress
* @tag express
*/
export const PostCreateAddress = httpRoute({
path: '/api/v2/{coin}/wallet/{id}/address',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const ExpressWalletUpdateResponse = {
* For other coins, use the standard wallet update endpoint.
*
* @operationId express.wallet.update
* @tag express
*/
export const PutExpressWalletUpdate = httpRoute({
path: '/express/api/v2/{coin}/wallet/{id}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const KeychainChangePasswordResponse = {
* Change a keychain's passphrase, re-encrypting the key to a new password.
*
* @operationId express.v2.keychain.changePassword
* @tag express
*/
export const PostKeychainChangePassword = httpRoute({
path: '/api/v2/{coin}/keychain/{id}/changepassword',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v2/keychainLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const KeychainLocalResponse = {
*
* For security reasons, it is highly recommended that you encrypt and destroy the original xprv immediately to prevent theft.
*
* @tag express
* @operationId express.keychain.local
* @tag express
*/
export const PostKeychainLocal = httpRoute({
path: '/api/v2/{coin}/keychain/local',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const LightningInitWalletResponse = {
* Lightning - This is only used for self-custody lightning. Initialize a newly created Lightning Network Daemon (LND) for the first time.
* Returns the updated wallet with the encrypted admin macaroon in the `coinSpecific` response field.
*
* @tag express
* @operationId express.lightning.initWallet
* @tag express
*/
export const PostLightningInitWallet = httpRoute({
path: '/api/v2/{coin}/wallet/{walletId}/initwallet',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v2/lightningState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const LightningStateResponse = {
*
* This is only used for self-custody lightning. Get the current state of the lightning node.
*
* @tag express
* @operationId express.lightning.getState
* @tag express
*/
export const GetLightningState = httpRoute({
method: 'GET',
Expand Down
7 changes: 4 additions & 3 deletions modules/express/src/typedRoutes/api/v2/ofcSignPayload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as t from 'io-ts';
import { Json, NonEmptyString, JsonFromString } from 'io-ts-types';
import { Json, NonEmptyString } from 'io-ts-types';
import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http';
import { BitgoExpressError } from '../../schemas/error';
import { JsonFromStringifiedJson } from '../../schemas/jsonFromStringifiedJson';

/**
* Sign an arbitrary payload using an OFC trading account key.
Expand All @@ -10,7 +11,7 @@ export const OfcSignPayloadBody = {
/** The ID of the OFC wallet to sign the payload with. */
walletId: NonEmptyString,
/** The payload to sign. The input can either be a stringified JSON, or a JSON object. */
payload: t.union([Json, t.string.pipe(JsonFromString)]),
payload: t.union([Json, JsonFromStringifiedJson]),
/** The passphrase to decrypt the user key. */
walletPassphrase: optional(t.string),
} as const;
Expand All @@ -35,8 +36,8 @@ export const OfcSignPayloadResponse = {
/** Sign payload with an OFC wallet key.
* Signs an arbitrary payload with an OFC wallet key.
*
* @tag express
* @operationId express.ofc.signPayload
* @tag express
*/
export const PostOfcSignPayload = httpRoute({
path: '/api/v2/ofc/signPayload',
Expand Down
1 change: 1 addition & 0 deletions modules/express/src/typedRoutes/api/v2/shareWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const ShareWalletResponse = {
* Share this wallet with another BitGo user.
*
* @operationId express.v2.wallet.share
* @tag express
*/
export const PostShareWallet = httpRoute({
path: '/api/v2/{coin}/wallet/{id}/share',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v2/unlockWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const UnlockLightningWalletResponse = {
*
* This is only used for self-custody lightning. Unlock the Lightning Network Daemon (LND) node with the given wallet password.
*
* @tag express
* @operationId express.lightning.unlockWallet
* @tag express
*/
export const PostUnlockLightningWallet = httpRoute({
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion modules/express/src/typedRoutes/api/v2/verifyAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const VerifyAddressV2Body = {
* Returns whether the address is valid for the specified coin.
* For UTXO coins, an optional legacy script hash flag can be provided to allow previous script hash versions.
*
* @tag express
* @operationId express.verifycoinaddress
* @tag express
*/
export const PostVerifyCoinAddress = httpRoute({
path: '/api/v2/{coin}/verifyaddress',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as t from 'io-ts';
import { JsonFromString } from 'io-ts-types';

export const JsonFromStringifiedJson = t.string.pipe(JsonFromString);